1
0

mach-wlr8100.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Sitecom X8 AC1750 WLR-8100 board support
  3. *
  4. * Based on the Qualcomm Atheros AP135/AP136 reference board support code
  5. * Copyright (c) 2012 Qualcomm Atheros
  6. * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
  7. *
  8. * Permission to use, copy, modify, and/or distribute this software for any
  9. * purpose with or without fee is hereby granted, provided that the above
  10. * copyright notice and this permission notice appear in all copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. *
  20. */
  21. #include <linux/platform_device.h>
  22. #include <linux/ar8216_platform.h>
  23. #include <asm/mach-ath79/ar71xx_regs.h>
  24. #include "common.h"
  25. #include "pci.h"
  26. #include "dev-ap9x-pci.h"
  27. #include "dev-gpio-buttons.h"
  28. #include "dev-eth.h"
  29. #include "dev-leds-gpio.h"
  30. #include "dev-m25p80.h"
  31. #include "dev-usb.h"
  32. #include "dev-wmac.h"
  33. #include "machtypes.h"
  34. #define WLR8100_GPIO_LED_USB 4
  35. #define WLR8100_GPIO_LED_WLAN_5G 12
  36. #define WLR8100_GPIO_LED_WLAN_2G 13
  37. #define WLR8100_GPIO_LED_STATUS_RED 14
  38. #define WLR8100_GPIO_LED_WPS_RED 15
  39. #define WLR8100_GPIO_LED_STATUS_AMBER 19
  40. #define WLR8100_GPIO_LED_WPS_GREEN 20
  41. #define WLR8100_GPIO_BTN_WPS 16
  42. #define WLR8100_GPIO_BTN_RFKILL 21
  43. #define WLR8100_KEYS_POLL_INTERVAL 20 /* msecs */
  44. #define WLR8100_KEYS_DEBOUNCE_INTERVAL (3 * WLR8100_KEYS_POLL_INTERVAL)
  45. #define WLR8100_MAC0_OFFSET 0
  46. #define WLR8100_MAC1_OFFSET 6
  47. #define WLR8100_WMAC_CALDATA_OFFSET 0x1000
  48. #define WLR8100_PCIE_CALDATA_OFFSET 0x5000
  49. static struct gpio_led wlr8100_leds_gpio[] __initdata = {
  50. {
  51. .name = "wlr8100:amber:status",
  52. .gpio = WLR8100_GPIO_LED_STATUS_AMBER,
  53. .active_low = 1,
  54. },
  55. {
  56. .name = "wlr8100:red:status",
  57. .gpio = WLR8100_GPIO_LED_STATUS_RED,
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "wlr8100:green:wps",
  62. .gpio = WLR8100_GPIO_LED_WPS_GREEN,
  63. .active_low = 1,
  64. },
  65. {
  66. .name = "wlr8100:red:wps",
  67. .gpio = WLR8100_GPIO_LED_WPS_RED,
  68. .active_low = 1,
  69. },
  70. {
  71. .name = "wlr8100:red:wlan-2g",
  72. .gpio = WLR8100_GPIO_LED_WLAN_2G,
  73. .active_low = 1,
  74. },
  75. {
  76. .name = "wlr8100:red:usb",
  77. .gpio = WLR8100_GPIO_LED_USB,
  78. .active_low = 1,
  79. }
  80. };
  81. static struct gpio_keys_button wlr8100_gpio_keys[] __initdata = {
  82. {
  83. .desc = "WPS button",
  84. .type = EV_KEY,
  85. .code = KEY_WPS_BUTTON,
  86. .debounce_interval = WLR8100_KEYS_DEBOUNCE_INTERVAL,
  87. .gpio = WLR8100_GPIO_BTN_WPS,
  88. .active_low = 1,
  89. },
  90. {
  91. .desc = "RFKILL button",
  92. .type = EV_KEY,
  93. .code = KEY_RFKILL,
  94. .debounce_interval = WLR8100_KEYS_DEBOUNCE_INTERVAL,
  95. .gpio = WLR8100_GPIO_BTN_RFKILL,
  96. .active_low = 1,
  97. },
  98. };
  99. static struct ar8327_pad_cfg wlr8100_ar8327_pad0_cfg;
  100. static struct ar8327_pad_cfg wlr8100_ar8327_pad6_cfg;
  101. static struct ar8327_platform_data wlr8100_ar8327_data = {
  102. .pad0_cfg = &wlr8100_ar8327_pad0_cfg,
  103. .pad6_cfg = &wlr8100_ar8327_pad6_cfg,
  104. .port0_cfg = {
  105. .force_link = 1,
  106. .speed = AR8327_PORT_SPEED_1000,
  107. .duplex = 1,
  108. .txpause = 1,
  109. .rxpause = 1,
  110. },
  111. .port6_cfg = {
  112. .force_link = 1,
  113. .speed = AR8327_PORT_SPEED_1000,
  114. .duplex = 1,
  115. .txpause = 1,
  116. .rxpause = 1,
  117. },
  118. };
  119. static struct mdio_board_info wlr8100_mdio0_info[] = {
  120. {
  121. .bus_id = "ag71xx-mdio.0",
  122. .phy_addr = 0,
  123. .platform_data = &wlr8100_ar8327_data,
  124. },
  125. };
  126. static void __init wlr8100_common_setup(void)
  127. {
  128. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  129. ath79_register_m25p80(NULL);
  130. ath79_register_leds_gpio(-1, ARRAY_SIZE(wlr8100_leds_gpio),
  131. wlr8100_leds_gpio);
  132. ath79_register_gpio_keys_polled(-1, WLR8100_KEYS_POLL_INTERVAL,
  133. ARRAY_SIZE(wlr8100_gpio_keys),
  134. wlr8100_gpio_keys);
  135. ath79_register_usb();
  136. ath79_register_wmac(art + WLR8100_WMAC_CALDATA_OFFSET, NULL);
  137. ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  138. ath79_register_mdio(0, 0x0);
  139. ath79_init_mac(ath79_eth0_data.mac_addr, art + WLR8100_MAC0_OFFSET, 0);
  140. mdiobus_register_board_info(wlr8100_mdio0_info,
  141. ARRAY_SIZE(wlr8100_mdio0_info));
  142. /* GMAC0 is connected to the RMGII interface */
  143. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  144. ath79_eth0_data.phy_mask = BIT(0);
  145. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  146. ath79_register_eth(0);
  147. /* GMAC1 is connected tot eh SGMII interface */
  148. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  149. ath79_eth1_data.speed = SPEED_1000;
  150. ath79_eth1_data.duplex = DUPLEX_FULL;
  151. ath79_register_eth(1);
  152. }
  153. static void __init wlr8100_010_setup(void)
  154. {
  155. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  156. /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
  157. wlr8100_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
  158. wlr8100_ar8327_pad0_cfg.txclk_delay_en = true;
  159. wlr8100_ar8327_pad0_cfg.rxclk_delay_en = true;
  160. wlr8100_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  161. wlr8100_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  162. /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
  163. wlr8100_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
  164. wlr8100_ar8327_pad6_cfg.rxclk_delay_en = true;
  165. wlr8100_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
  166. ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  167. ath79_eth1_pll_data.pll_1000 = 0x03000101;
  168. wlr8100_common_setup();
  169. ap91_pci_init(art + WLR8100_PCIE_CALDATA_OFFSET, NULL);
  170. }
  171. MIPS_MACHINE(ATH79_MACH_WLR8100, "WLR8100",
  172. "Sitecom WLR-8100",
  173. wlr8100_010_setup);