mach-archer-c60-v1.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * TP-Link Archer C60 v1 board support
  3. *
  4. * Copyright (C) 2017 Henryk Heisig <hyniu@o2.pl>
  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/platform_device.h>
  11. #include <linux/ath9k_platform.h>
  12. #include <linux/ar8216_platform.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include <linux/gpio.h>
  15. #include "common.h"
  16. #include "dev-m25p80.h"
  17. #include "machtypes.h"
  18. #include "pci.h"
  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-spi.h"
  24. #include "dev-usb.h"
  25. #include "dev-wmac.h"
  26. #define ARCHER_C60_V1_GPIO_LED_LAN 2
  27. #define ARCHER_C60_V1_GPIO_LED_POWER 16
  28. #define ARCHER_C60_V1_GPIO_LED_WLAN2 17
  29. #define ARCHER_C60_V1_GPIO_LED_WLAN5 18
  30. #define ARCHER_C60_V1_GPIO_LED_WPS 19
  31. #define ARCHER_C60_V1_GPIO_LED_WAN_GREEN 20
  32. #define ARCHER_C60_V1_GPIO_LED_WAN_AMBER 22
  33. #define ARCHER_C60_V1_KEYS_POLL_INTERVAL 20
  34. #define ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C60_V1_KEYS_POLL_INTERVAL)
  35. #define ARCHER_C60_V1_GPIO_BTN_RESET 21
  36. #define ARCHER_C60_V1_GPIO_BTN_RFKILL 1
  37. #define ARCHER_C60_V1_WMAC_CALDATA_OFFSET 0x1000
  38. #define ARCHER_C60_V1_PCI_CALDATA_OFFSET 0x5000
  39. static struct gpio_led archer_c60_v1_leds_gpio[] __initdata = {
  40. {
  41. .name = "archer-c60-v1:green:power",
  42. .gpio = ARCHER_C60_V1_GPIO_LED_POWER,
  43. .active_low = 1,
  44. },
  45. {
  46. .name = "archer-c60-v1:green:wlan2g",
  47. .gpio = ARCHER_C60_V1_GPIO_LED_WLAN2,
  48. .active_low = 1,
  49. },
  50. {
  51. .name = "archer-c60-v1:green:wlan5g",
  52. .gpio = ARCHER_C60_V1_GPIO_LED_WLAN5,
  53. .active_low = 1,
  54. },
  55. {
  56. .name = "archer-c60-v1:green:lan",
  57. .gpio = ARCHER_C60_V1_GPIO_LED_LAN,
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "archer-c60-v1:green:wan",
  62. .gpio = ARCHER_C60_V1_GPIO_LED_WAN_GREEN,
  63. .active_low = 1,
  64. },
  65. {
  66. .name = "archer-c60-v1:amber:wan",
  67. .gpio = ARCHER_C60_V1_GPIO_LED_WAN_AMBER,
  68. .active_low = 1,
  69. },
  70. {
  71. .name = "archer-c60-v1:green:wps",
  72. .gpio = ARCHER_C60_V1_GPIO_LED_WPS,
  73. .active_low = 1,
  74. },
  75. };
  76. static struct gpio_led archer_c60_v2_leds_gpio[] __initdata = {
  77. {
  78. .name = "archer-c60-v2:green:power",
  79. .gpio = ARCHER_C60_V1_GPIO_LED_POWER,
  80. .active_low = 1,
  81. },
  82. {
  83. .name = "archer-c60-v2:green:wlan2g",
  84. .gpio = ARCHER_C60_V1_GPIO_LED_WLAN2,
  85. .active_low = 1,
  86. },
  87. {
  88. .name = "archer-c60-v2:green:wlan5g",
  89. .gpio = ARCHER_C60_V1_GPIO_LED_WLAN5,
  90. .active_low = 1,
  91. },
  92. {
  93. .name = "archer-c60-v2:green:lan",
  94. .gpio = ARCHER_C60_V1_GPIO_LED_LAN,
  95. .active_low = 1,
  96. },
  97. {
  98. .name = "archer-c60-v2:green:wan",
  99. .gpio = ARCHER_C60_V1_GPIO_LED_WAN_GREEN,
  100. .active_low = 1,
  101. },
  102. {
  103. .name = "archer-c60-v2:amber:wan",
  104. .gpio = ARCHER_C60_V1_GPIO_LED_WAN_AMBER,
  105. .active_low = 1,
  106. },
  107. {
  108. .name = "archer-c60-v2:green:wps",
  109. .gpio = ARCHER_C60_V1_GPIO_LED_WPS,
  110. .active_low = 1,
  111. },
  112. };
  113. static struct gpio_keys_button archer_c60_v1_gpio_keys[] __initdata = {
  114. {
  115. .desc = "Reset button",
  116. .type = EV_KEY,
  117. .code = KEY_RESTART,
  118. .debounce_interval = ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL,
  119. .gpio = ARCHER_C60_V1_GPIO_BTN_RESET,
  120. .active_low = 1,
  121. },
  122. {
  123. .desc = "RFKILL button",
  124. .type = EV_KEY,
  125. .code = KEY_RFKILL,
  126. .debounce_interval = ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL,
  127. .gpio = ARCHER_C60_V1_GPIO_BTN_RFKILL,
  128. .active_low = 1,
  129. },
  130. };
  131. static void __init archer_c60_v1_setup(void)
  132. {
  133. u8 *mac = (u8 *) KSEG1ADDR(0x1f010008);
  134. u8 *art = (u8 *) KSEG1ADDR(0x1f7f0000);
  135. ath79_register_m25p80(NULL);
  136. ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c60_v1_leds_gpio),
  137. archer_c60_v1_leds_gpio);
  138. ath79_register_gpio_keys_polled(-1, ARCHER_C60_V1_KEYS_POLL_INTERVAL,
  139. ARRAY_SIZE(archer_c60_v1_gpio_keys),
  140. archer_c60_v1_gpio_keys);
  141. ath79_register_mdio(0, 0x0);
  142. ath79_register_mdio(1, 0x0);
  143. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  144. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  145. /* WAN port */
  146. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  147. ath79_eth0_data.speed = SPEED_100;
  148. ath79_eth0_data.duplex = DUPLEX_FULL;
  149. ath79_eth0_data.phy_mask = BIT(4);
  150. ath79_register_eth(0);
  151. /* LAN ports */
  152. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  153. ath79_eth1_data.speed = SPEED_1000;
  154. ath79_eth1_data.duplex = DUPLEX_FULL;
  155. ath79_switch_data.phy_poll_mask |= BIT(4);
  156. ath79_switch_data.phy4_mii_en = 1;
  157. ath79_register_eth(1);
  158. ath79_register_wmac(art + ARCHER_C60_V1_WMAC_CALDATA_OFFSET, mac);
  159. ap91_pci_init(art + ARCHER_C60_V1_PCI_CALDATA_OFFSET, NULL);
  160. }
  161. MIPS_MACHINE(ATH79_MACH_ARCHER_C60_V1, "ARCHER-C60-V1",
  162. "TP-LINK Archer C60 v1", archer_c60_v1_setup);
  163. static void __init archer_c60_v2_setup(void)
  164. {
  165. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fb08);
  166. u8 *art = (u8 *) KSEG1ADDR(0x1f7f0000);
  167. ath79_register_m25p80(NULL);
  168. ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c60_v2_leds_gpio),
  169. archer_c60_v2_leds_gpio);
  170. ath79_register_gpio_keys_polled(-1, ARCHER_C60_V1_KEYS_POLL_INTERVAL,
  171. ARRAY_SIZE(archer_c60_v1_gpio_keys),
  172. archer_c60_v1_gpio_keys);
  173. ath79_register_mdio(0, 0x0);
  174. ath79_register_mdio(1, 0x0);
  175. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  176. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  177. /* WAN port */
  178. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  179. ath79_eth0_data.speed = SPEED_100;
  180. ath79_eth0_data.duplex = DUPLEX_FULL;
  181. ath79_eth0_data.phy_mask = BIT(4);
  182. ath79_register_eth(0);
  183. /* LAN ports */
  184. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  185. ath79_eth1_data.speed = SPEED_1000;
  186. ath79_eth1_data.duplex = DUPLEX_FULL;
  187. ath79_switch_data.phy_poll_mask |= BIT(4);
  188. ath79_switch_data.phy4_mii_en = 1;
  189. ath79_register_eth(1);
  190. ath79_register_wmac(art + ARCHER_C60_V1_WMAC_CALDATA_OFFSET, mac);
  191. ap91_pci_init(art + ARCHER_C60_V1_PCI_CALDATA_OFFSET, NULL);
  192. }
  193. MIPS_MACHINE(ATH79_MACH_ARCHER_C60_V2, "ARCHER-C60-V2",
  194. "TP-LINK Archer C60 v2", archer_c60_v2_setup);