mach-om5pac.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * OpenMesh OM5P-AC support
  3. *
  4. * Copyright (C) 2013 Marek Lindner <marek@open-mesh.com>
  5. * Copyright (C) 2014 Sven Eckelmann <sven@open-mesh.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/gpio.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/i2c.h>
  16. #include <linux/i2c-algo-bit.h>
  17. #include <linux/i2c-gpio.h>
  18. #include <linux/platform_data/phy-at803x.h>
  19. #include <asm/mach-ath79/ar71xx_regs.h>
  20. #include <asm/mach-ath79/ath79.h>
  21. #include "common.h"
  22. #include "dev-ap9x-pci.h"
  23. #include "dev-eth.h"
  24. #include "dev-leds-gpio.h"
  25. #include "dev-m25p80.h"
  26. #include "dev-wmac.h"
  27. #include "machtypes.h"
  28. #include "pci.h"
  29. #define OM5PAC_GPIO_LED_POWER 18
  30. #define OM5PAC_GPIO_LED_GREEN 21
  31. #define OM5PAC_GPIO_LED_RED 23
  32. #define OM5PAC_GPIO_LED_YELLOW 22
  33. #define OM5PAC_GPIO_LED_LAN 20
  34. #define OM5PAC_GPIO_LED_WAN 19
  35. #define OM5PAC_GPIO_I2C_SCL 12
  36. #define OM5PAC_GPIO_I2C_SDA 11
  37. #define OM5PAC_KEYS_POLL_INTERVAL 20 /* msecs */
  38. #define OM5PAC_KEYS_DEBOUNCE_INTERVAL (3 * OM5PAC_KEYS_POLL_INTERVAL)
  39. #define OM5PAC_WMAC_CALDATA_OFFSET 0x1000
  40. static struct gpio_led om5pac_leds_gpio[] __initdata = {
  41. {
  42. .name = "om5pac:blue:power",
  43. .gpio = OM5PAC_GPIO_LED_POWER,
  44. .active_low = 1,
  45. }, {
  46. .name = "om5pac:red:wifi",
  47. .gpio = OM5PAC_GPIO_LED_RED,
  48. .active_low = 1,
  49. }, {
  50. .name = "om5pac:yellow:wifi",
  51. .gpio = OM5PAC_GPIO_LED_YELLOW,
  52. .active_low = 1,
  53. }, {
  54. .name = "om5pac:green:wifi",
  55. .gpio = OM5PAC_GPIO_LED_GREEN,
  56. .active_low = 1,
  57. }, {
  58. .name = "om5pac:blue:lan",
  59. .gpio = OM5PAC_GPIO_LED_LAN,
  60. .active_low = 1,
  61. }, {
  62. .name = "om5pac:blue:wan",
  63. .gpio = OM5PAC_GPIO_LED_WAN,
  64. .active_low = 1,
  65. }
  66. };
  67. static struct flash_platform_data om5pac_flash_data = {
  68. .type = "mx25l12805d",
  69. };
  70. static struct i2c_gpio_platform_data om5pac_i2c_device_platdata = {
  71. .sda_pin = OM5PAC_GPIO_I2C_SDA,
  72. .scl_pin = OM5PAC_GPIO_I2C_SCL,
  73. .udelay = 10,
  74. .sda_is_open_drain = 1,
  75. .scl_is_open_drain = 1,
  76. };
  77. static struct platform_device om5pac_i2c_device = {
  78. .name = "i2c-gpio",
  79. .id = 0,
  80. .dev = {
  81. .platform_data = &om5pac_i2c_device_platdata,
  82. },
  83. };
  84. static struct i2c_board_info om5pac_i2c_devs[] __initdata = {
  85. {
  86. I2C_BOARD_INFO("tmp423", 0x4c),
  87. },
  88. };
  89. static struct at803x_platform_data om5pac_at803x_data = {
  90. .disable_smarteee = 1,
  91. .enable_rgmii_rx_delay = 1,
  92. .enable_rgmii_tx_delay = 1,
  93. };
  94. static struct mdio_board_info om5pac_mdio0_info[] = {
  95. {
  96. .bus_id = "ag71xx-mdio.0",
  97. .phy_addr = 1,
  98. .platform_data = &om5pac_at803x_data,
  99. },
  100. {
  101. .bus_id = "ag71xx-mdio.0",
  102. .phy_addr = 2,
  103. .platform_data = &om5pac_at803x_data,
  104. },
  105. };
  106. static void __init om5p_ac_setup_qca955x_eth_cfg(u32 mask,
  107. unsigned int rxd,
  108. unsigned int rxdv,
  109. unsigned int txd,
  110. unsigned int txe)
  111. {
  112. void __iomem *base;
  113. u32 t;
  114. base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
  115. t = mask;
  116. t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT;
  117. t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT;
  118. t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT;
  119. t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT;
  120. __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
  121. iounmap(base);
  122. }
  123. static void __init om5p_ac_setup(void)
  124. {
  125. u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  126. u8 mac[6];
  127. /* temperature sensor */
  128. platform_device_register(&om5pac_i2c_device);
  129. i2c_register_board_info(0, om5pac_i2c_devs,
  130. ARRAY_SIZE(om5pac_i2c_devs));
  131. ath79_gpio_output_select(OM5PAC_GPIO_LED_WAN, QCA955X_GPIO_OUT_GPIO);
  132. ath79_register_m25p80(&om5pac_flash_data);
  133. ath79_register_leds_gpio(-1, ARRAY_SIZE(om5pac_leds_gpio),
  134. om5pac_leds_gpio);
  135. ath79_init_mac(mac, art, 0x02);
  136. ath79_register_wmac(art + OM5PAC_WMAC_CALDATA_OFFSET, mac);
  137. om5p_ac_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN, 3, 3, 0, 0);
  138. ath79_register_mdio(0, 0x0);
  139. mdiobus_register_board_info(om5pac_mdio0_info,
  140. ARRAY_SIZE(om5pac_mdio0_info));
  141. ath79_init_mac(ath79_eth0_data.mac_addr, art, 0x00);
  142. ath79_init_mac(ath79_eth1_data.mac_addr, art, 0x01);
  143. /* GMAC0 is connected to the PHY1 */
  144. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  145. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  146. ath79_eth0_data.phy_mask = BIT(1);
  147. ath79_eth0_pll_data.pll_1000 = 0x82000101;
  148. ath79_eth0_pll_data.pll_100 = 0x80000101;
  149. ath79_eth0_pll_data.pll_10 = 0x80001313;
  150. ath79_register_eth(0);
  151. /* GMAC1 is connected to MDIO1 in SGMII mode */
  152. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  153. ath79_eth1_data.mii_bus_dev = &ath79_mdio0_device.dev;
  154. ath79_eth1_data.phy_mask = BIT(2);
  155. ath79_eth1_pll_data.pll_1000 = 0x03000101;
  156. ath79_eth1_pll_data.pll_100 = 0x80000101;
  157. ath79_eth1_pll_data.pll_10 = 0x80001313;
  158. ath79_eth1_data.speed = SPEED_1000;
  159. ath79_eth1_data.duplex = DUPLEX_FULL;
  160. ath79_register_eth(1);
  161. ath79_register_pci();
  162. }
  163. MIPS_MACHINE(ATH79_MACH_OM5P_AC, "OM5P-AC", "OpenMesh OM5P AC", om5p_ac_setup);