1
0

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

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