mach-wpj558.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Compex WPJ558 board support
  3. *
  4. * Copyright (c) 2012 Qualcomm Atheros
  5. * Copyright (c) 2012-2013 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/gpio.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/ath9k_platform.h>
  25. #include <linux/ar8216_platform.h>
  26. #include <asm/mach-ath79/ar71xx_regs.h>
  27. #include "common.h"
  28. #include "pci.h"
  29. #include "dev-ap9x-pci.h"
  30. #include "dev-gpio-buttons.h"
  31. #include "dev-eth.h"
  32. #include "dev-usb.h"
  33. #include "dev-leds-gpio.h"
  34. #include "dev-m25p80.h"
  35. #include "dev-spi.h"
  36. #include "dev-wmac.h"
  37. #include "machtypes.h"
  38. #define WPJ558_GPIO_LED_SIG1 14
  39. #define WPJ558_GPIO_LED_SIG2 15
  40. #define WPJ558_GPIO_LED_SIG3 22
  41. #define WPJ558_GPIO_LED_SIG4 23
  42. #define WPJ558_GPIO_BUZZER 4
  43. #define WPJ558_GPIO_BTN_RESET 17
  44. #define WPJ558_KEYS_POLL_INTERVAL 20 /* msecs */
  45. #define WPJ558_KEYS_DEBOUNCE_INTERVAL (3 * WPJ558_KEYS_POLL_INTERVAL)
  46. #define WPJ558_MAC_OFFSET 0x1002
  47. #define WPJ558_WMAC_CALDATA_OFFSET 0x1000
  48. static struct gpio_led wpj558_leds_gpio[] __initdata = {
  49. {
  50. .name = "wpj558:red:sig1",
  51. .gpio = WPJ558_GPIO_LED_SIG1,
  52. .active_low = 1,
  53. },
  54. {
  55. .name = "wpj558:yellow:sig2",
  56. .gpio = WPJ558_GPIO_LED_SIG2,
  57. .active_low = 1,
  58. },
  59. {
  60. .name = "wpj558:green:sig3",
  61. .gpio = WPJ558_GPIO_LED_SIG3,
  62. .active_low = 1,
  63. },
  64. {
  65. .name = "wpj558:green:sig4",
  66. .gpio = WPJ558_GPIO_LED_SIG4,
  67. .active_low = 1,
  68. },
  69. {
  70. .name = "wpj558:buzzer",
  71. .gpio = WPJ558_GPIO_BUZZER,
  72. .active_low = 0,
  73. }
  74. };
  75. static struct gpio_keys_button wpj558_gpio_keys[] __initdata = {
  76. {
  77. .desc = "reset",
  78. .type = EV_KEY,
  79. .code = KEY_RESTART,
  80. .debounce_interval = WPJ558_KEYS_DEBOUNCE_INTERVAL,
  81. .gpio = WPJ558_GPIO_BTN_RESET,
  82. .active_low = 1,
  83. },
  84. };
  85. static struct ar8327_pad_cfg wpj558_ar8327_pad0_cfg = {
  86. .mode = AR8327_PAD_MAC_SGMII,
  87. .sgmii_delay_en = true,
  88. };
  89. static struct ar8327_pad_cfg wpj558_ar8327_pad6_cfg = {
  90. .mode = AR8327_PAD_MAC_RGMII,
  91. .txclk_delay_en = true,
  92. .rxclk_delay_en = true,
  93. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  94. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  95. };
  96. static struct ar8327_platform_data wpj558_ar8327_data = {
  97. .pad0_cfg = &wpj558_ar8327_pad0_cfg,
  98. .pad6_cfg = &wpj558_ar8327_pad6_cfg,
  99. .port0_cfg = {
  100. .force_link = 1,
  101. .speed = AR8327_PORT_SPEED_1000,
  102. .duplex = 1,
  103. .txpause = 1,
  104. .rxpause = 1,
  105. },
  106. .port6_cfg = {
  107. .force_link = 1,
  108. .speed = AR8327_PORT_SPEED_1000,
  109. .duplex = 1,
  110. .txpause = 1,
  111. .rxpause = 1,
  112. },
  113. };
  114. static struct mdio_board_info wpj558_mdio0_info[] = {
  115. {
  116. .bus_id = "ag71xx-mdio.0",
  117. .phy_addr = 0,
  118. .platform_data = &wpj558_ar8327_data,
  119. },
  120. };
  121. static void __init wpj558_setup(void)
  122. {
  123. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  124. ath79_register_m25p80(NULL);
  125. ath79_register_leds_gpio(-1, ARRAY_SIZE(wpj558_leds_gpio),
  126. wpj558_leds_gpio);
  127. ath79_register_gpio_keys_polled(-1, WPJ558_KEYS_POLL_INTERVAL,
  128. ARRAY_SIZE(wpj558_gpio_keys),
  129. wpj558_gpio_keys);
  130. ath79_register_usb();
  131. ath79_register_wmac(art + WPJ558_WMAC_CALDATA_OFFSET, NULL);
  132. ath79_register_pci();
  133. mdiobus_register_board_info(wpj558_mdio0_info,
  134. ARRAY_SIZE(wpj558_mdio0_info));
  135. ath79_register_mdio(0, 0x0);
  136. ath79_init_mac(ath79_eth0_data.mac_addr, art + WPJ558_MAC_OFFSET, 0);
  137. ath79_init_mac(ath79_eth1_data.mac_addr, art + WPJ558_MAC_OFFSET, 0);
  138. ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  139. /* GMAC0 is connected to an AR8327 switch */
  140. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  141. ath79_eth0_data.phy_mask = BIT(0);
  142. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  143. ath79_eth0_pll_data.pll_1000 = 0x56000000;
  144. /* GMAC1 is connected to the SGMII interface */
  145. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  146. ath79_eth1_data.speed = SPEED_1000;
  147. ath79_eth1_data.duplex = DUPLEX_FULL;
  148. ath79_eth1_pll_data.pll_1000 = 0x03000101;
  149. ath79_register_eth(0);
  150. ath79_register_eth(1);
  151. }
  152. MIPS_MACHINE(ATH79_MACH_WPJ558, "WPJ558", "Compex WPJ558", wpj558_setup);