0072-ar71xx-add-kernel-support-for-the-OpenMesh-OM5P-ACv2-board.patch 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. From: Sven Eckelmann <sven.eckelmann@open-mesh.com>
  2. Date: Sat, 9 Apr 2016 10:26:15 +0000
  3. Subject: ar71xx: add kernel support for the OpenMesh OM5P-ACv2 board
  4. Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
  5. Backport of r49149
  6. Forwarded: https://patchwork.ozlabs.org/patch/624199/
  7. diff --git a/target/linux/ar71xx/config-3.18 b/target/linux/ar71xx/config-3.18
  8. index dd89357..514f7d5 100644
  9. --- a/target/linux/ar71xx/config-3.18
  10. +++ b/target/linux/ar71xx/config-3.18
  11. @@ -92,6 +92,7 @@ CONFIG_ATH79_MACH_NBG6716=y
  12. CONFIG_ATH79_MACH_OM2P=y
  13. CONFIG_ATH79_MACH_OM5P=y
  14. CONFIG_ATH79_MACH_OM5P_AC=y
  15. +CONFIG_ATH79_MACH_OM5P_ACv2=y
  16. CONFIG_ATH79_MACH_ONION_OMEGA=y
  17. CONFIG_ATH79_MACH_PB42=y
  18. CONFIG_ATH79_MACH_PB44=y
  19. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-om5pacv2.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-om5pacv2.c
  20. new file mode 100644
  21. index 0000000..587ca32
  22. --- /dev/null
  23. +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-om5pacv2.c
  24. @@ -0,0 +1,216 @@
  25. +/*
  26. + * OpenMesh OM5P-ACv2 support
  27. + *
  28. + * Copyright (C) 2013 Marek Lindner <marek@open-mesh.com>
  29. + * Copyright (C) 2014-2016 Sven Eckelmann <sven@open-mesh.com>
  30. + * Copyright (C) 2015 Open-Mesh - Jim Collar <jim.collar@eqware.net>
  31. + *
  32. + * This program is free software; you can redistribute it and/or modify it
  33. + * under the terms of the GNU General Public License version 2 as published
  34. + * by the Free Software Foundation.
  35. + */
  36. +
  37. +#include <linux/gpio.h>
  38. +#include <linux/mdio-gpio.h>
  39. +#include <linux/mtd/mtd.h>
  40. +#include <linux/mtd/partitions.h>
  41. +#include <linux/platform_device.h>
  42. +#include <linux/i2c.h>
  43. +#include <linux/i2c-algo-bit.h>
  44. +#include <linux/i2c-gpio.h>
  45. +#include <linux/platform_data/phy-at803x.h>
  46. +
  47. +#include <asm/mach-ath79/ar71xx_regs.h>
  48. +#include <asm/mach-ath79/ath79.h>
  49. +
  50. +#include "common.h"
  51. +#include "dev-ap9x-pci.h"
  52. +#include "dev-eth.h"
  53. +#include "dev-gpio-buttons.h"
  54. +#include "dev-leds-gpio.h"
  55. +#include "dev-m25p80.h"
  56. +#include "dev-wmac.h"
  57. +#include "machtypes.h"
  58. +#include "pci.h"
  59. +
  60. +#define OM5PACV2_GPIO_LED_POWER 14
  61. +#define OM5PACV2_GPIO_LED_GREEN 13
  62. +#define OM5PACV2_GPIO_LED_RED 23
  63. +#define OM5PACV2_GPIO_LED_YELLOW 15
  64. +#define OM5PACV2_GPIO_BTN_RESET 1
  65. +#define OM5PACV2_GPIO_I2C_SCL 18
  66. +#define OM5PACV2_GPIO_I2C_SDA 19
  67. +#define OM5PACV2_GPIO_PA_DCDC 2
  68. +#define OM5PACV2_GPIO_PA_HIGH 16
  69. +
  70. +#define OM5PACV2_KEYS_POLL_INTERVAL 20 /* msecs */
  71. +#define OM5PACV2_KEYS_DEBOUNCE_INTERVAL (3 * OM5PACV2_KEYS_POLL_INTERVAL)
  72. +
  73. +#define OM5PACV2_WMAC_CALDATA_OFFSET 0x1000
  74. +
  75. +static struct gpio_led om5pacv2_leds_gpio[] __initdata = {
  76. + {
  77. + .name = "om5pac:blue:power",
  78. + .gpio = OM5PACV2_GPIO_LED_POWER,
  79. + .active_low = 1,
  80. + }, {
  81. + .name = "om5pac:red:wifi",
  82. + .gpio = OM5PACV2_GPIO_LED_RED,
  83. + .active_low = 1,
  84. + }, {
  85. + .name = "om5pac:yellow:wifi",
  86. + .gpio = OM5PACV2_GPIO_LED_YELLOW,
  87. + .active_low = 1,
  88. + }, {
  89. + .name = "om5pac:green:wifi",
  90. + .gpio = OM5PACV2_GPIO_LED_GREEN,
  91. + .active_low = 1,
  92. + }
  93. +};
  94. +
  95. +static struct gpio_keys_button om5pacv2_gpio_keys[] __initdata = {
  96. + {
  97. + .desc = "reset",
  98. + .type = EV_KEY,
  99. + .code = KEY_RESTART,
  100. + .debounce_interval = OM5PACV2_KEYS_DEBOUNCE_INTERVAL,
  101. + .gpio = OM5PACV2_GPIO_BTN_RESET,
  102. + .active_low = 1,
  103. + }
  104. +};
  105. +
  106. +static struct i2c_gpio_platform_data om5pacv2_i2c_device_platdata = {
  107. + .sda_pin = OM5PACV2_GPIO_I2C_SDA,
  108. + .scl_pin = OM5PACV2_GPIO_I2C_SCL,
  109. + .udelay = 10,
  110. + .sda_is_open_drain = 1,
  111. + .scl_is_open_drain = 1,
  112. +};
  113. +
  114. +static struct platform_device om5pacv2_i2c_device = {
  115. + .name = "i2c-gpio",
  116. + .id = 0,
  117. + .dev = {
  118. + .platform_data = &om5pacv2_i2c_device_platdata,
  119. + },
  120. +};
  121. +
  122. +static struct i2c_board_info om5pacv2_i2c_devs[] __initdata = {
  123. + {
  124. + I2C_BOARD_INFO("tmp423", 0x4e),
  125. + },
  126. +};
  127. +
  128. +static struct flash_platform_data om5pacv2_flash_data = {
  129. + .type = "mx25l12805d",
  130. +};
  131. +
  132. +static struct at803x_platform_data om5pacv2_an_at803x_data = {
  133. + .disable_smarteee = 1,
  134. + .enable_rgmii_rx_delay = 1,
  135. + .enable_rgmii_tx_delay = 1,
  136. +};
  137. +
  138. +static struct at803x_platform_data om5pacv2_an_at8031_data = {
  139. + .disable_smarteee = 1,
  140. + .enable_rgmii_rx_delay = 1,
  141. + .enable_rgmii_tx_delay = 1,
  142. +};
  143. +
  144. +static struct mdio_board_info om5pacv2_an_mdio0_info[] = {
  145. + {
  146. + .bus_id = "ag71xx-mdio.0",
  147. + .phy_addr = 4,
  148. + .platform_data = &om5pacv2_an_at803x_data,
  149. + },
  150. + {
  151. + .bus_id = "ag71xx-mdio.1",
  152. + .phy_addr = 1,
  153. + .platform_data = &om5pacv2_an_at8031_data,
  154. + },
  155. +};
  156. +
  157. +static void __init om5p_acv2_setup_qca955x_eth_cfg(u32 mask,
  158. + unsigned int rxd,
  159. + unsigned int rxdv,
  160. + unsigned int txd,
  161. + unsigned int txe)
  162. +{
  163. + void __iomem *base;
  164. + u32 t;
  165. +
  166. + base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
  167. +
  168. + t = mask;
  169. + t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT;
  170. + t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT;
  171. + t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT;
  172. + t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT;
  173. +
  174. + __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
  175. +
  176. + iounmap(base);
  177. +}
  178. +
  179. +static void __init om5p_acv2_setup(void)
  180. +{
  181. + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
  182. + u8 mac[6];
  183. +
  184. + /* power amplifier high power, 4.2V at RFFM4203/4503 instead of 3.3 */
  185. + ath79_gpio_function_enable(QCA955X_GPIO_FUNC_JTAG_DISABLE);
  186. + ath79_gpio_output_select(OM5PACV2_GPIO_PA_DCDC, QCA955X_GPIO_OUT_GPIO);
  187. + ath79_gpio_output_select(OM5PACV2_GPIO_PA_HIGH, QCA955X_GPIO_OUT_GPIO);
  188. + gpio_request_one(OM5PACV2_GPIO_PA_DCDC, GPIOF_OUT_INIT_HIGH,
  189. + "PA DC/DC");
  190. + gpio_request_one(OM5PACV2_GPIO_PA_HIGH, GPIOF_OUT_INIT_HIGH, "PA HIGH");
  191. +
  192. + /* temperature sensor */
  193. + platform_device_register(&om5pacv2_i2c_device);
  194. + i2c_register_board_info(0, om5pacv2_i2c_devs,
  195. + ARRAY_SIZE(om5pacv2_i2c_devs));
  196. +
  197. + ath79_register_m25p80(&om5pacv2_flash_data);
  198. + ath79_register_leds_gpio(-1, ARRAY_SIZE(om5pacv2_leds_gpio),
  199. + om5pacv2_leds_gpio);
  200. + ath79_register_gpio_keys_polled(-1, OM5PACV2_KEYS_POLL_INTERVAL,
  201. + ARRAY_SIZE(om5pacv2_gpio_keys),
  202. + om5pacv2_gpio_keys);
  203. +
  204. + ath79_init_mac(mac, art, 0x02);
  205. + ath79_register_wmac(art + OM5PACV2_WMAC_CALDATA_OFFSET, mac);
  206. +
  207. + om5p_acv2_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN, 2, 2, 0, 0);
  208. + ath79_register_mdio(0, 0x0);
  209. + ath79_register_mdio(1, 0x0);
  210. +
  211. + mdiobus_register_board_info(om5pacv2_an_mdio0_info,
  212. + ARRAY_SIZE(om5pacv2_an_mdio0_info));
  213. +
  214. + ath79_init_mac(ath79_eth0_data.mac_addr, art, 0x00);
  215. + ath79_init_mac(ath79_eth1_data.mac_addr, art, 0x01);
  216. +
  217. + /* GMAC0 is connected to the PHY4 */
  218. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  219. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  220. + ath79_eth0_data.phy_mask = BIT(4);
  221. + ath79_eth0_pll_data.pll_1000 = 0x82000101;
  222. + ath79_eth0_pll_data.pll_100 = 0x80000101;
  223. + ath79_eth0_pll_data.pll_10 = 0x80001313;
  224. + ath79_register_eth(0);
  225. +
  226. + /* GMAC1 is connected to MDIO1 in SGMII mode */
  227. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  228. + ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
  229. + ath79_eth1_data.phy_mask = BIT(1);
  230. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  231. + ath79_eth1_pll_data.pll_100 = 0x80000101;
  232. + ath79_eth1_pll_data.pll_10 = 0x80001313;
  233. + ath79_eth1_data.speed = SPEED_1000;
  234. + ath79_eth1_data.duplex = DUPLEX_FULL;
  235. + ath79_register_eth(1);
  236. +
  237. + ath79_register_pci();
  238. +}
  239. +
  240. +MIPS_MACHINE(ATH79_MACH_OM5P_ACv2, "OM5P-ACv2", "OpenMesh OM5P ACv2", om5p_acv2_setup);
  241. diff --git a/target/linux/ar71xx/patches-3.18/816-MIPS-ath79-add-om5pacv-support.patch b/target/linux/ar71xx/patches-3.18/816-MIPS-ath79-add-om5pacv-support.patch
  242. new file mode 100644
  243. index 0000000..fbbf171
  244. --- /dev/null
  245. +++ b/target/linux/ar71xx/patches-3.18/816-MIPS-ath79-add-om5pacv-support.patch
  246. @@ -0,0 +1,39 @@
  247. +--- a/arch/mips/ath79/Kconfig
  248. ++++ b/arch/mips/ath79/Kconfig
  249. +@@ -808,6 +808,16 @@ config ATH79_MACH_OM5P_AC
  250. + select ATH79_DEV_M25P80
  251. + select ATH79_DEV_WMAC
  252. +
  253. ++config ATH79_MACH_OM5P_ACv2
  254. ++ bool "OpenMesh OM5P-ACv2 board support"
  255. ++ select SOC_QCA955X
  256. ++ select ATH79_DEV_AP9X_PCI if PCI
  257. ++ select ATH79_DEV_ETH
  258. ++ select ATH79_DEV_GPIO_BUTTONS
  259. ++ select ATH79_DEV_LEDS_GPIO
  260. ++ select ATH79_DEV_M25P80
  261. ++ select ATH79_DEV_WMAC
  262. ++
  263. + config ATH79_MACH_ONION_OMEGA
  264. + bool "ONION OMEGA support"
  265. + select SOC_AR933X
  266. +--- a/arch/mips/ath79/Makefile
  267. ++++ b/arch/mips/ath79/Makefile
  268. +@@ -101,6 +101,7 @@ obj-$(CONFIG_ATH79_MACH_NBG460N) += mach
  269. + obj-$(CONFIG_ATH79_MACH_OM2P) += mach-om2p.o
  270. + obj-$(CONFIG_ATH79_MACH_OM5P) += mach-om5p.o
  271. + obj-$(CONFIG_ATH79_MACH_OM5P_AC) += mach-om5pac.o
  272. ++obj-$(CONFIG_ATH79_MACH_OM5P_ACv2) += mach-om5pacv2.o
  273. + obj-$(CONFIG_ATH79_MACH_ONION_OMEGA) += mach-onion-omega.o
  274. + obj-$(CONFIG_ATH79_MACH_PB42) += mach-pb42.o
  275. + obj-$(CONFIG_ATH79_MACH_PB44) += mach-pb44.o
  276. +--- a/arch/mips/ath79/machtypes.h
  277. ++++ b/arch/mips/ath79/machtypes.h
  278. +@@ -96,6 +96,7 @@ enum ath79_mach_type {
  279. + ATH79_MACH_OM2Pv2, /* OpenMesh OM2Pv2 */
  280. + ATH79_MACH_OM2P, /* OpenMesh OM2P */
  281. + ATH79_MACH_OM5P_AC, /* OpenMesh OM5P-AC */
  282. ++ ATH79_MACH_OM5P_ACv2, /* OpenMesh OM5P-ACv2 */
  283. + ATH79_MACH_OM5P_AN, /* OpenMesh OM5P-AN */
  284. + ATH79_MACH_OM5P, /* OpenMesh OM5P */
  285. + ATH79_MACH_ONION_OMEGA, /* ONION OMEGA */