mach-tl-wr2543n.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * TP-LINK TL-WR2543N/ND board support
  3. *
  4. * Copyright (C) 2011-2012 Gabor Juhos <[email protected]>
  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. #define TL_WR2543N_GPIO_BTN_RESET 11
  23. #define TL_WR2543N_GPIO_BTN_WPS 12
  24. #define TL_WR2543N_GPIO_RTL8367_SDA 1
  25. #define TL_WR2543N_GPIO_RTL8367_SCK 6
  26. #define TL_WR2543N_KEYS_POLL_INTERVAL 20 /* msecs */
  27. #define TL_WR2543N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR2543N_KEYS_POLL_INTERVAL)
  28. static const char *tl_wr2543n_part_probes[] = {
  29. "tp-link",
  30. NULL,
  31. };
  32. static struct flash_platform_data tl_wr2543n_flash_data = {
  33. .part_probes = tl_wr2543n_part_probes,
  34. .max_read_len = 64,
  35. };
  36. static struct gpio_led tl_wr2543n_leds_gpio[] __initdata = {
  37. {
  38. .name = "tp-link:green:usb",
  39. .gpio = TL_WR2543N_GPIO_LED_USB,
  40. .active_low = 1,
  41. }, {
  42. .name = "tp-link:green:wps",
  43. .gpio = TL_WR2543N_GPIO_LED_WPS,
  44. .active_low = 1,
  45. }
  46. };
  47. static struct gpio_keys_button tl_wr2543n_gpio_keys[] __initdata = {
  48. {
  49. .desc = "reset",
  50. .type = EV_KEY,
  51. .code = KEY_RESTART,
  52. .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
  53. .gpio = TL_WR2543N_GPIO_BTN_RESET,
  54. .active_low = 1,
  55. }, {
  56. .desc = "wps",
  57. .type = EV_KEY,
  58. .code = KEY_WPS_BUTTON,
  59. .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
  60. .gpio = TL_WR2543N_GPIO_BTN_WPS,
  61. }
  62. };
  63. static struct rtl8367_extif_config tl_wr2543n_rtl8367_extif0_cfg = {
  64. .mode = RTL8367_EXTIF_MODE_RGMII,
  65. .txdelay = 1,
  66. .rxdelay = 0,
  67. .ability = {
  68. .force_mode = 1,
  69. .txpause = 1,
  70. .rxpause = 1,
  71. .link = 1,
  72. .duplex = 1,
  73. .speed = RTL8367_PORT_SPEED_1000,
  74. },
  75. };
  76. static struct rtl8367_platform_data tl_wr2543n_rtl8367_data = {
  77. .gpio_sda = TL_WR2543N_GPIO_RTL8367_SDA,
  78. .gpio_sck = TL_WR2543N_GPIO_RTL8367_SCK,
  79. .extif0_cfg = &tl_wr2543n_rtl8367_extif0_cfg,
  80. };
  81. static struct platform_device tl_wr2543n_rtl8367_device = {
  82. .name = RTL8367_DRIVER_NAME,
  83. .id = -1,
  84. .dev = {
  85. .platform_data = &tl_wr2543n_rtl8367_data,
  86. }
  87. };
  88. static void __init tl_wr2543n_setup(void)
  89. {
  90. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  91. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  92. ath79_register_m25p80(&tl_wr2543n_flash_data);
  93. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr2543n_leds_gpio),
  94. tl_wr2543n_leds_gpio);
  95. ath79_register_gpio_keys_polled(-1, TL_WR2543N_KEYS_POLL_INTERVAL,
  96. ARRAY_SIZE(tl_wr2543n_gpio_keys),
  97. tl_wr2543n_gpio_keys);
  98. ath79_register_usb();
  99. ap91_pci_init(eeprom, mac);
  100. ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  101. ath79_eth0_data.mii_bus_dev = &tl_wr2543n_rtl8367_device.dev;
  102. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  103. ath79_eth0_data.speed = SPEED_1000;
  104. ath79_eth0_data.duplex = DUPLEX_FULL;
  105. ath79_eth0_pll_data.pll_1000 = 0x1a000000;
  106. ath79_register_eth(0);
  107. platform_device_register(&tl_wr2543n_rtl8367_device);
  108. }
  109. MIPS_MACHINE(ATH79_MACH_TL_WR2543N, "TL-WR2543N", "TP-LINK TL-WR2543N/ND",
  110. tl_wr2543n_setup);