mach-tl-mr3x20.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * TP-LINK TL-MR3220/3420 board support
  3. *
  4. * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  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-ap9x-pci.h"
  14. #include "dev-gpio-buttons.h"
  15. #include "dev-leds-gpio.h"
  16. #include "dev-m25p80.h"
  17. #include "dev-usb.h"
  18. #include "machtypes.h"
  19. #define TL_MR3X20_GPIO_LED_QSS 0
  20. #define TL_MR3X20_GPIO_LED_SYSTEM 1
  21. #define TL_MR3X20_GPIO_LED_3G 8
  22. #define TL_MR3X20_GPIO_BTN_RESET 11
  23. #define TL_MR3X20_GPIO_BTN_QSS 12
  24. #define TL_MR3X20_GPIO_USB_POWER 6
  25. #define TL_MR3X20_KEYS_POLL_INTERVAL 20 /* msecs */
  26. #define TL_MR3X20_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3X20_KEYS_POLL_INTERVAL)
  27. static const char *tl_mr3x20_part_probes[] = {
  28. "tp-link",
  29. NULL,
  30. };
  31. static struct flash_platform_data tl_mr3x20_flash_data = {
  32. .part_probes = tl_mr3x20_part_probes,
  33. };
  34. static struct gpio_led tl_mr3x20_leds_gpio[] __initdata = {
  35. {
  36. .name = "tp-link:green:system",
  37. .gpio = TL_MR3X20_GPIO_LED_SYSTEM,
  38. .active_low = 1,
  39. }, {
  40. .name = "tp-link:green:qss",
  41. .gpio = TL_MR3X20_GPIO_LED_QSS,
  42. .active_low = 1,
  43. }, {
  44. .name = "tp-link:green:3g",
  45. .gpio = TL_MR3X20_GPIO_LED_3G,
  46. .active_low = 1,
  47. }
  48. };
  49. static struct gpio_keys_button tl_mr3x20_gpio_keys[] __initdata = {
  50. {
  51. .desc = "reset",
  52. .type = EV_KEY,
  53. .code = KEY_RESTART,
  54. .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
  55. .gpio = TL_MR3X20_GPIO_BTN_RESET,
  56. .active_low = 1,
  57. }, {
  58. .desc = "qss",
  59. .type = EV_KEY,
  60. .code = KEY_WPS_BUTTON,
  61. .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
  62. .gpio = TL_MR3X20_GPIO_BTN_QSS,
  63. .active_low = 1,
  64. }
  65. };
  66. static void __init tl_ap99_setup(void)
  67. {
  68. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  69. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  70. ath79_register_m25p80(&tl_mr3x20_flash_data);
  71. ath79_register_gpio_keys_polled(-1, TL_MR3X20_KEYS_POLL_INTERVAL,
  72. ARRAY_SIZE(tl_mr3x20_gpio_keys),
  73. tl_mr3x20_gpio_keys);
  74. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  75. ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  76. ath79_register_mdio(0, 0x0);
  77. /* LAN ports */
  78. ath79_register_eth(1);
  79. /* WAN port */
  80. ath79_register_eth(0);
  81. ap91_pci_init(ee, mac);
  82. }
  83. static void __init tl_mr3x20_usb_setup(void)
  84. {
  85. /* enable power for the USB port */
  86. gpio_request_one(TL_MR3X20_GPIO_USB_POWER,
  87. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  88. "USB power");
  89. ath79_register_usb();
  90. }
  91. static void __init tl_mr3220_setup(void)
  92. {
  93. tl_ap99_setup();
  94. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
  95. tl_mr3x20_leds_gpio);
  96. ap9x_pci_setup_wmac_led_pin(0, 1);
  97. tl_mr3x20_usb_setup();
  98. }
  99. MIPS_MACHINE(ATH79_MACH_TL_MR3220, "TL-MR3220", "TP-LINK TL-MR3220",
  100. tl_mr3220_setup);
  101. static void __init tl_mr3420_setup(void)
  102. {
  103. tl_ap99_setup();
  104. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
  105. tl_mr3x20_leds_gpio);
  106. ap9x_pci_setup_wmac_led_pin(0, 0);
  107. tl_mr3x20_usb_setup();
  108. }
  109. MIPS_MACHINE(ATH79_MACH_TL_MR3420, "TL-MR3420", "TP-LINK TL-MR3420",
  110. tl_mr3420_setup);
  111. static void __init tl_wr841n_v7_setup(void)
  112. {
  113. tl_ap99_setup();
  114. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio) - 1,
  115. tl_mr3x20_leds_gpio);
  116. ap9x_pci_setup_wmac_led_pin(0, 0);
  117. }
  118. MIPS_MACHINE(ATH79_MACH_TL_WR841N_V7, "TL-WR841N-v7",
  119. "TP-LINK TL-WR841N/ND v7", tl_wr841n_v7_setup);