mach-ap143.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Atheros AP143 reference board support
  3. *
  4. * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
  5. * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. */
  20. #include <linux/platform_device.h>
  21. #include <linux/ath9k_platform.h>
  22. #include <linux/ar8216_platform.h>
  23. #include <asm/mach-ath79/ar71xx_regs.h>
  24. #include "common.h"
  25. #include "dev-eth.h"
  26. #include "dev-gpio-buttons.h"
  27. #include "dev-leds-gpio.h"
  28. #include "dev-m25p80.h"
  29. #include "dev-spi.h"
  30. #include "dev-usb.h"
  31. #include "dev-wmac.h"
  32. #include "machtypes.h"
  33. #define AP143_GPIO_LED_WLAN 12
  34. #define AP143_GPIO_LED_WPS 13
  35. #define AP143_GPIO_LED_STATUS 13
  36. #define AP143_GPIO_LED_WAN 4
  37. #define AP143_GPIO_LED_LAN1 16
  38. #define AP143_GPIO_LED_LAN2 15
  39. #define AP143_GPIO_LED_LAN3 14
  40. #define AP143_GPIO_LED_LAN4 11
  41. #define AP143_GPIO_BTN_WPS 17
  42. #define AP143_KEYS_POLL_INTERVAL 20 /* msecs */
  43. #define AP143_KEYS_DEBOUNCE_INTERVAL (3 * AP143_KEYS_POLL_INTERVAL)
  44. #define AP143_MAC0_OFFSET 0
  45. #define AP143_MAC1_OFFSET 6
  46. #define AP143_WMAC_CALDATA_OFFSET 0x1000
  47. static struct gpio_led ap143_leds_gpio[] __initdata = {
  48. {
  49. .name = "ap143:green:status",
  50. .gpio = AP143_GPIO_LED_STATUS,
  51. .active_low = 1,
  52. },
  53. {
  54. .name = "ap143:green:wlan",
  55. .gpio = AP143_GPIO_LED_WLAN,
  56. .active_low = 1,
  57. }
  58. };
  59. static struct gpio_keys_button ap143_gpio_keys[] __initdata = {
  60. {
  61. .desc = "WPS button",
  62. .type = EV_KEY,
  63. .code = KEY_WPS_BUTTON,
  64. .debounce_interval = AP143_KEYS_DEBOUNCE_INTERVAL,
  65. .gpio = AP143_GPIO_BTN_WPS,
  66. .active_low = 1,
  67. },
  68. };
  69. static void __init ap143_gpio_led_setup(void)
  70. {
  71. ath79_gpio_direction_select(AP143_GPIO_LED_WAN, true);
  72. ath79_gpio_direction_select(AP143_GPIO_LED_LAN1, true);
  73. ath79_gpio_direction_select(AP143_GPIO_LED_LAN2, true);
  74. ath79_gpio_direction_select(AP143_GPIO_LED_LAN3, true);
  75. ath79_gpio_direction_select(AP143_GPIO_LED_LAN4, true);
  76. ath79_gpio_output_select(AP143_GPIO_LED_WAN,
  77. QCA953X_GPIO_OUT_MUX_LED_LINK5);
  78. ath79_gpio_output_select(AP143_GPIO_LED_LAN1,
  79. QCA953X_GPIO_OUT_MUX_LED_LINK1);
  80. ath79_gpio_output_select(AP143_GPIO_LED_LAN2,
  81. QCA953X_GPIO_OUT_MUX_LED_LINK2);
  82. ath79_gpio_output_select(AP143_GPIO_LED_LAN3,
  83. QCA953X_GPIO_OUT_MUX_LED_LINK3);
  84. ath79_gpio_output_select(AP143_GPIO_LED_LAN4,
  85. QCA953X_GPIO_OUT_MUX_LED_LINK4);
  86. ath79_register_leds_gpio(-1, ARRAY_SIZE(ap143_leds_gpio),
  87. ap143_leds_gpio);
  88. ath79_register_gpio_keys_polled(-1, AP143_KEYS_POLL_INTERVAL,
  89. ARRAY_SIZE(ap143_gpio_keys),
  90. ap143_gpio_keys);
  91. }
  92. static void __init ap143_setup(void)
  93. {
  94. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  95. ath79_register_m25p80(NULL);
  96. ap143_gpio_led_setup();
  97. ath79_register_usb();
  98. ath79_wmac_set_led_pin(AP143_GPIO_LED_WLAN);
  99. ath79_register_wmac(art + AP143_WMAC_CALDATA_OFFSET, NULL);
  100. ath79_register_mdio(0, 0x0);
  101. ath79_register_mdio(1, 0x0);
  102. ath79_init_mac(ath79_eth0_data.mac_addr, art + AP143_MAC0_OFFSET, 0);
  103. ath79_init_mac(ath79_eth1_data.mac_addr, art + AP143_MAC1_OFFSET, 0);
  104. /* WAN port */
  105. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  106. ath79_eth0_data.speed = SPEED_100;
  107. ath79_eth0_data.duplex = DUPLEX_FULL;
  108. ath79_eth0_data.phy_mask = BIT(4);
  109. ath79_register_eth(0);
  110. /* LAN ports */
  111. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  112. ath79_eth1_data.speed = SPEED_1000;
  113. ath79_eth1_data.duplex = DUPLEX_FULL;
  114. ath79_switch_data.phy_poll_mask |= BIT(4);
  115. ath79_switch_data.phy4_mii_en = 1;
  116. ath79_register_eth(1);
  117. }
  118. MIPS_MACHINE(ATH79_MACH_AP143, "AP143", "Qualcomm Atheros AP143 reference board",
  119. ap143_setup);