mach-cf-e316n-v2.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * COMFAST CF-E316N v2
  3. * by Shenzhen Four Seas Global Link Network Technology Co., Ltd
  4. *
  5. * aka CF-E316V2, CF-E316N-V2 and CF-E316Nv2.0 (no FCC ID)
  6. *
  7. * Copyright (C) 2015 Paul Fertser <fercerpav@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. */
  13. #include <linux/gpio.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/timer.h>
  16. #include <asm/mach-ath79/ath79.h>
  17. #include <asm/mach-ath79/ar71xx_regs.h>
  18. #include "common.h"
  19. #include "dev-eth.h"
  20. #include "dev-gpio-buttons.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-m25p80.h"
  23. #include "dev-wmac.h"
  24. #include "dev-usb.h"
  25. #include "machtypes.h"
  26. static struct gpio_led cf_e316n_v2_leds_gpio[] __initdata = {
  27. {
  28. .name = "cf-e316n-v2:blue:diag",
  29. .gpio = 0,
  30. .active_low = 0,
  31. }, {
  32. .name = "cf-e316n-v2:red:diag",
  33. .gpio = 2,
  34. .active_low = 0,
  35. }, {
  36. .name = "cf-e316n-v2:green:diag",
  37. .gpio = 3,
  38. .active_low = 0,
  39. }, {
  40. .name = "cf-e316n-v2:blue:wlan",
  41. .gpio = 12,
  42. .active_low = 1,
  43. }, {
  44. .name = "cf-e316n-v2:blue:wan",
  45. .gpio = 17,
  46. .active_low = 1,
  47. }, {
  48. .name = "cf-e316n-v2:blue:lan",
  49. .gpio = 19,
  50. .active_low = 1,
  51. },
  52. };
  53. static struct gpio_keys_button cf_e316n_v2_gpio_keys[] __initdata = {
  54. {
  55. .desc = "Reset button",
  56. .type = EV_KEY,
  57. .code = KEY_RESTART,
  58. .debounce_interval = 60,
  59. .gpio = 20,
  60. .active_low = 1,
  61. },
  62. };
  63. /* There's a Pericon Technology PT7A7514 connected to GPIO 16 */
  64. #define EXT_WATCHDOG_GPIO 16
  65. static struct timer_list gpio_wdt_timer;
  66. static void gpio_wdt_toggle(unsigned long period)
  67. {
  68. static int state;
  69. state = !state;
  70. gpio_set_value(EXT_WATCHDOG_GPIO, state);
  71. mod_timer(&gpio_wdt_timer, jiffies + period);
  72. }
  73. static void __init cf_e316n_v2_setup(void)
  74. {
  75. u8 *maclan = (u8 *) KSEG1ADDR(0x1f010000);
  76. u8 *macwlan = (u8 *) KSEG1ADDR(0x1f011002);
  77. u8 *ee = (u8 *) KSEG1ADDR(0x1f011000);
  78. u8 tmpmac[ETH_ALEN];
  79. gpio_request(EXT_WATCHDOG_GPIO, "PT7A7514 watchdog");
  80. gpio_direction_output(EXT_WATCHDOG_GPIO, 0);
  81. setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, msecs_to_jiffies(500));
  82. gpio_wdt_toggle(msecs_to_jiffies(1));
  83. ath79_register_m25p80(NULL);
  84. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  85. ath79_register_mdio(1, 0x0);
  86. /* GMAC0 is connected to the PHY0 of the internal switch */
  87. ath79_switch_data.phy4_mii_en = 1;
  88. ath79_switch_data.phy_poll_mask = BIT(0);
  89. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  90. ath79_eth0_data.phy_mask = BIT(0);
  91. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  92. ath79_init_mac(ath79_eth0_data.mac_addr, maclan, 0);
  93. ath79_register_eth(0);
  94. /* GMAC1 is connected to the internal switch */
  95. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  96. ath79_init_mac(ath79_eth1_data.mac_addr, maclan, 2);
  97. ath79_register_eth(1);
  98. /* Enable 2x Skyworks SE2576L WLAN power amplifiers */
  99. gpio_request(13, "RF Amp 1");
  100. gpio_direction_output(13, 1);
  101. gpio_request(14, "RF Amp 2");
  102. gpio_direction_output(14, 1);
  103. ath79_init_mac(tmpmac, macwlan, 0);
  104. ath79_register_wmac(ee, tmpmac);
  105. ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio),
  106. cf_e316n_v2_leds_gpio);
  107. ath79_register_gpio_keys_polled(1, 20,
  108. ARRAY_SIZE(cf_e316n_v2_gpio_keys),
  109. cf_e316n_v2_gpio_keys);
  110. /* J1 is a High-Speed USB port, pin 1 is Vcc */
  111. ath79_register_usb();
  112. }
  113. MIPS_MACHINE(ATH79_MACH_CF_E316N_V2, "CF-E316N-V2", "COMFAST CF-E316N v2",
  114. cf_e316n_v2_setup);