1
0

mach-tl-wa701nd-v2.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * TP-LINK TL-WA701ND v2 board support
  3. *
  4. * Copyright (C) 2015 Luigi Tarenga <luigi.tarenga@gmail.com>
  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 <asm/mach-ath79/ath79.h>
  12. #include "dev-eth.h"
  13. #include "dev-gpio-buttons.h"
  14. #include "dev-leds-gpio.h"
  15. #include "dev-m25p80.h"
  16. #include "dev-usb.h"
  17. #include "dev-wmac.h"
  18. #include "machtypes.h"
  19. #define TL_WA701NDV2_GPIO_LED_WLAN 0
  20. #define TL_WA701NDV2_GPIO_LED_QSS 1
  21. #define TL_WA701NDV2_GPIO_LED_LAN 17
  22. #define TL_WA701NDV2_GPIO_LED_SYSTEM 27
  23. #define TL_WA701NDV2_GPIO_BTN_RESET 11
  24. #define TL_WA701NDV2_GPIO_BTN_QSS 26
  25. #define TL_WA701NDV2_GPIO_USB_POWER 8
  26. #define TL_WA701NDV2_KEYS_POLL_INTERVAL 20 /* msecs */
  27. #define TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA701NDV2_KEYS_POLL_INTERVAL)
  28. static const char *tl_wa701ndv2_part_probes[] = {
  29. "tp-link",
  30. NULL,
  31. };
  32. static struct flash_platform_data tl_wa701ndv2_flash_data = {
  33. .part_probes = tl_wa701ndv2_part_probes,
  34. };
  35. static struct gpio_led tl_wa701ndv2_leds_gpio[] __initdata = {
  36. {
  37. .name = "tp-link:green:wlan",
  38. .gpio = TL_WA701NDV2_GPIO_LED_WLAN,
  39. .active_low = 0,
  40. }, {
  41. .name = "tp-link:green:qss",
  42. .gpio = TL_WA701NDV2_GPIO_LED_QSS,
  43. .active_low = 0,
  44. }, {
  45. .name = "tp-link:green:lan",
  46. .gpio = TL_WA701NDV2_GPIO_LED_LAN,
  47. .active_low = 1,
  48. }, {
  49. .name = "tp-link:green:system",
  50. .gpio = TL_WA701NDV2_GPIO_LED_SYSTEM,
  51. .active_low = 1,
  52. }
  53. };
  54. static struct gpio_keys_button tl_wa701ndv2_gpio_keys[] __initdata = {
  55. {
  56. .desc = "reset",
  57. .type = EV_KEY,
  58. .code = KEY_RESTART,
  59. .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
  60. .gpio = TL_WA701NDV2_GPIO_BTN_RESET,
  61. .active_low = 0,
  62. } , {
  63. .desc = "qss",
  64. .type = EV_KEY,
  65. .code = KEY_WPS_BUTTON,
  66. .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
  67. .gpio = TL_WA701NDV2_GPIO_BTN_QSS,
  68. .active_low = 0,
  69. }
  70. };
  71. static void __init tl_wa701ndv2_setup(void)
  72. {
  73. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  74. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  75. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  76. ath79_setup_ar933x_phy4_switch(false, false);
  77. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa701ndv2_leds_gpio),
  78. tl_wa701ndv2_leds_gpio);
  79. ath79_register_gpio_keys_polled(-1, TL_WA701NDV2_KEYS_POLL_INTERVAL,
  80. ARRAY_SIZE(tl_wa701ndv2_gpio_keys),
  81. tl_wa701ndv2_gpio_keys);
  82. gpio_request_one(TL_WA701NDV2_GPIO_USB_POWER,
  83. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  84. "USB power");
  85. ath79_register_usb();
  86. ath79_register_m25p80(&tl_wa701ndv2_flash_data);
  87. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  88. /* ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1); */
  89. ath79_register_mdio(0, 0x0);
  90. ath79_register_eth(0);
  91. ath79_register_eth(1);
  92. ath79_register_wmac(ee, mac);
  93. }
  94. MIPS_MACHINE(ATH79_MACH_TL_WA701ND_V2, "TL-WA701ND-v2",
  95. "TP-LINK TL-WA701ND v2", tl_wa701ndv2_setup);