mach-tl-wpa8630.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * TP-Link TL-WPA8630 board support
  3. *
  4. * Copyright (C) 2016 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 "common.h"
  15. #include "dev-m25p80.h"
  16. #include "machtypes.h"
  17. #include "pci.h"
  18. #include "dev-ap9x-pci.h"
  19. #include "dev-eth.h"
  20. #include "dev-gpio-buttons.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-spi.h"
  23. #include "dev-wmac.h"
  24. #define TL_WPA8630_KEYS_POLL_INTERVAL 20
  25. #define TL_WPA8630_KEYS_DEBOUNCE_INTERVAL (3 * TL_WPA8630_KEYS_POLL_INTERVAL)
  26. #define TL_WPA8630_GPIO_LED_POWER 1
  27. #define TL_WPA8630_GPIO_LED_LAN 5
  28. #define TL_WPA8630_GPIO_LED_WLAN 19
  29. #define TL_WPA8630_GPIO_LED_WLAN5 21
  30. #define TL_WPA8630_GPIO_BTN_RESET 2
  31. #define TL_WPA8630_GPIO_BTN_RFKILL 8
  32. #define TL_WPA8630_GPIO_BTN_LED 6
  33. #define TL_WPA8630_GPIO_BTN_PAIR 7
  34. #define TL_WPA8630_MAC0_OFFSET 0x0000
  35. #define TL_WPA8630_WMAC_CALDATA_OFFSET 0x1000
  36. #define TL_WPA8630_PCI_CALDATA_OFFSET 0x5000
  37. static const char *tl_wpa8630_part_probes[] = {
  38. "tp-link-64k",
  39. NULL,
  40. };
  41. static struct flash_platform_data tl_wpa8630_flash_data = {
  42. .part_probes = tl_wpa8630_part_probes,
  43. .type = "s25fl064k",
  44. };
  45. static struct gpio_led tl_wpa8630_leds_gpio[] __initdata = {
  46. {
  47. .name = "tl-wpa8630:green:power",
  48. .gpio = TL_WPA8630_GPIO_LED_POWER,
  49. .active_low = 1,
  50. },
  51. {
  52. .name = "tl-wpa8630:green:lan",
  53. .gpio = TL_WPA8630_GPIO_LED_LAN,
  54. .active_low = 1,
  55. },
  56. {
  57. .name = "tl-wpa8630:green:wlan",
  58. .gpio = TL_WPA8630_GPIO_LED_WLAN,
  59. .active_low = 1,
  60. },
  61. {
  62. .name = "tl-wpa8630:green:wlan5",
  63. .gpio = TL_WPA8630_GPIO_LED_WLAN5,
  64. .active_low = 1,
  65. },
  66. };
  67. static struct gpio_keys_button tl_wpa8630_gpio_keys[] __initdata = {
  68. {
  69. .desc = "Reset button",
  70. .type = EV_KEY,
  71. .code = KEY_RESTART,
  72. .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
  73. .gpio = TL_WPA8630_GPIO_BTN_RESET,
  74. .active_low = 1,
  75. },
  76. {
  77. .desc = "RFKILL button",
  78. .type = EV_KEY,
  79. .code = KEY_RFKILL,
  80. .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
  81. .gpio = TL_WPA8630_GPIO_BTN_RFKILL,
  82. .active_low = 1,
  83. },
  84. {
  85. .desc = "LED",
  86. .type = EV_KEY,
  87. .code = BTN_0,
  88. .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
  89. .gpio = TL_WPA8630_GPIO_BTN_LED,
  90. .active_low = 1,
  91. },
  92. {
  93. .desc = "Pair",
  94. .type = EV_KEY,
  95. .code = BTN_1,
  96. .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
  97. .gpio = TL_WPA8630_GPIO_BTN_PAIR,
  98. .active_low = 1,
  99. },
  100. };
  101. /* GMAC0 of the QCA8337 switch is connected to the QCA9563 SoC via SGMII */
  102. static struct ar8327_pad_cfg tl_wpa8630_qca8337_pad0_cfg = {
  103. .mode = AR8327_PAD_MAC_SGMII,
  104. .sgmii_delay_en = true,
  105. };
  106. static struct ar8327_platform_data tl_wpa8630_qca8337_data = {
  107. .pad0_cfg = &tl_wpa8630_qca8337_pad0_cfg,
  108. .port0_cfg = {
  109. .force_link = 1,
  110. .speed = AR8327_PORT_SPEED_1000,
  111. .duplex = 1,
  112. .txpause = 1,
  113. .rxpause = 1,
  114. },
  115. };
  116. static struct mdio_board_info tl_wpa8630_mdio0_info[] = {
  117. {
  118. .bus_id = "ag71xx-mdio.0",
  119. .phy_addr = 0,
  120. .platform_data = &tl_wpa8630_qca8337_data,
  121. },
  122. };
  123. static void __init tl_wpa8630_setup(void)
  124. {
  125. u8 *mac = (u8 *) KSEG1ADDR(0x1f00fc00);
  126. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  127. ath79_register_m25p80(&tl_wpa8630_flash_data);
  128. ath79_init_mac(ath79_eth0_data.mac_addr,
  129. art + TL_WPA8630_MAC0_OFFSET, 0);
  130. platform_device_register(&ath79_mdio0_device);
  131. mdiobus_register_board_info(tl_wpa8630_mdio0_info,
  132. ARRAY_SIZE(tl_wpa8630_mdio0_info));
  133. /* GMAC0 is connected to an AR8337 switch */
  134. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  135. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  136. ath79_eth0_data.phy_mask = ~BIT(4);
  137. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  138. ath79_register_eth(0);
  139. ath79_register_wmac(art + TL_WPA8630_WMAC_CALDATA_OFFSET, mac);
  140. ap91_pci_init(art + TL_WPA8630_PCI_CALDATA_OFFSET, NULL);
  141. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wpa8630_leds_gpio),
  142. tl_wpa8630_leds_gpio);
  143. ath79_register_gpio_keys_polled(-1, TL_WPA8630_KEYS_POLL_INTERVAL,
  144. ARRAY_SIZE(tl_wpa8630_gpio_keys),
  145. tl_wpa8630_gpio_keys);
  146. }
  147. MIPS_MACHINE(ATH79_MACH_TL_WPA8630, "TL-WPA8630", "TP-Link TL-WPA8630",
  148. tl_wpa8630_setup);