mach-cr5000.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * PowerCloud CR5000 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-usb.h"
  38. #include "dev-wmac.h"
  39. #include "machtypes.h"
  40. #define CR5000_GPIO_LED_WLAN_2G 14
  41. #define CR5000_GPIO_LED_WPS 12
  42. #define CR5000_GPIO_LED_POWER_AMBER 4
  43. /* GPIO2 has to have JTAG disabled as it is also to
  44. * power led
  45. */
  46. #define CR5000_GPIO_LED_POWER_ENABLE 2
  47. #define CR5000_GPIO_BTN_WPS 16
  48. #define CR5000_GPIO_BTN_RESET 17
  49. #define CR5000_KEYS_POLL_INTERVAL 20 /* msecs */
  50. #define CR5000_KEYS_DEBOUNCE_INTERVAL (3 * CR5000_KEYS_POLL_INTERVAL)
  51. #define CR5000_MAC0_OFFSET 0
  52. #define CR5000_WMAC_CALDATA_OFFSET 0x1000
  53. #define CR5000_WMAC_MAC_OFFSET 0x1002
  54. #define CR5000_PCIE_CALDATA_OFFSET 0x5000
  55. #define CR5000_PCIE_MAC_OFFSET 0x5002
  56. static struct gpio_led cr5000_leds_gpio[] __initdata = {
  57. {
  58. .name = "pcs:amber:power",
  59. .gpio = CR5000_GPIO_LED_POWER_AMBER,
  60. .active_low = 1,
  61. },
  62. {
  63. .name = "pcs:white:wps",
  64. .gpio = CR5000_GPIO_LED_WPS,
  65. .active_low = 1,
  66. },
  67. {
  68. .name = "pcs:blue:wlan",
  69. .gpio = CR5000_GPIO_LED_WLAN_2G,
  70. .active_low = 1,
  71. },
  72. };
  73. static struct gpio_keys_button cr5000_gpio_keys[] __initdata = {
  74. {
  75. .desc = "WPS button",
  76. .type = EV_KEY,
  77. .code = KEY_WPS_BUTTON,
  78. .debounce_interval = CR5000_KEYS_DEBOUNCE_INTERVAL,
  79. .gpio = CR5000_GPIO_BTN_WPS,
  80. .active_low = 1,
  81. },
  82. {
  83. .desc = "Reset button",
  84. .type = EV_KEY,
  85. .code = KEY_WPS_BUTTON,
  86. .debounce_interval = CR5000_KEYS_DEBOUNCE_INTERVAL,
  87. .gpio = CR5000_GPIO_BTN_RESET,
  88. .active_low = 1,
  89. },
  90. };
  91. static struct ar8327_pad_cfg cr5000_ar8327_pad0_cfg = {
  92. .mode = AR8327_PAD_MAC_RGMII,
  93. .txclk_delay_en = true,
  94. .rxclk_delay_en = true,
  95. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  96. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  97. };
  98. static struct ar8327_led_cfg cr5000_ar8327_led_cfg = {
  99. .led_ctrl0 = 0x00000000,
  100. .led_ctrl1 = 0xc737c737,
  101. .led_ctrl2 = 0x00000000,
  102. .led_ctrl3 = 0x00c30c00,
  103. .open_drain = true,
  104. };
  105. static struct ar8327_platform_data cr5000_ar8327_data = {
  106. .pad0_cfg = &cr5000_ar8327_pad0_cfg,
  107. .port0_cfg = {
  108. .force_link = 1,
  109. .speed = AR8327_PORT_SPEED_1000,
  110. .duplex = 1,
  111. .txpause = 1,
  112. .rxpause = 1,
  113. },
  114. .led_cfg = &cr5000_ar8327_led_cfg,
  115. };
  116. static struct mdio_board_info cr5000_mdio0_info[] = {
  117. {
  118. .bus_id = "ag71xx-mdio.0",
  119. .phy_addr = 0,
  120. .platform_data = &cr5000_ar8327_data,
  121. },
  122. };
  123. static void __init cr5000_setup(void)
  124. {
  125. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  126. ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
  127. gpio_request_one(CR5000_GPIO_LED_POWER_ENABLE,
  128. GPIOF_OUT_INIT_LOW, "Power LED enable");
  129. ath79_gpio_output_select(CR5000_GPIO_LED_POWER_AMBER, AR934X_GPIO_OUT_GPIO);
  130. ath79_gpio_output_select(CR5000_GPIO_LED_WLAN_2G, AR934X_GPIO_OUT_GPIO);
  131. ath79_gpio_output_select(CR5000_GPIO_LED_WPS, AR934X_GPIO_OUT_GPIO);
  132. ath79_register_m25p80(NULL);
  133. ath79_register_leds_gpio(-1, ARRAY_SIZE(cr5000_leds_gpio),
  134. cr5000_leds_gpio);
  135. ath79_register_gpio_keys_polled(-1, CR5000_KEYS_POLL_INTERVAL,
  136. ARRAY_SIZE(cr5000_gpio_keys),
  137. cr5000_gpio_keys);
  138. ath79_register_usb();
  139. ath79_register_wmac(art + CR5000_WMAC_CALDATA_OFFSET, art + CR5000_WMAC_MAC_OFFSET);
  140. ap94_pci_init(NULL, NULL, NULL, art + CR5000_PCIE_MAC_OFFSET);
  141. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  142. ath79_register_mdio(0, 0x0);
  143. ath79_init_mac(ath79_eth0_data.mac_addr, art + CR5000_MAC0_OFFSET, 0);
  144. mdiobus_register_board_info(cr5000_mdio0_info,
  145. ARRAY_SIZE(cr5000_mdio0_info));
  146. /* GMAC0 is connected to an AR8327 switch */
  147. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  148. ath79_eth0_data.phy_mask = BIT(0);
  149. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  150. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  151. ath79_register_eth(0);
  152. }
  153. MIPS_MACHINE(ATH79_MACH_CR5000, "CR5000", "PowerCloud CR5000",
  154. cr5000_setup);