mach-tl-wr2543n.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * TP-LINK TL-WR2543N/ND board support
  3. *
  4. * Copyright (C) 2011-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/rtl8367.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include "dev-eth.h"
  14. #include "dev-ap9x-pci.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 "machtypes.h"
  20. #define TL_WR2543N_GPIO_LED_WPS 0
  21. #define TL_WR2543N_GPIO_LED_USB 8
  22. /* The WLAN LEDs use GPIOs on the discrete AR9380 wmac */
  23. #define TL_WR2543N_GPIO_WMAC_LED_WLAN2G 0
  24. #define TL_WR2543N_GPIO_WMAC_LED_WLAN5G 1
  25. #define TL_WR2543N_GPIO_BTN_RESET 11
  26. #define TL_WR2543N_GPIO_BTN_WPS 12
  27. #define TL_WR2543N_GPIO_RTL8367_SDA 1
  28. #define TL_WR2543N_GPIO_RTL8367_SCK 6
  29. #define TL_WR2543N_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define TL_WR2543N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR2543N_KEYS_POLL_INTERVAL)
  31. static const char *tl_wr2543n_part_probes[] = {
  32. "tp-link",
  33. NULL,
  34. };
  35. static struct flash_platform_data tl_wr2543n_flash_data = {
  36. .part_probes = tl_wr2543n_part_probes,
  37. };
  38. static struct gpio_led tl_wr2543n_leds_gpio[] __initdata = {
  39. {
  40. .name = "tp-link:green:usb",
  41. .gpio = TL_WR2543N_GPIO_LED_USB,
  42. .active_low = 1,
  43. }, {
  44. .name = "tp-link:green:wps",
  45. .gpio = TL_WR2543N_GPIO_LED_WPS,
  46. .active_low = 1,
  47. }
  48. };
  49. static struct gpio_led tl_wr2543n_wmac_leds_gpio[] = {
  50. {
  51. .name = "tp-link:green:wlan5g",
  52. .gpio = TL_WR2543N_GPIO_WMAC_LED_WLAN5G,
  53. .active_low = 1,
  54. },
  55. };
  56. static struct gpio_keys_button tl_wr2543n_gpio_keys[] __initdata = {
  57. {
  58. .desc = "reset",
  59. .type = EV_KEY,
  60. .code = KEY_RESTART,
  61. .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
  62. .gpio = TL_WR2543N_GPIO_BTN_RESET,
  63. .active_low = 1,
  64. }, {
  65. .desc = "wps",
  66. .type = EV_KEY,
  67. .code = KEY_WPS_BUTTON,
  68. .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
  69. .gpio = TL_WR2543N_GPIO_BTN_WPS,
  70. .active_low = 1,
  71. }
  72. };
  73. static struct rtl8367_extif_config tl_wr2543n_rtl8367_extif0_cfg = {
  74. .mode = RTL8367_EXTIF_MODE_RGMII,
  75. .txdelay = 1,
  76. .rxdelay = 0,
  77. .ability = {
  78. .force_mode = 1,
  79. .txpause = 1,
  80. .rxpause = 1,
  81. .link = 1,
  82. .duplex = 1,
  83. .speed = RTL8367_PORT_SPEED_1000,
  84. },
  85. };
  86. static struct rtl8367_platform_data tl_wr2543n_rtl8367_data = {
  87. .gpio_sda = TL_WR2543N_GPIO_RTL8367_SDA,
  88. .gpio_sck = TL_WR2543N_GPIO_RTL8367_SCK,
  89. .extif0_cfg = &tl_wr2543n_rtl8367_extif0_cfg,
  90. };
  91. static struct platform_device tl_wr2543n_rtl8367_device = {
  92. .name = RTL8367_DRIVER_NAME,
  93. .id = -1,
  94. .dev = {
  95. .platform_data = &tl_wr2543n_rtl8367_data,
  96. }
  97. };
  98. static void __init tl_wr2543n_setup(void)
  99. {
  100. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  101. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  102. ath79_register_m25p80(&tl_wr2543n_flash_data);
  103. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr2543n_leds_gpio),
  104. tl_wr2543n_leds_gpio);
  105. ath79_register_gpio_keys_polled(-1, TL_WR2543N_KEYS_POLL_INTERVAL,
  106. ARRAY_SIZE(tl_wr2543n_gpio_keys),
  107. tl_wr2543n_gpio_keys);
  108. ath79_register_usb();
  109. /*
  110. * The ath9k driver uses this pin for its default led device, which is
  111. * named ath9k-phy0, and reflects activity on either the 2 GHz or 5 GHz
  112. * bands. This pin is connected to the WR2543's 2GHz WLAN LED.
  113. */
  114. ap9x_pci_setup_wmac_led_pin(0, TL_WR2543N_GPIO_WMAC_LED_WLAN2G);
  115. /*
  116. * We also have the driver set up an led device for the WR2543's
  117. * separate 5 GHz WLAN LED in case the user wants it.
  118. */
  119. ap9x_pci_setup_wmac_leds(0, tl_wr2543n_wmac_leds_gpio,
  120. ARRAY_SIZE(tl_wr2543n_wmac_leds_gpio));
  121. ap91_pci_init(eeprom, mac);
  122. ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  123. ath79_eth0_data.mii_bus_dev = &tl_wr2543n_rtl8367_device.dev;
  124. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  125. ath79_eth0_data.speed = SPEED_1000;
  126. ath79_eth0_data.duplex = DUPLEX_FULL;
  127. ath79_eth0_pll_data.pll_1000 = 0x1a000000;
  128. ath79_register_eth(0);
  129. platform_device_register(&tl_wr2543n_rtl8367_device);
  130. }
  131. MIPS_MACHINE(ATH79_MACH_TL_WR2543N, "TL-WR2543N", "TP-LINK TL-WR2543N/ND",
  132. tl_wr2543n_setup);