620-MIPS-ath79-add-support-for-QCA953x-SoC.patch 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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. @@ -117,6 +117,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. @@ -156,7 +160,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. @@ -354,6 +354,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. @@ -451,6 +536,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. @@ -104,6 +104,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. @@ -132,6 +134,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. @@ -94,6 +94,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. @@ -157,6 +158,9 @@ void __init ath79_gpio_init(void)
  173. } else if (soc_is_ar934x()) {
  174. ath79_gpio_pdata.ngpios = AR934X_GPIO_COUNT;
  175. ath79_gpio_pdata.oe_inverted = 1;
  176. + } else if (soc_is_qca953x()) {
  177. + ath79_gpio_pdata.ngpios = QCA953X_GPIO_COUNT;
  178. + ath79_gpio_pdata.oe_inverted = 1;
  179. } else if (soc_is_qca955x()) {
  180. ath79_gpio_pdata.ngpios = QCA955X_GPIO_COUNT;
  181. ath79_gpio_pdata.oe_inverted = 1;
  182. --- a/arch/mips/ath79/dev-usb.c
  183. +++ b/arch/mips/ath79/dev-usb.c
  184. @@ -236,6 +236,30 @@ static void __init ar934x_usb_setup(void
  185. &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  186. }
  187. +static void __init qca953x_usb_setup(void)
  188. +{
  189. + u32 bootstrap;
  190. +
  191. + bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  192. +
  193. + ath79_device_reset_set(QCA953X_RESET_USBSUS_OVERRIDE);
  194. + udelay(1000);
  195. +
  196. + ath79_device_reset_clear(QCA953X_RESET_USB_PHY);
  197. + udelay(1000);
  198. +
  199. + ath79_device_reset_clear(QCA953X_RESET_USB_PHY_ANALOG);
  200. + udelay(1000);
  201. +
  202. + ath79_device_reset_clear(QCA953X_RESET_USB_HOST);
  203. + udelay(1000);
  204. +
  205. + ath79_usb_register("ehci-platform", -1,
  206. + QCA953X_EHCI_BASE, QCA953X_EHCI_SIZE,
  207. + ATH79_CPU_IRQ(3),
  208. + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  209. +}
  210. +
  211. static void qca955x_usb_reset_notifier(struct platform_device *pdev)
  212. {
  213. u32 base;
  214. @@ -286,6 +310,8 @@ void __init ath79_register_usb(void)
  215. ar933x_usb_setup();
  216. else if (soc_is_ar934x())
  217. ar934x_usb_setup();
  218. + else if (soc_is_qca953x())
  219. + qca953x_usb_setup();
  220. else if (soc_is_qca955x())
  221. qca955x_usb_setup();
  222. else
  223. --- a/arch/mips/ath79/dev-wmac.c
  224. +++ b/arch/mips/ath79/dev-wmac.c
  225. @@ -101,7 +101,7 @@ static int ar933x_wmac_reset(void)
  226. return -ETIMEDOUT;
  227. }
  228. -static int ar933x_r1_get_wmac_revision(void)
  229. +static int ar93xx_get_soc_revision(void)
  230. {
  231. return ath79_soc_rev;
  232. }
  233. @@ -126,7 +126,7 @@ static void __init ar933x_wmac_setup(voi
  234. ath79_wmac_data.is_clk_25mhz = true;
  235. if (ath79_soc_rev == 1)
  236. - ath79_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision;
  237. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  238. ath79_wmac_data.external_reset = ar933x_wmac_reset;
  239. }
  240. @@ -151,6 +151,26 @@ static void ar934x_wmac_setup(void)
  241. ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  242. }
  243. +static void qca953x_wmac_setup(void)
  244. +{
  245. + u32 t;
  246. +
  247. + ath79_wmac_device.name = "qca953x_wmac";
  248. +
  249. + ath79_wmac_resources[0].start = QCA953X_WMAC_BASE;
  250. + ath79_wmac_resources[0].end = QCA953X_WMAC_BASE + QCA953X_WMAC_SIZE - 1;
  251. + ath79_wmac_resources[1].start = ATH79_IP2_IRQ(1);
  252. + ath79_wmac_resources[1].end = ATH79_IP2_IRQ(1);
  253. +
  254. + t = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
  255. + if (t & QCA953X_BOOTSTRAP_REF_CLK_40)
  256. + ath79_wmac_data.is_clk_25mhz = false;
  257. + else
  258. + ath79_wmac_data.is_clk_25mhz = true;
  259. +
  260. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  261. +}
  262. +
  263. static void qca955x_wmac_setup(void)
  264. {
  265. u32 t;
  266. @@ -368,6 +388,8 @@ void __init ath79_register_wmac(u8 *cal_
  267. ar933x_wmac_setup();
  268. else if (soc_is_ar934x())
  269. ar934x_wmac_setup();
  270. + else if (soc_is_qca953x())
  271. + qca953x_wmac_setup();
  272. else if (soc_is_qca955x())
  273. qca955x_wmac_setup();
  274. else
  275. --- a/arch/mips/ath79/early_printk.c
  276. +++ b/arch/mips/ath79/early_printk.c
  277. @@ -116,6 +116,8 @@ static void prom_putchar_init(void)
  278. case REV_ID_MAJOR_AR9341:
  279. case REV_ID_MAJOR_AR9342:
  280. case REV_ID_MAJOR_AR9344:
  281. + case REV_ID_MAJOR_QCA9533:
  282. + case REV_ID_MAJOR_QCA9533_V2:
  283. case REV_ID_MAJOR_QCA9556:
  284. case REV_ID_MAJOR_QCA9558:
  285. _prom_putchar = prom_putchar_ar71xx;
  286. --- a/arch/mips/ath79/gpio.c
  287. +++ b/arch/mips/ath79/gpio.c
  288. @@ -31,7 +31,7 @@ static void __iomem *ath79_gpio_get_func
  289. soc_is_ar913x() ||
  290. soc_is_ar933x())
  291. reg = AR71XX_GPIO_REG_FUNC;
  292. - else if (soc_is_ar934x())
  293. + else if (soc_is_ar934x() || soc_is_qca953x())
  294. reg = AR934X_GPIO_REG_FUNC;
  295. else
  296. BUG();
  297. @@ -64,7 +64,7 @@ void __init ath79_gpio_output_select(uns
  298. unsigned int reg;
  299. u32 t, s;
  300. - BUG_ON(!soc_is_ar934x());
  301. + BUG_ON(!soc_is_ar934x() && !soc_is_qca953x());
  302. if (gpio >= AR934X_GPIO_COUNT)
  303. return;
  304. --- a/arch/mips/ath79/irq.c
  305. +++ b/arch/mips/ath79/irq.c
  306. @@ -105,6 +105,7 @@ static void __init ath79_misc_irq_init(v
  307. else if (soc_is_ar724x() ||
  308. soc_is_ar933x() ||
  309. soc_is_ar934x() ||
  310. + soc_is_qca953x() ||
  311. soc_is_qca955x())
  312. ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
  313. else
  314. @@ -148,6 +149,34 @@ static void ar934x_ip2_irq_init(void)
  315. irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
  316. }
  317. +static void qca953x_ip2_irq_dispatch(struct irq_desc *desc)
  318. +{
  319. + u32 status;
  320. +
  321. + status = ath79_reset_rr(QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS);
  322. +
  323. + if (status & QCA953X_PCIE_WMAC_INT_PCIE_ALL) {
  324. + ath79_ddr_wb_flush(3);
  325. + generic_handle_irq(ATH79_IP2_IRQ(0));
  326. + } else if (status & QCA953X_PCIE_WMAC_INT_WMAC_ALL) {
  327. + ath79_ddr_wb_flush(4);
  328. + generic_handle_irq(ATH79_IP2_IRQ(1));
  329. + } else {
  330. + spurious_interrupt();
  331. + }
  332. +}
  333. +
  334. +static void qca953x_irq_init(void)
  335. +{
  336. + int i;
  337. +
  338. + for (i = ATH79_IP2_IRQ_BASE;
  339. + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  340. + irq_set_chip_and_handler(i, &dummy_irq_chip, handle_level_irq);
  341. +
  342. + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca953x_ip2_irq_dispatch);
  343. +}
  344. +
  345. static void qca955x_ip2_irq_dispatch(struct irq_desc *desc)
  346. {
  347. u32 status;
  348. @@ -362,7 +391,7 @@ void __init arch_init_irq(void)
  349. soc_is_ar913x() || soc_is_ar933x()) {
  350. irq_wb_chan[2] = 3;
  351. irq_wb_chan[3] = 2;
  352. - } else if (soc_is_ar934x()) {
  353. + } else if (soc_is_ar934x() || soc_is_qca953x()) {
  354. irq_wb_chan[3] = 2;
  355. }
  356. @@ -371,6 +400,8 @@ void __init arch_init_irq(void)
  357. if (soc_is_ar934x())
  358. ar934x_ip2_irq_init();
  359. + else if (soc_is_qca953x())
  360. + qca953x_irq_init();
  361. else if (soc_is_qca955x())
  362. qca955x_irq_init();
  363. }
  364. --- a/arch/mips/ath79/setup.c
  365. +++ b/arch/mips/ath79/setup.c
  366. @@ -64,6 +64,7 @@ static void __init ath79_detect_sys_type
  367. u32 major;
  368. u32 minor;
  369. u32 rev = 0;
  370. + u32 ver = 1;
  371. id = ath79_reset_rr(AR71XX_RESET_REG_REV_ID);
  372. major = id & REV_ID_MAJOR_MASK;
  373. @@ -156,6 +157,17 @@ static void __init ath79_detect_sys_type
  374. rev = id & AR934X_REV_ID_REVISION_MASK;
  375. break;
  376. + case REV_ID_MAJOR_QCA9533_V2:
  377. + ver = 2;
  378. + ath79_soc_rev = 2;
  379. + /* drop through */
  380. +
  381. + case REV_ID_MAJOR_QCA9533:
  382. + ath79_soc = ATH79_SOC_QCA9533;
  383. + chip = "9533";
  384. + rev = id & QCA953X_REV_ID_REVISION_MASK;
  385. + break;
  386. +
  387. case REV_ID_MAJOR_QCA9556:
  388. ath79_soc = ATH79_SOC_QCA9556;
  389. chip = "9556";
  390. @@ -172,11 +184,12 @@ static void __init ath79_detect_sys_type
  391. panic("ath79: unknown SoC, id:0x%08x", id);
  392. }
  393. - ath79_soc_rev = rev;
  394. + if (ver == 1)
  395. + ath79_soc_rev = rev;
  396. - if (soc_is_qca955x())
  397. - sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s rev %u",
  398. - chip, rev);
  399. + if (soc_is_qca953x() || soc_is_qca955x())
  400. + sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s ver %u rev %u",
  401. + chip, ver, rev);
  402. else
  403. sprintf(ath79_sys_type, "Atheros AR%s rev %u", chip, rev);
  404. pr_info("SoC: %s\n", ath79_sys_type);
  405. --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  406. +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  407. @@ -105,6 +105,21 @@
  408. #define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  409. #define AR934X_SRIF_SIZE 0x1000
  410. +#define QCA953X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  411. +#define QCA953X_GMAC_SIZE 0x14
  412. +#define QCA953X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  413. +#define QCA953X_WMAC_SIZE 0x20000
  414. +#define QCA953X_EHCI_BASE 0x1b000000
  415. +#define QCA953X_EHCI_SIZE 0x200
  416. +#define QCA953X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
  417. +#define QCA953X_SRIF_SIZE 0x1000
  418. +
  419. +#define QCA953X_PCI_CFG_BASE0 0x14000000
  420. +#define QCA953X_PCI_CTRL_BASE0 (AR71XX_APB_BASE + 0x000f0000)
  421. +#define QCA953X_PCI_CRP_BASE0 (AR71XX_APB_BASE + 0x000c0000)
  422. +#define QCA953X_PCI_MEM_BASE0 0x10000000
  423. +#define QCA953X_PCI_MEM_SIZE 0x02000000
  424. +
  425. #define QCA955X_PCI_MEM_BASE0 0x10000000
  426. #define QCA955X_PCI_MEM_BASE1 0x12000000
  427. #define QCA955X_PCI_MEM_SIZE 0x02000000
  428. @@ -173,6 +188,12 @@
  429. #define AR934X_DDR_REG_FLUSH_PCIE 0xa8
  430. #define AR934X_DDR_REG_FLUSH_WMAC 0xac
  431. +#define QCA953X_DDR_REG_FLUSH_GE0 0x9c
  432. +#define QCA953X_DDR_REG_FLUSH_GE1 0xa0
  433. +#define QCA953X_DDR_REG_FLUSH_USB 0xa4
  434. +#define QCA953X_DDR_REG_FLUSH_PCIE 0xa8
  435. +#define QCA953X_DDR_REG_FLUSH_WMAC 0xac
  436. +
  437. /*
  438. * PLL block
  439. */
  440. @@ -279,6 +300,44 @@
  441. #define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL BIT(6)
  442. +#define QCA953X_PLL_CPU_CONFIG_REG 0x00
  443. +#define QCA953X_PLL_DDR_CONFIG_REG 0x04
  444. +#define QCA953X_PLL_CLK_CTRL_REG 0x08
  445. +#define QCA953X_PLL_SWITCH_CLOCK_CONTROL_REG 0x24
  446. +#define QCA953X_PLL_ETH_XMII_CONTROL_REG 0x2c
  447. +#define QCA953X_PLL_ETH_SGMII_CONTROL_REG 0x48
  448. +
  449. +#define QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
  450. +#define QCA953X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
  451. +#define QCA953X_PLL_CPU_CONFIG_NINT_SHIFT 6
  452. +#define QCA953X_PLL_CPU_CONFIG_NINT_MASK 0x3f
  453. +#define QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
  454. +#define QCA953X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
  455. +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
  456. +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
  457. +
  458. +#define QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT 0
  459. +#define QCA953X_PLL_DDR_CONFIG_NFRAC_MASK 0x3ff
  460. +#define QCA953X_PLL_DDR_CONFIG_NINT_SHIFT 10
  461. +#define QCA953X_PLL_DDR_CONFIG_NINT_MASK 0x3f
  462. +#define QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
  463. +#define QCA953X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
  464. +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
  465. +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
  466. +
  467. +#define QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
  468. +#define QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
  469. +#define QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
  470. +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
  471. +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
  472. +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
  473. +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
  474. +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
  475. +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
  476. +#define QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL BIT(20)
  477. +#define QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
  478. +#define QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  479. +
  480. #define QCA955X_PLL_CPU_CONFIG_REG 0x00
  481. #define QCA955X_PLL_DDR_CONFIG_REG 0x04
  482. #define QCA955X_PLL_CLK_CTRL_REG 0x08
  483. @@ -355,6 +414,10 @@
  484. #define AR934X_RESET_REG_BOOTSTRAP 0xb0
  485. #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
  486. +#define QCA953X_RESET_REG_RESET_MODULE 0x1c
  487. +#define QCA953X_RESET_REG_BOOTSTRAP 0xb0
  488. +#define QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
  489. +
  490. #define QCA955X_RESET_REG_RESET_MODULE 0x1c
  491. #define QCA955X_RESET_REG_BOOTSTRAP 0xb0
  492. #define QCA955X_RESET_REG_EXT_INT_STATUS 0xac
  493. @@ -450,6 +513,27 @@
  494. #define AR934X_RESET_MBOX BIT(1)
  495. #define AR934X_RESET_I2S BIT(0)
  496. +#define QCA953X_RESET_USB_EXT_PWR BIT(29)
  497. +#define QCA953X_RESET_EXTERNAL BIT(28)
  498. +#define QCA953X_RESET_RTC BIT(27)
  499. +#define QCA953X_RESET_FULL_CHIP BIT(24)
  500. +#define QCA953X_RESET_GE1_MDIO BIT(23)
  501. +#define QCA953X_RESET_GE0_MDIO BIT(22)
  502. +#define QCA953X_RESET_CPU_NMI BIT(21)
  503. +#define QCA953X_RESET_CPU_COLD BIT(20)
  504. +#define QCA953X_RESET_DDR BIT(16)
  505. +#define QCA953X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
  506. +#define QCA953X_RESET_GE1_MAC BIT(13)
  507. +#define QCA953X_RESET_ETH_SWITCH_ANALOG BIT(12)
  508. +#define QCA953X_RESET_USB_PHY_ANALOG BIT(11)
  509. +#define QCA953X_RESET_GE0_MAC BIT(9)
  510. +#define QCA953X_RESET_ETH_SWITCH BIT(8)
  511. +#define QCA953X_RESET_PCIE_PHY BIT(7)
  512. +#define QCA953X_RESET_PCIE BIT(6)
  513. +#define QCA953X_RESET_USB_HOST BIT(5)
  514. +#define QCA953X_RESET_USB_PHY BIT(4)
  515. +#define QCA953X_RESET_USBSUS_OVERRIDE BIT(3)
  516. +
  517. #define QCA955X_RESET_HOST BIT(31)
  518. #define QCA955X_RESET_SLIC BIT(30)
  519. #define QCA955X_RESET_HDMA BIT(29)
  520. @@ -503,6 +587,13 @@
  521. #define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  522. #define AR934X_BOOTSTRAP_DDR1 BIT(0)
  523. +#define QCA953X_BOOTSTRAP_SW_OPTION2 BIT(12)
  524. +#define QCA953X_BOOTSTRAP_SW_OPTION1 BIT(11)
  525. +#define QCA953X_BOOTSTRAP_EJTAG_MODE BIT(5)
  526. +#define QCA953X_BOOTSTRAP_REF_CLK_40 BIT(4)
  527. +#define QCA953X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
  528. +#define QCA953X_BOOTSTRAP_DDR1 BIT(0)
  529. +
  530. #define QCA955X_BOOTSTRAP_REF_CLK_40 BIT(4)
  531. #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  532. @@ -523,6 +614,24 @@
  533. AR934X_PCIE_WMAC_INT_PCIE_RC1 | AR934X_PCIE_WMAC_INT_PCIE_RC2 | \
  534. AR934X_PCIE_WMAC_INT_PCIE_RC3)
  535. +#define QCA953X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  536. +#define QCA953X_PCIE_WMAC_INT_WMAC_TX BIT(1)
  537. +#define QCA953X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
  538. +#define QCA953X_PCIE_WMAC_INT_WMAC_RXHP BIT(3)
  539. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC BIT(4)
  540. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC0 BIT(5)
  541. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC1 BIT(6)
  542. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC2 BIT(7)
  543. +#define QCA953X_PCIE_WMAC_INT_PCIE_RC3 BIT(8)
  544. +#define QCA953X_PCIE_WMAC_INT_WMAC_ALL \
  545. + (QCA953X_PCIE_WMAC_INT_WMAC_MISC | QCA953X_PCIE_WMAC_INT_WMAC_TX | \
  546. + QCA953X_PCIE_WMAC_INT_WMAC_RXLP | QCA953X_PCIE_WMAC_INT_WMAC_RXHP)
  547. +
  548. +#define QCA953X_PCIE_WMAC_INT_PCIE_ALL \
  549. + (QCA953X_PCIE_WMAC_INT_PCIE_RC | QCA953X_PCIE_WMAC_INT_PCIE_RC0 | \
  550. + QCA953X_PCIE_WMAC_INT_PCIE_RC1 | QCA953X_PCIE_WMAC_INT_PCIE_RC2 | \
  551. + QCA953X_PCIE_WMAC_INT_PCIE_RC3)
  552. +
  553. #define QCA955X_EXT_INT_WMAC_MISC BIT(0)
  554. #define QCA955X_EXT_INT_WMAC_TX BIT(1)
  555. #define QCA955X_EXT_INT_WMAC_RXLP BIT(2)
  556. @@ -565,6 +674,8 @@
  557. #define REV_ID_MAJOR_AR9341 0x0120
  558. #define REV_ID_MAJOR_AR9342 0x1120
  559. #define REV_ID_MAJOR_AR9344 0x2120
  560. +#define REV_ID_MAJOR_QCA9533 0x0140
  561. +#define REV_ID_MAJOR_QCA9533_V2 0x0160
  562. #define REV_ID_MAJOR_QCA9556 0x0130
  563. #define REV_ID_MAJOR_QCA9558 0x1130
  564. @@ -587,6 +698,8 @@
  565. #define AR934X_REV_ID_REVISION_MASK 0xf
  566. +#define QCA953X_REV_ID_REVISION_MASK 0xf
  567. +
  568. #define QCA955X_REV_ID_REVISION_MASK 0xf
  569. /*
  570. @@ -634,6 +747,25 @@
  571. #define AR934X_GPIO_REG_OUT_FUNC5 0x40
  572. #define AR934X_GPIO_REG_FUNC 0x6c
  573. +#define QCA953X_GPIO_REG_OUT_FUNC0 0x2c
  574. +#define QCA953X_GPIO_REG_OUT_FUNC1 0x30
  575. +#define QCA953X_GPIO_REG_OUT_FUNC2 0x34
  576. +#define QCA953X_GPIO_REG_OUT_FUNC3 0x38
  577. +#define QCA953X_GPIO_REG_OUT_FUNC4 0x3c
  578. +#define QCA953X_GPIO_REG_IN_ENABLE0 0x44
  579. +#define QCA953X_GPIO_REG_FUNC 0x6c
  580. +
  581. +#define QCA953X_GPIO_OUT_MUX_SPI_CS1 10
  582. +#define QCA953X_GPIO_OUT_MUX_SPI_CS2 11
  583. +#define QCA953X_GPIO_OUT_MUX_SPI_CS0 9
  584. +#define QCA953X_GPIO_OUT_MUX_SPI_CLK 8
  585. +#define QCA953X_GPIO_OUT_MUX_SPI_MOSI 12
  586. +#define QCA953X_GPIO_OUT_MUX_LED_LINK1 41
  587. +#define QCA953X_GPIO_OUT_MUX_LED_LINK2 42
  588. +#define QCA953X_GPIO_OUT_MUX_LED_LINK3 43
  589. +#define QCA953X_GPIO_OUT_MUX_LED_LINK4 44
  590. +#define QCA953X_GPIO_OUT_MUX_LED_LINK5 45
  591. +
  592. #define QCA955X_GPIO_REG_OUT_FUNC0 0x2c
  593. #define QCA955X_GPIO_REG_OUT_FUNC1 0x30
  594. #define QCA955X_GPIO_REG_OUT_FUNC2 0x34
  595. @@ -648,6 +780,7 @@
  596. #define AR913X_GPIO_COUNT 22
  597. #define AR933X_GPIO_COUNT 30
  598. #define AR934X_GPIO_COUNT 23
  599. +#define QCA953X_GPIO_COUNT 18
  600. #define QCA955X_GPIO_COUNT 24
  601. /*
  602. @@ -671,6 +804,24 @@
  603. #define AR934X_SRIF_DPLL2_OUTDIV_SHIFT 13
  604. #define AR934X_SRIF_DPLL2_OUTDIV_MASK 0x7
  605. +#define QCA953X_SRIF_CPU_DPLL1_REG 0x1c0
  606. +#define QCA953X_SRIF_CPU_DPLL2_REG 0x1c4
  607. +#define QCA953X_SRIF_CPU_DPLL3_REG 0x1c8
  608. +
  609. +#define QCA953X_SRIF_DDR_DPLL1_REG 0x240
  610. +#define QCA953X_SRIF_DDR_DPLL2_REG 0x244
  611. +#define QCA953X_SRIF_DDR_DPLL3_REG 0x248
  612. +
  613. +#define QCA953X_SRIF_DPLL1_REFDIV_SHIFT 27
  614. +#define QCA953X_SRIF_DPLL1_REFDIV_MASK 0x1f
  615. +#define QCA953X_SRIF_DPLL1_NINT_SHIFT 18
  616. +#define QCA953X_SRIF_DPLL1_NINT_MASK 0x1ff
  617. +#define QCA953X_SRIF_DPLL1_NFRAC_MASK 0x0003ffff
  618. +
  619. +#define QCA953X_SRIF_DPLL2_LOCAL_PLL BIT(30)
  620. +#define QCA953X_SRIF_DPLL2_OUTDIV_SHIFT 13
  621. +#define QCA953X_SRIF_DPLL2_OUTDIV_MASK 0x7
  622. +
  623. #define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
  624. #define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
  625. #define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
  626. @@ -877,6 +1028,16 @@
  627. #define AR934X_ETH_CFG_RDV_DELAY_SHIFT 16
  628. /*
  629. + * QCA953X GMAC Interface
  630. + */
  631. +#define QCA953X_GMAC_REG_ETH_CFG 0x00
  632. +
  633. +#define QCA953X_ETH_CFG_SW_ONLY_MODE BIT(6)
  634. +#define QCA953X_ETH_CFG_SW_PHY_SWAP BIT(7)
  635. +#define QCA953X_ETH_CFG_SW_APB_ACCESS BIT(9)
  636. +#define QCA953X_ETH_CFG_SW_ACC_MSB_FIRST BIT(13)
  637. +
  638. +/*
  639. * QCA955X GMAC Interface
  640. */
  641. --- a/arch/mips/include/asm/mach-ath79/ath79.h
  642. +++ b/arch/mips/include/asm/mach-ath79/ath79.h
  643. @@ -32,6 +32,7 @@ enum ath79_soc_type {
  644. ATH79_SOC_AR9341,
  645. ATH79_SOC_AR9342,
  646. ATH79_SOC_AR9344,
  647. + ATH79_SOC_QCA9533,
  648. ATH79_SOC_QCA9556,
  649. ATH79_SOC_QCA9558,
  650. };
  651. @@ -100,6 +101,16 @@ static inline int soc_is_ar934x(void)
  652. return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
  653. }
  654. +static inline int soc_is_qca9533(void)
  655. +{
  656. + return ath79_soc == ATH79_SOC_QCA9533;
  657. +}
  658. +
  659. +static inline int soc_is_qca953x(void)
  660. +{
  661. + return soc_is_qca9533();
  662. +}
  663. +
  664. static inline int soc_is_qca9556(void)
  665. {
  666. return ath79_soc == ATH79_SOC_QCA9556;