mach-cpe510.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * TP-LINK CPE210/220/510/520 board support
  3. *
  4. * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
  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/gpio.h>
  11. #include <linux/platform_device.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define CPE510_GPIO_LED_LAN0 11
  22. #define CPE510_GPIO_LED_LAN1 12
  23. #define CPE510_GPIO_LED_L1 13
  24. #define CPE510_GPIO_LED_L2 14
  25. #define CPE510_GPIO_LED_L3 15
  26. #define CPE510_GPIO_LED_L4 16
  27. #define CPE510_GPIO_EXTERNAL_LNA0 18
  28. #define CPE510_GPIO_EXTERNAL_LNA1 19
  29. #define CPE510_GPIO_BTN_RESET 4
  30. #define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */
  31. #define CPE510_KEYS_DEBOUNCE_INTERVAL (3 * CPE510_KEYS_POLL_INTERVAL)
  32. static struct gpio_led cpe510_leds_gpio[] __initdata = {
  33. {
  34. .name = "tp-link:green:lan0",
  35. .gpio = CPE510_GPIO_LED_LAN0,
  36. .active_low = 1,
  37. }, {
  38. .name = "tp-link:green:lan1",
  39. .gpio = CPE510_GPIO_LED_LAN1,
  40. .active_low = 1,
  41. }, {
  42. .name = "tp-link:green:link1",
  43. .gpio = CPE510_GPIO_LED_L1,
  44. .active_low = 1,
  45. }, {
  46. .name = "tp-link:green:link2",
  47. .gpio = CPE510_GPIO_LED_L2,
  48. .active_low = 1,
  49. }, {
  50. .name = "tp-link:green:link3",
  51. .gpio = CPE510_GPIO_LED_L3,
  52. .active_low = 1,
  53. }, {
  54. .name = "tp-link:green:link4",
  55. .gpio = CPE510_GPIO_LED_L4,
  56. .active_low = 1,
  57. },
  58. };
  59. static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
  60. {
  61. .desc = "Reset button",
  62. .type = EV_KEY,
  63. .code = KEY_RESTART,
  64. .debounce_interval = CPE510_KEYS_DEBOUNCE_INTERVAL,
  65. .gpio = CPE510_GPIO_BTN_RESET,
  66. .active_low = 1,
  67. }
  68. };
  69. static void __init cpe_setup(u8 *mac)
  70. {
  71. /* Disable JTAG, enabling GPIOs 0-3 */
  72. /* Configure OBS4 line, for GPIO 4*/
  73. ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  74. AR934X_GPIO_FUNC_CLK_OBS4_EN);
  75. ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe510_leds_gpio),
  76. cpe510_leds_gpio);
  77. ath79_register_gpio_keys_polled(1, CPE510_KEYS_POLL_INTERVAL,
  78. ARRAY_SIZE(cpe510_gpio_keys),
  79. cpe510_gpio_keys);
  80. ath79_wmac_set_ext_lna_gpio(0, CPE510_GPIO_EXTERNAL_LNA0);
  81. ath79_wmac_set_ext_lna_gpio(1, CPE510_GPIO_EXTERNAL_LNA1);
  82. ath79_register_m25p80(NULL);
  83. ath79_register_mdio(1, 0);
  84. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  85. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  86. ath79_register_eth(1);
  87. }
  88. static void __init cpe210_setup(void)
  89. {
  90. u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
  91. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  92. cpe_setup(mac);
  93. ath79_register_wmac(ee, mac);
  94. }
  95. static void __init cpe510_setup(void)
  96. {
  97. u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
  98. u8 *ee = (u8 *) KSEG1ADDR(0x1fff5000);
  99. cpe_setup(mac);
  100. ath79_register_wmac(ee, mac);
  101. }
  102. MIPS_MACHINE(ATH79_MACH_CPE210, "CPE210", "TP-LINK CPE210/220",
  103. cpe210_setup);
  104. MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE510/520",
  105. cpe510_setup);