mach-cpe510.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_BTN_RESET 4
  28. #define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */
  29. #define CPE510_KEYS_DEBOUNCE_INTERVAL (3 * CPE510_KEYS_POLL_INTERVAL)
  30. static struct gpio_led cpe510_leds_gpio[] __initdata = {
  31. {
  32. .name = "tp-link:green:lan0",
  33. .gpio = CPE510_GPIO_LED_LAN0,
  34. .active_low = 1,
  35. }, {
  36. .name = "tp-link:green:lan1",
  37. .gpio = CPE510_GPIO_LED_LAN1,
  38. .active_low = 1,
  39. }, {
  40. .name = "tp-link:green:link1",
  41. .gpio = CPE510_GPIO_LED_L1,
  42. .active_low = 1,
  43. }, {
  44. .name = "tp-link:green:link2",
  45. .gpio = CPE510_GPIO_LED_L2,
  46. .active_low = 1,
  47. }, {
  48. .name = "tp-link:green:link3",
  49. .gpio = CPE510_GPIO_LED_L3,
  50. .active_low = 1,
  51. }, {
  52. .name = "tp-link:green:link4",
  53. .gpio = CPE510_GPIO_LED_L4,
  54. .active_low = 1,
  55. },
  56. };
  57. static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
  58. {
  59. .desc = "Reset button",
  60. .type = EV_KEY,
  61. .code = KEY_RESTART,
  62. .debounce_interval = CPE510_KEYS_DEBOUNCE_INTERVAL,
  63. .gpio = CPE510_GPIO_BTN_RESET,
  64. .active_low = 1,
  65. }
  66. };
  67. static void __init cpe510_setup(void)
  68. {
  69. u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
  70. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  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_register_m25p80(NULL);
  81. ath79_register_mdio(1, 0);
  82. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  83. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  84. ath79_register_eth(1);
  85. ath79_register_wmac(ee, mac);
  86. }
  87. MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE210/220/510/520",
  88. cpe510_setup);