1
0

mach-ap147.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Atheros AP147 reference board support
  3. *
  4. * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
  5. * Copyright (C) 2015 Sven Eckelmann <sven@open-mesh.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/ar8216_platform.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include <asm/mach-ath79/ath79.h>
  15. #include "common.h"
  16. #include "dev-ap9x-pci.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-usb.h"
  22. #include "dev-wmac.h"
  23. #include "machtypes.h"
  24. #include "pci.h"
  25. #define AP147_GPIO_LED_WAN 4
  26. #define AP147_GPIO_LED_LAN1 16
  27. #define AP147_GPIO_LED_LAN2 15
  28. #define AP147_GPIO_LED_LAN3 14
  29. #define AP147_GPIO_LED_LAN4 11
  30. #define AP147_GPIO_LED_STATUS 13
  31. #define AP147_GPIO_LED_WLAN_2G 12
  32. #define AP147_GPIO_BTN_WPS 17
  33. #define AP147_KEYS_POLL_INTERVAL 20 /* msecs */
  34. #define AP147_KEYS_DEBOUNCE_INTERVAL (3 * AP147_KEYS_POLL_INTERVAL)
  35. #define AP147_MAC0_OFFSET 0x1000
  36. static struct gpio_led ap147_leds_gpio[] __initdata = {
  37. {
  38. .name = "ap147:green:status",
  39. .gpio = AP147_GPIO_LED_STATUS,
  40. .active_low = 1,
  41. }, {
  42. .name = "ap147:green:wlan-2g",
  43. .gpio = AP147_GPIO_LED_WLAN_2G,
  44. .active_low = 1,
  45. }, {
  46. .name = "ap147:green:lan1",
  47. .gpio = AP147_GPIO_LED_LAN1,
  48. .active_low = 1,
  49. }, {
  50. .name = "ap147:green:lan2",
  51. .gpio = AP147_GPIO_LED_LAN2,
  52. .active_low = 1,
  53. }, {
  54. .name = "ap147:green:lan3",
  55. .gpio = AP147_GPIO_LED_LAN3,
  56. .active_low = 1,
  57. }, {
  58. .name = "ap147:green:lan4",
  59. .gpio = AP147_GPIO_LED_LAN4,
  60. .active_low = 1,
  61. }, {
  62. .name = "ap147:green:wan",
  63. .gpio = AP147_GPIO_LED_WAN,
  64. .active_low = 1,
  65. },
  66. };
  67. static struct gpio_keys_button ap147_gpio_keys[] __initdata = {
  68. {
  69. .desc = "wps button",
  70. .type = EV_KEY,
  71. .code = KEY_WPS_BUTTON,
  72. .debounce_interval = AP147_KEYS_DEBOUNCE_INTERVAL,
  73. .gpio = AP147_GPIO_BTN_WPS,
  74. .active_low = 1,
  75. }
  76. };
  77. static void __init ap147_setup(void)
  78. {
  79. u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  80. ath79_register_m25p80(NULL);
  81. ath79_register_leds_gpio(-1, ARRAY_SIZE(ap147_leds_gpio),
  82. ap147_leds_gpio);
  83. ath79_register_gpio_keys_polled(-1, AP147_KEYS_POLL_INTERVAL,
  84. ARRAY_SIZE(ap147_gpio_keys),
  85. ap147_gpio_keys);
  86. ath79_register_usb();
  87. ath79_register_pci();
  88. ath79_register_wmac(art + AP147_MAC0_OFFSET, NULL);
  89. ath79_setup_ar933x_phy4_switch(false, false);
  90. ath79_register_mdio(0, 0x0);
  91. /* LAN */
  92. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  93. ath79_eth1_data.duplex = DUPLEX_FULL;
  94. ath79_switch_data.phy_poll_mask |= BIT(4);
  95. ath79_init_mac(ath79_eth1_data.mac_addr, art, 0);
  96. ath79_register_eth(1);
  97. /* WAN */
  98. ath79_switch_data.phy4_mii_en = 1;
  99. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  100. ath79_eth0_data.duplex = DUPLEX_FULL;
  101. ath79_eth0_data.speed = SPEED_100;
  102. ath79_eth0_data.phy_mask = BIT(4);
  103. ath79_init_mac(ath79_eth0_data.mac_addr, art, 1);
  104. ath79_register_eth(0);
  105. }
  106. MIPS_MACHINE(ATH79_MACH_AP147_010, "AP147-010", "Atheros AP147-010 reference board", ap147_setup);