mach-dlan-pro-500-wp.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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-spi.h"
  34. #include "dev-wmac.h"
  35. #include "machtypes.h"
  36. #define DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE 13
  37. #define DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE 17
  38. #define DLAN_PRO_500_WP_GPIO_LED_WLAN_5G 11
  39. #define DLAN_PRO_500_WP_GPIO_LED_WLAN_2G 12
  40. #define DLAN_PRO_500_WP_GPIO_LED_STATUS 16
  41. #define DLAN_PRO_500_WP_GPIO_LED_ETH 14
  42. #define DLAN_PRO_500_WP_GPIO_BTN_WPS 20
  43. #define DLAN_PRO_500_WP_GPIO_BTN_WLAN 22
  44. #define DLAN_PRO_500_WP_GPIO_BTN_DLAN 21
  45. #define DLAN_PRO_500_WP_GPIO_BTN_RESET 4
  46. #define DLAN_PRO_500_WP_KEYS_POLL_INTERVAL 20 /* msecs */
  47. #define DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_PRO_500_WP_KEYS_POLL_INTERVAL)
  48. #define DLAN_PRO_500_WP_ART_ADDRESS 0x1fff0000
  49. #define DLAN_PRO_500_WP_CALDATA_OFFSET 0x1000
  50. #define DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET 0x1002
  51. #define DLAN_PRO_500_WP_PCIE_CALDATA_OFFSET 0x5000
  52. static struct gpio_led dlan_pro_500_wp_leds_gpio[] __initdata = {
  53. {
  54. .name = "devolo:green:status",
  55. .gpio = DLAN_PRO_500_WP_GPIO_LED_STATUS,
  56. .active_low = 1,
  57. },
  58. {
  59. .name = "devolo:green:eth",
  60. .gpio = DLAN_PRO_500_WP_GPIO_LED_ETH,
  61. .active_low = 1,
  62. },
  63. {
  64. .name = "devolo:blue:wlan-5g",
  65. .gpio = DLAN_PRO_500_WP_GPIO_LED_WLAN_5G,
  66. .active_low = 1,
  67. },
  68. {
  69. .name = "devolo:green:wlan-2g",
  70. .gpio = DLAN_PRO_500_WP_GPIO_LED_WLAN_2G,
  71. .active_low = 1,
  72. }
  73. };
  74. static struct gpio_keys_button dlan_pro_500_wp_gpio_keys[] __initdata = {
  75. {
  76. .desc = "dLAN button",
  77. .type = EV_KEY,
  78. .code = BTN_0,
  79. .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  80. .gpio = DLAN_PRO_500_WP_GPIO_BTN_DLAN,
  81. .active_low = 0,
  82. },
  83. {
  84. .desc = "WPS button",
  85. .type = EV_KEY,
  86. .code = KEY_WPS_BUTTON,
  87. .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  88. .gpio = DLAN_PRO_500_WP_GPIO_BTN_WPS,
  89. .active_low = 0,
  90. },
  91. {
  92. .desc = "WLAN button",
  93. .type = EV_KEY,
  94. .code = BTN_2,
  95. .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  96. .gpio = DLAN_PRO_500_WP_GPIO_BTN_WLAN,
  97. .active_low = 1,
  98. },
  99. {
  100. .desc = "Reset button",
  101. .type = EV_KEY,
  102. .code = KEY_RESTART,
  103. .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
  104. .gpio = DLAN_PRO_500_WP_GPIO_BTN_RESET,
  105. .active_low = 1,
  106. }
  107. };
  108. static struct ar8327_pad_cfg dlan_pro_500_wp_ar8327_pad0_cfg = {
  109. .mode = AR8327_PAD_PHY_RGMII,
  110. .txclk_delay_en = false,
  111. .rxclk_delay_en = false,
  112. .txclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  113. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  114. };
  115. static struct ar8327_led_cfg dlan_pro_500_wp_ar8327_led_cfg = {
  116. .led_ctrl0 = 0x00000000,
  117. .led_ctrl1 = 0xc737c737,
  118. .led_ctrl2 = 0x00000000,
  119. .led_ctrl3 = 0x00c30c00,
  120. .open_drain = true,
  121. };
  122. static struct ar8327_platform_data dlan_pro_500_wp_ar8327_data = {
  123. .pad0_cfg = &dlan_pro_500_wp_ar8327_pad0_cfg,
  124. .port0_cfg = {
  125. .force_link = 1,
  126. .speed = AR8327_PORT_SPEED_1000,
  127. .duplex = 1,
  128. .txpause = 0,
  129. .rxpause = 0,
  130. },
  131. .led_cfg = &dlan_pro_500_wp_ar8327_led_cfg,
  132. };
  133. static struct mdio_board_info dlan_pro_500_wp_mdio0_info[] = {
  134. {
  135. .bus_id = "ag71xx-mdio.0",
  136. .phy_addr = 0,
  137. .platform_data = &dlan_pro_500_wp_ar8327_data,
  138. },
  139. };
  140. static void __init dlan_pro_500_wp_setup(void)
  141. {
  142. u8 *art = (u8 *) KSEG1ADDR(DLAN_PRO_500_WP_ART_ADDRESS);
  143. u8 *cal = art + DLAN_PRO_500_WP_CALDATA_OFFSET;
  144. u8 *wifi_mac = art + DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET;
  145. ath79_register_m25p80(NULL);
  146. ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_pro_500_wp_leds_gpio),
  147. dlan_pro_500_wp_leds_gpio);
  148. ath79_register_gpio_keys_polled(-1, DLAN_PRO_500_WP_KEYS_POLL_INTERVAL,
  149. ARRAY_SIZE(dlan_pro_500_wp_gpio_keys),
  150. dlan_pro_500_wp_gpio_keys);
  151. gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE,
  152. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  153. "PLC power");
  154. gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE,
  155. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  156. "PLC LEDs");
  157. ath79_register_wmac(cal, wifi_mac);
  158. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  159. ath79_register_mdio(1, 0x0);
  160. ath79_register_mdio(0, 0x0);
  161. mdiobus_register_board_info(dlan_pro_500_wp_mdio0_info,
  162. ARRAY_SIZE(dlan_pro_500_wp_mdio0_info));
  163. /* GMAC0 is connected to a AR7400 PLC in PHY mode */
  164. ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 2);
  165. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  166. ath79_eth0_pll_data.pll_1000 = 0x0e000000;
  167. ath79_eth0_data.speed = SPEED_1000;
  168. ath79_eth0_data.duplex = DUPLEX_FULL;
  169. ath79_register_eth(0);
  170. /* GMAC1 is connected to the internal switch */
  171. ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 1);
  172. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  173. ath79_eth1_data.speed = SPEED_1000;
  174. ath79_eth1_data.duplex = DUPLEX_FULL;
  175. ath79_register_eth(1);
  176. }
  177. MIPS_MACHINE(ATH79_MACH_DLAN_PRO_500_WP, "dLAN-pro-500-wp", "devolo dLAN pro 500 Wireless+",
  178. dlan_pro_500_wp_setup);