mach-wnr2000-v3.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * NETGEAR WNR2000v3/WNR612v2/WNR1000v2/WPN824N board support
  3. *
  4. * Copyright (C) 2015 Hartmut Knaack <knaack.h@gmx.de>
  5. * Copyright (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
  6. * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  7. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8. * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. */
  14. #include <linux/mtd/mtd.h>
  15. #include <linux/mtd/partitions.h>
  16. #include <asm/mach-ath79/ath79.h>
  17. #include <asm/mach-ath79/ar71xx_regs.h> /* needed to disable switch LEDs */
  18. #include "common.h" /* needed to disable switch LEDs */
  19. #include "dev-ap9x-pci.h"
  20. #include "dev-eth.h"
  21. #include "dev-gpio-buttons.h"
  22. #include "dev-leds-gpio.h"
  23. #include "dev-m25p80.h"
  24. #include "machtypes.h"
  25. #define WNR2000V3_GPIO_LED_WAN_GREEN 0
  26. #define WNR2000V3_GPIO_LED_LAN1_AMBER 1
  27. #define WNR2000V3_GPIO_LED_LAN4_AMBER 12
  28. #define WNR2000V3_GPIO_LED_PWR_GREEN 14
  29. #define WNR2000V3_GPIO_BTN_WPS 11
  30. #define WNR612V2_GPIO_LED_PWR_GREEN 11
  31. #define WNR1000V2_GPIO_LED_PWR_AMBER 1
  32. #define WNR1000V2_GPIO_LED_PWR_GREEN 11
  33. /* Connected through AR7240 */
  34. #define WPN824N_GPIO_LED_WAN_AMBER 0
  35. #define WPN824N_GPIO_LED_STATUS_AMBER 1
  36. #define WPN824N_GPIO_LED_LAN1_AMBER 6 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  37. #define WPN824N_GPIO_LED_LAN2_AMBER 7 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  38. #define WPN824N_GPIO_LED_LAN3_AMBER 8 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  39. #define WPN824N_GPIO_LED_LAN4_AMBER 12
  40. #define WPN824N_GPIO_LED_LAN1_GREEN 13
  41. #define WPN824N_GPIO_LED_LAN2_GREEN 14
  42. #define WPN824N_GPIO_LED_LAN3_GREEN 15 /* AR724X_GPIO_FUNC_CLK_OBS3_EN */
  43. #define WPN824N_GPIO_LED_LAN4_GREEN 16
  44. #define WPN824N_GPIO_LED_WAN_GREEN 17
  45. /* Connected through AR9285 */
  46. #define WPN824N_WGPIO_LED_PWR_GREEN 0
  47. #define WPN824N_WGPIO_LED_WLAN_BLUE 1
  48. #define WPN824N_WGPIO_LED_WPS1_BLUE 5
  49. #define WPN824N_WGPIO_LED_WPS2_BLUE 9
  50. #define WPN824N_WGPIO_LED_TEST_AMBER 10
  51. #define WPN824N_WGPIO_BTN_PUSH 6 /* currently unused */
  52. #define WPN824N_WGPIO_BTN_RESET 7 /* currently unused */
  53. #define WPN824N_WGPIO_BTN_WLAN 8 /* currently unused */
  54. #define WNR2000V3_KEYS_POLL_INTERVAL 20 /* msecs */
  55. #define WNR2000V3_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V3_KEYS_POLL_INTERVAL)
  56. #define WNR2000V3_MAC0_OFFSET 0
  57. #define WNR2000V3_MAC1_OFFSET 6
  58. #define WNR2000V3_PCIE_CALDATA_OFFSET 0x1000
  59. static struct gpio_led wnr2000v3_leds_gpio[] __initdata = {
  60. {
  61. .name = "wnr2000v3:green:power",
  62. .gpio = WNR2000V3_GPIO_LED_PWR_GREEN,
  63. .active_low = 1,
  64. }, {
  65. .name = "wnr2000v3:green:wan",
  66. .gpio = WNR2000V3_GPIO_LED_WAN_GREEN,
  67. .active_low = 1,
  68. }
  69. };
  70. static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
  71. {
  72. .name = "netgear:green:power",
  73. .gpio = WNR612V2_GPIO_LED_PWR_GREEN,
  74. .active_low = 1,
  75. }
  76. };
  77. static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
  78. {
  79. .name = "netgear:green:power",
  80. .gpio = WNR1000V2_GPIO_LED_PWR_GREEN,
  81. .active_low = 1,
  82. }, {
  83. .name = "netgear:amber:power",
  84. .gpio = WNR1000V2_GPIO_LED_PWR_AMBER,
  85. .active_low = 1,
  86. }
  87. };
  88. static struct gpio_led wpn824n_leds_gpio[] __initdata = {
  89. {
  90. .name = "netgear:amber:wan",
  91. .gpio = WPN824N_GPIO_LED_WAN_AMBER,
  92. .active_low = 1,
  93. }, {
  94. .name = "netgear:amber:status",
  95. .gpio = WPN824N_GPIO_LED_STATUS_AMBER,
  96. .active_low = 1,
  97. }, {
  98. .name = "netgear:amber:lan1",
  99. .gpio = WPN824N_GPIO_LED_LAN1_AMBER,
  100. .active_low = 1,
  101. }, {
  102. .name = "netgear:amber:lan2",
  103. .gpio = WPN824N_GPIO_LED_LAN2_AMBER,
  104. .active_low = 1,
  105. }, {
  106. .name = "netgear:amber:lan3",
  107. .gpio = WPN824N_GPIO_LED_LAN3_AMBER,
  108. .active_low = 1,
  109. }, {
  110. .name = "netgear:amber:lan4",
  111. .gpio = WPN824N_GPIO_LED_LAN4_AMBER,
  112. .active_low = 1,
  113. }, {
  114. .name = "netgear:green:lan1",
  115. .gpio = WPN824N_GPIO_LED_LAN1_GREEN,
  116. .active_low = 1,
  117. }, {
  118. .name = "netgear:green:lan2",
  119. .gpio = WPN824N_GPIO_LED_LAN2_GREEN,
  120. .active_low = 1,
  121. }, {
  122. .name = "netgear:green:lan3",
  123. .gpio = WPN824N_GPIO_LED_LAN3_GREEN,
  124. .active_low = 1,
  125. }, {
  126. .name = "netgear:green:lan4",
  127. .gpio = WPN824N_GPIO_LED_LAN4_GREEN,
  128. .active_low = 1,
  129. }, {
  130. .name = "netgear:green:wan",
  131. .gpio = WPN824N_GPIO_LED_WAN_GREEN,
  132. .active_low = 1,
  133. }
  134. };
  135. static struct gpio_led wpn824n_wmac_leds_gpio[] = {
  136. {
  137. .name = "netgear:green:power",
  138. .gpio = WPN824N_WGPIO_LED_PWR_GREEN,
  139. .active_low = 1,
  140. }, {
  141. .name = "netgear:blue:wlan",
  142. .gpio = WPN824N_WGPIO_LED_WLAN_BLUE,
  143. .active_low = 1,
  144. }, {
  145. .name = "netgear:blue:wps1",
  146. .gpio = WPN824N_WGPIO_LED_WPS1_BLUE,
  147. .active_low = 1,
  148. }, {
  149. .name = "netgear:blue:wps2",
  150. .gpio = WPN824N_WGPIO_LED_WPS2_BLUE,
  151. .active_low = 1,
  152. }, {
  153. .name = "netgear:amber:test",
  154. .gpio = WPN824N_WGPIO_LED_TEST_AMBER,
  155. .active_low = 1,
  156. }
  157. };
  158. static struct gpio_keys_button wnr2000v3_gpio_keys[] __initdata = {
  159. {
  160. .desc = "wps",
  161. .type = EV_KEY,
  162. .code = KEY_WPS_BUTTON,
  163. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  164. .gpio = WNR2000V3_GPIO_BTN_WPS,
  165. }
  166. };
  167. static void __init wnr_common_setup(void)
  168. {
  169. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  170. ath79_register_mdio(0, 0x0);
  171. ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V3_MAC0_OFFSET, 0);
  172. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  173. ath79_eth0_data.speed = SPEED_100;
  174. ath79_eth0_data.duplex = DUPLEX_FULL;
  175. ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V3_MAC1_OFFSET, 0);
  176. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  177. ath79_eth1_data.phy_mask = 0x10;
  178. ath79_register_eth(0);
  179. ath79_register_eth(1);
  180. ath79_register_m25p80(NULL);
  181. ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, NULL);
  182. }
  183. static void __init wnr2000v3_setup(void)
  184. {
  185. wnr_common_setup();
  186. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
  187. wnr2000v3_leds_gpio);
  188. ath79_register_gpio_keys_polled(-1, WNR2000V3_KEYS_POLL_INTERVAL,
  189. ARRAY_SIZE(wnr2000v3_gpio_keys),
  190. wnr2000v3_gpio_keys);
  191. }
  192. MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup);
  193. static void __init wnr612v2_setup(void)
  194. {
  195. wnr_common_setup();
  196. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
  197. wnr612v2_leds_gpio);
  198. }
  199. MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
  200. static void __init wnr1000v2_setup(void)
  201. {
  202. wnr_common_setup();
  203. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
  204. wnr1000v2_leds_gpio);
  205. }
  206. MIPS_MACHINE(ATH79_MACH_WNR1000_V2, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup);
  207. static void __init wpn824n_setup(void)
  208. {
  209. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  210. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  211. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  212. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  213. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  214. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
  215. AR724X_GPIO_FUNC_CLK_OBS3_EN);
  216. wnr_common_setup();
  217. ath79_register_leds_gpio(-1, ARRAY_SIZE(wpn824n_leds_gpio),
  218. wpn824n_leds_gpio);
  219. ap9x_pci_setup_wmac_led_pin(0, WPN824N_WGPIO_LED_WLAN_BLUE);
  220. ap9x_pci_setup_wmac_leds(0, wpn824n_wmac_leds_gpio,
  221. ARRAY_SIZE(wpn824n_wmac_leds_gpio));
  222. }
  223. MIPS_MACHINE(ATH79_MACH_WPN824N, "WPN824N", "NETGEAR WPN824N", wpn824n_setup);