mach-tl-wa830re-v2.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * TP-LINK TL-WA830RE v2 board support
  3. *
  4. * Copyright (C) 2014 Fredrik Jonson <fredrik@famjonson.se>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/platform_device.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-usb.h"
  20. #include "dev-wmac.h"
  21. #include "machtypes.h"
  22. #define TL_WA830REV2_GPIO_LED_WLAN 13
  23. #define TL_WA830REV2_GPIO_LED_QSS 15
  24. #define TL_WA830REV2_GPIO_LED_LAN 18
  25. #define TL_WA830REV2_GPIO_LED_SYSTEM 14
  26. #define TL_WA830REV2_GPIO_BTN_RESET 17
  27. #define TL_WA830REV2_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */
  28. #define TL_WA830REV2_GPIO_USB_POWER 4
  29. #define TL_WA830REV2_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA830REV2_KEYS_POLL_INTERVAL)
  31. static const char *tl_wa830re_v2_part_probes[] = {
  32. "tp-link",
  33. NULL,
  34. };
  35. static struct flash_platform_data tl_wa830re_v2_flash_data = {
  36. .part_probes = tl_wa830re_v2_part_probes,
  37. };
  38. static struct gpio_led tl_wa830re_v2_leds_gpio[] __initdata = {
  39. {
  40. .name = "tp-link:green:qss",
  41. .gpio = TL_WA830REV2_GPIO_LED_QSS,
  42. .active_low = 1,
  43. }, {
  44. .name = "tp-link:green:system",
  45. .gpio = TL_WA830REV2_GPIO_LED_SYSTEM,
  46. .active_low = 1,
  47. }, {
  48. .name = "tp-link:green:lan",
  49. .gpio = TL_WA830REV2_GPIO_LED_LAN,
  50. .active_low = 1,
  51. }, {
  52. .name = "tp-link:green:wlan",
  53. .gpio = TL_WA830REV2_GPIO_LED_WLAN,
  54. .active_low = 1,
  55. },
  56. };
  57. static struct gpio_keys_button tl_wa830re_v2_gpio_keys[] __initdata = {
  58. {
  59. .desc = "Reset button",
  60. .type = EV_KEY,
  61. .code = KEY_RESTART,
  62. .debounce_interval = TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL,
  63. .gpio = TL_WA830REV2_GPIO_BTN_RESET,
  64. .active_low = 1,
  65. }, {
  66. .desc = "RFKILL switch",
  67. .type = EV_SW,
  68. .code = KEY_RFKILL,
  69. .debounce_interval = TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL,
  70. .gpio = TL_WA830REV2_GPIO_SW_RFKILL,
  71. .active_low = 0,
  72. }
  73. };
  74. static void __init tl_ap123_setup(void)
  75. {
  76. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  77. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  78. /* Disable JTAG, enabling GPIOs 0-3 */
  79. /* Configure OBS4 line, for GPIO 4*/
  80. ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  81. AR934X_GPIO_FUNC_CLK_OBS4_EN);
  82. /* config gpio4 as normal gpio function */
  83. ath79_gpio_output_select(TL_WA830REV2_GPIO_USB_POWER,
  84. AR934X_GPIO_OUT_GPIO);
  85. ath79_register_m25p80(&tl_wa830re_v2_flash_data);
  86. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  87. ath79_register_mdio(1, 0x0);
  88. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  89. /* GMAC0 is connected to the PHY0 of the internal switch */
  90. ath79_switch_data.phy4_mii_en = 1;
  91. ath79_switch_data.phy_poll_mask = BIT(0);
  92. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  93. ath79_eth0_data.phy_mask = BIT(0);
  94. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  95. ath79_register_eth(0);
  96. ath79_register_wmac(ee, mac);
  97. }
  98. static void __init tl_wa830re_v2_setup(void)
  99. {
  100. tl_ap123_setup();
  101. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa830re_v2_leds_gpio) - 1,
  102. tl_wa830re_v2_leds_gpio);
  103. ath79_register_gpio_keys_polled(1, TL_WA830REV2_KEYS_POLL_INTERVAL,
  104. ARRAY_SIZE(tl_wa830re_v2_gpio_keys),
  105. tl_wa830re_v2_gpio_keys);
  106. }
  107. MIPS_MACHINE(ATH79_MACH_TL_WA830RE_V2, "TL-WA830RE-v2", "TP-LINK TL-WA830RE v2",
  108. tl_wa830re_v2_setup);