mach-tl-mr6400.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * TP-LINK TL-MR6400 board support
  3. *
  4. * Copyright (C) 2017 Filip Moc <lede@moc6.cz>
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. * * The name of the author may not be used to endorse or promote products
  9. * derived from this software without specific prior written permission.
  10. *
  11. * THIS SOFTWARE IS PROVIDED BY AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  12. * WARRANTIES, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  13. * DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE.
  14. */
  15. #include <linux/gpio.h>
  16. #include <linux/platform_device.h>
  17. #include <asm/mach-ath79/ar71xx_regs.h>
  18. #include "common.h"
  19. #include "dev-gpio-buttons.h"
  20. #include "dev-eth.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-m25p80.h"
  23. #include "dev-usb.h"
  24. #include "dev-wmac.h"
  25. #include "machtypes.h"
  26. #define TL_MR6400_GPIO_LTE_POWER 4
  27. #define TL_MR6400_GPIO_BTN_RESET 12 /* SW2 */
  28. #define TL_MR6400_GPIO_BTN_RFKILL 14 /* SW3 */
  29. #define TL_MR6400_GPIO_LED_WAN 0 /* D12 */
  30. #define TL_MR6400_GPIO_LED_4G 1 /* D11 */
  31. #define TL_MR6400_GPIO_LED_WPS 3 /* D5 */
  32. #define TL_MR6400_GPIO_LED_WLAN 11 /* D3 */
  33. #define TL_MR6400_GPIO_LED_POWER 13 /* D2 */
  34. #define TL_MR6400_GPIO_LED_LAN 16 /* D4 */
  35. #define TL_MR6400_KEYS_POLL_INTERVAL 20 /* msecs */
  36. #define TL_MR6400_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR6400_KEYS_POLL_INTERVAL)
  37. #define TL_MR6400_WMAC_CALDATA_OFFSET 0x1000
  38. static const char *tl_mr6400_part_probes[] = {
  39. "tp-link",
  40. NULL,
  41. };
  42. static struct flash_platform_data tl_mr6400_flash_data = {
  43. .part_probes = tl_mr6400_part_probes,
  44. .type = "w25q64",
  45. };
  46. static struct gpio_led tl_mr6400_leds_gpio[] __initdata = {
  47. {
  48. .name = "tp-link:white:wan",
  49. .gpio = TL_MR6400_GPIO_LED_WAN,
  50. .active_low = 0,
  51. },
  52. {
  53. .name = "tp-link:white:4g",
  54. .gpio = TL_MR6400_GPIO_LED_4G,
  55. .active_low = 0,
  56. },
  57. {
  58. .name = "tp-link:white:wps",
  59. .gpio = TL_MR6400_GPIO_LED_WPS,
  60. .active_low = 0,
  61. },
  62. {
  63. .name = "tp-link:white:wlan",
  64. .gpio = TL_MR6400_GPIO_LED_WLAN,
  65. .active_low = 0,
  66. },
  67. {
  68. .name = "tp-link:white:power",
  69. .gpio = TL_MR6400_GPIO_LED_POWER,
  70. .active_low = 0,
  71. },
  72. {
  73. .name = "tp-link:white:lan",
  74. .gpio = TL_MR6400_GPIO_LED_LAN,
  75. .active_low = 0,
  76. },
  77. };
  78. static struct gpio_keys_button tl_mr6400_gpio_keys[] __initdata = {
  79. {
  80. .desc = "reset",
  81. .type = EV_KEY,
  82. .code = KEY_RESTART,
  83. .debounce_interval = TL_MR6400_KEYS_DEBOUNCE_INTERVAL,
  84. .gpio = TL_MR6400_GPIO_BTN_RESET,
  85. .active_low = 1,
  86. },
  87. {
  88. .desc = "rfkill",
  89. .type = EV_KEY,
  90. .code = KEY_RFKILL,
  91. .debounce_interval = TL_MR6400_KEYS_DEBOUNCE_INTERVAL,
  92. .gpio = TL_MR6400_GPIO_BTN_RFKILL,
  93. .active_low = 1,
  94. },
  95. };
  96. static void __init tl_mr6400_setup(void)
  97. {
  98. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  99. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  100. ath79_register_m25p80(&tl_mr6400_flash_data);
  101. ath79_register_mdio(0, 0x0);
  102. /* LAN1, LAN2, LAN3 */
  103. ath79_switch_data.phy4_mii_en = 1;
  104. ath79_switch_data.phy_poll_mask |= BIT(0);
  105. ath79_eth1_data.duplex = DUPLEX_FULL;
  106. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  107. ath79_eth1_data.speed = SPEED_1000;
  108. ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  109. ath79_register_eth(1);
  110. /* LAN4 / WAN */
  111. ath79_eth0_data.phy_mask = BIT(0);
  112. ath79_eth0_data.duplex = DUPLEX_FULL;
  113. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  114. ath79_eth0_data.speed = SPEED_100;
  115. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  116. ath79_register_eth(0);
  117. ath79_register_wmac(art + TL_MR6400_WMAC_CALDATA_OFFSET, mac);
  118. ath79_register_leds_gpio(-1,
  119. ARRAY_SIZE(tl_mr6400_leds_gpio),
  120. tl_mr6400_leds_gpio);
  121. ath79_register_gpio_keys_polled(-1,
  122. TL_MR6400_KEYS_POLL_INTERVAL,
  123. ARRAY_SIZE(tl_mr6400_gpio_keys),
  124. tl_mr6400_gpio_keys);
  125. gpio_request_one(TL_MR6400_GPIO_LTE_POWER,
  126. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED | GPIOF_ACTIVE_LOW,
  127. "LTE power");
  128. ath79_register_usb();
  129. }
  130. MIPS_MACHINE(ATH79_MACH_TL_MR6400, "TL-MR6400", "TP-LINK TL-MR6400",
  131. tl_mr6400_setup);