mach-tl-wr941nd.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * TP-LINK TL-WR941ND board support
  3. *
  4. * Copyright (C) 2009-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/platform_device.h>
  11. #include <asm/mach-ath79/ath79.h>
  12. #include "dev-dsa.h"
  13. #include "dev-eth.h"
  14. #include "dev-gpio-buttons.h"
  15. #include "dev-leds-gpio.h"
  16. #include "dev-m25p80.h"
  17. #include "dev-wmac.h"
  18. #include "machtypes.h"
  19. #define TL_WR941ND_GPIO_LED_SYSTEM 2
  20. #define TL_WR941ND_GPIO_LED_QSS_RED 4
  21. #define TL_WR941ND_GPIO_LED_QSS_GREEN 5
  22. #define TL_WR941ND_GPIO_LED_WLAN 9
  23. #define TL_WR941ND_GPIO_BTN_RESET 3
  24. #define TL_WR941ND_GPIO_BTN_QSS 7
  25. #define TL_WR941ND_KEYS_POLL_INTERVAL 20 /* msecs */
  26. #define TL_WR941ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR941ND_KEYS_POLL_INTERVAL)
  27. static const char *tl_wr941nd_part_probes[] = {
  28. "tp-link",
  29. NULL,
  30. };
  31. static struct flash_platform_data tl_wr941nd_flash_data = {
  32. .part_probes = tl_wr941nd_part_probes,
  33. };
  34. static struct gpio_led tl_wr941nd_leds_gpio[] __initdata = {
  35. {
  36. .name = "tp-link:green:system",
  37. .gpio = TL_WR941ND_GPIO_LED_SYSTEM,
  38. .active_low = 1,
  39. }, {
  40. .name = "tp-link:red:qss",
  41. .gpio = TL_WR941ND_GPIO_LED_QSS_RED,
  42. }, {
  43. .name = "tp-link:green:qss",
  44. .gpio = TL_WR941ND_GPIO_LED_QSS_GREEN,
  45. }, {
  46. .name = "tp-link:green:wlan",
  47. .gpio = TL_WR941ND_GPIO_LED_WLAN,
  48. .active_low = 1,
  49. }
  50. };
  51. static struct gpio_keys_button tl_wr941nd_gpio_keys[] __initdata = {
  52. {
  53. .desc = "reset",
  54. .type = EV_KEY,
  55. .code = KEY_RESTART,
  56. .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
  57. .gpio = TL_WR941ND_GPIO_BTN_RESET,
  58. .active_low = 1,
  59. }, {
  60. .desc = "qss",
  61. .type = EV_KEY,
  62. .code = KEY_WPS_BUTTON,
  63. .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
  64. .gpio = TL_WR941ND_GPIO_BTN_QSS,
  65. .active_low = 1,
  66. }
  67. };
  68. static struct dsa_chip_data tl_wr941nd_dsa_chip = {
  69. .port_names[0] = "wan",
  70. .port_names[1] = "lan1",
  71. .port_names[2] = "lan2",
  72. .port_names[3] = "lan3",
  73. .port_names[4] = "lan4",
  74. .port_names[5] = "cpu",
  75. };
  76. static struct dsa_platform_data tl_wr941nd_dsa_data = {
  77. .nr_chips = 1,
  78. .chip = &tl_wr941nd_dsa_chip,
  79. };
  80. static void __init tl_wr941nd_setup(void)
  81. {
  82. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  83. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  84. ath79_register_mdio(0, 0x0);
  85. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  86. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  87. ath79_eth0_data.speed = SPEED_100;
  88. ath79_eth0_data.duplex = DUPLEX_FULL;
  89. ath79_register_eth(0);
  90. ath79_register_dsa(&ath79_eth0_device.dev, &ath79_mdio0_device.dev,
  91. &tl_wr941nd_dsa_data);
  92. ath79_register_m25p80(&tl_wr941nd_flash_data);
  93. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_leds_gpio),
  94. tl_wr941nd_leds_gpio);
  95. ath79_register_gpio_keys_polled(-1, TL_WR941ND_KEYS_POLL_INTERVAL,
  96. ARRAY_SIZE(tl_wr941nd_gpio_keys),
  97. tl_wr941nd_gpio_keys);
  98. ath79_register_wmac(eeprom, mac);
  99. }
  100. MIPS_MACHINE(ATH79_MACH_TL_WR941ND, "TL-WR941ND", "TP-LINK TL-WR941ND",
  101. tl_wr941nd_setup);