mach-tl-wr1043nd.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * TP-LINK TL-WR1043N/ND 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 <linux/rtl8366.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "dev-eth.h"
  15. #include "dev-m25p80.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-usb.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define TL_WR1043ND_GPIO_LED_USB 1
  22. #define TL_WR1043ND_GPIO_LED_SYSTEM 2
  23. #define TL_WR1043ND_GPIO_LED_QSS 5
  24. #define TL_WR1043ND_GPIO_LED_WLAN 9
  25. #define TL_WR1043ND_GPIO_BTN_RESET 3
  26. #define TL_WR1043ND_GPIO_BTN_QSS 7
  27. #define TL_WR1043ND_GPIO_RTL8366_SDA 18
  28. #define TL_WR1043ND_GPIO_RTL8366_SCK 19
  29. #define TL_WR1043ND_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043ND_KEYS_POLL_INTERVAL)
  31. static const char *tl_wr1043nd_part_probes[] = {
  32. "tp-link",
  33. NULL,
  34. };
  35. static struct flash_platform_data tl_wr1043nd_flash_data = {
  36. .part_probes = tl_wr1043nd_part_probes,
  37. };
  38. static struct gpio_led tl_wr1043nd_leds_gpio[] __initdata = {
  39. {
  40. .name = "tp-link:green:usb",
  41. .gpio = TL_WR1043ND_GPIO_LED_USB,
  42. .active_low = 1,
  43. }, {
  44. .name = "tp-link:green:system",
  45. .gpio = TL_WR1043ND_GPIO_LED_SYSTEM,
  46. .active_low = 1,
  47. }, {
  48. .name = "tp-link:green:qss",
  49. .gpio = TL_WR1043ND_GPIO_LED_QSS,
  50. .active_low = 0,
  51. }, {
  52. .name = "tp-link:green:wlan",
  53. .gpio = TL_WR1043ND_GPIO_LED_WLAN,
  54. .active_low = 1,
  55. }
  56. };
  57. static struct gpio_keys_button tl_wr1043nd_gpio_keys[] __initdata = {
  58. {
  59. .desc = "reset",
  60. .type = EV_KEY,
  61. .code = KEY_RESTART,
  62. .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
  63. .gpio = TL_WR1043ND_GPIO_BTN_RESET,
  64. .active_low = 1,
  65. }, {
  66. .desc = "qss",
  67. .type = EV_KEY,
  68. .code = KEY_WPS_BUTTON,
  69. .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
  70. .gpio = TL_WR1043ND_GPIO_BTN_QSS,
  71. .active_low = 1,
  72. }
  73. };
  74. static void tl_wr1043nd_rtl8366rb_hw_reset(bool active)
  75. {
  76. if (active)
  77. ath79_device_reset_set(AR71XX_RESET_GE0_PHY);
  78. else
  79. ath79_device_reset_clear(AR71XX_RESET_GE0_PHY);
  80. }
  81. static struct rtl8366_platform_data tl_wr1043nd_rtl8366rb_data = {
  82. .gpio_sda = TL_WR1043ND_GPIO_RTL8366_SDA,
  83. .gpio_sck = TL_WR1043ND_GPIO_RTL8366_SCK,
  84. .hw_reset = tl_wr1043nd_rtl8366rb_hw_reset,
  85. };
  86. static struct platform_device tl_wr1043nd_rtl8366rb_device = {
  87. .name = RTL8366RB_DRIVER_NAME,
  88. .id = -1,
  89. .dev = {
  90. .platform_data = &tl_wr1043nd_rtl8366rb_data,
  91. }
  92. };
  93. static void __init tl_wr1043nd_setup(void)
  94. {
  95. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  96. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  97. tl_wr1043nd_rtl8366rb_hw_reset(true);
  98. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  99. ath79_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
  100. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  101. ath79_eth0_data.speed = SPEED_1000;
  102. ath79_eth0_data.duplex = DUPLEX_FULL;
  103. ath79_eth0_pll_data.pll_1000 = 0x1a000000;
  104. ath79_register_eth(0);
  105. ath79_register_usb();
  106. ath79_register_m25p80(&tl_wr1043nd_flash_data);
  107. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio),
  108. tl_wr1043nd_leds_gpio);
  109. platform_device_register(&tl_wr1043nd_rtl8366rb_device);
  110. ath79_register_gpio_keys_polled(-1, TL_WR1043ND_KEYS_POLL_INTERVAL,
  111. ARRAY_SIZE(tl_wr1043nd_gpio_keys),
  112. tl_wr1043nd_gpio_keys);
  113. ath79_register_wmac(eeprom, mac);
  114. }
  115. MIPS_MACHINE(ATH79_MACH_TL_WR1043ND, "TL-WR1043ND", "TP-LINK TL-WR1043ND",
  116. tl_wr1043nd_setup);