mach-eap120.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * TP-LINK EAP120 board support
  3. *
  4. * Copyright (C) 2016 Henryk Heisig <hyniu@o2.pl>
  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 <linux/platform_data/mdio-gpio.h>
  13. #include <asm/mach-ath79/ath79.h>
  14. #include <asm/mach-ath79/ar71xx_regs.h>
  15. #include <linux/platform_data/phy-at803x.h>
  16. #include "common.h"
  17. #include "dev-eth.h"
  18. #include "dev-gpio-buttons.h"
  19. #include "dev-leds-gpio.h"
  20. #include "dev-m25p80.h"
  21. #include "dev-wmac.h"
  22. #include "machtypes.h"
  23. #define EAP120_GPIO_LED_RED 12
  24. #define EAP120_GPIO_LED_YEL 13
  25. #define EAP120_GPIO_LED_GRN 15
  26. #define EAP120_GPIO_BTN_RESET 4
  27. #define EAP120_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define EAP120_KEYS_DEBOUNCE_INTERVAL (3 * EAP120_KEYS_POLL_INTERVAL)
  29. #define EAP120_GPIO_SMI_MDIO 16
  30. #define EAP120_GPIO_SMI_MDC 17
  31. #define EAP120_LAN_PHYADDR 4
  32. static struct gpio_led eap120_leds_gpio[] __initdata = {
  33. {
  34. .name = "eap120:red:system",
  35. .gpio = EAP120_GPIO_LED_RED,
  36. .active_low = 1,
  37. }, {
  38. .name = "eap120:yellow:system",
  39. .gpio = EAP120_GPIO_LED_YEL,
  40. .active_low = 1,
  41. }, {
  42. .name = "eap120:green:system",
  43. .gpio = EAP120_GPIO_LED_GRN,
  44. .active_low = 1,
  45. },
  46. };
  47. static struct gpio_keys_button eap120_gpio_keys[] __initdata = {
  48. {
  49. .desc = "Reset button",
  50. .type = EV_KEY,
  51. .code = KEY_RESTART,
  52. .debounce_interval = EAP120_KEYS_DEBOUNCE_INTERVAL,
  53. .gpio = EAP120_GPIO_BTN_RESET,
  54. .active_low = 1,
  55. }
  56. };
  57. static struct mdio_gpio_platform_data eap120_mdio = {
  58. .mdc = EAP120_GPIO_SMI_MDC,
  59. .mdio = EAP120_GPIO_SMI_MDIO,
  60. .phy_mask = ~BIT(EAP120_LAN_PHYADDR),
  61. };
  62. static struct at803x_platform_data eap120_ar8035_data = {
  63. .disable_smarteee = 0,
  64. .enable_rgmii_rx_delay = 1,
  65. .enable_rgmii_tx_delay = 0,
  66. .fixup_rgmii_tx_delay = 1,
  67. };
  68. static struct platform_device eap120_phy_device = {
  69. .name = "mdio-gpio",
  70. .id = 0,
  71. .dev = {
  72. .platform_data = &eap120_mdio, &eap120_ar8035_data
  73. },
  74. };
  75. static void __init eap_setup(u8 *mac)
  76. {
  77. ath79_register_leds_gpio(-1, ARRAY_SIZE(eap120_leds_gpio),
  78. eap120_leds_gpio);
  79. ath79_register_gpio_keys_polled(1, EAP120_KEYS_POLL_INTERVAL,
  80. ARRAY_SIZE(eap120_gpio_keys),
  81. eap120_gpio_keys);
  82. ath79_register_m25p80(NULL);
  83. /* MDIO Interface */
  84. platform_device_register(&eap120_phy_device);
  85. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  86. /* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */
  87. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  88. ath79_eth0_data.mii_bus_dev = &eap120_phy_device.dev;
  89. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  90. ath79_eth0_data.phy_mask = BIT(EAP120_LAN_PHYADDR);
  91. ath79_eth0_pll_data.pll_1000 = 0x0e000000;
  92. ath79_eth0_pll_data.pll_100 = 0x00000101;
  93. ath79_eth0_pll_data.pll_10 = 0x00001313;
  94. ath79_register_eth(0);
  95. }
  96. static void __init eap120_setup(void)
  97. {
  98. u8 *mac = (u8 *) KSEG1ADDR(0x1f030008);
  99. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  100. eap_setup(mac);
  101. ath79_register_wmac(ee, mac);
  102. }
  103. MIPS_MACHINE(ATH79_MACH_EAP120, "EAP120", "TP-LINK EAP120",
  104. eap120_setup);