mach-tl-mr11u.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * TP-LINK TL-MR11U/TL-MR3040 board support
  3. *
  4. * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  5. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/gpio.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-usb.h"
  20. #include "dev-wmac.h"
  21. #include "machtypes.h"
  22. #define TL_MR11U_GPIO_LED_3G 27
  23. #define TL_MR11U_GPIO_LED_WLAN 26
  24. #define TL_MR11U_GPIO_LED_LAN 17
  25. #define TL_MR11U_GPIO_BTN_WPS 20
  26. #define TL_MR11U_GPIO_BTN_RESET 11
  27. #define TL_MR11U_GPIO_USB_POWER 8
  28. #define TL_MR3040_GPIO_USB_POWER 18
  29. #define TL_MR3040_V2_GPIO_BTN_SW1 19
  30. #define TL_MR3040_V2_GPIO_BTN_SW2 20
  31. #define TL_MR11U_KEYS_POLL_INTERVAL 20 /* msecs */
  32. #define TL_MR11U_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR11U_KEYS_POLL_INTERVAL)
  33. static const char *tl_mr11u_part_probes[] = {
  34. "tp-link",
  35. NULL,
  36. };
  37. static struct flash_platform_data tl_mr11u_flash_data = {
  38. .part_probes = tl_mr11u_part_probes,
  39. };
  40. static struct gpio_led tl_mr11u_leds_gpio[] __initdata = {
  41. {
  42. .name = "tp-link:green:3g",
  43. .gpio = TL_MR11U_GPIO_LED_3G,
  44. .active_low = 1,
  45. },
  46. {
  47. .name = "tp-link:green:wlan",
  48. .gpio = TL_MR11U_GPIO_LED_WLAN,
  49. .active_low = 1,
  50. },
  51. {
  52. .name = "tp-link:green:lan",
  53. .gpio = TL_MR11U_GPIO_LED_LAN,
  54. .active_low = 1,
  55. }
  56. };
  57. static struct gpio_keys_button tl_mr11u_gpio_keys[] __initdata = {
  58. {
  59. .desc = "reset",
  60. .type = EV_KEY,
  61. .code = KEY_RESTART,
  62. .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  63. .gpio = TL_MR11U_GPIO_BTN_RESET,
  64. .active_low = 0,
  65. },
  66. {
  67. .desc = "wps",
  68. .type = EV_KEY,
  69. .code = KEY_WPS_BUTTON,
  70. .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  71. .gpio = TL_MR11U_GPIO_BTN_WPS,
  72. .active_low = 0,
  73. },
  74. };
  75. static struct gpio_keys_button tl_mr3040_v2_gpio_keys[] __initdata = {
  76. {
  77. .desc = "reset",
  78. .type = EV_KEY,
  79. .code = KEY_RESTART,
  80. .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  81. .gpio = TL_MR11U_GPIO_BTN_RESET,
  82. .active_low = 0,
  83. },
  84. {
  85. .desc = "sw1",
  86. .type = EV_SW,
  87. .code = BTN_0,
  88. .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  89. .gpio = TL_MR3040_V2_GPIO_BTN_SW1,
  90. .active_low = 0,
  91. },
  92. {
  93. .desc = "sw2",
  94. .type = EV_SW,
  95. .code = BTN_1,
  96. .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
  97. .gpio = TL_MR3040_V2_GPIO_BTN_SW2,
  98. .active_low = 0,
  99. }
  100. };
  101. static void __init common_setup(void)
  102. {
  103. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  104. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  105. /* Disable hardware control LAN1 and LAN2 LEDs, enabling GPIO14 and GPIO15 */
  106. ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  107. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN);
  108. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  109. ath79_setup_ar933x_phy4_switch(false, false);
  110. ath79_register_m25p80(&tl_mr11u_flash_data);
  111. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr11u_leds_gpio),
  112. tl_mr11u_leds_gpio);
  113. ath79_register_usb();
  114. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  115. ath79_register_mdio(0, 0x0);
  116. ath79_register_eth(0);
  117. ath79_register_wmac(ee, mac);
  118. }
  119. static void __init tl_mr11u_setup(void)
  120. {
  121. common_setup();
  122. ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
  123. ARRAY_SIZE(tl_mr11u_gpio_keys),
  124. tl_mr11u_gpio_keys);
  125. gpio_request_one(TL_MR11U_GPIO_USB_POWER,
  126. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  127. "USB power");
  128. }
  129. MIPS_MACHINE(ATH79_MACH_TL_MR11U, "TL-MR11U", "TP-LINK TL-MR11U",
  130. tl_mr11u_setup);
  131. static void __init tl_mr3040_setup(void)
  132. {
  133. common_setup();
  134. ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
  135. 1, tl_mr11u_gpio_keys);
  136. gpio_request_one(TL_MR3040_GPIO_USB_POWER,
  137. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  138. "USB power");
  139. }
  140. MIPS_MACHINE(ATH79_MACH_TL_MR3040, "TL-MR3040", "TP-LINK TL-MR3040",
  141. tl_mr3040_setup);
  142. static void __init tl_mr3040_v2_setup(void)
  143. {
  144. common_setup();
  145. ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
  146. ARRAY_SIZE(tl_mr3040_v2_gpio_keys),
  147. tl_mr3040_v2_gpio_keys);
  148. gpio_request_one(TL_MR3040_GPIO_USB_POWER,
  149. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  150. "USB power");
  151. }
  152. MIPS_MACHINE(ATH79_MACH_TL_MR3040_V2, "TL-MR3040-v2", "TP-LINK TL-MR3040 v2",
  153. tl_mr3040_v2_setup);