mach-dr344.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * Wallys DR342/DR344 boards support
  3. *
  4. * Copyright (c) 2011 Qualcomm Atheros
  5. * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (c) 2015 Philippe Duchein <wireless-dev@duchein.net>
  7. * Copyright (c) 2017 Piotr Dymacz <pepe2k@gmail.com>
  8. *
  9. * Permission to use, copy, modify, and/or distribute this software for any
  10. * purpose with or without fee is hereby granted, provided that the above
  11. * copyright notice and this permission notice appear in all copies.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  14. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  15. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  16. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  17. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  18. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  19. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  20. *
  21. */
  22. #include <linux/gpio.h>
  23. #include <linux/phy.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/ath9k_platform.h>
  26. #include <linux/platform_data/phy-at803x.h>
  27. #include <asm/mach-ath79/ar71xx_regs.h>
  28. #include "common.h"
  29. #include "pci.h"
  30. #include "dev-ap9x-pci.h"
  31. #include "dev-gpio-buttons.h"
  32. #include "dev-eth.h"
  33. #include "dev-usb.h"
  34. #include "dev-leds-gpio.h"
  35. #include "dev-m25p80.h"
  36. #include "dev-spi.h"
  37. #include "dev-wmac.h"
  38. #include "machtypes.h"
  39. #define DR34X_GPIO_LED_SIG1 12
  40. #define DR34X_GPIO_LED_SIG2 13
  41. #define DR34X_GPIO_LED_SIG3 14
  42. #define DR34X_GPIO_LED_SIG4 15
  43. #define DR34X_GPIO_LED_STATUS 11
  44. #define DR344_GPIO_LED_LAN 17
  45. #define DR344_GPIO_EXTERNAL_LNA0 18
  46. #define DR344_GPIO_EXTERNAL_LNA1 19
  47. #define DR34X_GPIO_BTN_RESET 16
  48. #define DR344_KEYS_POLL_INTERVAL 20 /* msecs */
  49. #define DR344_KEYS_DEBOUNCE_INTERVAL (3 * DR344_KEYS_POLL_INTERVAL)
  50. #define DR34X_MAC0_OFFSET 0
  51. #define DR34X_MAC1_OFFSET 8
  52. #define DR34X_WMAC_CALDATA_OFFSET 0x1000
  53. static struct gpio_led dr342_leds_gpio[] __initdata = {
  54. {
  55. .name = "dr342:green:status",
  56. .gpio = DR34X_GPIO_LED_STATUS,
  57. .active_low = 1,
  58. },
  59. {
  60. .name = "dr342:green:sig1",
  61. .gpio = DR34X_GPIO_LED_SIG1,
  62. .active_low = 1,
  63. },
  64. {
  65. .name = "dr342:green:sig2",
  66. .gpio = DR34X_GPIO_LED_SIG2,
  67. .active_low = 1,
  68. },
  69. {
  70. .name = "dr342:green:sig3",
  71. .gpio = DR34X_GPIO_LED_SIG3,
  72. .active_low = 1,
  73. },
  74. {
  75. .name = "dr342:green:sig4",
  76. .gpio = DR34X_GPIO_LED_SIG4,
  77. .active_low = 1,
  78. }
  79. };
  80. static struct gpio_led dr344_leds_gpio[] __initdata = {
  81. {
  82. .name = "dr344:green:lan",
  83. .gpio = DR344_GPIO_LED_LAN,
  84. .active_low = 1,
  85. },
  86. {
  87. .name = "dr344:green:status",
  88. .gpio = DR34X_GPIO_LED_STATUS,
  89. .active_low = 1,
  90. },
  91. {
  92. .name = "dr344:green:sig1",
  93. .gpio = DR34X_GPIO_LED_SIG1,
  94. .active_low = 1,
  95. },
  96. {
  97. .name = "dr344:green:sig2",
  98. .gpio = DR34X_GPIO_LED_SIG2,
  99. .active_low = 1,
  100. },
  101. {
  102. .name = "dr344:green:sig3",
  103. .gpio = DR34X_GPIO_LED_SIG3,
  104. .active_low = 1,
  105. },
  106. {
  107. .name = "dr344:green:sig4",
  108. .gpio = DR34X_GPIO_LED_SIG4,
  109. .active_low = 1,
  110. }
  111. };
  112. static struct gpio_keys_button dr34x_gpio_keys[] __initdata = {
  113. {
  114. .desc = "reset",
  115. .type = EV_KEY,
  116. .code = KEY_RESTART,
  117. .debounce_interval = DR344_KEYS_DEBOUNCE_INTERVAL,
  118. .gpio = DR34X_GPIO_BTN_RESET,
  119. .active_low = 1,
  120. },
  121. };
  122. static struct at803x_platform_data dr34x_at803x_data = {
  123. .disable_smarteee = 1,
  124. .enable_rgmii_rx_delay = 1,
  125. .enable_rgmii_tx_delay = 1,
  126. };
  127. static struct mdio_board_info dr34x_mdio0_info[] = {
  128. {
  129. .bus_id = "ag71xx-mdio.0",
  130. .mdio_addr = 0,
  131. .platform_data = &dr34x_at803x_data,
  132. },
  133. };
  134. static void __init dr34x_setup(void)
  135. {
  136. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  137. u8 *mac = (u8 *) KSEG1ADDR(0x1f03f810);
  138. ath79_register_m25p80(NULL);
  139. ath79_gpio_direction_select(DR34X_GPIO_LED_STATUS, true);
  140. gpio_set_value(DR34X_GPIO_LED_STATUS, 1);
  141. ath79_gpio_output_select(DR34X_GPIO_LED_STATUS, 0);
  142. ath79_register_gpio_keys_polled(-1, DR344_KEYS_POLL_INTERVAL,
  143. ARRAY_SIZE(dr34x_gpio_keys),
  144. dr34x_gpio_keys);
  145. ath79_register_usb();
  146. ath79_register_wmac(art + DR34X_WMAC_CALDATA_OFFSET, NULL);
  147. ath79_register_pci();
  148. mdiobus_register_board_info(dr34x_mdio0_info,
  149. ARRAY_SIZE(dr34x_mdio0_info));
  150. ath79_register_mdio(0, 0x0);
  151. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  152. AR934X_ETH_CFG_SW_ONLY_MODE);
  153. /* GMAC0 is connected to an AR8035 Gbps PHY */
  154. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  155. ath79_eth0_data.phy_mask = BIT(0);
  156. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  157. ath79_eth0_pll_data.pll_1000 = 0x02000000;
  158. ath79_eth0_pll_data.pll_100 = 0x0101;
  159. ath79_eth0_pll_data.pll_10 = 0x1313;
  160. ath79_init_mac(ath79_eth0_data.mac_addr, mac + DR34X_MAC0_OFFSET, 0);
  161. ath79_register_eth(0);
  162. }
  163. static void __init dr342_setup(void)
  164. {
  165. dr34x_setup();
  166. ath79_register_leds_gpio(-1, ARRAY_SIZE(dr342_leds_gpio),
  167. dr342_leds_gpio);
  168. }
  169. static void __init dr344_setup(void)
  170. {
  171. u8 *mac = (u8 *) KSEG1ADDR(0x1f03f810);
  172. dr34x_setup();
  173. ath79_gpio_direction_select(DR344_GPIO_LED_LAN, true);
  174. gpio_set_value(DR344_GPIO_LED_LAN, 1);
  175. ath79_gpio_output_select(DR344_GPIO_LED_LAN, 0);
  176. ath79_register_leds_gpio(-1, ARRAY_SIZE(dr344_leds_gpio),
  177. dr344_leds_gpio);
  178. ath79_wmac_set_ext_lna_gpio(0, DR344_GPIO_EXTERNAL_LNA0);
  179. ath79_wmac_set_ext_lna_gpio(1, DR344_GPIO_EXTERNAL_LNA1);
  180. ath79_register_mdio(1, 0x0);
  181. /* GMAC1 is connected to the internal switch */
  182. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  183. ath79_eth1_data.speed = SPEED_1000;
  184. ath79_eth1_data.duplex = DUPLEX_FULL;
  185. ath79_init_mac(ath79_eth1_data.mac_addr, mac + DR34X_MAC1_OFFSET, 0);
  186. ath79_register_eth(1);
  187. }
  188. MIPS_MACHINE(ATH79_MACH_DR342, "DR342", "Wallys DR342", dr342_setup);
  189. MIPS_MACHINE(ATH79_MACH_DR344, "DR344", "Wallys DR344", dr344_setup);