mach-re450.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * TP-LINK Archer RE450 board support
  3. *
  4. * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (c) 2016 Tal Keren <kooolk@gmail.com>
  6. *
  7. * Based on the Qualcomm Atheros AP135/AP136 reference board support code
  8. * Copyright (c) 2012 Qualcomm Atheros
  9. *
  10. * Permission to use, copy, modify, and/or distribute this software for any
  11. * purpose with or without fee is hereby granted, provided that the above
  12. * copyright notice and this permission notice appear in all copies.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  15. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  16. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  17. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  18. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  19. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  20. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21. *
  22. */
  23. #include <linux/pci.h>
  24. #include <linux/phy.h>
  25. #include <linux/gpio.h>
  26. #include <linux/platform_data/mdio-gpio.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/ar8216_platform.h>
  29. #include <asm/mach-ath79/ath79.h>
  30. #include <asm/mach-ath79/ar71xx_regs.h>
  31. #include "common.h"
  32. #include "dev-ap9x-pci.h"
  33. #include "dev-eth.h"
  34. #include "dev-gpio-buttons.h"
  35. #include "dev-leds-gpio.h"
  36. #include "dev-m25p80.h"
  37. #include "dev-wmac.h"
  38. #include "machtypes.h"
  39. #include "pci.h"
  40. #define RE450_GPIO_LED_SYSTEM 12
  41. #define RE450_GPIO_LED_WLAN2G 13
  42. #define RE450_GPIO_LED_WLAN5G 14
  43. #define RE450_GPIO_LED_LAN_DATA 17
  44. #define RE450_GPIO_LED_JUMPSTART 21
  45. #define RE450_GPIO_LED_JUMPSTART_RED 22
  46. #define RE450_GPIO_LED_LAN_LINK 23
  47. #define RE450_GPIO_BTN_RESET 18
  48. #define RE450_GPIO_BTN_LED 19
  49. #define RE450_GPIO_BTN_JUMPSTART 20
  50. #define RE450_GPIO_SMI_MDIO 1
  51. #define RE450_GPIO_SMI_MDC 3
  52. #define RE450_LAN_PHYADDR 4
  53. #define RE450_KEYS_POLL_INTERVAL 20 /* msecs */
  54. #define RE450_KEYS_DEBOUNCE_INTERVAL (3 * RE450_KEYS_POLL_INTERVAL)
  55. #define RE450_WMAC_CALDATA_OFFSET 0x1000
  56. static const char *tl_re450_part_probes[] = {
  57. "cmdlinepart",
  58. NULL,
  59. };
  60. static struct flash_platform_data tl_re450_flash_data = {
  61. .part_probes = tl_re450_part_probes,
  62. };
  63. static struct gpio_led re450_leds_gpio[] __initdata = {
  64. {
  65. .name = "re450:blue:power",
  66. .gpio = RE450_GPIO_LED_SYSTEM,
  67. .active_low = 1,
  68. },
  69. {
  70. .name = "re450:blue:wlan2g",
  71. .gpio = RE450_GPIO_LED_WLAN2G,
  72. .active_low = 1,
  73. },
  74. {
  75. .name = "re450:blue:wlan5g",
  76. .gpio = RE450_GPIO_LED_WLAN5G,
  77. .active_low = 1,
  78. },
  79. {
  80. .name = "re450:blue:wps",
  81. .gpio = RE450_GPIO_LED_JUMPSTART,
  82. },
  83. {
  84. .name = "re450:red:wps",
  85. .gpio = RE450_GPIO_LED_JUMPSTART_RED,
  86. },
  87. {
  88. .name = "re450:green:lan_data",
  89. .gpio = RE450_GPIO_LED_LAN_DATA,
  90. .active_low = 1,
  91. },
  92. {
  93. .name = "re450:green:lan_link",
  94. .gpio = RE450_GPIO_LED_LAN_LINK,
  95. .active_low = 1,
  96. },
  97. };
  98. static struct gpio_keys_button re450_gpio_keys[] __initdata = {
  99. {
  100. .desc = "Reset button",
  101. .type = EV_KEY,
  102. .code = KEY_WPS_BUTTON,
  103. .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
  104. .gpio = RE450_GPIO_BTN_RESET,
  105. .active_low = 1,
  106. },
  107. {
  108. .desc = "WPS button",
  109. .type = EV_KEY,
  110. .code = KEY_RESTART,
  111. .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
  112. .gpio = RE450_GPIO_BTN_JUMPSTART,
  113. .active_low = 1,
  114. },
  115. {
  116. .desc = "Control LED button",
  117. .type = EV_KEY,
  118. .code = BTN_0,
  119. .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
  120. .gpio = RE450_GPIO_BTN_LED,
  121. .active_low = 1,
  122. },
  123. };
  124. static struct mdio_gpio_platform_data re450_mdio = {
  125. .mdc = RE450_GPIO_SMI_MDC,
  126. .mdio = RE450_GPIO_SMI_MDIO,
  127. .phy_mask = ~BIT(RE450_LAN_PHYADDR),
  128. };
  129. static struct platform_device re450_phy_device = {
  130. .name = "mdio-gpio",
  131. .id = 0,
  132. .dev = {
  133. .platform_data = &re450_mdio,
  134. },
  135. };
  136. static void __init re450_setup(void)
  137. {
  138. u8 *mac = (u8 *) KSEG1ADDR(0x1f610008);
  139. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  140. u8 tmpmac[ETH_ALEN];
  141. ath79_register_m25p80(&tl_re450_flash_data);
  142. ath79_register_leds_gpio(-1, ARRAY_SIZE(re450_leds_gpio),
  143. re450_leds_gpio);
  144. ath79_register_gpio_keys_polled(-1, RE450_KEYS_POLL_INTERVAL,
  145. ARRAY_SIZE(re450_gpio_keys),
  146. re450_gpio_keys);
  147. ath79_init_mac(tmpmac, mac, -1);
  148. ath79_register_wmac(art + RE450_WMAC_CALDATA_OFFSET, tmpmac);
  149. ath79_register_pci();
  150. /* MDIO Interface */
  151. platform_device_register(&re450_phy_device);
  152. ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  153. /* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */
  154. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  155. ath79_eth0_data.mii_bus_dev = &re450_phy_device.dev;
  156. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  157. ath79_eth0_data.phy_mask = BIT(RE450_LAN_PHYADDR);
  158. ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  159. ath79_eth0_pll_data.pll_100 = 0xa0000101;
  160. ath79_eth0_pll_data.pll_10 = 0x80001313;
  161. ath79_register_eth(0);
  162. }
  163. MIPS_MACHINE(ATH79_MACH_RE450, "RE450", "TP-LINK RE450",
  164. re450_setup)