mach-tl-wax50re.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /*
  2. * TP-LINK TL-WA750RE v1/TL-WA801ND v2/TL-WA850RE v1/TL-WA901ND v3
  3. * board support
  4. *
  5. * Copyright (C) 2013 Martijn Zilverschoon <thefriedzombie@gmail.com>
  6. * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
  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/gpio.h>
  13. #include <linux/platform_device.h>
  14. #include <asm/mach-ath79/ath79.h>
  15. #include <asm/mach-ath79/ar71xx_regs.h>
  16. #include "common.h"
  17. #include "dev-eth.h"
  18. #include "dev-gpio-buttons.h"
  19. #include "dev-leds-gpio.h"
  20. #include "dev-m25p80.h"
  21. #include "dev-wmac.h"
  22. #include "machtypes.h"
  23. #define TL_WAX50RE_GPIO_LED_LAN 20
  24. #define TL_WAX50RE_GPIO_LED_WLAN 13
  25. #define TL_WAX50RE_GPIO_LED_RE 15
  26. #define TL_WAX50RE_GPIO_LED_SIGNAL1 0
  27. #define TL_WAX50RE_GPIO_LED_SIGNAL2 1
  28. #define TL_WAX50RE_GPIO_LED_SIGNAL3 2
  29. #define TL_WAX50RE_GPIO_LED_SIGNAL4 3
  30. #define TL_WAX50RE_GPIO_LED_SIGNAL5 4
  31. #define TL_WA860RE_GPIO_LED_WLAN_ORANGE 0
  32. #define TL_WA860RE_GPIO_LED_WLAN_GREEN 2
  33. #define TL_WA860RE_GPIO_LED_POWER_ORANGE 12
  34. #define TL_WA860RE_GPIO_LED_POWER_GREEN 14
  35. #define TL_WA860RE_GPIO_LED_LAN 20
  36. #define TL_WA801ND_V2_GPIO_LED_LAN 18
  37. #define TL_WA801ND_V2_GPIO_LED_SYSTEM 14
  38. #define TL_WAX50RE_GPIO_BTN_RESET 17
  39. #define TL_WAX50RE_GPIO_BTN_WPS 16
  40. #define TL_WA860RE_GPIO_BTN_RESET 17
  41. #define TL_WA860RE_GPIO_BTN_WPS 16
  42. #define TL_WA860RE_GPIO_BTN_ONOFF 11
  43. #define TL_WAX50RE_KEYS_POLL_INTERVAL 20 /* msecs */
  44. #define TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL (3 * TL_WAX50RE_KEYS_POLL_INTERVAL)
  45. static const char *tl_wax50re_part_probes[] = {
  46. "tp-link",
  47. NULL,
  48. };
  49. static struct flash_platform_data tl_wax50re_flash_data = {
  50. .part_probes = tl_wax50re_part_probes,
  51. };
  52. static struct gpio_led tl_wa750re_leds_gpio[] __initdata = {
  53. {
  54. .name = "tp-link:orange:lan",
  55. .gpio = TL_WAX50RE_GPIO_LED_LAN,
  56. .active_low = 1,
  57. }, {
  58. .name = "tp-link:orange:wlan",
  59. .gpio = TL_WAX50RE_GPIO_LED_WLAN,
  60. .active_low = 1,
  61. }, {
  62. .name = "tp-link:orange:re",
  63. .gpio = TL_WAX50RE_GPIO_LED_RE,
  64. .active_low = 1,
  65. }, {
  66. .name = "tp-link:orange:signal1",
  67. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
  68. .active_low = 1,
  69. }, {
  70. .name = "tp-link:orange:signal2",
  71. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
  72. .active_low = 1,
  73. }, {
  74. .name = "tp-link:orange:signal3",
  75. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
  76. .active_low = 1,
  77. }, {
  78. .name = "tp-link:orange:signal4",
  79. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
  80. .active_low = 1,
  81. }, {
  82. .name = "tp-link:orange:signal5",
  83. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
  84. .active_low = 1,
  85. },
  86. };
  87. static struct gpio_led tl_wa850re_leds_gpio[] __initdata = {
  88. {
  89. .name = "tp-link:blue:lan",
  90. .gpio = TL_WAX50RE_GPIO_LED_LAN,
  91. .active_low = 1,
  92. }, {
  93. .name = "tp-link:blue:wlan",
  94. .gpio = TL_WAX50RE_GPIO_LED_WLAN,
  95. .active_low = 1,
  96. }, {
  97. .name = "tp-link:blue:re",
  98. .gpio = TL_WAX50RE_GPIO_LED_RE,
  99. .active_low = 1,
  100. }, {
  101. .name = "tp-link:blue:signal1",
  102. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
  103. .active_low = 1,
  104. }, {
  105. .name = "tp-link:blue:signal2",
  106. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
  107. .active_low = 1,
  108. }, {
  109. .name = "tp-link:blue:signal3",
  110. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
  111. .active_low = 1,
  112. }, {
  113. .name = "tp-link:blue:signal4",
  114. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
  115. .active_low = 1,
  116. }, {
  117. .name = "tp-link:blue:signal5",
  118. .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
  119. .active_low = 1,
  120. },
  121. };
  122. static struct gpio_led tl_wa860re_leds_gpio[] __initdata = {
  123. {
  124. .name = "tp-link:green:lan",
  125. .gpio = TL_WA860RE_GPIO_LED_LAN,
  126. .active_low = 1,
  127. }, {
  128. .name = "tp-link:green:power",
  129. .gpio = TL_WA860RE_GPIO_LED_POWER_GREEN,
  130. .active_low = 1,
  131. }, {
  132. .name = "tp-link:orange:power",
  133. .gpio = TL_WA860RE_GPIO_LED_POWER_ORANGE,
  134. .active_low = 1,
  135. }, {
  136. .name = "tp-link:green:wlan",
  137. .gpio = TL_WA860RE_GPIO_LED_WLAN_GREEN,
  138. .active_low = 1,
  139. }, {
  140. .name = "tp-link:orange:wlan",
  141. .gpio = TL_WA860RE_GPIO_LED_WLAN_ORANGE,
  142. .active_low = 1,
  143. },
  144. };
  145. static struct gpio_keys_button tl_wax50re_gpio_keys[] __initdata = {
  146. {
  147. .desc = "Reset button",
  148. .type = EV_KEY,
  149. .code = KEY_RESTART,
  150. .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  151. .gpio = TL_WAX50RE_GPIO_BTN_RESET,
  152. .active_low = 1,
  153. }, {
  154. .desc = "WPS",
  155. .type = EV_KEY,
  156. .code = KEY_WPS_BUTTON,
  157. .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  158. .gpio = TL_WAX50RE_GPIO_BTN_WPS,
  159. .active_low = 1,
  160. },
  161. };
  162. static struct gpio_keys_button tl_wa860re_gpio_keys[] __initdata = {
  163. {
  164. .desc = "Reset button",
  165. .type = EV_KEY,
  166. .code = KEY_RESTART,
  167. .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  168. .gpio = TL_WA860RE_GPIO_BTN_RESET,
  169. .active_low = 1,
  170. }, {
  171. .desc = "WPS",
  172. .type = EV_KEY,
  173. .code = KEY_WPS_BUTTON,
  174. .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  175. .gpio = TL_WA860RE_GPIO_BTN_WPS,
  176. .active_low = 1,
  177. }, {
  178. .desc = "ONOFF",
  179. .type = EV_KEY,
  180. .code = BTN_1,
  181. .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
  182. .gpio = TL_WA860RE_GPIO_BTN_ONOFF,
  183. .active_low = 1,
  184. },
  185. };
  186. static struct gpio_led tl_wa801nd_v2_leds_gpio[] __initdata = {
  187. {
  188. .name = "tp-link:green:lan",
  189. .gpio = TL_WA801ND_V2_GPIO_LED_LAN,
  190. .active_low = 1,
  191. }, {
  192. .name = "tp-link:green:wlan",
  193. .gpio = TL_WAX50RE_GPIO_LED_WLAN,
  194. .active_low = 1,
  195. }, {
  196. .name = "tp-link:green:qss",
  197. .gpio = TL_WAX50RE_GPIO_LED_RE,
  198. .active_low = 1,
  199. }, {
  200. .name = "tp-link:green:system",
  201. .gpio = TL_WA801ND_V2_GPIO_LED_SYSTEM,
  202. .active_low = 1,
  203. },
  204. };
  205. static void __init tl_ap123_setup(void)
  206. {
  207. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  208. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  209. ath79_register_m25p80(&tl_wax50re_flash_data);
  210. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  211. ath79_register_mdio(1, 0x0);
  212. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  213. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  214. ath79_eth0_data.phy_mask = BIT(0);
  215. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  216. ath79_register_eth(0);
  217. ath79_register_wmac(ee, mac);
  218. }
  219. static void __init tl_wa750re_setup(void)
  220. {
  221. tl_ap123_setup();
  222. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa750re_leds_gpio),
  223. tl_wa750re_leds_gpio);
  224. ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  225. ARRAY_SIZE(tl_wax50re_gpio_keys),
  226. tl_wax50re_gpio_keys);
  227. }
  228. MIPS_MACHINE(ATH79_MACH_TL_WA750RE, "TL-WA750RE", "TP-LINK TL-WA750RE",
  229. tl_wa750re_setup);
  230. static void __init tl_wa801nd_v2_setup(void)
  231. {
  232. tl_ap123_setup();
  233. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
  234. tl_wa801nd_v2_leds_gpio);
  235. ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  236. ARRAY_SIZE(tl_wax50re_gpio_keys),
  237. tl_wax50re_gpio_keys);
  238. }
  239. MIPS_MACHINE(ATH79_MACH_TL_WA801ND_V2, "TL-WA801ND-v2", "TP-LINK TL-WA801ND v2",
  240. tl_wa801nd_v2_setup);
  241. static void __init tl_wa850re_setup(void)
  242. {
  243. tl_ap123_setup();
  244. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa850re_leds_gpio),
  245. tl_wa850re_leds_gpio);
  246. ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  247. ARRAY_SIZE(tl_wax50re_gpio_keys),
  248. tl_wax50re_gpio_keys);
  249. }
  250. MIPS_MACHINE(ATH79_MACH_TL_WA850RE, "TL-WA850RE", "TP-LINK TL-WA850RE",
  251. tl_wa850re_setup);
  252. static void __init tl_wa860re_setup(void)
  253. {
  254. tl_ap123_setup();
  255. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa860re_leds_gpio),
  256. tl_wa860re_leds_gpio);
  257. ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  258. ARRAY_SIZE(tl_wa860re_gpio_keys),
  259. tl_wa860re_gpio_keys);
  260. }
  261. MIPS_MACHINE(ATH79_MACH_TL_WA860RE, "TL-WA860RE", "TP-LINK TL-WA860RE",
  262. tl_wa860re_setup);
  263. static void __init tl_wa901nd_v3_setup(void)
  264. {
  265. tl_ap123_setup();
  266. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
  267. tl_wa801nd_v2_leds_gpio);
  268. ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
  269. ARRAY_SIZE(tl_wax50re_gpio_keys) - 1,
  270. tl_wax50re_gpio_keys);
  271. }
  272. MIPS_MACHINE(ATH79_MACH_TL_WA901ND_V3, "TL-WA901ND-v3", "TP-LINK TL-WA901ND v3",
  273. tl_wa901nd_v3_setup);