mach-f9k1115v2.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Belkin AC1750DB (F9K1115V2) board support
  3. *
  4. * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/gpio.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/ar8216_platform.h>
  14. #include <asm/mach-ath79/ar71xx_regs.h>
  15. #include "common.h"
  16. #include "pci.h"
  17. #include "dev-gpio-buttons.h"
  18. #include "dev-eth.h"
  19. #include "dev-leds-gpio.h"
  20. #include "dev-m25p80.h"
  21. #include "dev-usb.h"
  22. #include "dev-wmac.h"
  23. #include "machtypes.h"
  24. #define F9K1115V2_GPIO_LED_USB2 4
  25. #define F9K1115V2_GPIO_LED_WPS_AMBER 14
  26. #define F9K1115V2_GPIO_LED_STATUS_AMBER 15
  27. #define F9K1115V2_GPIO_LED_WPS_BLUE 19
  28. #define F9K1115V2_GPIO_LED_STATUS_BLUE 20
  29. #define F9K1115V2_GPIO_BTN_WPS 16
  30. #define F9K1115V2_GPIO_BTN_RESET 17
  31. #define F9K1115V2_GPIO_USB2_POWER 21
  32. #define F9K1115V2_KEYS_POLL_INTERVAL 20 /* msecs */
  33. #define F9K1115V2_KEYS_DEBOUNCE_INTERVAL (3 * F9K1115V2_KEYS_POLL_INTERVAL)
  34. #define F9K1115V2_WAN_MAC_OFFSET 0
  35. #define F9K1115V2_LAN_MAC_OFFSET 6
  36. #define F9K1115V2_WMAC_CALDATA_OFFSET 0x1000
  37. #define F9K1115V2_PCIE_CALDATA_OFFSET 0x5000
  38. static struct gpio_led f9k1115v2_leds_gpio[] __initdata = {
  39. {
  40. .name = "belkin:amber:status",
  41. .gpio = F9K1115V2_GPIO_LED_STATUS_AMBER,
  42. .active_low = 1,
  43. },
  44. {
  45. .name = "belkin:blue:status",
  46. .gpio = F9K1115V2_GPIO_LED_STATUS_BLUE,
  47. .active_low = 1,
  48. },
  49. {
  50. .name = "belkin:blue:wps",
  51. .gpio = F9K1115V2_GPIO_LED_WPS_BLUE,
  52. .active_low = 1,
  53. },
  54. {
  55. .name = "belkin:amber:wps",
  56. .gpio = F9K1115V2_GPIO_LED_WPS_AMBER,
  57. .active_low = 1,
  58. },
  59. {
  60. .name = "belkin:green:usb2",
  61. .gpio = F9K1115V2_GPIO_LED_USB2,
  62. .active_low = 1,
  63. },
  64. };
  65. static struct gpio_keys_button f9k1115v2_gpio_keys[] __initdata = {
  66. {
  67. .desc = "Reset button",
  68. .type = EV_KEY,
  69. .code = KEY_RESTART,
  70. .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
  71. .gpio = F9K1115V2_GPIO_BTN_RESET,
  72. .active_low = 1,
  73. },
  74. {
  75. .desc = "WPS button",
  76. .type = EV_KEY,
  77. .code = KEY_WPS_BUTTON,
  78. .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
  79. .gpio = F9K1115V2_GPIO_BTN_WPS,
  80. .active_low = 1,
  81. },
  82. };
  83. static struct ar8327_pad_cfg f9k1115v2_ar8327_pad0_cfg = {
  84. /* Use the RGMII interface for the GMAC0 of the AR8337 switch */
  85. .mode = AR8327_PAD_MAC_RGMII,
  86. .txclk_delay_en = true,
  87. .rxclk_delay_en = true,
  88. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  89. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  90. };
  91. static struct ar8327_pad_cfg f9k1115v2_ar8327_pad6_cfg = {
  92. /* Use the SGMII interface for the GMAC6 of the AR8337 switch */
  93. .mode = AR8327_PAD_MAC_SGMII,
  94. .rxclk_delay_en = true,
  95. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  96. };
  97. static struct ar8327_platform_data f9k1115v2_ar8327_data = {
  98. .pad0_cfg = &f9k1115v2_ar8327_pad0_cfg,
  99. .pad6_cfg = &f9k1115v2_ar8327_pad6_cfg,
  100. .port0_cfg = {
  101. .force_link = 1,
  102. .speed = AR8327_PORT_SPEED_1000,
  103. .duplex = 1,
  104. .txpause = 1,
  105. .rxpause = 1,
  106. },
  107. .port6_cfg = {
  108. .force_link = 1,
  109. .speed = AR8327_PORT_SPEED_1000,
  110. .duplex = 1,
  111. .txpause = 1,
  112. .rxpause = 1,
  113. },
  114. };
  115. static struct mdio_board_info f9k1115v2_mdio0_info[] = {
  116. {
  117. .bus_id = "ag71xx-mdio.0",
  118. .phy_addr = 0,
  119. .platform_data = &f9k1115v2_ar8327_data,
  120. },
  121. };
  122. static void __init f9k1115v2_setup(void)
  123. {
  124. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  125. ath79_register_m25p80(NULL);
  126. ath79_register_leds_gpio(-1, ARRAY_SIZE(f9k1115v2_leds_gpio),
  127. f9k1115v2_leds_gpio);
  128. ath79_register_gpio_keys_polled(-1, F9K1115V2_KEYS_POLL_INTERVAL,
  129. ARRAY_SIZE(f9k1115v2_gpio_keys),
  130. f9k1115v2_gpio_keys);
  131. ath79_register_wmac(art + F9K1115V2_WMAC_CALDATA_OFFSET, NULL);
  132. ath79_register_mdio(0, 0x0);
  133. mdiobus_register_board_info(f9k1115v2_mdio0_info,
  134. ARRAY_SIZE(f9k1115v2_mdio0_info));
  135. ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  136. ath79_init_mac(ath79_eth0_data.mac_addr,
  137. art + F9K1115V2_WAN_MAC_OFFSET, 0);
  138. ath79_init_mac(ath79_eth1_data.mac_addr,
  139. art + F9K1115V2_LAN_MAC_OFFSET, 0);
  140. ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  141. ath79_eth1_pll_data.pll_1000 = 0x03000101;
  142. /* GMAC0 is connected to the RMGII interface */
  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_register_eth(0);
  147. /* GMAC1 is connected to the SGMII interface */
  148. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  149. ath79_eth1_data.speed = SPEED_1000;
  150. ath79_eth1_data.duplex = DUPLEX_FULL;
  151. ath79_register_eth(1);
  152. ath79_register_pci();
  153. ath79_register_usb();
  154. gpio_request_one(F9K1115V2_GPIO_USB2_POWER,
  155. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  156. "USB2 power");
  157. }
  158. MIPS_MACHINE(ATH79_MACH_F9K1115V2, "F9K1115V2", "Belkin AC1750DB",
  159. f9k1115v2_setup);