0017-ar71xx-add-support-for-QCA953x-SoC.patch 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Sat, 29 Mar 2014 21:55:41 +0100
  3. Subject: ar71xx: add support for QCA953x SoC
  4. diff --git a/target/linux/ar71xx/config-3.3 b/target/linux/ar71xx/config-3.3
  5. index dfc5bf2..1c3ba3c 100644
  6. --- a/target/linux/ar71xx/config-3.3
  7. +++ b/target/linux/ar71xx/config-3.3
  8. @@ -40,11 +40,11 @@ CONFIG_ATH79_MACH_EW_DORIN=y
  9. CONFIG_ATH79_MACH_HORNET_UB=y
  10. CONFIG_ATH79_MACH_JA76PF=y
  11. CONFIG_ATH79_MACH_JWAP003=y
  12. +CONFIG_ATH79_MACH_MR600=y
  13. CONFIG_ATH79_MACH_MZK_W04NU=y
  14. CONFIG_ATH79_MACH_MZK_W300NH=y
  15. CONFIG_ATH79_MACH_NBG460N=y
  16. CONFIG_ATH79_MACH_OM2P=y
  17. -CONFIG_ATH79_MACH_MR600=y
  18. CONFIG_ATH79_MACH_PB42=y
  19. CONFIG_ATH79_MACH_PB44=y
  20. CONFIG_ATH79_MACH_PB92=y
  21. @@ -214,6 +214,7 @@ CONFIG_SOC_AR724X=y
  22. CONFIG_SOC_AR913X=y
  23. CONFIG_SOC_AR933X=y
  24. CONFIG_SOC_AR934X=y
  25. +CONFIG_SOC_QCA953X=y
  26. CONFIG_SOC_QCA955X=y
  27. CONFIG_SPI=y
  28. CONFIG_SPI_AP83=y
  29. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
  30. index 5a0b950..1a9b0df 100644
  31. --- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
  32. +++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
  33. @@ -195,6 +195,7 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
  34. case ATH79_SOC_AR7241:
  35. case ATH79_SOC_AR9330:
  36. case ATH79_SOC_AR9331:
  37. + case ATH79_SOC_QCA9533:
  38. mdio_dev = &ath79_mdio1_device;
  39. mdio_data = &ath79_mdio1_data;
  40. break;
  41. @@ -250,6 +251,11 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
  42. }
  43. mdio_data->is_ar934x = 1;
  44. break;
  45. +
  46. + case ATH79_SOC_QCA9533:
  47. + mdio_data->builtin_switch = 1;
  48. + break;
  49. +
  50. case ATH79_SOC_QCA9558:
  51. if (id == 1)
  52. mdio_data->builtin_switch = 1;
  53. @@ -540,6 +546,7 @@ static void __init ath79_init_eth_pll_data(unsigned int id)
  54. case ATH79_SOC_AR9341:
  55. case ATH79_SOC_AR9342:
  56. case ATH79_SOC_AR9344:
  57. + case ATH79_SOC_QCA9533:
  58. case ATH79_SOC_QCA9558:
  59. pll_10 = AR934X_PLL_VAL_10;
  60. pll_100 = AR934X_PLL_VAL_100;
  61. @@ -596,6 +603,7 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
  62. case ATH79_SOC_AR7241:
  63. case ATH79_SOC_AR9330:
  64. case ATH79_SOC_AR9331:
  65. + case ATH79_SOC_QCA9533:
  66. pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
  67. break;
  68. @@ -645,6 +653,7 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
  69. case ATH79_SOC_AR7241:
  70. case ATH79_SOC_AR9330:
  71. case ATH79_SOC_AR9331:
  72. + case ATH79_SOC_QCA9533:
  73. pdata->phy_if_mode = PHY_INTERFACE_MODE_GMII;
  74. break;
  75. @@ -882,6 +891,37 @@ void __init ath79_register_eth(unsigned int id)
  76. pdata->fifo_cfg3 = 0x01f00140;
  77. break;
  78. + case ATH79_SOC_QCA9533:
  79. + if (id == 0) {
  80. + pdata->reset_bit = AR933X_RESET_GE0_MAC |
  81. + AR933X_RESET_GE0_MDIO;
  82. + pdata->set_speed = ath79_set_speed_dummy;
  83. +
  84. + pdata->phy_mask = BIT(4);
  85. + } else {
  86. + pdata->reset_bit = AR933X_RESET_GE1_MAC |
  87. + AR933X_RESET_GE1_MDIO;
  88. + pdata->set_speed = ath79_set_speed_dummy;
  89. +
  90. + pdata->speed = SPEED_1000;
  91. + pdata->duplex = DUPLEX_FULL;
  92. + pdata->switch_data = &ath79_switch_data;
  93. +
  94. + ath79_switch_data.phy_poll_mask |= BIT(4);
  95. + }
  96. +
  97. + pdata->ddr_flush = ath79_ddr_no_flush;
  98. + pdata->has_gbit = 1;
  99. + pdata->is_ar724x = 1;
  100. +
  101. + if (!pdata->fifo_cfg1)
  102. + pdata->fifo_cfg1 = 0x0010ffff;
  103. + if (!pdata->fifo_cfg2)
  104. + pdata->fifo_cfg2 = 0x015500aa;
  105. + if (!pdata->fifo_cfg3)
  106. + pdata->fifo_cfg3 = 0x01f00140;
  107. + break;
  108. +
  109. case ATH79_SOC_AR9341:
  110. case ATH79_SOC_AR9342:
  111. case ATH79_SOC_AR9344:
  112. @@ -953,6 +993,7 @@ void __init ath79_register_eth(unsigned int id)
  113. case ATH79_SOC_AR7241:
  114. case ATH79_SOC_AR9330:
  115. case ATH79_SOC_AR9331:
  116. + case ATH79_SOC_QCA9533:
  117. pdata->mii_bus_dev = &ath79_mdio1_device.dev;
  118. break;
  119. diff --git a/target/linux/ar71xx/patches-3.3/705-MIPS-ath79-add-support-for-QCA953x-SoC.patch b/target/linux/ar71xx/patches-3.3/705-MIPS-ath79-add-support-for-QCA953x-SoC.patch
  120. new file mode 100644
  121. index 0000000..bd08685
  122. --- /dev/null
  123. +++ b/target/linux/ar71xx/patches-3.3/705-MIPS-ath79-add-support-for-QCA953x-SoC.patch
  124. @@ -0,0 +1,584 @@
  125. +From 5300a7cd7ed2f88488ddba62947b9c6bb9663777 Mon Sep 17 00:00:00 2001
  126. +Message-Id: <5300a7cd7ed2f88488ddba62947b9c6bb9663777.1396122227.git.mschiffer@universe-factory.net>
  127. +From: Matthias Schiffer <mschiffer@universe-factory.net>
  128. +Date: Sat, 29 Mar 2014 20:26:08 +0100
  129. +Subject: [PATCH 1/2] MIPS: ath79: add support for QCA953x SoC
  130. +
  131. +Note that the clock calculation looks very similar to the QCA955x, but actually
  132. +some bits' meanings are slightly different.
  133. +---
  134. + arch/mips/ath79/Kconfig | 6 +-
  135. + arch/mips/ath79/clock.c | 78 ++++++++++++++++++++++++++
  136. + arch/mips/ath79/common.c | 4 ++
  137. + arch/mips/ath79/dev-common.c | 1 +
  138. + arch/mips/ath79/dev-wmac.c | 20 +++++++
  139. + arch/mips/ath79/early_printk.c | 1 +
  140. + arch/mips/ath79/gpio.c | 4 +-
  141. + arch/mips/ath79/irq.c | 4 ++
  142. + arch/mips/ath79/setup.c | 8 ++-
  143. + arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 48 ++++++++++++++++
  144. + arch/mips/include/asm/mach-ath79/ath79.h | 11 ++++
  145. + 11 files changed, 182 insertions(+), 3 deletions(-)
  146. +
  147. +--- a/arch/mips/ath79/Kconfig
  148. ++++ b/arch/mips/ath79/Kconfig
  149. +@@ -698,6 +698,10 @@ config SOC_AR934X
  150. + select PCI_AR724X if PCI
  151. + def_bool n
  152. +
  153. ++config SOC_QCA953X
  154. ++ select USB_ARCH_HAS_EHCI
  155. ++ def_bool n
  156. ++
  157. + config SOC_QCA955X
  158. + select USB_ARCH_HAS_EHCI
  159. + select HW_HAS_PCI
  160. +@@ -741,7 +745,7 @@ config ATH79_DEV_USB
  161. + def_bool n
  162. +
  163. + config ATH79_DEV_WMAC
  164. +- depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA955X)
  165. ++ depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA953X || SOC_QCA955X)
  166. + def_bool n
  167. +
  168. + config ATH79_NVRAM
  169. +--- a/arch/mips/ath79/clock.c
  170. ++++ b/arch/mips/ath79/clock.c
  171. +@@ -295,6 +295,82 @@ static void __init ar934x_clocks_init(vo
  172. + iounmap(dpll_base);
  173. + }
  174. +
  175. ++static void __init qca953x_clocks_init(void)
  176. ++{
  177. ++ u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
  178. ++ u32 cpu_pll, ddr_pll;
  179. ++ u32 bootstrap;
  180. ++
  181. ++ bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  182. ++ if (bootstrap & QCA953X_BOOTSTRAP_REF_CLK_40)
  183. ++ ath79_ref_clk.rate = 40 * 1000 * 1000;
  184. ++ else
  185. ++ ath79_ref_clk.rate = 25 * 1000 * 1000;
  186. ++
  187. ++ pll = ath79_pll_rr(QCA953X_PLL_CPU_CONFIG_REG);
  188. ++ out_div = (pll >> QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  189. ++ QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK;
  190. ++ ref_div = (pll >> QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  191. ++ QCA953X_PLL_CPU_CONFIG_REFDIV_MASK;
  192. ++ nint = (pll >> QCA953X_PLL_CPU_CONFIG_NINT_SHIFT) &
  193. ++ QCA953X_PLL_CPU_CONFIG_NINT_MASK;
  194. ++ frac = (pll >> QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
  195. ++ QCA953X_PLL_CPU_CONFIG_NFRAC_MASK;
  196. ++
  197. ++ cpu_pll = nint * ath79_ref_clk.rate / ref_div;
  198. ++ cpu_pll += frac * (ath79_ref_clk.rate >> 6) / ref_div;
  199. ++ cpu_pll /= (1 << out_div);
  200. ++
  201. ++ pll = ath79_pll_rr(QCA953X_PLL_DDR_CONFIG_REG);
  202. ++ out_div = (pll >> QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  203. ++ QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK;
  204. ++ ref_div = (pll >> QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  205. ++ QCA953X_PLL_DDR_CONFIG_REFDIV_MASK;
  206. ++ nint = (pll >> QCA953X_PLL_DDR_CONFIG_NINT_SHIFT) &
  207. ++ QCA953X_PLL_DDR_CONFIG_NINT_MASK;
  208. ++ frac = (pll >> QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
  209. ++ QCA953X_PLL_DDR_CONFIG_NFRAC_MASK;
  210. ++
  211. ++ ddr_pll = nint * ath79_ref_clk.rate / ref_div;
  212. ++ ddr_pll += frac * (ath79_ref_clk.rate >> 6) / (ref_div << 4);
  213. ++ ddr_pll /= (1 << out_div);
  214. ++
  215. ++ clk_ctrl = ath79_pll_rr(QCA953X_PLL_CLK_CTRL_REG);
  216. ++
  217. ++ postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  218. ++ QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  219. ++
  220. ++ if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
  221. ++ ath79_cpu_clk.rate = ath79_ref_clk.rate;
  222. ++ else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
  223. ++ ath79_cpu_clk.rate = cpu_pll / (postdiv + 1);
  224. ++ else
  225. ++ ath79_cpu_clk.rate = ddr_pll / (postdiv + 1);
  226. ++
  227. ++ postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
  228. ++ QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
  229. ++
  230. ++ if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
  231. ++ ath79_ddr_clk.rate = ath79_ref_clk.rate;
  232. ++ else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
  233. ++ ath79_ddr_clk.rate = ddr_pll / (postdiv + 1);
  234. ++ else
  235. ++ ath79_ddr_clk.rate = cpu_pll / (postdiv + 1);
  236. ++
  237. ++ postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
  238. ++ QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
  239. ++
  240. ++ if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
  241. ++ ath79_ahb_clk.rate = ath79_ref_clk.rate;
  242. ++ else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
  243. ++ ath79_ahb_clk.rate = ddr_pll / (postdiv + 1);
  244. ++ else
  245. ++ ath79_ahb_clk.rate = cpu_pll / (postdiv + 1);
  246. ++
  247. ++ ath79_wdt_clk.rate = ath79_ref_clk.rate;
  248. ++ ath79_uart_clk.rate = ath79_ref_clk.rate;
  249. ++}
  250. ++
  251. + static void __init qca955x_clocks_init(void)
  252. + {
  253. + u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
  254. +@@ -383,6 +459,8 @@ void __init ath79_clocks_init(void)
  255. + ar933x_clocks_init();
  256. + else if (soc_is_ar934x())
  257. + ar934x_clocks_init();
  258. ++ else if (soc_is_qca953x())
  259. ++ qca953x_clocks_init();
  260. + else if (soc_is_qca955x())
  261. + qca955x_clocks_init();
  262. + else
  263. +--- a/arch/mips/ath79/common.c
  264. ++++ b/arch/mips/ath79/common.c
  265. +@@ -71,9 +71,12 @@ void ath79_device_reset_set(u32 mask)
  266. + reg = AR913X_RESET_REG_RESET_MODULE;
  267. + else if (soc_is_ar933x())
  268. + reg = AR933X_RESET_REG_RESET_MODULE;
  269. +- else if (soc_is_ar934x() ||
  270. +- soc_is_qca955x())
  271. ++ else if (soc_is_ar934x())
  272. + reg = AR934X_RESET_REG_RESET_MODULE;
  273. ++ else if (soc_is_qca953x())
  274. ++ reg = QCA953X_RESET_REG_RESET_MODULE;
  275. ++ else if (soc_is_qca955x())
  276. ++ reg = QCA955X_RESET_REG_RESET_MODULE;
  277. + else
  278. + BUG();
  279. +
  280. +@@ -98,9 +101,12 @@ void ath79_device_reset_clear(u32 mask)
  281. + reg = AR913X_RESET_REG_RESET_MODULE;
  282. + else if (soc_is_ar933x())
  283. + reg = AR933X_RESET_REG_RESET_MODULE;
  284. +- else if (soc_is_ar934x() ||
  285. +- soc_is_qca955x())
  286. ++ else if (soc_is_ar934x())
  287. + reg = AR934X_RESET_REG_RESET_MODULE;
  288. ++ else if (soc_is_qca953x())
  289. ++ reg = QCA953X_RESET_REG_RESET_MODULE;
  290. ++ else if (soc_is_qca955x())
  291. ++ reg = QCA955X_RESET_REG_RESET_MODULE;
  292. + else
  293. + BUG();
  294. +
  295. +--- a/arch/mips/ath79/dev-common.c
  296. ++++ b/arch/mips/ath79/dev-common.c
  297. +@@ -100,6 +100,7 @@ void __init ath79_register_uart(void)
  298. + soc_is_ar724x() ||
  299. + soc_is_ar913x() ||
  300. + soc_is_ar934x() ||
  301. ++ soc_is_qca953x() ||
  302. + soc_is_qca955x()) {
  303. + ath79_uart_data[0].uartclk = clk_get_rate(clk);
  304. + platform_device_register(&ath79_uart_device);
  305. +--- a/arch/mips/ath79/dev-wmac.c
  306. ++++ b/arch/mips/ath79/dev-wmac.c
  307. +@@ -147,6 +147,24 @@ static void ar934x_wmac_setup(void)
  308. + ath79_wmac_data.is_clk_25mhz = true;
  309. + }
  310. +
  311. ++static void qca953x_wmac_setup(void)
  312. ++{
  313. ++ u32 t;
  314. ++
  315. ++ ath79_wmac_device.name = "qca953x_wmac";
  316. ++
  317. ++ ath79_wmac_resources[0].start = QCA953X_WMAC_BASE;
  318. ++ ath79_wmac_resources[0].end = QCA953X_WMAC_BASE + QCA953X_WMAC_SIZE - 1;
  319. ++ ath79_wmac_resources[1].start = ATH79_CPU_IRQ_IP2;
  320. ++ ath79_wmac_resources[1].end = ATH79_CPU_IRQ_IP2;
  321. ++
  322. ++ t = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  323. ++ if (t & QCA953X_BOOTSTRAP_REF_CLK_40)
  324. ++ ath79_wmac_data.is_clk_25mhz = false;
  325. ++ else
  326. ++ ath79_wmac_data.is_clk_25mhz = true;
  327. ++}
  328. ++
  329. + static void qca955x_wmac_setup(void)
  330. + {
  331. + u32 t;
  332. +@@ -314,6 +332,8 @@ void __init ath79_register_wmac(u8 *cal_
  333. + ar933x_wmac_setup();
  334. + else if (soc_is_ar934x())
  335. + ar934x_wmac_setup();
  336. ++ else if (soc_is_qca953x())
  337. ++ qca953x_wmac_setup();
  338. + else if (soc_is_qca955x())
  339. + qca955x_wmac_setup();
  340. + else
  341. +--- a/arch/mips/ath79/early_printk.c
  342. ++++ b/arch/mips/ath79/early_printk.c
  343. +@@ -114,6 +114,7 @@ static void prom_putchar_init(void)
  344. + case REV_ID_MAJOR_AR9341:
  345. + case REV_ID_MAJOR_AR9342:
  346. + case REV_ID_MAJOR_AR9344:
  347. ++ case REV_ID_MAJOR_QCA9533:
  348. + case REV_ID_MAJOR_QCA9558:
  349. + _prom_putchar = prom_putchar_ar71xx;
  350. + break;
  351. +--- a/arch/mips/ath79/gpio.c
  352. ++++ b/arch/mips/ath79/gpio.c
  353. +@@ -232,14 +232,18 @@ void __init ath79_gpio_init(void)
  354. +
  355. + if (soc_is_ar71xx())
  356. + ath79_gpio_count = AR71XX_GPIO_COUNT;
  357. +- else if (soc_is_ar724x())
  358. +- ath79_gpio_count = AR724X_GPIO_COUNT;
  359. ++ else if (soc_is_ar7240())
  360. ++ ath79_gpio_count = AR7240_GPIO_COUNT;
  361. ++ else if (soc_is_ar7241() || soc_is_ar7242())
  362. ++ ath79_gpio_count = AR7241_GPIO_COUNT;
  363. + else if (soc_is_ar913x())
  364. + ath79_gpio_count = AR913X_GPIO_COUNT;
  365. + else if (soc_is_ar933x())
  366. + ath79_gpio_count = AR933X_GPIO_COUNT;
  367. + else if (soc_is_ar934x())
  368. + ath79_gpio_count = AR934X_GPIO_COUNT;
  369. ++ else if (soc_is_qca953x())
  370. ++ ath79_gpio_count = QCA953X_GPIO_COUNT;
  371. + else if (soc_is_qca955x())
  372. + ath79_gpio_count = QCA955X_GPIO_COUNT;
  373. + else
  374. +@@ -247,7 +251,7 @@ void __init ath79_gpio_init(void)
  375. +
  376. + ath79_gpio_base = ioremap_nocache(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
  377. + ath79_gpio_chip.ngpio = ath79_gpio_count;
  378. +- if (soc_is_ar934x() || soc_is_qca955x()) {
  379. ++ if (soc_is_ar934x() || soc_is_qca953x() || soc_is_qca955x()) {
  380. + ath79_gpio_chip.direction_input = ar934x_gpio_direction_input;
  381. + ath79_gpio_chip.direction_output = ar934x_gpio_direction_output;
  382. + }
  383. +--- a/arch/mips/ath79/irq.c
  384. ++++ b/arch/mips/ath79/irq.c
  385. +@@ -106,6 +106,7 @@ static void __init ath79_misc_irq_init(v
  386. + else if (soc_is_ar724x() ||
  387. + soc_is_ar933x() ||
  388. + soc_is_ar934x() ||
  389. ++ soc_is_qca953x() ||
  390. + soc_is_qca955x())
  391. + ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
  392. + else
  393. +@@ -352,6 +353,9 @@ void __init arch_init_irq(void)
  394. + } else if (soc_is_ar934x()) {
  395. + ath79_ip2_handler = ath79_default_ip2_handler;
  396. + ath79_ip3_handler = ar934x_ip3_handler;
  397. ++ } else if (soc_is_qca953x()) {
  398. ++ ath79_ip2_handler = ath79_default_ip2_handler;
  399. ++ ath79_ip3_handler = ath79_default_ip3_handler;
  400. + } else if (soc_is_qca955x()) {
  401. + ath79_ip2_handler = ath79_default_ip2_handler;
  402. + ath79_ip3_handler = ath79_default_ip3_handler;
  403. +--- a/arch/mips/ath79/setup.c
  404. ++++ b/arch/mips/ath79/setup.c
  405. +@@ -164,10 +164,16 @@ static void __init ath79_detect_sys_type
  406. + rev = id & AR934X_REV_ID_REVISION_MASK;
  407. + break;
  408. +
  409. ++ case REV_ID_MAJOR_QCA9533:
  410. ++ ath79_soc = ATH79_SOC_QCA9533;
  411. ++ chip = "9533";
  412. ++ rev = id & QCA955X_REV_ID_REVISION_MASK;
  413. ++ break;
  414. ++
  415. + case REV_ID_MAJOR_QCA9558:
  416. + ath79_soc = ATH79_SOC_QCA9558;
  417. + chip = "9558";
  418. +- rev = id & AR944X_REV_ID_REVISION_MASK;
  419. ++ rev = id & QCA955X_REV_ID_REVISION_MASK;
  420. + break;
  421. +
  422. + default:
  423. +@@ -176,7 +182,7 @@ static void __init ath79_detect_sys_type
  424. +
  425. + ath79_soc_rev = rev;
  426. +
  427. +- if (soc_is_qca955x())
  428. ++ if (soc_is_qca953x() || soc_is_qca955x())
  429. + sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s rev %u",
  430. + chip, rev);
  431. + else
  432. +--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  433. ++++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  434. +@@ -38,8 +38,8 @@
  435. + #define AR71XX_UART_SIZE 0x100
  436. + #define AR71XX_USB_CTRL_BASE (AR71XX_APB_BASE + 0x00030000)
  437. + #define AR71XX_USB_CTRL_SIZE 0x100
  438. +-#define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000)
  439. +-#define AR71XX_GPIO_SIZE 0x100
  440. ++#define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000)
  441. ++#define AR71XX_GPIO_SIZE 0x100
  442. + #define AR71XX_PLL_BASE (AR71XX_APB_BASE + 0x00050000)
  443. + #define AR71XX_PLL_SIZE 0x100
  444. + #define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
  445. +@@ -101,10 +101,13 @@
  446. + #define AR934X_WMAC_SIZE 0x20000
  447. + #define AR934X_EHCI_BASE 0x1b000000
  448. + #define AR934X_EHCI_SIZE 0x200
  449. +-#define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  450. +-#define AR934X_SRIF_SIZE 0x1000
  451. + #define AR934X_NFC_BASE 0x1b000200
  452. + #define AR934X_NFC_SIZE 0xb8
  453. ++#define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  454. ++#define AR934X_SRIF_SIZE 0x1000
  455. ++
  456. ++#define QCA953X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  457. ++#define QCA953X_WMAC_SIZE 0x20000
  458. +
  459. + #define QCA955X_PCI_MEM_BASE0 0x10000000
  460. + #define QCA955X_PCI_MEM_BASE1 0x12000000
  461. +@@ -119,14 +122,14 @@
  462. + #define QCA955X_PCI_CTRL_BASE1 (AR71XX_APB_BASE + 0x00280000)
  463. + #define QCA955X_PCI_CTRL_SIZE 0x100
  464. +
  465. ++#define QCA955X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  466. ++#define QCA955X_GMAC_SIZE 0x40
  467. + #define QCA955X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  468. + #define QCA955X_WMAC_SIZE 0x20000
  469. + #define QCA955X_EHCI0_BASE 0x1b000000
  470. + #define QCA955X_EHCI1_BASE 0x1b400000
  471. +-#define QCA955X_EHCI_SIZE 0x200
  472. +-#define QCA955X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  473. +-#define QCA955X_GMAC_SIZE 0x40
  474. +-#define QCA955X_NFC_BASE 0x1b000200
  475. ++#define QCA955X_EHCI_SIZE 0x1000
  476. ++#define QCA955X_NFC_BASE 0x1b800200
  477. + #define QCA955X_NFC_SIZE 0xb8
  478. +
  479. + #define AR9300_OTP_BASE 0x14000
  480. +@@ -280,9 +283,48 @@
  481. +
  482. + #define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL BIT(6)
  483. +
  484. ++#define QCA953X_PLL_CPU_CONFIG_REG 0x00
  485. ++#define QCA953X_PLL_DDR_CONFIG_REG 0x04
  486. ++#define QCA953X_PLL_CLK_CTRL_REG 0x08
  487. ++#define QCA953X_PLL_ETH_XMII_CONTROL_REG 0x2c
  488. ++#define QCA953X_PLL_ETH_SGMII_CONTROL_REG 0x48
  489. ++
  490. ++#define QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
  491. ++#define QCA953X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
  492. ++#define QCA953X_PLL_CPU_CONFIG_NINT_SHIFT 6
  493. ++#define QCA953X_PLL_CPU_CONFIG_NINT_MASK 0x3f
  494. ++#define QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
  495. ++#define QCA953X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
  496. ++#define QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
  497. ++#define QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK 0x3
  498. ++
  499. ++#define QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT 0
  500. ++#define QCA953X_PLL_DDR_CONFIG_NFRAC_MASK 0x3ff
  501. ++#define QCA953X_PLL_DDR_CONFIG_NINT_SHIFT 10
  502. ++#define QCA953X_PLL_DDR_CONFIG_NINT_MASK 0x3f
  503. ++#define QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
  504. ++#define QCA953X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
  505. ++#define QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
  506. ++#define QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
  507. ++
  508. ++#define QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
  509. ++#define QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
  510. ++#define QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
  511. ++#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
  512. ++#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
  513. ++#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
  514. ++#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
  515. ++#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
  516. ++#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
  517. ++#define QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL BIT(20)
  518. ++#define QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
  519. ++#define QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  520. ++
  521. + #define QCA955X_PLL_CPU_CONFIG_REG 0x00
  522. + #define QCA955X_PLL_DDR_CONFIG_REG 0x04
  523. + #define QCA955X_PLL_CLK_CTRL_REG 0x08
  524. ++#define QCA955X_PLL_ETH_XMII_CONTROL_REG 0x28
  525. ++#define QCA955X_PLL_ETH_SGMII_CONTROL_REG 0x48
  526. +
  527. + #define QCA955X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
  528. + #define QCA955X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
  529. +@@ -354,6 +396,11 @@
  530. + #define AR934X_RESET_REG_BOOTSTRAP 0xb0
  531. + #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
  532. +
  533. ++#define QCA953X_RESET_REG_RESET_MODULE 0x1c
  534. ++#define QCA953X_RESET_REG_BOOTSTRAP 0xb0
  535. ++#define QCA953X_RESET_REG_EXT_INT_STATUS 0xac
  536. ++
  537. ++#define QCA955X_RESET_REG_RESET_MODULE 0x1c
  538. + #define QCA955X_RESET_REG_BOOTSTRAP 0xb0
  539. + #define QCA955X_RESET_REG_EXT_INT_STATUS 0xac
  540. +
  541. +@@ -448,6 +495,39 @@
  542. + #define AR934X_RESET_MBOX BIT(1)
  543. + #define AR934X_RESET_I2S BIT(0)
  544. +
  545. ++#define QCA955X_RESET_HOST BIT(31)
  546. ++#define QCA955X_RESET_SLIC BIT(30)
  547. ++#define QCA955X_RESET_HDMA BIT(29)
  548. ++#define QCA955X_RESET_EXTERNAL BIT(28)
  549. ++#define QCA955X_RESET_RTC BIT(27)
  550. ++#define QCA955X_RESET_PCIE_EP_INT BIT(26)
  551. ++#define QCA955X_RESET_CHKSUM_ACC BIT(25)
  552. ++#define QCA955X_RESET_FULL_CHIP BIT(24)
  553. ++#define QCA955X_RESET_GE1_MDIO BIT(23)
  554. ++#define QCA955X_RESET_GE0_MDIO BIT(22)
  555. ++#define QCA955X_RESET_CPU_NMI BIT(21)
  556. ++#define QCA955X_RESET_CPU_COLD BIT(20)
  557. ++#define QCA955X_RESET_HOST_RESET_INT BIT(19)
  558. ++#define QCA955X_RESET_PCIE_EP BIT(18)
  559. ++#define QCA955X_RESET_UART1 BIT(17)
  560. ++#define QCA955X_RESET_DDR BIT(16)
  561. ++#define QCA955X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
  562. ++#define QCA955X_RESET_NANDF BIT(14)
  563. ++#define QCA955X_RESET_GE1_MAC BIT(13)
  564. ++#define QCA955X_RESET_SGMII_ANALOG BIT(12)
  565. ++#define QCA955X_RESET_USB_PHY_ANALOG BIT(11)
  566. ++#define QCA955X_RESET_HOST_DMA_INT BIT(10)
  567. ++#define QCA955X_RESET_GE0_MAC BIT(9)
  568. ++#define QCA955X_RESET_SGMII BIT(8)
  569. ++#define QCA955X_RESET_PCIE_PHY BIT(7)
  570. ++#define QCA955X_RESET_PCIE BIT(6)
  571. ++#define QCA955X_RESET_USB_HOST BIT(5)
  572. ++#define QCA955X_RESET_USB_PHY BIT(4)
  573. ++#define QCA955X_RESET_USBSUS_OVERRIDE BIT(3)
  574. ++#define QCA955X_RESET_LUT BIT(2)
  575. ++#define QCA955X_RESET_MBOX BIT(1)
  576. ++#define QCA955X_RESET_I2S BIT(0)
  577. ++
  578. + #define AR933X_BOOTSTRAP_MDIO_GPIO_EN BIT(18)
  579. + #define AR933X_BOOTSTRAP_EEPBUSY BIT(4)
  580. + #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0)
  581. +@@ -465,9 +545,11 @@
  582. + #define AR934X_BOOTSTRAP_EJTAG_MODE BIT(5)
  583. + #define AR934X_BOOTSTRAP_REF_CLK_40 BIT(4)
  584. + #define AR934X_BOOTSTRAP_BOOT_FROM_SPI BIT(2)
  585. +-#define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  586. ++#define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  587. + #define AR934X_BOOTSTRAP_DDR1 BIT(0)
  588. +
  589. ++#define QCA953X_BOOTSTRAP_REF_CLK_40 BIT(4)
  590. ++
  591. + #define QCA955X_BOOTSTRAP_REF_CLK_40 BIT(4)
  592. +
  593. + #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  594. +@@ -530,6 +612,8 @@
  595. + #define REV_ID_MAJOR_AR9341 0x0120
  596. + #define REV_ID_MAJOR_AR9342 0x1120
  597. + #define REV_ID_MAJOR_AR9344 0x2120
  598. ++#define REV_ID_MAJOR_QCA9533 0x0140
  599. ++#define REV_ID_MAJOR_QCA9556 0x0130
  600. + #define REV_ID_MAJOR_QCA9558 0x1130
  601. +
  602. + #define AR71XX_REV_ID_MINOR_MASK 0x3
  603. +@@ -549,9 +633,9 @@
  604. +
  605. + #define AR724X_REV_ID_REVISION_MASK 0x3
  606. +
  607. +-#define AR934X_REV_ID_REVISION_MASK 0xf
  608. ++#define AR934X_REV_ID_REVISION_MASK 0xf
  609. +
  610. +-#define AR944X_REV_ID_REVISION_MASK 0xf
  611. ++#define QCA955X_REV_ID_REVISION_MASK 0xf
  612. +
  613. + /*
  614. + * SPI block
  615. +@@ -599,10 +683,12 @@
  616. + #define AR934X_GPIO_REG_FUNC 0x6c
  617. +
  618. + #define AR71XX_GPIO_COUNT 16
  619. +-#define AR724X_GPIO_COUNT 18
  620. ++#define AR7240_GPIO_COUNT 18
  621. ++#define AR7241_GPIO_COUNT 20
  622. + #define AR913X_GPIO_COUNT 22
  623. + #define AR933X_GPIO_COUNT 30
  624. + #define AR934X_GPIO_COUNT 23
  625. ++#define QCA953X_GPIO_COUNT 24 /* (?) */
  626. + #define QCA955X_GPIO_COUNT 24
  627. +
  628. + /*
  629. +@@ -693,12 +779,14 @@
  630. + #define AR934X_GPIO_FUNC_CLK_OBS0_EN BIT(2)
  631. + #define AR934X_GPIO_FUNC_JTAG_DISABLE BIT(1)
  632. +
  633. +-#define AR934X_GPIO_OUT_GPIO 0
  634. +-#define AR934X_GPIO_OUT_LED_LINK0 41
  635. +-#define AR934X_GPIO_OUT_LED_LINK1 42
  636. +-#define AR934X_GPIO_OUT_LED_LINK2 43
  637. +-#define AR934X_GPIO_OUT_LED_LINK3 44
  638. +-#define AR934X_GPIO_OUT_LED_LINK4 45
  639. ++#define AR934X_GPIO_OUT_GPIO 0
  640. ++#define AR934X_GPIO_OUT_LED_LINK0 41
  641. ++#define AR934X_GPIO_OUT_LED_LINK1 42
  642. ++#define AR934X_GPIO_OUT_LED_LINK2 43
  643. ++#define AR934X_GPIO_OUT_LED_LINK3 44
  644. ++#define AR934X_GPIO_OUT_LED_LINK4 45
  645. ++#define AR934X_GPIO_OUT_EXT_LNA0 46
  646. ++#define AR934X_GPIO_OUT_EXT_LNA1 47
  647. +
  648. + /*
  649. + * MII_CTRL block
  650. +@@ -756,6 +844,8 @@
  651. + #define AR933X_ETH_CFG_MII_CNTL_SPEED BIT(11)
  652. + #define AR934X_ETH_CFG_RMII_GMAC0_MASTER BIT(12)
  653. + #define AR933X_ETH_CFG_SW_ACC_MSB_FIRST BIT(13)
  654. ++#define AR934X_ETH_CFG_RXD_DELAY BIT(14)
  655. ++#define AR934X_ETH_CFG_RDV_DELAY BIT(16)
  656. +
  657. + /*
  658. + * QCA955X GMAC Interface
  659. +@@ -763,7 +853,7 @@
  660. +
  661. + #define QCA955X_GMAC_REG_ETH_CFG 0x00
  662. +
  663. +-#define QCA955X_ETH_CFG_RGMII_GMAC0 BIT(0)
  664. +-#define QCA955X_ETH_CFG_SGMII_GMAC0 BIT(6)
  665. ++#define QCA955X_ETH_CFG_RGMII_EN BIT(0)
  666. ++#define QCA955X_ETH_CFG_GE0_SGMII BIT(6)
  667. +
  668. + #endif /* __ASM_MACH_AR71XX_REGS_H */
  669. +--- a/arch/mips/include/asm/mach-ath79/ath79.h
  670. ++++ b/arch/mips/include/asm/mach-ath79/ath79.h
  671. +@@ -32,6 +32,7 @@ enum ath79_soc_type {
  672. + ATH79_SOC_AR9341,
  673. + ATH79_SOC_AR9342,
  674. + ATH79_SOC_AR9344,
  675. ++ ATH79_SOC_QCA9533,
  676. + ATH79_SOC_QCA9558,
  677. + };
  678. +
  679. +@@ -99,6 +100,16 @@ static inline int soc_is_ar934x(void)
  680. + return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
  681. + }
  682. +
  683. ++static inline int soc_is_qca9533(void)
  684. ++{
  685. ++ return ath79_soc == ATH79_SOC_QCA9533;
  686. ++}
  687. ++
  688. ++static inline int soc_is_qca953x(void)
  689. ++{
  690. ++ return soc_is_qca9533();
  691. ++}
  692. ++
  693. + static inline int soc_is_qca9558(void)
  694. + {
  695. + return ath79_soc == ATH79_SOC_QCA9558;
  696. +--- a/arch/mips/ath79/mach-ap136.c
  697. ++++ b/arch/mips/ath79/mach-ap136.c
  698. +@@ -149,8 +149,8 @@ static void __init ap136_gmac_setup(void
  699. +
  700. + t = __raw_readl(base + QCA955X_GMAC_REG_ETH_CFG);
  701. +
  702. +- t &= ~(QCA955X_ETH_CFG_RGMII_GMAC0 | QCA955X_ETH_CFG_SGMII_GMAC0);
  703. +- t |= QCA955X_ETH_CFG_RGMII_GMAC0;
  704. ++ t &= ~(QCA955X_ETH_CFG_RGMII_EN | QCA955X_ETH_CFG_GE0_SGMII);
  705. ++ t |= QCA955X_ETH_CFG_RGMII_EN;
  706. +
  707. + __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
  708. +