mach-mr1750.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * MR1750 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 <asm/mach-ath79/ar71xx_regs.h>
  23. #include <linux/platform_data/phy-at803x.h>
  24. #include "common.h"
  25. #include "dev-ap9x-pci.h"
  26. #include "dev-gpio-buttons.h"
  27. #include "dev-eth.h"
  28. #include "dev-leds-gpio.h"
  29. #include "dev-m25p80.h"
  30. #include "dev-wmac.h"
  31. #include "machtypes.h"
  32. #include "pci.h"
  33. #define MR1750_GPIO_LED_LAN 12
  34. #define MR1750_GPIO_LED_WLAN_2G 13
  35. #define MR1750_GPIO_LED_STATUS_GREEN 19
  36. #define MR1750_GPIO_LED_STATUS_RED 21
  37. #define MR1750_GPIO_LED_POWER 22
  38. #define MR1750_GPIO_LED_WLAN_5G 23
  39. #define MR1750_GPIO_BTN_RESET 17
  40. #define MR1750_KEYS_POLL_INTERVAL 20 /* msecs */
  41. #define MR1750_KEYS_DEBOUNCE_INTERVAL (3 * MR1750_KEYS_POLL_INTERVAL)
  42. #define MR1750_MAC0_OFFSET 0
  43. #define MR1750_WMAC_CALDATA_OFFSET 0x1000
  44. static struct gpio_led mr1750_leds_gpio[] __initdata = {
  45. {
  46. .name = "mr1750:blue:power",
  47. .gpio = MR1750_GPIO_LED_POWER,
  48. .active_low = 1,
  49. },
  50. {
  51. .name = "mr1750:blue:wan",
  52. .gpio = MR1750_GPIO_LED_LAN,
  53. .active_low = 1,
  54. },
  55. {
  56. .name = "mr1750:blue:wlan24",
  57. .gpio = MR1750_GPIO_LED_WLAN_2G,
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "mr1750:blue:wlan58",
  62. .gpio = MR1750_GPIO_LED_WLAN_5G,
  63. .active_low = 1,
  64. },
  65. {
  66. .name = "mr1750:green:status",
  67. .gpio = MR1750_GPIO_LED_STATUS_GREEN,
  68. .active_low = 1,
  69. },
  70. {
  71. .name = "mr1750:red:status",
  72. .gpio = MR1750_GPIO_LED_STATUS_RED,
  73. .active_low = 1,
  74. },
  75. };
  76. static struct gpio_keys_button mr1750_gpio_keys[] __initdata = {
  77. {
  78. .desc = "Reset button",
  79. .type = EV_KEY,
  80. .code = KEY_RESTART,
  81. .debounce_interval = MR1750_KEYS_DEBOUNCE_INTERVAL,
  82. .gpio = MR1750_GPIO_BTN_RESET,
  83. .active_low = 1,
  84. },
  85. };
  86. static struct at803x_platform_data mr1750_at803x_data = {
  87. .disable_smarteee = 1,
  88. .enable_rgmii_rx_delay = 1,
  89. .enable_rgmii_tx_delay = 0,
  90. .fixup_rgmii_tx_delay = 1,
  91. };
  92. static struct mdio_board_info mr1750_mdio0_info[] = {
  93. {
  94. .bus_id = "ag71xx-mdio.0",
  95. .phy_addr = 5,
  96. .platform_data = &mr1750_at803x_data,
  97. },
  98. };
  99. static void __init mr1750_setup_qca955x_eth_cfg(u32 mask,
  100. unsigned int rxd,
  101. unsigned int rxdv,
  102. unsigned int txd,
  103. unsigned int txe)
  104. {
  105. void __iomem *base;
  106. u32 t;
  107. base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
  108. t = mask;
  109. t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT;
  110. t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT;
  111. t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT;
  112. t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT;
  113. __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
  114. iounmap(base);
  115. }
  116. static void __init mr1750_setup(void)
  117. {
  118. u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  119. u8 mac[6];
  120. ath79_eth0_pll_data.pll_1000 = 0xae000000;
  121. ath79_eth0_pll_data.pll_100 = 0xa0000101;
  122. ath79_eth0_pll_data.pll_10 = 0xa0001313;
  123. ath79_register_m25p80(NULL);
  124. ath79_register_leds_gpio(-1, ARRAY_SIZE(mr1750_leds_gpio),
  125. mr1750_leds_gpio);
  126. ath79_register_gpio_keys_polled(-1, MR1750_KEYS_POLL_INTERVAL,
  127. ARRAY_SIZE(mr1750_gpio_keys),
  128. mr1750_gpio_keys);
  129. ath79_init_mac(mac, art + MR1750_MAC0_OFFSET, 1);
  130. ath79_register_wmac(art + MR1750_WMAC_CALDATA_OFFSET, mac);
  131. ath79_register_pci();
  132. mr1750_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN, 3, 3, 0, 0);
  133. ath79_register_mdio(0, 0x0);
  134. mdiobus_register_board_info(mr1750_mdio0_info,
  135. ARRAY_SIZE(mr1750_mdio0_info));
  136. ath79_init_mac(ath79_eth0_data.mac_addr, art + MR1750_MAC0_OFFSET, 0);
  137. /* GMAC0 is connected to the RMGII interface */
  138. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  139. ath79_eth0_data.phy_mask = BIT(5);
  140. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  141. ath79_register_eth(0);
  142. }
  143. MIPS_MACHINE(ATH79_MACH_MR1750, "MR1750", "OpenMesh MR1750", mr1750_setup);
  144. MIPS_MACHINE(ATH79_MACH_MR1750V2, "MR1750v2", "OpenMesh MR1750v2", mr1750_setup);