1
0

mach-om5p.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * OpenMesh OM5P 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-gpio-buttons.h"
  25. #include "dev-leds-gpio.h"
  26. #include "dev-m25p80.h"
  27. #include "dev-wmac.h"
  28. #include "machtypes.h"
  29. #define OM5P_GPIO_LED_POWER 13
  30. #define OM5P_GPIO_LED_GREEN 16
  31. #define OM5P_GPIO_LED_RED 19
  32. #define OM5P_GPIO_LED_YELLOW 17
  33. #define OM5P_GPIO_LED_LAN 14
  34. #define OM5P_GPIO_LED_WAN 15
  35. #define OM5P_GPIO_BTN_RESET 4
  36. #define OM5P_GPIO_I2C_SCL 20
  37. #define OM5P_GPIO_I2C_SDA 21
  38. #define OM5P_KEYS_POLL_INTERVAL 20 /* msecs */
  39. #define OM5P_KEYS_DEBOUNCE_INTERVAL (3 * OM5P_KEYS_POLL_INTERVAL)
  40. #define OM5P_WMAC_CALDATA_OFFSET 0x1000
  41. #define OM5P_PCI_CALDATA_OFFSET 0x5000
  42. static struct gpio_led om5p_leds_gpio[] __initdata = {
  43. {
  44. .name = "om5p:blue:power",
  45. .gpio = OM5P_GPIO_LED_POWER,
  46. .active_low = 1,
  47. }, {
  48. .name = "om5p:red:wifi",
  49. .gpio = OM5P_GPIO_LED_RED,
  50. .active_low = 1,
  51. }, {
  52. .name = "om5p:yellow:wifi",
  53. .gpio = OM5P_GPIO_LED_YELLOW,
  54. .active_low = 1,
  55. }, {
  56. .name = "om5p:green:wifi",
  57. .gpio = OM5P_GPIO_LED_GREEN,
  58. .active_low = 1,
  59. }, {
  60. .name = "om5p:blue:lan",
  61. .gpio = OM5P_GPIO_LED_LAN,
  62. .active_low = 1,
  63. }, {
  64. .name = "om5p:blue:wan",
  65. .gpio = OM5P_GPIO_LED_WAN,
  66. .active_low = 1,
  67. }
  68. };
  69. static struct gpio_keys_button om5p_gpio_keys[] __initdata = {
  70. {
  71. .desc = "reset",
  72. .type = EV_KEY,
  73. .code = KEY_RESTART,
  74. .debounce_interval = OM5P_KEYS_DEBOUNCE_INTERVAL,
  75. .gpio = OM5P_GPIO_BTN_RESET,
  76. .active_low = 1,
  77. }
  78. };
  79. static struct flash_platform_data om5p_flash_data = {
  80. .type = "mx25l12805d",
  81. };
  82. static void __init om5p_setup(void)
  83. {
  84. u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  85. u8 mac[6];
  86. /* make lan / wan leds software controllable */
  87. ath79_gpio_output_select(OM5P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
  88. ath79_gpio_output_select(OM5P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
  89. ath79_register_m25p80(&om5p_flash_data);
  90. ath79_register_leds_gpio(-1, ARRAY_SIZE(om5p_leds_gpio),
  91. om5p_leds_gpio);
  92. ath79_register_gpio_keys_polled(-1, OM5P_KEYS_POLL_INTERVAL,
  93. ARRAY_SIZE(om5p_gpio_keys),
  94. om5p_gpio_keys);
  95. ath79_init_mac(mac, art, 2);
  96. ath79_register_wmac(art + OM5P_WMAC_CALDATA_OFFSET, mac);
  97. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  98. ath79_register_mdio(1, 0x0);
  99. ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
  100. ath79_init_mac(ath79_eth1_data.mac_addr, art, 1);
  101. /* GMAC0 is connected to the PHY0 of the internal switch */
  102. ath79_switch_data.phy4_mii_en = 1;
  103. ath79_switch_data.phy_poll_mask = BIT(0);
  104. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  105. ath79_eth0_data.phy_mask = BIT(0);
  106. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  107. ath79_register_eth(0);
  108. /* GMAC1 is connected to the internal switch */
  109. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  110. ath79_register_eth(1);
  111. }
  112. MIPS_MACHINE(ATH79_MACH_OM5P, "OM5P", "OpenMesh OM5P", om5p_setup);
  113. static struct i2c_gpio_platform_data om5pan_i2c_device_platdata = {
  114. .sda_pin = OM5P_GPIO_I2C_SDA,
  115. .scl_pin = OM5P_GPIO_I2C_SCL,
  116. .udelay = 10,
  117. .sda_is_open_drain = 1,
  118. .scl_is_open_drain = 1,
  119. };
  120. static struct platform_device om5pan_i2c_device = {
  121. .name = "i2c-gpio",
  122. .id = 0,
  123. .dev = {
  124. .platform_data = &om5pan_i2c_device_platdata,
  125. },
  126. };
  127. static struct i2c_board_info om5pan_i2c_devs[] __initdata = {
  128. {
  129. I2C_BOARD_INFO("tmp423", 0x4c),
  130. },
  131. };
  132. static struct at803x_platform_data om5p_an_at803x_data = {
  133. .disable_smarteee = 1,
  134. .enable_rgmii_rx_delay = 1,
  135. .enable_rgmii_tx_delay = 1,
  136. };
  137. static struct mdio_board_info om5p_an_mdio0_info[] = {
  138. {
  139. .bus_id = "ag71xx-mdio.0",
  140. .phy_addr = 7,
  141. .platform_data = &om5p_an_at803x_data,
  142. },
  143. };
  144. static void __init om5p_an_setup(void)
  145. {
  146. u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  147. u8 mac[6];
  148. /* temperature sensor */
  149. platform_device_register(&om5pan_i2c_device);
  150. i2c_register_board_info(0, om5pan_i2c_devs,
  151. ARRAY_SIZE(om5pan_i2c_devs));
  152. /* make lan / wan leds software controllable */
  153. ath79_gpio_output_select(OM5P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
  154. ath79_gpio_output_select(OM5P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
  155. ath79_register_m25p80(&om5p_flash_data);
  156. ath79_register_leds_gpio(-1, ARRAY_SIZE(om5p_leds_gpio),
  157. om5p_leds_gpio);
  158. ath79_init_mac(mac, art, 0x02);
  159. ath79_register_wmac(art + OM5P_WMAC_CALDATA_OFFSET, mac);
  160. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  161. ath79_setup_ar934x_eth_rx_delay(2, 2);
  162. ath79_register_mdio(0, 0x0);
  163. ath79_register_mdio(1, 0x0);
  164. mdiobus_register_board_info(om5p_an_mdio0_info,
  165. ARRAY_SIZE(om5p_an_mdio0_info));
  166. ath79_init_mac(ath79_eth0_data.mac_addr, art, 0x00);
  167. ath79_init_mac(ath79_eth1_data.mac_addr, art, 0x01);
  168. /* GMAC0 is connected to the PHY7 */
  169. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  170. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  171. ath79_eth0_data.phy_mask = BIT(7);
  172. ath79_eth0_pll_data.pll_1000 = 0x02000000;
  173. ath79_eth0_pll_data.pll_100 = 0x00000101;
  174. ath79_eth0_pll_data.pll_10 = 0x00001313;
  175. ath79_register_eth(0);
  176. /* GMAC1 is connected to the internal switch */
  177. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  178. ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
  179. ath79_register_eth(1);
  180. ath79_init_mac(mac, art, 0x10);
  181. ap91_pci_init(art + OM5P_PCI_CALDATA_OFFSET, mac);
  182. }
  183. MIPS_MACHINE(ATH79_MACH_OM5P_AN, "OM5P-AN", "OpenMesh OM5P AN", om5p_an_setup);