mach-tl-wr741nd-v4.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * TP-LINK TL-WR741ND v4/TL-MR3220 v2 board support
  3. *
  4. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/gpio.h>
  11. #include <asm/mach-ath79/ath79.h>
  12. #include <asm/mach-ath79/ar71xx_regs.h>
  13. #include "common.h"
  14. #include "dev-eth.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "dev-usb.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define TL_WR741NDV4_GPIO_BTN_RESET 11
  22. #define TL_WR741NDV4_GPIO_BTN_WPS 26
  23. #define TL_WR741NDV4_GPIO_LED_WLAN 0
  24. #define TL_WR741NDV4_GPIO_LED_QSS 1
  25. #define TL_WR741NDV4_GPIO_LED_WAN 13
  26. #define TL_WR741NDV4_GPIO_LED_LAN1 14
  27. #define TL_WR741NDV4_GPIO_LED_LAN2 15
  28. #define TL_WR741NDV4_GPIO_LED_LAN3 16
  29. #define TL_WR741NDV4_GPIO_LED_LAN4 17
  30. #define TL_WR741NDV4_GPIO_LED_SYSTEM 27
  31. #define TL_MR3220V2_GPIO_BTN_WPS 11
  32. #define TL_MR3220V2_GPIO_BTN_WIFI 24
  33. #define TL_MR3220V2_GPIO_LED_3G 26
  34. #define TL_MR3220V2_GPIO_USB_POWER 8
  35. #define TL_WR741NDV4_KEYS_POLL_INTERVAL 20 /* msecs */
  36. #define TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741NDV4_KEYS_POLL_INTERVAL)
  37. static const char *tl_wr741ndv4_part_probes[] = {
  38. "tp-link",
  39. NULL,
  40. };
  41. static struct flash_platform_data tl_wr741ndv4_flash_data = {
  42. .part_probes = tl_wr741ndv4_part_probes,
  43. };
  44. static struct gpio_led tl_wr741ndv4_leds_gpio[] __initdata = {
  45. {
  46. .name = "tp-link:green:lan1",
  47. .gpio = TL_WR741NDV4_GPIO_LED_LAN1,
  48. .active_low = 0,
  49. }, {
  50. .name = "tp-link:green:lan2",
  51. .gpio = TL_WR741NDV4_GPIO_LED_LAN2,
  52. .active_low = 0,
  53. }, {
  54. .name = "tp-link:green:lan3",
  55. .gpio = TL_WR741NDV4_GPIO_LED_LAN3,
  56. .active_low = 0,
  57. }, {
  58. .name = "tp-link:green:lan4",
  59. .gpio = TL_WR741NDV4_GPIO_LED_LAN4,
  60. .active_low = 1,
  61. }, {
  62. .name = "tp-link:green:qss",
  63. .gpio = TL_WR741NDV4_GPIO_LED_QSS,
  64. .active_low = 0,
  65. }, {
  66. .name = "tp-link:green:system",
  67. .gpio = TL_WR741NDV4_GPIO_LED_SYSTEM,
  68. .active_low = 1,
  69. }, {
  70. .name = "tp-link:green:wan",
  71. .gpio = TL_WR741NDV4_GPIO_LED_WAN,
  72. .active_low = 0,
  73. }, {
  74. .name = "tp-link:green:wlan",
  75. .gpio = TL_WR741NDV4_GPIO_LED_WLAN,
  76. .active_low = 0,
  77. }, {
  78. /* the 3G LED is only present on the MR3220 v2 */
  79. .name = "tp-link:green:3g",
  80. .gpio = TL_MR3220V2_GPIO_LED_3G,
  81. .active_low = 0,
  82. },
  83. };
  84. static struct gpio_keys_button tl_wr741ndv4_gpio_keys[] __initdata = {
  85. {
  86. .desc = "reset",
  87. .type = EV_KEY,
  88. .code = KEY_RESTART,
  89. .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  90. .gpio = TL_WR741NDV4_GPIO_BTN_RESET,
  91. .active_low = 0,
  92. }, {
  93. .desc = "WPS",
  94. .type = EV_KEY,
  95. .code = KEY_WPS_BUTTON,
  96. .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  97. .gpio = TL_WR741NDV4_GPIO_BTN_WPS,
  98. .active_low = 0,
  99. }
  100. };
  101. static struct gpio_keys_button tl_mr3220v2_gpio_keys[] __initdata = {
  102. {
  103. .desc = "WPS",
  104. .type = EV_KEY,
  105. .code = KEY_WPS_BUTTON,
  106. .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  107. .gpio = TL_MR3220V2_GPIO_BTN_WPS,
  108. .active_low = 0,
  109. }, {
  110. .desc = "WIFI button",
  111. .type = EV_KEY,
  112. .code = KEY_RFKILL,
  113. .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  114. .gpio = TL_MR3220V2_GPIO_BTN_WIFI,
  115. .active_low = 0,
  116. }
  117. };
  118. static void __init tl_ap121_setup(void)
  119. {
  120. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  121. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  122. ath79_setup_ar933x_phy4_switch(true, true);
  123. ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  124. AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  125. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  126. AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  127. AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  128. ath79_register_m25p80(&tl_wr741ndv4_flash_data);
  129. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  130. ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  131. ath79_register_mdio(0, 0x0);
  132. ath79_register_eth(1);
  133. ath79_register_eth(0);
  134. ath79_register_wmac(ee, mac);
  135. }
  136. static void __init tl_wr741ndv4_setup(void)
  137. {
  138. tl_ap121_setup();
  139. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio) - 1,
  140. tl_wr741ndv4_leds_gpio);
  141. ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
  142. ARRAY_SIZE(tl_wr741ndv4_gpio_keys),
  143. tl_wr741ndv4_gpio_keys);
  144. }
  145. MIPS_MACHINE(ATH79_MACH_TL_WR741ND_V4, "TL-WR741ND-v4",
  146. "TP-LINK TL-WR741ND v4", tl_wr741ndv4_setup);
  147. static void __init tl_mr3220v2_setup(void)
  148. {
  149. tl_ap121_setup();
  150. gpio_request_one(TL_MR3220V2_GPIO_USB_POWER,
  151. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  152. "USB power");
  153. ath79_register_usb();
  154. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio),
  155. tl_wr741ndv4_leds_gpio);
  156. ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
  157. ARRAY_SIZE(tl_mr3220v2_gpio_keys),
  158. tl_mr3220v2_gpio_keys);
  159. }
  160. MIPS_MACHINE(ATH79_MACH_TL_MR3220_V2, "TL-MR3220-v2",
  161. "TP-LINK TL-MR3220 v2", tl_mr3220v2_setup);