mach-mr900.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * MR900 board support
  3. *
  4. * Copyright (c) 2012 Qualcomm Atheros
  5. * Copyright (c) 2012-2013 Marek Lindner <marek@open-mesh.com>
  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/ar8216_platform.h>
  22. #include <linux/ath9k_platform.h>
  23. #include <asm/mach-ath79/ar71xx_regs.h>
  24. #include <linux/platform_data/phy-at803x.h>
  25. #include "common.h"
  26. #include "dev-ap9x-pci.h"
  27. #include "dev-gpio-buttons.h"
  28. #include "dev-eth.h"
  29. #include "dev-leds-gpio.h"
  30. #include "dev-m25p80.h"
  31. #include "dev-wmac.h"
  32. #include "machtypes.h"
  33. #include "pci.h"
  34. #define MR900_GPIO_LED_LAN 12
  35. #define MR900_GPIO_LED_WLAN_2G 13
  36. #define MR900_GPIO_LED_STATUS_GREEN 19
  37. #define MR900_GPIO_LED_STATUS_RED 21
  38. #define MR900_GPIO_LED_POWER 22
  39. #define MR900_GPIO_LED_WLAN_5G 23
  40. #define MR900_GPIO_BTN_RESET 17
  41. #define MR900_KEYS_POLL_INTERVAL 20 /* msecs */
  42. #define MR900_KEYS_DEBOUNCE_INTERVAL (3 * MR900_KEYS_POLL_INTERVAL)
  43. #define MR900_MAC0_OFFSET 0
  44. #define MR900_WMAC_CALDATA_OFFSET 0x1000
  45. #define MR900_PCIE_CALDATA_OFFSET 0x5000
  46. static struct gpio_led mr900_leds_gpio[] __initdata = {
  47. {
  48. .name = "mr900:blue:power",
  49. .gpio = MR900_GPIO_LED_POWER,
  50. .active_low = 1,
  51. },
  52. {
  53. .name = "mr900:blue:wan",
  54. .gpio = MR900_GPIO_LED_LAN,
  55. .active_low = 1,
  56. },
  57. {
  58. .name = "mr900:blue:wlan24",
  59. .gpio = MR900_GPIO_LED_WLAN_2G,
  60. .active_low = 1,
  61. },
  62. {
  63. .name = "mr900:blue:wlan58",
  64. .gpio = MR900_GPIO_LED_WLAN_5G,
  65. .active_low = 1,
  66. },
  67. {
  68. .name = "mr900:green:status",
  69. .gpio = MR900_GPIO_LED_STATUS_GREEN,
  70. .active_low = 1,
  71. },
  72. {
  73. .name = "mr900:red:status",
  74. .gpio = MR900_GPIO_LED_STATUS_RED,
  75. .active_low = 1,
  76. },
  77. };
  78. static struct gpio_keys_button mr900_gpio_keys[] __initdata = {
  79. {
  80. .desc = "Reset button",
  81. .type = EV_KEY,
  82. .code = KEY_RESTART,
  83. .debounce_interval = MR900_KEYS_DEBOUNCE_INTERVAL,
  84. .gpio = MR900_GPIO_BTN_RESET,
  85. .active_low = 1,
  86. },
  87. };
  88. static struct at803x_platform_data mr900_at803x_data = {
  89. .disable_smarteee = 1,
  90. .enable_rgmii_rx_delay = 1,
  91. .enable_rgmii_tx_delay = 0,
  92. .fixup_rgmii_tx_delay = 1,
  93. };
  94. static struct mdio_board_info mr900_mdio0_info[] = {
  95. {
  96. .bus_id = "ag71xx-mdio.0",
  97. .phy_addr = 5,
  98. .platform_data = &mr900_at803x_data,
  99. },
  100. };
  101. static void __init mr900_setup_qca955x_eth_cfg(u32 mask,
  102. unsigned int rxd,
  103. unsigned int rxdv,
  104. unsigned int txd,
  105. unsigned int txe)
  106. {
  107. void __iomem *base;
  108. u32 t;
  109. base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
  110. t = mask;
  111. t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT;
  112. t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT;
  113. t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT;
  114. t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT;
  115. __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
  116. iounmap(base);
  117. }
  118. static void __init mr900_setup(void)
  119. {
  120. u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  121. u8 mac[6], pcie_mac[6];
  122. struct ath9k_platform_data *pdata;
  123. ath79_eth0_pll_data.pll_1000 = 0xae000000;
  124. ath79_eth0_pll_data.pll_100 = 0xa0000101;
  125. ath79_eth0_pll_data.pll_10 = 0xa0001313;
  126. ath79_register_m25p80(NULL);
  127. ath79_register_leds_gpio(-1, ARRAY_SIZE(mr900_leds_gpio),
  128. mr900_leds_gpio);
  129. ath79_register_gpio_keys_polled(-1, MR900_KEYS_POLL_INTERVAL,
  130. ARRAY_SIZE(mr900_gpio_keys),
  131. mr900_gpio_keys);
  132. ath79_init_mac(mac, art + MR900_MAC0_OFFSET, 1);
  133. ath79_register_wmac(art + MR900_WMAC_CALDATA_OFFSET, mac);
  134. ath79_init_mac(pcie_mac, art + MR900_MAC0_OFFSET, 16);
  135. ap91_pci_init(art + MR900_PCIE_CALDATA_OFFSET, pcie_mac);
  136. pdata = ap9x_pci_get_wmac_data(0);
  137. if (!pdata) {
  138. pr_err("mr900: unable to get address of wlan data\n");
  139. return;
  140. }
  141. pdata->use_eeprom = true;
  142. mr900_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN, 3, 3, 0, 0);
  143. ath79_register_mdio(0, 0x0);
  144. mdiobus_register_board_info(mr900_mdio0_info,
  145. ARRAY_SIZE(mr900_mdio0_info));
  146. ath79_init_mac(ath79_eth0_data.mac_addr, art + MR900_MAC0_OFFSET, 0);
  147. /* GMAC0 is connected to the RMGII interface */
  148. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  149. ath79_eth0_data.phy_mask = BIT(5);
  150. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  151. ath79_register_eth(0);
  152. }
  153. MIPS_MACHINE(ATH79_MACH_MR900, "MR900", "OpenMesh MR900", mr900_setup);
  154. MIPS_MACHINE(ATH79_MACH_MR900v2, "MR900v2", "OpenMesh MR900v2", mr900_setup);