mach-tl-wdr6500-v2.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * TP-LINK TL-WDR6500 v2
  3. *
  4. * Copyright (C) 2015 Weijie Gao <hackpascal@gmail.com>
  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/pci.h>
  11. #include <linux/gpio.h>
  12. #include <linux/platform_device.h>
  13. #include <asm/mach-ath79/ath79.h>
  14. #include <asm/mach-ath79/ar71xx_regs.h>
  15. #include "common.h"
  16. #include "dev-eth.h"
  17. #include "dev-ap9x-pci.h"
  18. #include "dev-gpio-buttons.h"
  19. #include "dev-leds-gpio.h"
  20. #include "dev-m25p80.h"
  21. #include "dev-usb.h"
  22. #include "dev-wmac.h"
  23. #include "machtypes.h"
  24. #include "pci.h"
  25. #define TL_WDR6500_V2_GPIO_LED_SYS 21
  26. #define TL_WDR6500_V2_GPIO_LED_WAN 18
  27. #define TL_WDR6500_V2_GPIO_LED_LAN1 17
  28. #define TL_WDR6500_V2_GPIO_LED_LAN2 16
  29. #define TL_WDR6500_V2_GPIO_LED_LAN3 15
  30. #define TL_WDR6500_V2_GPIO_LED_LAN4 14
  31. #define TL_WDR6500_V2_GPIO_BTN_RESET 1
  32. #define TL_WDR6500_V2_KEYS_POLL_INTERVAL 20 /* msecs */
  33. #define TL_WDR6500_V2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WDR6500_V2_KEYS_POLL_INTERVAL)
  34. #define TL_WDR6500_V2_WMAC_CALDATA_OFFSET 0x1000
  35. #define TL_WDR6500_V2_PCIE_CALDATA_OFFSET 0x5000
  36. static const char *tl_wdr6500_v2_part_probes[] = {
  37. "tp-link-64k",
  38. NULL,
  39. };
  40. static struct flash_platform_data tl_wdr6500_v2_flash_data = {
  41. .part_probes = tl_wdr6500_v2_part_probes,
  42. };
  43. static struct gpio_led tl_wdr6500_v2_leds_gpio[] __initdata = {
  44. {
  45. .name = "tp-link:green:lan1",
  46. .gpio = TL_WDR6500_V2_GPIO_LED_LAN1,
  47. .active_low = 1,
  48. }, {
  49. .name = "tp-link:green:lan2",
  50. .gpio = TL_WDR6500_V2_GPIO_LED_LAN2,
  51. .active_low = 1,
  52. }, {
  53. .name = "tp-link:green:lan3",
  54. .gpio = TL_WDR6500_V2_GPIO_LED_LAN3,
  55. .active_low = 1,
  56. }, {
  57. .name = "tp-link:green:lan4",
  58. .gpio = TL_WDR6500_V2_GPIO_LED_LAN4,
  59. .active_low = 1,
  60. }, {
  61. .name = "tp-link:green:wan",
  62. .gpio = TL_WDR6500_V2_GPIO_LED_WAN,
  63. .active_low = 1,
  64. }, {
  65. .name = "tp-link:white:system",
  66. .gpio = TL_WDR6500_V2_GPIO_LED_SYS,
  67. .active_low = 0,
  68. },
  69. };
  70. static struct gpio_keys_button tl_wdr6500_v2_gpio_keys[] __initdata = {
  71. {
  72. .desc = "Reset button",
  73. .type = EV_KEY,
  74. .code = KEY_RESTART,
  75. .debounce_interval = TL_WDR6500_V2_KEYS_DEBOUNCE_INTERVAL,
  76. .gpio = TL_WDR6500_V2_GPIO_BTN_RESET,
  77. .active_low = 1,
  78. }
  79. };
  80. static void __init tl_ap151_setup(void)
  81. {
  82. u8 *mac = (u8 *) KSEG1ADDR(0x1f00fc00);
  83. u8 *ee = (u8 *) KSEG1ADDR(0x1fff0000);
  84. u8 tmpmac[ETH_ALEN];
  85. ath79_register_m25p80(&tl_wdr6500_v2_flash_data);
  86. ath79_setup_ar933x_phy4_switch(false, false);
  87. ath79_register_mdio(1, 0x0);
  88. /* WAN */
  89. ath79_switch_data.phy4_mii_en = 1;
  90. ath79_switch_data.phy_poll_mask = BIT(4);
  91. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  92. ath79_eth0_data.phy_mask = BIT(4);
  93. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  94. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  95. ath79_register_eth(0);
  96. /* LAN */
  97. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  98. ath79_eth1_data.duplex = DUPLEX_FULL;
  99. ath79_eth1_data.speed = SPEED_1000;
  100. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  101. ath79_register_eth(1);
  102. ath79_init_mac(tmpmac, mac, -1);
  103. ath79_register_wmac(ee + TL_WDR6500_V2_WMAC_CALDATA_OFFSET, tmpmac);
  104. ath79_register_pci();
  105. ath79_register_usb();
  106. }
  107. static void __init tl_wdr6500_v2_setup(void)
  108. {
  109. tl_ap151_setup();
  110. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wdr6500_v2_leds_gpio),
  111. tl_wdr6500_v2_leds_gpio);
  112. ath79_register_gpio_keys_polled(1, TL_WDR6500_V2_KEYS_POLL_INTERVAL,
  113. ARRAY_SIZE(tl_wdr6500_v2_gpio_keys),
  114. tl_wdr6500_v2_gpio_keys);
  115. }
  116. MIPS_MACHINE(ATH79_MACH_TL_WDR6500_V2, "TL-WDR6500-v2", "TP-LINK TL-WDR6500 v2",
  117. tl_wdr6500_v2_setup);