mach-e1700ac-v2.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Qxwlan E1700AC v2 board support
  3. *
  4. * Copyright (C) 2017 Peng Zhang <sd20@qxwlan.com>
  5. * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com>
  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/platform_device.h>
  12. #include <linux/ar8216_platform.h>
  13. #include "common.h"
  14. #include "dev-eth.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "dev-usb.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #include "pci.h"
  22. #define E1700AC_V2_GPIO_LED_SYS 1
  23. #define E1700AC_V2_GPIO_LED_USB 7
  24. #define E1700AC_V2_GPIO_LED_WLAN2G 19
  25. #define E1700AC_V2_GPIO_BTN_SW1 2
  26. #define E1700AC_V2_GPIO_BTN_RESET 11
  27. #define E1700AC_V2_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define E1700AC_V2_KEYS_DEBOUNCE_INTERVAL \
  29. (3 * E1700AC_V2_KEYS_POLL_INTERVAL)
  30. static struct gpio_led e1700ac_v2_leds_gpio[] __initdata = {
  31. {
  32. .name = "e1700ac-v2:green:system",
  33. .gpio = E1700AC_V2_GPIO_LED_SYS,
  34. .active_low = 1,
  35. }, {
  36. .name = "e1700ac-v2:green:usb",
  37. .gpio = E1700AC_V2_GPIO_LED_USB,
  38. .active_low = 1,
  39. }, {
  40. .name = "e1700ac-v2:green:wlan2g",
  41. .gpio = E1700AC_V2_GPIO_LED_WLAN2G,
  42. .active_low = 1,
  43. },
  44. };
  45. static struct gpio_keys_button e1700ac_v2_gpio_keys[] __initdata = {
  46. {
  47. .desc = "reset",
  48. .type = EV_KEY,
  49. .code = KEY_RESTART,
  50. .debounce_interval = E1700AC_V2_KEYS_DEBOUNCE_INTERVAL,
  51. .gpio = E1700AC_V2_GPIO_BTN_RESET,
  52. .active_low = 1,
  53. }, {
  54. .desc = "sw1",
  55. .type = EV_KEY,
  56. .code = BTN_0,
  57. .debounce_interval = E1700AC_V2_KEYS_DEBOUNCE_INTERVAL,
  58. .gpio = E1700AC_V2_GPIO_BTN_SW1,
  59. .active_low = 1,
  60. },
  61. };
  62. static const struct ar8327_led_info e1700ac_v2_leds_qca8334[] = {
  63. AR8327_LED_INFO(PHY1_0, HW, "e1700ac-v2:green:lan"),
  64. AR8327_LED_INFO(PHY2_0, HW, "e1700ac-v2:green:wan"),
  65. };
  66. /* Blink rate: 1 Gbps -> 8 hz, 100 Mbs -> 4 Hz, 10 Mbps -> 2 Hz */
  67. static struct ar8327_led_cfg e1700ac_v2_qca8334_led_cfg = {
  68. .led_ctrl0 = 0xcf37cf37,
  69. .led_ctrl1 = 0xcf37cf37,
  70. .led_ctrl2 = 0xcf37cf37,
  71. .led_ctrl3 = 0x0,
  72. .open_drain = true,
  73. };
  74. static struct ar8327_pad_cfg e1700ac_v2_qca8334_pad0_cfg = {
  75. .mode = AR8327_PAD_MAC_SGMII,
  76. .sgmii_delay_en = true,
  77. };
  78. static struct ar8327_platform_data e1700ac_v2_qca8334_data = {
  79. .pad0_cfg = &e1700ac_v2_qca8334_pad0_cfg,
  80. .port0_cfg = {
  81. .force_link = 1,
  82. .speed = AR8327_PORT_SPEED_1000,
  83. .duplex = 1,
  84. .txpause = 1,
  85. .rxpause = 1,
  86. },
  87. .led_cfg = &e1700ac_v2_qca8334_led_cfg,
  88. .leds = e1700ac_v2_leds_qca8334,
  89. .num_leds = ARRAY_SIZE(e1700ac_v2_leds_qca8334),
  90. };
  91. static struct mdio_board_info e1700ac_v2_mdio0_info[] = {
  92. {
  93. .bus_id = "ag71xx-mdio.0",
  94. .mdio_addr = 0,
  95. .platform_data = &e1700ac_v2_qca8334_data,
  96. },
  97. };
  98. static void __init e1700ac_v2_setup(void)
  99. {
  100. u8 *mac = (u8 *) KSEG1ADDR(0x1f050400);
  101. u8 *art = (u8 *) KSEG1ADDR(0x1f061000);
  102. ath79_register_m25p80(NULL);
  103. ath79_register_leds_gpio(-1, ARRAY_SIZE(e1700ac_v2_leds_gpio),
  104. e1700ac_v2_leds_gpio);
  105. ath79_register_gpio_keys_polled(-1, E1700AC_V2_KEYS_POLL_INTERVAL,
  106. ARRAY_SIZE(e1700ac_v2_gpio_keys),
  107. e1700ac_v2_gpio_keys);
  108. ath79_register_mdio(0, 0x0);
  109. mdiobus_register_board_info(e1700ac_v2_mdio0_info,
  110. ARRAY_SIZE(e1700ac_v2_mdio0_info));
  111. /* GMAC0 is connected to QCA8334 switch */
  112. ath79_eth0_data.duplex = DUPLEX_FULL;
  113. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  114. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  115. ath79_eth0_data.phy_mask = BIT(0);
  116. ath79_eth0_data.speed = SPEED_1000;
  117. ath79_eth0_pll_data.pll_1000 = 0x03000101;
  118. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  119. ath79_register_eth(0);
  120. ath79_register_pci();
  121. ath79_register_usb();
  122. ath79_register_wmac(art, NULL);
  123. }
  124. MIPS_MACHINE(ATH79_MACH_E1700AC_V2, "E1700AC-V2", "Qxwlan E1700AC v2",
  125. e1700ac_v2_setup);