mach-dlan-pro-1200-ac.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * devolo dLAN pro 500 Wireless+ support
  3. *
  4. * Copyright (c) 2013-2015 devolo AG
  5. * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. */
  20. #include <linux/pci.h>
  21. #include <linux/phy.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/ath9k_platform.h>
  24. #include <linux/ar8216_platform.h>
  25. #include <linux/gpio.h>
  26. #include <asm/mach-ath79/ar71xx_regs.h>
  27. #include "common.h"
  28. #include "dev-ap9x-pci.h"
  29. #include "dev-eth.h"
  30. #include "dev-gpio-buttons.h"
  31. #include "dev-leds-gpio.h"
  32. #include "dev-m25p80.h"
  33. #include "dev-nfc.h"
  34. #include "dev-spi.h"
  35. #include "dev-wmac.h"
  36. #include "machtypes.h"
  37. #define DLAN_PRO_1200_AC_GPIO_DLAN_POWER_ENABLE 13
  38. #define DLAN_PRO_1200_AC_GPIO_WLAN_POWER_ENABLE 21
  39. #define DLAN_PRO_1200_AC_GPIO_LED_WLAN 12
  40. #define DLAN_PRO_1200_AC_GPIO_LED_DLAN 14
  41. #define DLAN_PRO_1200_AC_GPIO_LED_DLAN_ERR 15
  42. #define DLAN_PRO_1200_AC_GPIO_BTN_WLAN 20
  43. #define DLAN_PRO_1200_AC_GPIO_BTN_DLAN 22
  44. #define DLAN_PRO_1200_AC_GPIO_BTN_RESET 4
  45. #define DLAN_PRO_1200_AC_GPIO_DLAN_IND 17
  46. #define DLAN_PRO_1200_AC_GPIO_DLAN_ERR_IND 16
  47. #define DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL 20 /* msecs */
  48. #define DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL)
  49. #define DLAN_PRO_1200_AC_ART_ADDRESS 0x1fff0000
  50. #define DLAN_PRO_1200_AC_CALDATA_OFFSET 0x1000
  51. #define DLAN_PRO_1200_AC_WIFIMAC_OFFSET 0x1002
  52. #define DLAN_PRO_1200_AC_PCIE_CALDATA_OFFSET 0x5000
  53. static struct gpio_led dlan_pro_1200_ac_leds_gpio[] __initdata = {
  54. {
  55. .name = "devolo:status:wlan",
  56. .gpio = DLAN_PRO_1200_AC_GPIO_LED_WLAN,
  57. .active_low = 1,
  58. },
  59. {
  60. .name = "devolo:status:dlan",
  61. .gpio = DLAN_PRO_1200_AC_GPIO_LED_DLAN,
  62. .active_low = 1,
  63. },
  64. {
  65. .name = "devolo:error:dlan",
  66. .gpio = DLAN_PRO_1200_AC_GPIO_LED_DLAN_ERR,
  67. .active_low = 0,
  68. }
  69. };
  70. static struct gpio_keys_button dlan_pro_1200_ac_gpio_keys[] __initdata = {
  71. {
  72. .desc = "dLAN button",
  73. .type = EV_KEY,
  74. .code = BTN_0,
  75. .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
  76. .gpio = DLAN_PRO_1200_AC_GPIO_BTN_DLAN,
  77. .active_low = 1,
  78. },
  79. {
  80. .desc = "WLAN button",
  81. .type = EV_KEY,
  82. .code = KEY_WPS_BUTTON,
  83. .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
  84. .gpio = DLAN_PRO_1200_AC_GPIO_BTN_WLAN,
  85. .active_low = 0,
  86. },
  87. {
  88. .desc = "Reset button",
  89. .type = EV_KEY,
  90. .code = KEY_RESTART,
  91. .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
  92. .gpio = DLAN_PRO_1200_AC_GPIO_BTN_RESET,
  93. .active_low = 1,
  94. }
  95. };
  96. static struct ar8327_pad_cfg dlan_pro_1200_ac_ar8327_pad0_cfg = {
  97. .mode = AR8327_PAD_MAC_RGMII,
  98. .txclk_delay_en = true,
  99. .rxclk_delay_en = false,
  100. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  101. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  102. .mac06_exchange_dis = true,
  103. };
  104. static struct ar8327_pad_cfg dlan_pro_1200_ac_ar8327_pad5_cfg = {
  105. .mode = 0,
  106. .txclk_delay_en = 0,
  107. .rxclk_delay_en = 0,
  108. .txclk_delay_sel = 0,
  109. .rxclk_delay_sel = 0,
  110. };
  111. static struct ar8327_platform_data dlan_pro_1200_ac_ar8327_data = {
  112. .pad0_cfg = &dlan_pro_1200_ac_ar8327_pad0_cfg,
  113. .pad5_cfg = &dlan_pro_1200_ac_ar8327_pad5_cfg,
  114. .port0_cfg = {
  115. .force_link = 1,
  116. .speed = AR8327_PORT_SPEED_1000,
  117. .duplex = 1,
  118. .txpause = 1,
  119. .rxpause = 1,
  120. },
  121. };
  122. static struct mdio_board_info dlan_pro_1200_ac_mdio0_info[] = {
  123. {
  124. .bus_id = "ag71xx-mdio.0",
  125. .phy_addr = 0,
  126. .platform_data = &dlan_pro_1200_ac_ar8327_data,
  127. },
  128. };
  129. static void __init dlan_pro_1200_ac_setup(void)
  130. {
  131. u8 *art = (u8 *) KSEG1ADDR(DLAN_PRO_1200_AC_ART_ADDRESS);
  132. u8 *cal = art + DLAN_PRO_1200_AC_CALDATA_OFFSET;
  133. u8 *wifi_mac = art + DLAN_PRO_1200_AC_WIFIMAC_OFFSET;
  134. ath79_register_m25p80(NULL);
  135. ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_pro_1200_ac_leds_gpio),
  136. dlan_pro_1200_ac_leds_gpio);
  137. ath79_register_gpio_keys_polled(-1, DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL,
  138. ARRAY_SIZE(dlan_pro_1200_ac_gpio_keys),
  139. dlan_pro_1200_ac_gpio_keys);
  140. /* dLAN power must be enabled from user-space as soon as the boot-from-host daemon is running */
  141. gpio_request_one(DLAN_PRO_1200_AC_GPIO_DLAN_POWER_ENABLE,
  142. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  143. "dLAN power");
  144. /* WLAN power is turned on initially to allow the PCI bus scan to succeed */
  145. gpio_request_one(DLAN_PRO_1200_AC_GPIO_WLAN_POWER_ENABLE,
  146. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  147. "WLAN power");
  148. ath79_register_wmac(cal, wifi_mac);
  149. ap91_pci_init(art + DLAN_PRO_1200_AC_PCIE_CALDATA_OFFSET, NULL);
  150. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 | AR934X_ETH_CFG_SW_ONLY_MODE);
  151. ath79_register_mdio(1, 0x0);
  152. ath79_register_mdio(0, 0x0);
  153. ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 2);
  154. mdiobus_register_board_info(dlan_pro_1200_ac_mdio0_info,
  155. ARRAY_SIZE(dlan_pro_1200_ac_mdio0_info));
  156. /* GMAC0 is connected to an AR8337 */
  157. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  158. ath79_eth0_data.phy_mask = BIT(0);
  159. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  160. ath79_eth0_pll_data.pll_1000 = 0x02000000;
  161. ath79_register_eth(0);
  162. }
  163. MIPS_MACHINE(ATH79_MACH_DLAN_PRO_1200_AC, "dLAN-pro-1200-ac", "devolo dLAN pro 1200+ WiFi ac",
  164. dlan_pro_1200_ac_setup);