mach-tl-mr3020.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * TP-LINK TL-MR3020 board support
  3. *
  4. * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  5. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  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/gpio.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.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. #define TL_MR3020_GPIO_LED_3G 27
  22. #define TL_MR3020_GPIO_LED_WLAN 0
  23. #define TL_MR3020_GPIO_LED_LAN 17
  24. #define TL_MR3020_GPIO_LED_WPS 26
  25. #define TL_MR3020_GPIO_BTN_WPS 11
  26. #define TL_MR3020_GPIO_BTN_SW1 18
  27. #define TL_MR3020_GPIO_BTN_SW2 20
  28. #define TL_MR3020_GPIO_USB_POWER 8
  29. #define TL_MR3020_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define TL_MR3020_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3020_KEYS_POLL_INTERVAL)
  31. static const char *tl_mr3020_part_probes[] = {
  32. "tp-link",
  33. NULL,
  34. };
  35. static struct flash_platform_data tl_mr3020_flash_data = {
  36. .part_probes = tl_mr3020_part_probes,
  37. };
  38. static struct gpio_led tl_mr3020_leds_gpio[] __initdata = {
  39. {
  40. .name = "tp-link:green:3g",
  41. .gpio = TL_MR3020_GPIO_LED_3G,
  42. .active_low = 1,
  43. },
  44. {
  45. .name = "tp-link:green:wlan",
  46. .gpio = TL_MR3020_GPIO_LED_WLAN,
  47. .active_low = 0,
  48. },
  49. {
  50. .name = "tp-link:green:lan",
  51. .gpio = TL_MR3020_GPIO_LED_LAN,
  52. .active_low = 1,
  53. },
  54. {
  55. .name = "tp-link:green:wps",
  56. .gpio = TL_MR3020_GPIO_LED_WPS,
  57. .active_low = 1,
  58. },
  59. };
  60. static struct gpio_keys_button tl_mr3020_gpio_keys[] __initdata = {
  61. {
  62. .desc = "wps",
  63. .type = EV_KEY,
  64. .code = KEY_WPS_BUTTON,
  65. .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
  66. .gpio = TL_MR3020_GPIO_BTN_WPS,
  67. .active_low = 0,
  68. },
  69. {
  70. .desc = "sw1",
  71. .type = EV_SW,
  72. .code = BTN_0,
  73. .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
  74. .gpio = TL_MR3020_GPIO_BTN_SW1,
  75. .active_low = 0,
  76. },
  77. {
  78. .desc = "sw2",
  79. .type = EV_SW,
  80. .code = BTN_1,
  81. .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
  82. .gpio = TL_MR3020_GPIO_BTN_SW2,
  83. .active_low = 0,
  84. }
  85. };
  86. static void __init tl_mr3020_setup(void)
  87. {
  88. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  89. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  90. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  91. ath79_setup_ar933x_phy4_switch(false, false);
  92. ath79_register_m25p80(&tl_mr3020_flash_data);
  93. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3020_leds_gpio),
  94. tl_mr3020_leds_gpio);
  95. ath79_register_gpio_keys_polled(-1, TL_MR3020_KEYS_POLL_INTERVAL,
  96. ARRAY_SIZE(tl_mr3020_gpio_keys),
  97. tl_mr3020_gpio_keys);
  98. gpio_request_one(TL_MR3020_GPIO_USB_POWER,
  99. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  100. "USB power");
  101. ath79_register_usb();
  102. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  103. ath79_register_mdio(0, 0x0);
  104. ath79_register_eth(0);
  105. ath79_register_wmac(ee, mac);
  106. }
  107. MIPS_MACHINE(ATH79_MACH_TL_MR3020, "TL-MR3020", "TP-LINK TL-MR3020",
  108. tl_mr3020_setup);