1
0

mach-cr3000.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * PowerCloud Systems CR3000 support
  3. *
  4. * Copyright (c) 2011 Qualcomm Atheros
  5. * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (c) 2012-2013 PowerCloud Systems
  7. * Copyright (c) 2015 Daniel Dickinson <openwrt@daniel.thecshore.com>
  8. *
  9. * Permission to use, copy, modify, and/or distribute this software for any
  10. * purpose with or without fee is hereby granted, provided that the above
  11. * copyright notice and this permission notice appear in all copies.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  14. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  15. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  16. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  17. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  18. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  19. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  20. *
  21. */
  22. #include <linux/gpio.h>
  23. #include <linux/pci.h>
  24. #include <linux/phy.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/ath9k_platform.h>
  27. #include <linux/ar8216_platform.h>
  28. #include <asm/mach-ath79/ar71xx_regs.h>
  29. #include <asm/mach-ath79/ath79.h>
  30. #include "common.h"
  31. #include "dev-ap9x-pci.h"
  32. #include "dev-eth.h"
  33. #include "dev-gpio-buttons.h"
  34. #include "dev-leds-gpio.h"
  35. #include "dev-m25p80.h"
  36. #include "dev-spi.h"
  37. #include "dev-wmac.h"
  38. #include "machtypes.h"
  39. #define CR3000_GPIO_LED_WLAN_2G 13
  40. #define CR3000_GPIO_LED_POWER_AMBER 15
  41. #define CR3000_GPIO_LED_WAN 18
  42. #define CR3000_GPIO_LED_LAN1 19
  43. #define CR3000_GPIO_LED_LAN2 20
  44. #define CR3000_GPIO_LED_LAN3 21
  45. #define CR3000_GPIO_LED_LAN4 22
  46. #define CR3000_GPIO_BTN_WPS 16
  47. #define CR3000_GPIO_BTN_RESET 17
  48. #define CR3000_KEYS_POLL_INTERVAL 20 /* msecs */
  49. #define CR3000_KEYS_DEBOUNCE_INTERVAL (3 * CR3000_KEYS_POLL_INTERVAL)
  50. #define CR3000_MAC0_OFFSET 0
  51. #define CR3000_MAC1_OFFSET 6
  52. #define CR3000_WMAC_CALDATA_OFFSET 0x1000
  53. #define CR3000_WMAC_MAC_OFFSET 0x1002
  54. #define CR3000_PCIE_CALDATA_OFFSET 0x5000
  55. static struct gpio_led cr3000_leds_gpio[] __initdata = {
  56. {
  57. .name = "pcs:amber:power",
  58. .gpio = CR3000_GPIO_LED_POWER_AMBER,
  59. .active_low = 1,
  60. },
  61. {
  62. .name = "pcs:blue:wlan",
  63. .gpio = CR3000_GPIO_LED_WLAN_2G,
  64. .active_low = 1,
  65. },
  66. {
  67. .name = "pcs:blue:wan",
  68. .gpio = CR3000_GPIO_LED_WAN,
  69. .active_low = 1,
  70. },
  71. {
  72. .name = "pcs:blue:lan1",
  73. .gpio = CR3000_GPIO_LED_LAN1,
  74. .active_low = 1,
  75. },
  76. {
  77. .name = "pcs:blue:lan2",
  78. .gpio = CR3000_GPIO_LED_LAN2,
  79. .active_low = 1,
  80. },
  81. {
  82. .name = "pcs:blue:lan3",
  83. .gpio = CR3000_GPIO_LED_LAN3,
  84. .active_low = 1,
  85. },
  86. {
  87. .name = "pcs:blue:lan4",
  88. .gpio = CR3000_GPIO_LED_LAN4,
  89. .active_low = 1,
  90. },
  91. };
  92. static struct gpio_keys_button cr3000_gpio_keys[] __initdata = {
  93. {
  94. .desc = "WPS button",
  95. .type = EV_KEY,
  96. .code = KEY_WPS_BUTTON,
  97. .debounce_interval = CR3000_KEYS_DEBOUNCE_INTERVAL,
  98. .gpio = CR3000_GPIO_BTN_WPS,
  99. .active_low = 1,
  100. },
  101. {
  102. .desc = "Reset button",
  103. .type = EV_KEY,
  104. .code = KEY_WPS_BUTTON,
  105. .debounce_interval = CR3000_KEYS_DEBOUNCE_INTERVAL,
  106. .gpio = CR3000_GPIO_BTN_RESET,
  107. .active_low = 1,
  108. },
  109. };
  110. static void __init cr3000_setup(void)
  111. {
  112. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  113. ath79_register_m25p80(NULL);
  114. ath79_register_leds_gpio(-1, ARRAY_SIZE(cr3000_leds_gpio),
  115. cr3000_leds_gpio);
  116. ath79_register_gpio_keys_polled(-1, CR3000_KEYS_POLL_INTERVAL,
  117. ARRAY_SIZE(cr3000_gpio_keys),
  118. cr3000_gpio_keys);
  119. /* WLAN 2GHz onboard */
  120. ath79_register_wmac(art + CR3000_WMAC_CALDATA_OFFSET, art + CR3000_WMAC_MAC_OFFSET);
  121. ath79_register_mdio(1, 0x0);
  122. ath79_register_mdio(0, 0x0);
  123. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  124. /* Lan 4-port switch attached to GMAC1 internal switch */
  125. ath79_init_mac(ath79_eth1_data.mac_addr, art + CR3000_MAC0_OFFSET, 0);
  126. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  127. ath79_eth1_data.speed = SPEED_1000;
  128. ath79_eth1_data.duplex = DUPLEX_FULL;
  129. ath79_register_eth(1);
  130. ath79_init_mac(ath79_eth0_data.mac_addr, art + CR3000_MAC1_OFFSET, 0);
  131. /* WAN Fast Ethernet interface attached to GMAC0 */
  132. ath79_switch_data.phy4_mii_en = 1;
  133. ath79_switch_data.phy_poll_mask = BIT(0);
  134. ath79_eth0_data.phy_mask = BIT(0);
  135. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  136. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  137. ath79_register_eth(0);
  138. }
  139. MIPS_MACHINE(ATH79_MACH_CR3000, "CR3000", "PowerCloud CR3000",
  140. cr3000_setup);