mach-eap7660d.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Senao EAP7660D board support
  3. *
  4. * Copyright (C) 2010 Daniel Golle <daniel.golle@gmail.com>
  5. * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/pci.h>
  13. #include <linux/ath5k_platform.h>
  14. #include <linux/delay.h>
  15. #include <asm/mach-ath79/ath79.h>
  16. #include "dev-eth.h"
  17. #include "dev-gpio-buttons.h"
  18. #include "dev-leds-gpio.h"
  19. #include "dev-m25p80.h"
  20. #include "machtypes.h"
  21. #include "pci.h"
  22. #define EAP7660D_KEYS_POLL_INTERVAL 20 /* msecs */
  23. #define EAP7660D_KEYS_DEBOUNCE_INTERVAL (3 * EAP7660D_KEYS_POLL_INTERVAL)
  24. #define EAP7660D_GPIO_DS4 7
  25. #define EAP7660D_GPIO_DS5 2
  26. #define EAP7660D_GPIO_DS7 0
  27. #define EAP7660D_GPIO_DS8 4
  28. #define EAP7660D_GPIO_SW1 3
  29. #define EAP7660D_GPIO_SW3 8
  30. #define EAP7660D_PHYMASK BIT(20)
  31. #define EAP7660D_BOARDCONFIG 0x1F7F0000
  32. #define EAP7660D_GBIC_MAC_OFFSET 0x1000
  33. #define EAP7660D_WMAC0_MAC_OFFSET 0x1010
  34. #define EAP7660D_WMAC1_MAC_OFFSET 0x1016
  35. #define EAP7660D_WMAC0_CALDATA_OFFSET 0x2000
  36. #define EAP7660D_WMAC1_CALDATA_OFFSET 0x3000
  37. #ifdef CONFIG_PCI
  38. static struct ath5k_platform_data eap7660d_wmac0_data;
  39. static struct ath5k_platform_data eap7660d_wmac1_data;
  40. static char eap7660d_wmac0_mac[6];
  41. static char eap7660d_wmac1_mac[6];
  42. static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
  43. static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
  44. static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
  45. {
  46. switch (PCI_SLOT(dev->devfn)) {
  47. case 17:
  48. dev->dev.platform_data = &eap7660d_wmac0_data;
  49. break;
  50. case 18:
  51. dev->dev.platform_data = &eap7660d_wmac1_data;
  52. break;
  53. }
  54. return 0;
  55. }
  56. void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
  57. u8 *cal_data1, u8 *mac_addr1)
  58. {
  59. if (cal_data0 && *cal_data0 == 0xa55a) {
  60. memcpy(eap7660d_wmac0_eeprom, cal_data0,
  61. ATH5K_PLAT_EEP_MAX_WORDS);
  62. eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
  63. }
  64. if (cal_data1 && *cal_data1 == 0xa55a) {
  65. memcpy(eap7660d_wmac1_eeprom, cal_data1,
  66. ATH5K_PLAT_EEP_MAX_WORDS);
  67. eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
  68. }
  69. if (mac_addr0) {
  70. memcpy(eap7660d_wmac0_mac, mac_addr0,
  71. sizeof(eap7660d_wmac0_mac));
  72. eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
  73. }
  74. if (mac_addr1) {
  75. memcpy(eap7660d_wmac1_mac, mac_addr1,
  76. sizeof(eap7660d_wmac1_mac));
  77. eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
  78. }
  79. ath79_pci_set_plat_dev_init(eap7660d_pci_plat_dev_init);
  80. ath79_register_pci();
  81. }
  82. #else
  83. static inline void eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
  84. u8 *cal_data1, u8 *mac_addr1)
  85. {
  86. }
  87. #endif /* CONFIG_PCI */
  88. static struct gpio_led eap7660d_leds_gpio[] __initdata = {
  89. {
  90. .name = "eap7660d:green:ds8",
  91. .gpio = EAP7660D_GPIO_DS8,
  92. .active_low = 0,
  93. },
  94. {
  95. .name = "eap7660d:green:ds5",
  96. .gpio = EAP7660D_GPIO_DS5,
  97. .active_low = 0,
  98. },
  99. {
  100. .name = "eap7660d:green:ds7",
  101. .gpio = EAP7660D_GPIO_DS7,
  102. .active_low = 0,
  103. },
  104. {
  105. .name = "eap7660d:green:ds4",
  106. .gpio = EAP7660D_GPIO_DS4,
  107. .active_low = 0,
  108. }
  109. };
  110. static struct gpio_keys_button eap7660d_gpio_keys[] __initdata = {
  111. {
  112. .desc = "reset",
  113. .type = EV_KEY,
  114. .code = KEY_RESTART,
  115. .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
  116. .gpio = EAP7660D_GPIO_SW1,
  117. .active_low = 1,
  118. },
  119. {
  120. .desc = "wps",
  121. .type = EV_KEY,
  122. .code = KEY_WPS_BUTTON,
  123. .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
  124. .gpio = EAP7660D_GPIO_SW3,
  125. .active_low = 1,
  126. }
  127. };
  128. static const char *eap7660d_part_probes[] = {
  129. "RedBoot",
  130. NULL,
  131. };
  132. static struct flash_platform_data eap7660d_flash_data = {
  133. .part_probes = eap7660d_part_probes,
  134. };
  135. static void __init eap7660d_setup(void)
  136. {
  137. u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
  138. ath79_register_mdio(0, ~EAP7660D_PHYMASK);
  139. ath79_init_mac(ath79_eth0_data.mac_addr,
  140. boardconfig + EAP7660D_GBIC_MAC_OFFSET, 0);
  141. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  142. ath79_eth0_data.phy_mask = EAP7660D_PHYMASK;
  143. ath79_register_eth(0);
  144. ath79_register_m25p80(&eap7660d_flash_data);
  145. ath79_register_leds_gpio(-1, ARRAY_SIZE(eap7660d_leds_gpio),
  146. eap7660d_leds_gpio);
  147. ath79_register_gpio_keys_polled(-1, EAP7660D_KEYS_POLL_INTERVAL,
  148. ARRAY_SIZE(eap7660d_gpio_keys),
  149. eap7660d_gpio_keys);
  150. eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
  151. boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
  152. boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,
  153. boardconfig + EAP7660D_WMAC1_MAC_OFFSET);
  154. };
  155. MIPS_MACHINE(ATH79_MACH_EAP7660D, "EAP7660D", "Senao EAP7660D",
  156. eap7660d_setup);
  157. MIPS_MACHINE(ATH79_MACH_ALL0305, "ALL0305", "Allnet ALL0305",
  158. eap7660d_setup);