707-MIPS-ath79-add-support-for-QCA953x-SoC.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. From 5300a7cd7ed2f88488ddba62947b9c6bb9663777 Mon Sep 17 00:00:00 2001
  2. Message-Id: <5300a7cd7ed2f88488ddba62947b9c6bb9663777.1396122227.git.mschiffer@universe-factory.net>
  3. From: Matthias Schiffer <mschiffer@universe-factory.net>
  4. Date: Sat, 29 Mar 2014 20:26:08 +0100
  5. Subject: [PATCH 1/2] MIPS: ath79: add support for QCA953x SoC
  6. Note that the clock calculation looks very similar to the QCA955x, but the
  7. meaning of the bits CPUCLK_FROM_CPUPLL and DDRCLK_FROM_DDRPLL is reversed.
  8. ---
  9. arch/mips/ath79/Kconfig | 6 +-
  10. arch/mips/ath79/clock.c | 78 ++++++++++++++++++++++++++
  11. arch/mips/ath79/common.c | 4 ++
  12. arch/mips/ath79/dev-common.c | 1 +
  13. arch/mips/ath79/dev-wmac.c | 20 +++++++
  14. arch/mips/ath79/early_printk.c | 1 +
  15. arch/mips/ath79/gpio.c | 4 +-
  16. arch/mips/ath79/irq.c | 4 ++
  17. arch/mips/ath79/setup.c | 8 ++-
  18. arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 48 ++++++++++++++++
  19. arch/mips/include/asm/mach-ath79/ath79.h | 11 ++++
  20. 11 files changed, 182 insertions(+), 3 deletions(-)
  21. --- a/arch/mips/ath79/Kconfig
  22. +++ b/arch/mips/ath79/Kconfig
  23. @@ -1277,6 +1277,10 @@ config SOC_AR934X
  24. select PCI_AR724X if PCI
  25. def_bool n
  26. +config SOC_QCA953X
  27. + select USB_ARCH_HAS_EHCI
  28. + def_bool n
  29. +
  30. config SOC_QCA955X
  31. select HW_HAS_PCI
  32. select PCI_AR724X if PCI
  33. @@ -1319,7 +1323,7 @@ config ATH79_DEV_USB
  34. def_bool n
  35. config ATH79_DEV_WMAC
  36. - depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA955X)
  37. + depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA953X || SOC_QCA955X)
  38. def_bool n
  39. config ATH79_NVRAM
  40. --- a/arch/mips/ath79/clock.c
  41. +++ b/arch/mips/ath79/clock.c
  42. @@ -350,6 +350,91 @@ static void __init ar934x_clocks_init(vo
  43. iounmap(dpll_base);
  44. }
  45. +static void __init qca953x_clocks_init(void)
  46. +{
  47. + unsigned long ref_rate;
  48. + unsigned long cpu_rate;
  49. + unsigned long ddr_rate;
  50. + unsigned long ahb_rate;
  51. + u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
  52. + u32 cpu_pll, ddr_pll;
  53. + u32 bootstrap;
  54. +
  55. + bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  56. + if (bootstrap & QCA953X_BOOTSTRAP_REF_CLK_40)
  57. + ref_rate = 40 * 1000 * 1000;
  58. + else
  59. + ref_rate = 25 * 1000 * 1000;
  60. +
  61. + pll = ath79_pll_rr(QCA953X_PLL_CPU_CONFIG_REG);
  62. + out_div = (pll >> QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  63. + QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK;
  64. + ref_div = (pll >> QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  65. + QCA953X_PLL_CPU_CONFIG_REFDIV_MASK;
  66. + nint = (pll >> QCA953X_PLL_CPU_CONFIG_NINT_SHIFT) &
  67. + QCA953X_PLL_CPU_CONFIG_NINT_MASK;
  68. + frac = (pll >> QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
  69. + QCA953X_PLL_CPU_CONFIG_NFRAC_MASK;
  70. +
  71. + cpu_pll = nint * ref_rate / ref_div;
  72. + cpu_pll += frac * (ref_rate >> 6) / ref_div;
  73. + cpu_pll /= (1 << out_div);
  74. +
  75. + pll = ath79_pll_rr(QCA953X_PLL_DDR_CONFIG_REG);
  76. + out_div = (pll >> QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  77. + QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK;
  78. + ref_div = (pll >> QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  79. + QCA953X_PLL_DDR_CONFIG_REFDIV_MASK;
  80. + nint = (pll >> QCA953X_PLL_DDR_CONFIG_NINT_SHIFT) &
  81. + QCA953X_PLL_DDR_CONFIG_NINT_MASK;
  82. + frac = (pll >> QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
  83. + QCA953X_PLL_DDR_CONFIG_NFRAC_MASK;
  84. +
  85. + ddr_pll = nint * ref_rate / ref_div;
  86. + ddr_pll += frac * (ref_rate >> 6) / (ref_div << 4);
  87. + ddr_pll /= (1 << out_div);
  88. +
  89. + clk_ctrl = ath79_pll_rr(QCA953X_PLL_CLK_CTRL_REG);
  90. +
  91. + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  92. + QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  93. +
  94. + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
  95. + cpu_rate = ref_rate;
  96. + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
  97. + cpu_rate = cpu_pll / (postdiv + 1);
  98. + else
  99. + cpu_rate = ddr_pll / (postdiv + 1);
  100. +
  101. + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
  102. + QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
  103. +
  104. + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
  105. + ddr_rate = ref_rate;
  106. + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
  107. + ddr_rate = ddr_pll / (postdiv + 1);
  108. + else
  109. + ddr_rate = cpu_pll / (postdiv + 1);
  110. +
  111. + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
  112. + QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
  113. +
  114. + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
  115. + ahb_rate = ref_rate;
  116. + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
  117. + ahb_rate = ddr_pll / (postdiv + 1);
  118. + else
  119. + ahb_rate = cpu_pll / (postdiv + 1);
  120. +
  121. + ath79_add_sys_clkdev("ref", ref_rate);
  122. + ath79_add_sys_clkdev("cpu", cpu_rate);
  123. + ath79_add_sys_clkdev("ddr", ddr_rate);
  124. + ath79_add_sys_clkdev("ahb", ahb_rate);
  125. +
  126. + clk_add_alias("wdt", NULL, "ref", NULL);
  127. + clk_add_alias("uart", NULL, "ref", NULL);
  128. +}
  129. +
  130. static void __init qca955x_clocks_init(void)
  131. {
  132. unsigned long ref_rate;
  133. @@ -447,6 +532,8 @@ void __init ath79_clocks_init(void)
  134. ar933x_clocks_init();
  135. else if (soc_is_ar934x())
  136. ar934x_clocks_init();
  137. + else if (soc_is_qca953x())
  138. + qca953x_clocks_init();
  139. else if (soc_is_qca955x())
  140. qca955x_clocks_init();
  141. else
  142. --- a/arch/mips/ath79/common.c
  143. +++ b/arch/mips/ath79/common.c
  144. @@ -73,6 +73,8 @@ void ath79_device_reset_set(u32 mask)
  145. reg = AR933X_RESET_REG_RESET_MODULE;
  146. else if (soc_is_ar934x())
  147. reg = AR934X_RESET_REG_RESET_MODULE;
  148. + else if (soc_is_qca953x())
  149. + reg = QCA953X_RESET_REG_RESET_MODULE;
  150. else if (soc_is_qca955x())
  151. reg = QCA955X_RESET_REG_RESET_MODULE;
  152. else
  153. @@ -101,6 +103,8 @@ void ath79_device_reset_clear(u32 mask)
  154. reg = AR933X_RESET_REG_RESET_MODULE;
  155. else if (soc_is_ar934x())
  156. reg = AR934X_RESET_REG_RESET_MODULE;
  157. + else if (soc_is_qca953x())
  158. + reg = QCA953X_RESET_REG_RESET_MODULE;
  159. else if (soc_is_qca955x())
  160. reg = QCA955X_RESET_REG_RESET_MODULE;
  161. else
  162. --- a/arch/mips/ath79/dev-common.c
  163. +++ b/arch/mips/ath79/dev-common.c
  164. @@ -93,6 +93,7 @@ void __init ath79_register_uart(void)
  165. soc_is_ar724x() ||
  166. soc_is_ar913x() ||
  167. soc_is_ar934x() ||
  168. + soc_is_qca953x() ||
  169. soc_is_qca955x()) {
  170. ath79_uart_data[0].uartclk = uart_clk_rate;
  171. platform_device_register(&ath79_uart_device);
  172. --- a/arch/mips/ath79/dev-usb.c
  173. +++ b/arch/mips/ath79/dev-usb.c
  174. @@ -236,6 +236,30 @@ static void __init ar934x_usb_setup(void
  175. &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  176. }
  177. +static void __init qca953x_usb_setup(void)
  178. +{
  179. + u32 bootstrap;
  180. +
  181. + bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  182. +
  183. + ath79_device_reset_set(QCA953X_RESET_USBSUS_OVERRIDE);
  184. + udelay(1000);
  185. +
  186. + ath79_device_reset_clear(QCA953X_RESET_USB_PHY);
  187. + udelay(1000);
  188. +
  189. + ath79_device_reset_clear(QCA953X_RESET_USB_PHY_ANALOG);
  190. + udelay(1000);
  191. +
  192. + ath79_device_reset_clear(QCA953X_RESET_USB_HOST);
  193. + udelay(1000);
  194. +
  195. + ath79_usb_register("ehci-platform", -1,
  196. + QCA953X_EHCI_BASE, QCA953X_EHCI_SIZE,
  197. + ATH79_CPU_IRQ(3),
  198. + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  199. +}
  200. +
  201. static void qca955x_usb_reset_notifier(struct platform_device *pdev)
  202. {
  203. u32 base;
  204. @@ -286,6 +310,8 @@ void __init ath79_register_usb(void)
  205. ar933x_usb_setup();
  206. else if (soc_is_ar934x())
  207. ar934x_usb_setup();
  208. + else if (soc_is_qca953x())
  209. + qca953x_usb_setup();
  210. else if (soc_is_qca955x())
  211. qca955x_usb_setup();
  212. else
  213. --- a/arch/mips/ath79/dev-wmac.c
  214. +++ b/arch/mips/ath79/dev-wmac.c
  215. @@ -101,7 +101,7 @@ static int ar933x_wmac_reset(void)
  216. return -ETIMEDOUT;
  217. }
  218. -static int ar933x_r1_get_wmac_revision(void)
  219. +static int ar93xx_get_soc_revision(void)
  220. {
  221. return ath79_soc_rev;
  222. }
  223. @@ -126,7 +126,7 @@ static void __init ar933x_wmac_setup(voi
  224. ath79_wmac_data.is_clk_25mhz = true;
  225. if (ath79_soc_rev == 1)
  226. - ath79_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision;
  227. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  228. ath79_wmac_data.external_reset = ar933x_wmac_reset;
  229. }
  230. @@ -149,6 +149,26 @@ static void ar934x_wmac_setup(void)
  231. ath79_wmac_data.is_clk_25mhz = true;
  232. }
  233. +static void qca953x_wmac_setup(void)
  234. +{
  235. + u32 t;
  236. +
  237. + ath79_wmac_device.name = "qca953x_wmac";
  238. +
  239. + ath79_wmac_resources[0].start = QCA953X_WMAC_BASE;
  240. + ath79_wmac_resources[0].end = QCA953X_WMAC_BASE + QCA953X_WMAC_SIZE - 1;
  241. + ath79_wmac_resources[1].start = ATH79_IP2_IRQ(1);
  242. + ath79_wmac_resources[1].end = ATH79_IP2_IRQ(1);
  243. +
  244. + t = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  245. + if (t & QCA953X_BOOTSTRAP_REF_CLK_40)
  246. + ath79_wmac_data.is_clk_25mhz = false;
  247. + else
  248. + ath79_wmac_data.is_clk_25mhz = true;
  249. +
  250. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  251. +}
  252. +
  253. static void qca955x_wmac_setup(void)
  254. {
  255. u32 t;
  256. @@ -366,6 +386,8 @@ void __init ath79_register_wmac(u8 *cal_
  257. ar933x_wmac_setup();
  258. else if (soc_is_ar934x())
  259. ar934x_wmac_setup();
  260. + else if (soc_is_qca953x())
  261. + qca953x_wmac_setup();
  262. else if (soc_is_qca955x())
  263. qca955x_wmac_setup();
  264. else
  265. --- a/arch/mips/ath79/early_printk.c
  266. +++ b/arch/mips/ath79/early_printk.c
  267. @@ -116,6 +116,8 @@ static void prom_putchar_init(void)
  268. case REV_ID_MAJOR_AR9341:
  269. case REV_ID_MAJOR_AR9342:
  270. case REV_ID_MAJOR_AR9344:
  271. + case REV_ID_MAJOR_QCA9533:
  272. + case REV_ID_MAJOR_QCA9533_V2:
  273. case REV_ID_MAJOR_QCA9556:
  274. case REV_ID_MAJOR_QCA9558:
  275. _prom_putchar = prom_putchar_ar71xx;
  276. --- a/arch/mips/ath79/gpio.c
  277. +++ b/arch/mips/ath79/gpio.c
  278. @@ -148,7 +148,7 @@ static void __iomem *ath79_gpio_get_func
  279. soc_is_ar913x() ||
  280. soc_is_ar933x())
  281. reg = AR71XX_GPIO_REG_FUNC;
  282. - else if (soc_is_ar934x())
  283. + else if (soc_is_ar934x() || soc_is_qca953x())
  284. reg = AR934X_GPIO_REG_FUNC;
  285. else
  286. BUG();
  287. @@ -187,7 +187,7 @@ void __init ath79_gpio_output_select(uns
  288. unsigned int reg;
  289. u32 t, s;
  290. - BUG_ON(!soc_is_ar934x());
  291. + BUG_ON(!soc_is_ar934x() && !soc_is_qca953x());
  292. if (gpio >= AR934X_GPIO_COUNT)
  293. return;
  294. @@ -224,6 +224,8 @@ void __init ath79_gpio_init(void)
  295. ath79_gpio_count = AR933X_GPIO_COUNT;
  296. else if (soc_is_ar934x())
  297. ath79_gpio_count = AR934X_GPIO_COUNT;
  298. + else if (soc_is_qca953x())
  299. + ath79_gpio_count = QCA953X_GPIO_COUNT;
  300. else if (soc_is_qca955x())
  301. ath79_gpio_count = QCA955X_GPIO_COUNT;
  302. else
  303. @@ -231,7 +233,7 @@ void __init ath79_gpio_init(void)
  304. ath79_gpio_base = ioremap_nocache(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
  305. ath79_gpio_chip.ngpio = ath79_gpio_count;
  306. - if (soc_is_ar934x() || soc_is_qca955x()) {
  307. + if (soc_is_ar934x() || soc_is_qca953x() || soc_is_qca955x()) {
  308. ath79_gpio_chip.direction_input = ar934x_gpio_direction_input;
  309. ath79_gpio_chip.direction_output = ar934x_gpio_direction_output;
  310. }
  311. --- a/arch/mips/ath79/irq.c
  312. +++ b/arch/mips/ath79/irq.c
  313. @@ -106,6 +106,7 @@ static void __init ath79_misc_irq_init(v
  314. else if (soc_is_ar724x() ||
  315. soc_is_ar933x() ||
  316. soc_is_ar934x() ||
  317. + soc_is_qca953x() ||
  318. soc_is_qca955x())
  319. ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
  320. else
  321. @@ -153,6 +154,38 @@ static void ar934x_ip2_irq_init(void)
  322. irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
  323. }
  324. +static void qca953x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
  325. +{
  326. + u32 status;
  327. +
  328. + disable_irq_nosync(irq);
  329. +
  330. + status = ath79_reset_rr(QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS);
  331. +
  332. + if (status & QCA953X_PCIE_WMAC_INT_PCIE_ALL) {
  333. + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_PCIE);
  334. + generic_handle_irq(ATH79_IP2_IRQ(0));
  335. + } else if (status & QCA953X_PCIE_WMAC_INT_WMAC_ALL) {
  336. + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_WMAC);
  337. + generic_handle_irq(ATH79_IP2_IRQ(1));
  338. + } else {
  339. + spurious_interrupt();
  340. + }
  341. +
  342. + enable_irq(irq);
  343. +}
  344. +
  345. +static void qca953x_irq_init(void)
  346. +{
  347. + int i;
  348. +
  349. + for (i = ATH79_IP2_IRQ_BASE;
  350. + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  351. + irq_set_chip_and_handler(i, &dummy_irq_chip, handle_level_irq);
  352. +
  353. + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca953x_ip2_irq_dispatch);
  354. +}
  355. +
  356. static void qca955x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
  357. {
  358. u32 status;
  359. @@ -335,6 +368,12 @@ static void ar934x_ip3_handler(void)
  360. do_IRQ(ATH79_CPU_IRQ(3));
  361. }
  362. +static void qca953x_ip3_handler(void)
  363. +{
  364. + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_USB);
  365. + do_IRQ(ATH79_CPU_IRQ(3));
  366. +}
  367. +
  368. void __init arch_init_irq(void)
  369. {
  370. if (soc_is_ar71xx()) {
  371. @@ -352,6 +391,9 @@ void __init arch_init_irq(void)
  372. } else if (soc_is_ar934x()) {
  373. ath79_ip2_handler = ath79_default_ip2_handler;
  374. ath79_ip3_handler = ar934x_ip3_handler;
  375. + } else if (soc_is_qca953x()) {
  376. + ath79_ip2_handler = ath79_default_ip2_handler;
  377. + ath79_ip3_handler = qca953x_ip3_handler;
  378. } else if (soc_is_qca955x()) {
  379. ath79_ip2_handler = ath79_default_ip2_handler;
  380. ath79_ip3_handler = ath79_default_ip3_handler;
  381. @@ -365,6 +407,8 @@ void __init arch_init_irq(void)
  382. if (soc_is_ar934x())
  383. ar934x_ip2_irq_init();
  384. + else if (soc_is_qca953x())
  385. + qca953x_irq_init();
  386. else if (soc_is_qca955x())
  387. qca955x_irq_init();
  388. }
  389. --- a/arch/mips/ath79/setup.c
  390. +++ b/arch/mips/ath79/setup.c
  391. @@ -59,6 +59,7 @@ static void __init ath79_detect_sys_type
  392. u32 major;
  393. u32 minor;
  394. u32 rev = 0;
  395. + u32 ver = 1;
  396. id = ath79_reset_rr(AR71XX_RESET_REG_REV_ID);
  397. major = id & REV_ID_MAJOR_MASK;
  398. @@ -151,6 +152,17 @@ static void __init ath79_detect_sys_type
  399. rev = id & AR934X_REV_ID_REVISION_MASK;
  400. break;
  401. + case REV_ID_MAJOR_QCA9533_V2:
  402. + ver = 2;
  403. + ath79_soc_rev = 2;
  404. + /* drop through */
  405. +
  406. + case REV_ID_MAJOR_QCA9533:
  407. + ath79_soc = ATH79_SOC_QCA9533;
  408. + chip = "9533";
  409. + rev = id & QCA953X_REV_ID_REVISION_MASK;
  410. + break;
  411. +
  412. case REV_ID_MAJOR_QCA9556:
  413. ath79_soc = ATH79_SOC_QCA9556;
  414. chip = "9556";
  415. @@ -167,11 +179,12 @@ static void __init ath79_detect_sys_type
  416. panic("ath79: unknown SoC, id:0x%08x", id);
  417. }
  418. - ath79_soc_rev = rev;
  419. + if (ver == 1)
  420. + ath79_soc_rev = rev;
  421. - if (soc_is_qca955x())
  422. - sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s rev %u",
  423. - chip, rev);
  424. + if (soc_is_qca953x() || soc_is_qca955x())
  425. + sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s ver %u rev %u",
  426. + chip, ver, rev);
  427. else
  428. sprintf(ath79_sys_type, "Atheros AR%s rev %u", chip, rev);
  429. pr_info("SoC: %s\n", ath79_sys_type);
  430. --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  431. +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  432. @@ -105,6 +105,21 @@
  433. #define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  434. #define AR934X_SRIF_SIZE 0x1000
  435. +#define QCA953X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  436. +#define QCA953X_GMAC_SIZE 0x14
  437. +#define QCA953X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  438. +#define QCA953X_WMAC_SIZE 0x20000
  439. +#define QCA953X_EHCI_BASE 0x1b000000
  440. +#define QCA953X_EHCI_SIZE 0x200
  441. +#define QCA953X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  442. +#define QCA953X_SRIF_SIZE 0x1000
  443. +
  444. +#define QCA953X_PCI_CFG_BASE0 0x14000000
  445. +#define QCA953X_PCI_CTRL_BASE0 (AR71XX_APB_BASE + 0x000f0000)
  446. +#define QCA953X_PCI_CRP_BASE0 (AR71XX_APB_BASE + 0x000c0000)
  447. +#define QCA953X_PCI_MEM_BASE0 0x10000000
  448. +#define QCA953X_PCI_MEM_SIZE 0x02000000
  449. +
  450. #define QCA955X_PCI_MEM_BASE0 0x10000000
  451. #define QCA955X_PCI_MEM_BASE1 0x12000000
  452. #define QCA955X_PCI_MEM_SIZE 0x02000000
  453. @@ -173,6 +188,12 @@
  454. #define AR934X_DDR_REG_FLUSH_PCIE 0xa8
  455. #define AR934X_DDR_REG_FLUSH_WMAC 0xac
  456. +#define QCA953X_DDR_REG_FLUSH_GE0 0x9c
  457. +#define QCA953X_DDR_REG_FLUSH_GE1 0xa0
  458. +#define QCA953X_DDR_REG_FLUSH_USB 0xa4
  459. +#define QCA953X_DDR_REG_FLUSH_PCIE 0xa8
  460. +#define QCA953X_DDR_REG_FLUSH_WMAC 0xac
  461. +
  462. /*
  463. * PLL block
  464. */
  465. @@ -279,6 +300,44 @@
  466. #define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL BIT(6)
  467. +#define QCA953X_PLL_CPU_CONFIG_REG 0x00
  468. +#define QCA953X_PLL_DDR_CONFIG_REG 0x04
  469. +#define QCA953X_PLL_CLK_CTRL_REG 0x08
  470. +#define QCA953X_PLL_SWITCH_CLOCK_CONTROL_REG 0x24
  471. +#define QCA953X_PLL_ETH_XMII_CONTROL_REG 0x2c
  472. +#define QCA953X_PLL_ETH_SGMII_CONTROL_REG 0x48
  473. +
  474. +#define QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
  475. +#define QCA953X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
  476. +#define QCA953X_PLL_CPU_CONFIG_NINT_SHIFT 6
  477. +#define QCA953X_PLL_CPU_CONFIG_NINT_MASK 0x3f
  478. +#define QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
  479. +#define QCA953X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
  480. +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
  481. +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
  482. +
  483. +#define QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT 0
  484. +#define QCA953X_PLL_DDR_CONFIG_NFRAC_MASK 0x3ff
  485. +#define QCA953X_PLL_DDR_CONFIG_NINT_SHIFT 10
  486. +#define QCA953X_PLL_DDR_CONFIG_NINT_MASK 0x3f
  487. +#define QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
  488. +#define QCA953X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
  489. +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
  490. +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
  491. +
  492. +#define QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
  493. +#define QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
  494. +#define QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
  495. +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
  496. +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
  497. +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
  498. +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
  499. +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
  500. +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
  501. +#define QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL BIT(20)
  502. +#define QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
  503. +#define QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  504. +
  505. #define QCA955X_PLL_CPU_CONFIG_REG 0x00
  506. #define QCA955X_PLL_DDR_CONFIG_REG 0x04
  507. #define QCA955X_PLL_CLK_CTRL_REG 0x08
  508. @@ -355,6 +414,10 @@
  509. #define AR934X_RESET_REG_BOOTSTRAP 0xb0
  510. #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
  511. +#define QCA953X_RESET_REG_RESET_MODULE 0x1c
  512. +#define QCA953X_RESET_REG_BOOTSTRAP 0xb0
  513. +#define QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
  514. +
  515. #define QCA955X_RESET_REG_RESET_MODULE 0x1c
  516. #define QCA955X_RESET_REG_BOOTSTRAP 0xb0
  517. #define QCA955X_RESET_REG_EXT_INT_STATUS 0xac
  518. @@ -450,6 +513,27 @@
  519. #define AR934X_RESET_MBOX BIT(1)
  520. #define AR934X_RESET_I2S BIT(0)
  521. +#define QCA953X_RESET_USB_EXT_PWR BIT(29)
  522. +#define QCA953X_RESET_EXTERNAL BIT(28)
  523. +#define QCA953X_RESET_RTC BIT(27)
  524. +#define QCA953X_RESET_FULL_CHIP BIT(24)
  525. +#define QCA953X_RESET_GE1_MDIO BIT(23)
  526. +#define QCA953X_RESET_GE0_MDIO BIT(22)
  527. +#define QCA953X_RESET_CPU_NMI BIT(21)
  528. +#define QCA953X_RESET_CPU_COLD BIT(20)
  529. +#define QCA953X_RESET_DDR BIT(16)
  530. +#define QCA953X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
  531. +#define QCA953X_RESET_GE1_MAC BIT(13)
  532. +#define QCA953X_RESET_ETH_SWITCH_ANALOG BIT(12)
  533. +#define QCA953X_RESET_USB_PHY_ANALOG BIT(11)
  534. +#define QCA953X_RESET_GE0_MAC BIT(9)
  535. +#define QCA953X_RESET_ETH_SWITCH BIT(8)
  536. +#define QCA953X_RESET_PCIE_PHY BIT(7)
  537. +#define QCA953X_RESET_PCIE BIT(6)
  538. +#define QCA953X_RESET_USB_HOST BIT(5)
  539. +#define QCA953X_RESET_USB_PHY BIT(4)
  540. +#define QCA953X_RESET_USBSUS_OVERRIDE BIT(3)
  541. +
  542. #define QCA955X_RESET_HOST BIT(31)
  543. #define QCA955X_RESET_SLIC BIT(30)
  544. #define QCA955X_RESET_HDMA BIT(29)
  545. @@ -503,6 +587,13 @@
  546. #define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  547. #define AR934X_BOOTSTRAP_DDR1 BIT(0)
  548. +#define QCA953X_BOOTSTRAP_SW_OPTION2 BIT(12)
  549. +#define QCA953X_BOOTSTRAP_SW_OPTION1 BIT(11)
  550. +#define QCA953X_BOOTSTRAP_EJTAG_MODE BIT(5)
  551. +#define QCA953X_BOOTSTRAP_REF_CLK_40 BIT(4)
  552. +#define QCA953X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  553. +#define QCA953X_BOOTSTRAP_DDR1 BIT(0)
  554. +
  555. #define QCA955X_BOOTSTRAP_REF_CLK_40 BIT(4)
  556. #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  557. @@ -523,6 +614,24 @@
  558. AR934X_PCIE_WMAC_INT_PCIE_RC1 | AR934X_PCIE_WMAC_INT_PCIE_RC2 | \
  559. AR934X_PCIE_WMAC_INT_PCIE_RC3)
  560. +#define QCA953X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  561. +#define QCA953X_PCIE_WMAC_INT_WMAC_TX BIT(1)
  562. +#define QCA953X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
  563. +#define QCA953X_PCIE_WMAC_INT_WMAC_RXHP BIT(3)
  564. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC BIT(4)
  565. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC0 BIT(5)
  566. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC1 BIT(6)
  567. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC2 BIT(7)
  568. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC3 BIT(8)
  569. +#define QCA953X_PCIE_WMAC_INT_WMAC_ALL \
  570. + (QCA953X_PCIE_WMAC_INT_WMAC_MISC | QCA953X_PCIE_WMAC_INT_WMAC_TX | \
  571. + QCA953X_PCIE_WMAC_INT_WMAC_RXLP | QCA953X_PCIE_WMAC_INT_WMAC_RXHP)
  572. +
  573. +#define QCA953X_PCIE_WMAC_INT_PCIE_ALL \
  574. + (QCA953X_PCIE_WMAC_INT_PCIE_RC | QCA953X_PCIE_WMAC_INT_PCIE_RC0 | \
  575. + QCA953X_PCIE_WMAC_INT_PCIE_RC1 | QCA953X_PCIE_WMAC_INT_PCIE_RC2 | \
  576. + QCA953X_PCIE_WMAC_INT_PCIE_RC3)
  577. +
  578. #define QCA955X_EXT_INT_WMAC_MISC BIT(0)
  579. #define QCA955X_EXT_INT_WMAC_TX BIT(1)
  580. #define QCA955X_EXT_INT_WMAC_RXLP BIT(2)
  581. @@ -565,6 +674,8 @@
  582. #define REV_ID_MAJOR_AR9341 0x0120
  583. #define REV_ID_MAJOR_AR9342 0x1120
  584. #define REV_ID_MAJOR_AR9344 0x2120
  585. +#define REV_ID_MAJOR_QCA9533 0x0140
  586. +#define REV_ID_MAJOR_QCA9533_V2 0x0160
  587. #define REV_ID_MAJOR_QCA9556 0x0130
  588. #define REV_ID_MAJOR_QCA9558 0x1130
  589. @@ -587,6 +698,8 @@
  590. #define AR934X_REV_ID_REVISION_MASK 0xf
  591. +#define QCA953X_REV_ID_REVISION_MASK 0xf
  592. +
  593. #define QCA955X_REV_ID_REVISION_MASK 0xf
  594. /*
  595. @@ -642,12 +755,32 @@
  596. #define QCA955X_GPIO_REG_OUT_FUNC5 0x40
  597. #define QCA955X_GPIO_REG_FUNC 0x6c
  598. +#define QCA953X_GPIO_REG_OUT_FUNC0 0x2c
  599. +#define QCA953X_GPIO_REG_OUT_FUNC1 0x30
  600. +#define QCA953X_GPIO_REG_OUT_FUNC2 0x34
  601. +#define QCA953X_GPIO_REG_OUT_FUNC3 0x38
  602. +#define QCA953X_GPIO_REG_OUT_FUNC4 0x3c
  603. +#define QCA953X_GPIO_REG_IN_ENABLE0 0x44
  604. +#define QCA953X_GPIO_REG_FUNC 0x6c
  605. +
  606. +#define QCA953X_GPIO_OUT_MUX_SPI_CS1 10
  607. +#define QCA953X_GPIO_OUT_MUX_SPI_CS2 11
  608. +#define QCA953X_GPIO_OUT_MUX_SPI_CS0 9
  609. +#define QCA953X_GPIO_OUT_MUX_SPI_CLK 8
  610. +#define QCA953X_GPIO_OUT_MUX_SPI_MOSI 12
  611. +#define QCA953X_GPIO_OUT_MUX_LED_LINK1 41
  612. +#define QCA953X_GPIO_OUT_MUX_LED_LINK2 42
  613. +#define QCA953X_GPIO_OUT_MUX_LED_LINK3 43
  614. +#define QCA953X_GPIO_OUT_MUX_LED_LINK4 44
  615. +#define QCA953X_GPIO_OUT_MUX_LED_LINK5 45
  616. +
  617. #define AR71XX_GPIO_COUNT 16
  618. #define AR7240_GPIO_COUNT 18
  619. #define AR7241_GPIO_COUNT 20
  620. #define AR913X_GPIO_COUNT 22
  621. #define AR933X_GPIO_COUNT 30
  622. #define AR934X_GPIO_COUNT 23
  623. +#define QCA953X_GPIO_COUNT 18
  624. #define QCA955X_GPIO_COUNT 24
  625. /*
  626. @@ -671,6 +804,24 @@
  627. #define AR934X_SRIF_DPLL2_OUTDIV_SHIFT 13
  628. #define AR934X_SRIF_DPLL2_OUTDIV_MASK 0x7
  629. +#define QCA953X_SRIF_CPU_DPLL1_REG 0x1c0
  630. +#define QCA953X_SRIF_CPU_DPLL2_REG 0x1c4
  631. +#define QCA953X_SRIF_CPU_DPLL3_REG 0x1c8
  632. +
  633. +#define QCA953X_SRIF_DDR_DPLL1_REG 0x240
  634. +#define QCA953X_SRIF_DDR_DPLL2_REG 0x244
  635. +#define QCA953X_SRIF_DDR_DPLL3_REG 0x248
  636. +
  637. +#define QCA953X_SRIF_DPLL1_REFDIV_SHIFT 27
  638. +#define QCA953X_SRIF_DPLL1_REFDIV_MASK 0x1f
  639. +#define QCA953X_SRIF_DPLL1_NINT_SHIFT 18
  640. +#define QCA953X_SRIF_DPLL1_NINT_MASK 0x1ff
  641. +#define QCA953X_SRIF_DPLL1_NFRAC_MASK 0x0003ffff
  642. +
  643. +#define QCA953X_SRIF_DPLL2_LOCAL_PLL BIT(30)
  644. +#define QCA953X_SRIF_DPLL2_OUTDIV_SHIFT 13
  645. +#define QCA953X_SRIF_DPLL2_OUTDIV_MASK 0x7
  646. +
  647. #define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
  648. #define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
  649. #define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
  650. @@ -877,6 +1028,16 @@
  651. #define AR934X_ETH_CFG_RDV_DELAY_SHIFT 16
  652. /*
  653. + * QCA953X GMAC Interface
  654. + */
  655. +#define QCA953X_GMAC_REG_ETH_CFG 0x00
  656. +
  657. +#define QCA953X_ETH_CFG_SW_ONLY_MODE BIT(6)
  658. +#define QCA953X_ETH_CFG_SW_PHY_SWAP BIT(7)
  659. +#define QCA953X_ETH_CFG_SW_APB_ACCESS BIT(9)
  660. +#define QCA953X_ETH_CFG_SW_ACC_MSB_FIRST BIT(13)
  661. +
  662. +/*
  663. * QCA955X GMAC Interface
  664. */
  665. --- a/arch/mips/include/asm/mach-ath79/ath79.h
  666. +++ b/arch/mips/include/asm/mach-ath79/ath79.h
  667. @@ -32,6 +32,7 @@ enum ath79_soc_type {
  668. ATH79_SOC_AR9341,
  669. ATH79_SOC_AR9342,
  670. ATH79_SOC_AR9344,
  671. + ATH79_SOC_QCA9533,
  672. ATH79_SOC_QCA9556,
  673. ATH79_SOC_QCA9558,
  674. };
  675. @@ -100,6 +101,16 @@ static inline int soc_is_ar934x(void)
  676. return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
  677. }
  678. +static inline int soc_is_qca9533(void)
  679. +{
  680. + return ath79_soc == ATH79_SOC_QCA9533;
  681. +}
  682. +
  683. +static inline int soc_is_qca953x(void)
  684. +{
  685. + return soc_is_qca9533();
  686. +}
  687. +
  688. static inline int soc_is_qca9556(void)
  689. {
  690. return ath79_soc == ATH79_SOC_QCA9556;