mach-dr344.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Wallys DR344 board 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. *
  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/phy.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/ath9k_platform.h>
  24. #include <linux/ar8216_platform.h>
  25. #include <asm/mach-ath79/ar71xx_regs.h>
  26. #include "common.h"
  27. #include "pci.h"
  28. #include "dev-ap9x-pci.h"
  29. #include "dev-gpio-buttons.h"
  30. #include "dev-eth.h"
  31. #include "dev-usb.h"
  32. #include "dev-leds-gpio.h"
  33. #include "dev-m25p80.h"
  34. #include "dev-spi.h"
  35. #include "dev-wmac.h"
  36. #include "machtypes.h"
  37. #define DR344_GPIO_LED_SIG1 15
  38. #define DR344_GPIO_LED_SIG2 11
  39. #define DR344_GPIO_LED_SIG3 12
  40. #define DR344_GPIO_LED_SIG4 13
  41. #define DR344_GPIO_EXTERNAL_LNA0 18
  42. #define DR344_GPIO_EXTERNAL_LNA1 19
  43. #define DR344_GPIO_LED_STATUS 14
  44. #define DR344_GPIO_BTN_RESET 12
  45. #define DR344_KEYS_POLL_INTERVAL 20 /* msecs */
  46. #define DR344_KEYS_DEBOUNCE_INTERVAL (3 * DR344_KEYS_POLL_INTERVAL)
  47. #define DR344_MAC0_OFFSET 0
  48. #define DR344_MAC1_OFFSET 8
  49. #define DR344_WMAC_CALDATA_OFFSET 0x1000
  50. #define DR344_PCIE_CALDATA_OFFSET 0x5000
  51. static struct gpio_led dr344_leds_gpio[] __initdata = {
  52. {
  53. .name = "dr344:green:status",
  54. .gpio = DR344_GPIO_LED_STATUS,
  55. .active_low = 1,
  56. },
  57. {
  58. .name = "dr344:red:sig1",
  59. .gpio = DR344_GPIO_LED_SIG1,
  60. .active_low = 1,
  61. },
  62. {
  63. .name = "dr344:yellow:sig2",
  64. .gpio = DR344_GPIO_LED_SIG2,
  65. .active_low = 1,
  66. },
  67. {
  68. .name = "dr344:green:sig3",
  69. .gpio = DR344_GPIO_LED_SIG3,
  70. .active_low = 1,
  71. },
  72. {
  73. .name = "dr344:green:sig4",
  74. .gpio = DR344_GPIO_LED_SIG4,
  75. .active_low = 1,
  76. }
  77. };
  78. static struct gpio_keys_button dr344_gpio_keys[] __initdata = {
  79. {
  80. .desc = "reset",
  81. .type = EV_KEY,
  82. .code = KEY_RESTART,
  83. .debounce_interval = DR344_KEYS_DEBOUNCE_INTERVAL,
  84. .gpio = DR344_GPIO_BTN_RESET,
  85. .active_low = 1,
  86. },
  87. };
  88. static struct ar8327_pad_cfg dr344_ar8327_pad0_cfg = {
  89. .mode = AR8327_PAD_MAC_RGMII,
  90. .txclk_delay_en = true,
  91. .rxclk_delay_en = true,
  92. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  93. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  94. };
  95. static struct ar8327_led_cfg dr344_ar8327_led_cfg = {
  96. .led_ctrl0 = 0x00000000,
  97. .led_ctrl1 = 0xc737c737,
  98. .led_ctrl2 = 0x00000000,
  99. .led_ctrl3 = 0x00c30c00,
  100. .open_drain = true,
  101. };
  102. static struct ar8327_platform_data dr344_ar8327_data = {
  103. .pad0_cfg = &dr344_ar8327_pad0_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. .led_cfg = &dr344_ar8327_led_cfg,
  112. };
  113. static struct mdio_board_info dr344_mdio0_info[] = {
  114. {
  115. .bus_id = "ag71xx-mdio.0",
  116. .phy_addr = 0,
  117. .platform_data = &dr344_ar8327_data,
  118. },
  119. };
  120. static void __init dr344_setup(void)
  121. {
  122. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  123. ath79_register_m25p80(NULL);
  124. ath79_register_leds_gpio(-1, ARRAY_SIZE(dr344_leds_gpio),
  125. dr344_leds_gpio);
  126. ath79_register_gpio_keys_polled(-1, DR344_KEYS_POLL_INTERVAL,
  127. ARRAY_SIZE(dr344_gpio_keys),
  128. dr344_gpio_keys);
  129. ath79_register_usb();
  130. ath79_wmac_set_ext_lna_gpio(0, DR344_GPIO_EXTERNAL_LNA0);
  131. ath79_wmac_set_ext_lna_gpio(1, DR344_GPIO_EXTERNAL_LNA1);
  132. ath79_register_wmac(art + DR344_WMAC_CALDATA_OFFSET, NULL);
  133. ath79_register_pci();
  134. mdiobus_register_board_info(dr344_mdio0_info,
  135. ARRAY_SIZE(dr344_mdio0_info));
  136. ath79_register_mdio(1, 0x0);
  137. ath79_register_mdio(0, 0x0);
  138. ath79_init_mac(ath79_eth0_data.mac_addr, art + DR344_MAC0_OFFSET, 0);
  139. ath79_init_mac(ath79_eth1_data.mac_addr, art + DR344_MAC1_OFFSET, 0);
  140. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  141. AR934X_ETH_CFG_SW_ONLY_MODE);
  142. /* GMAC0 is connected to an AR8327 switch */
  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_eth0_pll_data.pll_1000 = 0x0e000000;
  147. ath79_eth0_pll_data.pll_100 = 0x0101;
  148. ath79_eth0_pll_data.pll_10 = 0x1313;
  149. /* GMAC1 is connected to the internal switch */
  150. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  151. ath79_eth1_data.speed = SPEED_1000;
  152. ath79_eth1_data.duplex = DUPLEX_FULL;
  153. ath79_register_eth(0);
  154. ath79_register_eth(1);
  155. }
  156. MIPS_MACHINE(ATH79_MACH_DR344, "DR344", "Wallys DR344", dr344_setup);