621-MIPS-ath79-add-support-for-QCA956x-SoC.patch 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. --- a/arch/mips/ath79/Kconfig
  2. +++ b/arch/mips/ath79/Kconfig
  3. @@ -125,6 +125,12 @@ config SOC_QCA955X
  4. select PCI_AR724X if PCI
  5. def_bool n
  6. +config SOC_QCA956X
  7. + select USB_ARCH_HAS_EHCI
  8. + select HW_HAS_PCI
  9. + select PCI_AR724X if PCI
  10. + def_bool n
  11. +
  12. config ATH79_DEV_M25P80
  13. select ATH79_DEV_SPI
  14. def_bool n
  15. @@ -159,7 +165,7 @@ config ATH79_DEV_USB
  16. def_bool n
  17. config ATH79_DEV_WMAC
  18. - depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA953X || SOC_QCA955X)
  19. + depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA953X || SOC_QCA955X || SOC_QCA956X)
  20. def_bool n
  21. config ATH79_NVRAM
  22. --- a/arch/mips/ath79/clock.c
  23. +++ b/arch/mips/ath79/clock.c
  24. @@ -524,6 +524,100 @@ static void __init qca955x_clocks_init(v
  25. clk_add_alias("uart", NULL, "ref", NULL);
  26. }
  27. +static void __init qca956x_clocks_init(void)
  28. +{
  29. + unsigned long ref_rate;
  30. + unsigned long cpu_rate;
  31. + unsigned long ddr_rate;
  32. + unsigned long ahb_rate;
  33. + u32 pll, out_div, ref_div, nint, hfrac, lfrac, clk_ctrl, postdiv;
  34. + u32 cpu_pll, ddr_pll;
  35. + u32 bootstrap;
  36. +
  37. + bootstrap = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
  38. + if (bootstrap & QCA956X_BOOTSTRAP_REF_CLK_40)
  39. + ref_rate = 40 * 1000 * 1000;
  40. + else
  41. + ref_rate = 25 * 1000 * 1000;
  42. +
  43. + pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG_REG);
  44. + out_div = (pll >> QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  45. + QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK;
  46. + ref_div = (pll >> QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  47. + QCA956X_PLL_CPU_CONFIG_REFDIV_MASK;
  48. +
  49. + pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG1_REG);
  50. + nint = (pll >> QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT) &
  51. + QCA956X_PLL_CPU_CONFIG1_NINT_MASK;
  52. + hfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT) &
  53. + QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK;
  54. + lfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT) &
  55. + QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK;
  56. +
  57. + cpu_pll = nint * ref_rate / ref_div;
  58. + cpu_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
  59. + cpu_pll += (hfrac >> 13) * ref_rate / ref_div;
  60. + cpu_pll /= (1 << out_div);
  61. +
  62. + pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG_REG);
  63. + out_div = (pll >> QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  64. + QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK;
  65. + ref_div = (pll >> QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  66. + QCA956X_PLL_DDR_CONFIG_REFDIV_MASK;
  67. + pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG1_REG);
  68. + nint = (pll >> QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT) &
  69. + QCA956X_PLL_DDR_CONFIG1_NINT_MASK;
  70. + hfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT) &
  71. + QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK;
  72. + lfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT) &
  73. + QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK;
  74. +
  75. + ddr_pll = nint * ref_rate / ref_div;
  76. + ddr_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
  77. + ddr_pll += (hfrac >> 13) * ref_rate / ref_div;
  78. + ddr_pll /= (1 << out_div);
  79. +
  80. + clk_ctrl = ath79_pll_rr(QCA956X_PLL_CLK_CTRL_REG);
  81. +
  82. + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  83. + QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  84. +
  85. + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
  86. + cpu_rate = ref_rate;
  87. + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL)
  88. + cpu_rate = ddr_pll / (postdiv + 1);
  89. + else
  90. + cpu_rate = cpu_pll / (postdiv + 1);
  91. +
  92. + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
  93. + QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
  94. +
  95. + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
  96. + ddr_rate = ref_rate;
  97. + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL)
  98. + ddr_rate = cpu_pll / (postdiv + 1);
  99. + else
  100. + ddr_rate = ddr_pll / (postdiv + 1);
  101. +
  102. + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
  103. + QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
  104. +
  105. + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
  106. + ahb_rate = ref_rate;
  107. + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
  108. + ahb_rate = ddr_pll / (postdiv + 1);
  109. + else
  110. + ahb_rate = cpu_pll / (postdiv + 1);
  111. +
  112. + ath79_add_sys_clkdev("ref", ref_rate);
  113. + ath79_add_sys_clkdev("cpu", cpu_rate);
  114. + ath79_add_sys_clkdev("ddr", ddr_rate);
  115. + ath79_add_sys_clkdev("ahb", ahb_rate);
  116. +
  117. + clk_add_alias("wdt", NULL, "ref", NULL);
  118. + clk_add_alias("uart", NULL, "ref", NULL);
  119. +}
  120. +
  121. void __init ath79_clocks_init(void)
  122. {
  123. if (soc_is_ar71xx())
  124. @@ -540,6 +634,8 @@ void __init ath79_clocks_init(void)
  125. qca953x_clocks_init();
  126. else if (soc_is_qca955x())
  127. qca955x_clocks_init();
  128. + else if (soc_is_qca956x() || soc_is_tp9343())
  129. + qca956x_clocks_init();
  130. else
  131. BUG();
  132. --- a/arch/mips/ath79/common.c
  133. +++ b/arch/mips/ath79/common.c
  134. @@ -107,6 +107,8 @@ void ath79_device_reset_set(u32 mask)
  135. reg = QCA953X_RESET_REG_RESET_MODULE;
  136. else if (soc_is_qca955x())
  137. reg = QCA955X_RESET_REG_RESET_MODULE;
  138. + else if (soc_is_qca956x() || soc_is_tp9343())
  139. + reg = QCA956X_RESET_REG_RESET_MODULE;
  140. else
  141. panic("Reset register not defined for this SOC");
  142. @@ -137,6 +139,8 @@ void ath79_device_reset_clear(u32 mask)
  143. reg = QCA953X_RESET_REG_RESET_MODULE;
  144. else if (soc_is_qca955x())
  145. reg = QCA955X_RESET_REG_RESET_MODULE;
  146. + else if (soc_is_qca956x() || soc_is_tp9343())
  147. + reg = QCA956X_RESET_REG_RESET_MODULE;
  148. else
  149. panic("Reset register not defined for this SOC");
  150. @@ -163,6 +167,8 @@ u32 ath79_device_reset_get(u32 mask)
  151. reg = AR933X_RESET_REG_RESET_MODULE;
  152. else if (soc_is_ar934x())
  153. reg = AR934X_RESET_REG_RESET_MODULE;
  154. + else if (soc_is_qca956x() || soc_is_tp9343())
  155. + reg = QCA956X_RESET_REG_RESET_MODULE;
  156. else
  157. BUG();
  158. --- a/arch/mips/ath79/dev-common.c
  159. +++ b/arch/mips/ath79/dev-common.c
  160. @@ -95,7 +95,9 @@ void __init ath79_register_uart(void)
  161. soc_is_ar913x() ||
  162. soc_is_ar934x() ||
  163. soc_is_qca953x() ||
  164. - soc_is_qca955x()) {
  165. + soc_is_qca955x() ||
  166. + soc_is_qca956x() ||
  167. + soc_is_tp9343()) {
  168. ath79_uart_data[0].uartclk = uart_clk_rate;
  169. platform_device_register(&ath79_uart_device);
  170. } else if (soc_is_ar933x()) {
  171. @@ -164,6 +166,9 @@ void __init ath79_gpio_init(void)
  172. } else if (soc_is_qca955x()) {
  173. ath79_gpio_pdata.ngpios = QCA955X_GPIO_COUNT;
  174. ath79_gpio_pdata.oe_inverted = 1;
  175. + } else if (soc_is_qca956x() || soc_is_tp9343()) {
  176. + ath79_gpio_pdata.ngpios = QCA956X_GPIO_COUNT;
  177. + ath79_gpio_pdata.oe_inverted = 1;
  178. } else {
  179. BUG();
  180. }
  181. --- a/arch/mips/ath79/dev-usb.c
  182. +++ b/arch/mips/ath79/dev-usb.c
  183. @@ -296,6 +296,19 @@ static void __init qca955x_usb_setup(voi
  184. &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  185. }
  186. +static void __init qca956x_usb_setup(void)
  187. +{
  188. + ath79_usb_register("ehci-platform", 0,
  189. + QCA956X_EHCI0_BASE, QCA956X_EHCI_SIZE,
  190. + ATH79_IP3_IRQ(0),
  191. + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  192. +
  193. + ath79_usb_register("ehci-platform", 1,
  194. + QCA956X_EHCI1_BASE, QCA956X_EHCI_SIZE,
  195. + ATH79_IP3_IRQ(1),
  196. + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  197. +}
  198. +
  199. void __init ath79_register_usb(void)
  200. {
  201. if (soc_is_ar71xx())
  202. @@ -314,6 +327,8 @@ void __init ath79_register_usb(void)
  203. qca953x_usb_setup();
  204. else if (soc_is_qca955x())
  205. qca955x_usb_setup();
  206. + else if (soc_is_qca956x())
  207. + qca956x_usb_setup();
  208. else
  209. BUG();
  210. }
  211. --- a/arch/mips/ath79/dev-wmac.c
  212. +++ b/arch/mips/ath79/dev-wmac.c
  213. @@ -189,6 +189,26 @@ static void qca955x_wmac_setup(void)
  214. ath79_wmac_data.is_clk_25mhz = true;
  215. }
  216. +static void qca956x_wmac_setup(void)
  217. +{
  218. + u32 t;
  219. +
  220. + ath79_wmac_device.name = "qca956x_wmac";
  221. +
  222. + ath79_wmac_resources[0].start = QCA956X_WMAC_BASE;
  223. + ath79_wmac_resources[0].end = QCA956X_WMAC_BASE + QCA956X_WMAC_SIZE - 1;
  224. + ath79_wmac_resources[1].start = ATH79_IP2_IRQ(1);
  225. + ath79_wmac_resources[1].end = ATH79_IP2_IRQ(1);
  226. +
  227. + t = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
  228. + if (t & QCA956X_BOOTSTRAP_REF_CLK_40)
  229. + ath79_wmac_data.is_clk_25mhz = false;
  230. + else
  231. + ath79_wmac_data.is_clk_25mhz = true;
  232. +
  233. + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
  234. +}
  235. +
  236. static bool __init
  237. ar93xx_wmac_otp_read_word(void __iomem *base, int addr, u32 *data)
  238. {
  239. @@ -392,6 +412,8 @@ void __init ath79_register_wmac(u8 *cal_
  240. qca953x_wmac_setup();
  241. else if (soc_is_qca955x())
  242. qca955x_wmac_setup();
  243. + else if (soc_is_qca956x() || soc_is_tp9343())
  244. + qca956x_wmac_setup();
  245. else
  246. BUG();
  247. --- a/arch/mips/ath79/early_printk.c
  248. +++ b/arch/mips/ath79/early_printk.c
  249. @@ -120,6 +120,8 @@ static void prom_putchar_init(void)
  250. case REV_ID_MAJOR_QCA9533_V2:
  251. case REV_ID_MAJOR_QCA9556:
  252. case REV_ID_MAJOR_QCA9558:
  253. + case REV_ID_MAJOR_TP9343:
  254. + case REV_ID_MAJOR_QCA956X:
  255. _prom_putchar = prom_putchar_ar71xx;
  256. break;
  257. --- a/arch/mips/ath79/gpio.c
  258. +++ b/arch/mips/ath79/gpio.c
  259. @@ -31,7 +31,10 @@ static void __iomem *ath79_gpio_get_func
  260. soc_is_ar913x() ||
  261. soc_is_ar933x())
  262. reg = AR71XX_GPIO_REG_FUNC;
  263. - else if (soc_is_ar934x() || soc_is_qca953x())
  264. + else if (soc_is_ar934x() ||
  265. + soc_is_qca953x() ||
  266. + soc_is_qca956x() ||
  267. + soc_is_tp9343())
  268. reg = AR934X_GPIO_REG_FUNC;
  269. else
  270. BUG();
  271. @@ -64,7 +67,7 @@ void __init ath79_gpio_output_select(uns
  272. unsigned int reg;
  273. u32 t, s;
  274. - BUG_ON(!soc_is_ar934x() && !soc_is_qca953x());
  275. + BUG_ON(!soc_is_ar934x() && !soc_is_qca953x() && !soc_is_qca956x());
  276. if (gpio >= AR934X_GPIO_COUNT)
  277. return;
  278. --- a/arch/mips/ath79/irq.c
  279. +++ b/arch/mips/ath79/irq.c
  280. @@ -106,7 +106,9 @@ static void __init ath79_misc_irq_init(v
  281. soc_is_ar933x() ||
  282. soc_is_ar934x() ||
  283. soc_is_qca953x() ||
  284. - soc_is_qca955x())
  285. + soc_is_qca955x() ||
  286. + soc_is_qca956x() ||
  287. + soc_is_tp9343())
  288. ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
  289. else
  290. BUG();
  291. @@ -263,6 +265,87 @@ static unsigned irq_wb_chan[8] = {
  292. -1, -1, -1, -1, -1, -1, -1, -1,
  293. };
  294. +static void qca956x_ip2_irq_dispatch(struct irq_desc *desc)
  295. +{
  296. + u32 status;
  297. +
  298. + status = ath79_reset_rr(QCA956X_RESET_REG_EXT_INT_STATUS);
  299. + status &= QCA956X_EXT_INT_PCIE_RC1_ALL | QCA956X_EXT_INT_WMAC_ALL;
  300. +
  301. + if (status == 0) {
  302. + spurious_interrupt();
  303. + return;
  304. + }
  305. +
  306. + if (status & QCA956X_EXT_INT_PCIE_RC1_ALL) {
  307. + /* TODO: flush DDR? */
  308. + generic_handle_irq(ATH79_IP2_IRQ(0));
  309. + }
  310. +
  311. + if (status & QCA956X_EXT_INT_WMAC_ALL) {
  312. + /* TODO: flsuh DDR? */
  313. + generic_handle_irq(ATH79_IP2_IRQ(1));
  314. + }
  315. +}
  316. +
  317. +static void qca956x_ip3_irq_dispatch(struct irq_desc *desc)
  318. +{
  319. + u32 status;
  320. +
  321. + status = ath79_reset_rr(QCA956X_RESET_REG_EXT_INT_STATUS);
  322. + status &= QCA956X_EXT_INT_PCIE_RC2_ALL |
  323. + QCA956X_EXT_INT_USB1 | QCA956X_EXT_INT_USB2;
  324. +
  325. + if (status == 0) {
  326. + spurious_interrupt();
  327. + return;
  328. + }
  329. +
  330. + if (status & QCA956X_EXT_INT_USB1) {
  331. + /* TODO: flush DDR? */
  332. + generic_handle_irq(ATH79_IP3_IRQ(0));
  333. + }
  334. +
  335. + if (status & QCA956X_EXT_INT_USB2) {
  336. + /* TODO: flush DDR? */
  337. + generic_handle_irq(ATH79_IP3_IRQ(1));
  338. + }
  339. +
  340. + if (status & QCA956X_EXT_INT_PCIE_RC2_ALL) {
  341. + /* TODO: flush DDR? */
  342. + generic_handle_irq(ATH79_IP3_IRQ(2));
  343. + }
  344. +}
  345. +
  346. +static void qca956x_enable_timer_cb(void) {
  347. + u32 misc;
  348. +
  349. + misc = ath79_reset_rr(AR71XX_RESET_REG_MISC_INT_ENABLE);
  350. + misc |= MISC_INT_MIPS_SI_TIMERINT_MASK;
  351. + ath79_reset_wr(AR71XX_RESET_REG_MISC_INT_ENABLE, misc);
  352. +}
  353. +
  354. +static void qca956x_irq_init(void)
  355. +{
  356. + int i;
  357. +
  358. + for (i = ATH79_IP2_IRQ_BASE;
  359. + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
  360. + irq_set_chip_and_handler(i, &dummy_irq_chip, handle_level_irq);
  361. +
  362. + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca956x_ip2_irq_dispatch);
  363. +
  364. + for (i = ATH79_IP3_IRQ_BASE;
  365. + i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
  366. + irq_set_chip_and_handler(i, &dummy_irq_chip, handle_level_irq);
  367. +
  368. + irq_set_chained_handler(ATH79_CPU_IRQ(3), qca956x_ip3_irq_dispatch);
  369. +
  370. + /* QCA956x timer init workaround has to be applied right before setting
  371. + * up the clock. Else, there will be no jiffies */
  372. + late_time_init = &qca956x_enable_timer_cb;
  373. +}
  374. +
  375. asmlinkage void plat_irq_dispatch(void)
  376. {
  377. unsigned long pending;
  378. @@ -404,4 +487,6 @@ void __init arch_init_irq(void)
  379. qca953x_irq_init();
  380. else if (soc_is_qca955x())
  381. qca955x_irq_init();
  382. + else if (soc_is_qca956x() || soc_is_tp9343())
  383. + qca956x_irq_init();
  384. }
  385. --- a/arch/mips/ath79/pci.c
  386. +++ b/arch/mips/ath79/pci.c
  387. @@ -68,6 +68,21 @@ static const struct ath79_pci_irq qca955
  388. },
  389. };
  390. +static const struct ath79_pci_irq qca956x_pci_irq_map[] __initconst = {
  391. + {
  392. + .bus = 0,
  393. + .slot = 0,
  394. + .pin = 1,
  395. + .irq = ATH79_PCI_IRQ(0),
  396. + },
  397. + {
  398. + .bus = 1,
  399. + .slot = 0,
  400. + .pin = 1,
  401. + .irq = ATH79_PCI_IRQ(1),
  402. + },
  403. +};
  404. +
  405. int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
  406. {
  407. int irq = -1;
  408. @@ -86,6 +101,9 @@ int __init pcibios_map_irq(const struct
  409. } else if (soc_is_qca955x()) {
  410. ath79_pci_irq_map = qca955x_pci_irq_map;
  411. ath79_pci_nr_irqs = ARRAY_SIZE(qca955x_pci_irq_map);
  412. + } else if (soc_is_qca956x()) {
  413. + ath79_pci_irq_map = qca956x_pci_irq_map;
  414. + ath79_pci_nr_irqs = ARRAY_SIZE(qca956x_pci_irq_map);
  415. } else {
  416. pr_crit("pci %s: invalid irq map\n",
  417. pci_name((struct pci_dev *) dev));
  418. @@ -303,6 +321,15 @@ int __init ath79_register_pci(void)
  419. QCA955X_PCI_MEM_SIZE,
  420. 1,
  421. ATH79_IP3_IRQ(2));
  422. + } else if (soc_is_qca956x()) {
  423. + pdev = ath79_register_pci_ar724x(0,
  424. + QCA956X_PCI_CFG_BASE1,
  425. + QCA956X_PCI_CTRL_BASE1,
  426. + QCA956X_PCI_CRP_BASE1,
  427. + QCA956X_PCI_MEM_BASE1,
  428. + QCA956X_PCI_MEM_SIZE,
  429. + 1,
  430. + ATH79_IP3_IRQ(2));
  431. } else {
  432. /* No PCI support */
  433. return -ENODEV;
  434. --- a/arch/mips/ath79/setup.c
  435. +++ b/arch/mips/ath79/setup.c
  436. @@ -180,6 +180,18 @@ static void __init ath79_detect_sys_type
  437. rev = id & QCA955X_REV_ID_REVISION_MASK;
  438. break;
  439. + case REV_ID_MAJOR_QCA956X:
  440. + ath79_soc = ATH79_SOC_QCA956X;
  441. + chip = "956X";
  442. + rev = id & QCA956X_REV_ID_REVISION_MASK;
  443. + break;
  444. +
  445. + case REV_ID_MAJOR_TP9343:
  446. + ath79_soc = ATH79_SOC_TP9343;
  447. + chip = "9343";
  448. + rev = id & QCA956X_REV_ID_REVISION_MASK;
  449. + break;
  450. +
  451. default:
  452. panic("ath79: unknown SoC, id:0x%08x", id);
  453. }
  454. @@ -187,9 +199,12 @@ static void __init ath79_detect_sys_type
  455. if (ver == 1)
  456. ath79_soc_rev = rev;
  457. - if (soc_is_qca953x() || soc_is_qca955x())
  458. + if (soc_is_qca953x() || soc_is_qca955x() || soc_is_qca956x())
  459. sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s ver %u rev %u",
  460. chip, ver, rev);
  461. + else if (soc_is_tp9343())
  462. + sprintf(ath79_sys_type, "Qualcomm Atheros TP%s rev %u",
  463. + chip, rev);
  464. else
  465. sprintf(ath79_sys_type, "Atheros AR%s rev %u", chip, rev);
  466. pr_info("SoC: %s\n", ath79_sys_type);
  467. --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  468. +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  469. @@ -143,6 +143,23 @@
  470. #define QCA955X_NFC_BASE 0x1b800200
  471. #define QCA955X_NFC_SIZE 0xb8
  472. +#define QCA956X_PCI_MEM_BASE1 0x12000000
  473. +#define QCA956X_PCI_MEM_SIZE 0x02000000
  474. +#define QCA956X_PCI_CFG_BASE1 0x16000000
  475. +#define QCA956X_PCI_CFG_SIZE 0x1000
  476. +#define QCA956X_PCI_CRP_BASE1 (AR71XX_APB_BASE + 0x00250000)
  477. +#define QCA956X_PCI_CRP_SIZE 0x1000
  478. +#define QCA956X_PCI_CTRL_BASE1 (AR71XX_APB_BASE + 0x00280000)
  479. +#define QCA956X_PCI_CTRL_SIZE 0x100
  480. +
  481. +#define QCA956X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
  482. +#define QCA956X_WMAC_SIZE 0x20000
  483. +#define QCA956X_EHCI0_BASE 0x1b000000
  484. +#define QCA956X_EHCI1_BASE 0x1b400000
  485. +#define QCA956X_EHCI_SIZE 0x200
  486. +#define QCA956X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
  487. +#define QCA956X_GMAC_SIZE 0x64
  488. +
  489. #define AR9300_OTP_BASE 0x14000
  490. #define AR9300_OTP_STATUS 0x15f18
  491. #define AR9300_OTP_STATUS_TYPE 0x7
  492. @@ -152,6 +169,13 @@
  493. #define AR9300_OTP_READ_DATA 0x15f1c
  494. /*
  495. + * Hidden Registers
  496. + */
  497. +#define QCA956X_DAM_RESET_OFFSET 0xb90001bc
  498. +#define QCA956X_DAM_RESET_SIZE 0x4
  499. +#define QCA956X_INLINE_CHKSUM_ENG BIT(27)
  500. +
  501. +/*
  502. * DDR_CTRL block
  503. */
  504. #define AR71XX_DDR_REG_PCI_WIN0 0x7c
  505. @@ -375,6 +399,49 @@
  506. #define QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
  507. #define QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  508. +#define QCA956X_PLL_CPU_CONFIG_REG 0x00
  509. +#define QCA956X_PLL_CPU_CONFIG1_REG 0x04
  510. +#define QCA956X_PLL_DDR_CONFIG_REG 0x08
  511. +#define QCA956X_PLL_DDR_CONFIG1_REG 0x0c
  512. +#define QCA956X_PLL_CLK_CTRL_REG 0x10
  513. +
  514. +#define QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
  515. +#define QCA956X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
  516. +#define QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
  517. +#define QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
  518. +
  519. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT 0
  520. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK 0x1f
  521. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT 5
  522. +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK 0x1fff
  523. +#define QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT 18
  524. +#define QCA956X_PLL_CPU_CONFIG1_NINT_MASK 0x1ff
  525. +
  526. +#define QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
  527. +#define QCA956X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
  528. +#define QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
  529. +#define QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
  530. +
  531. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT 0
  532. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK 0x1f
  533. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT 5
  534. +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK 0x1fff
  535. +#define QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT 18
  536. +#define QCA956X_PLL_DDR_CONFIG1_NINT_MASK 0x1ff
  537. +
  538. +#define QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
  539. +#define QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
  540. +#define QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
  541. +#define QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
  542. +#define QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
  543. +#define QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
  544. +#define QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
  545. +#define QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
  546. +#define QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
  547. +#define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL BIT(20)
  548. +#define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL BIT(21)
  549. +#define QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  550. +
  551. /*
  552. * USB_CONFIG block
  553. */
  554. @@ -422,6 +489,11 @@
  555. #define QCA955X_RESET_REG_BOOTSTRAP 0xb0
  556. #define QCA955X_RESET_REG_EXT_INT_STATUS 0xac
  557. +#define QCA956X_RESET_REG_RESET_MODULE 0x1c
  558. +#define QCA956X_RESET_REG_BOOTSTRAP 0xb0
  559. +#define QCA956X_RESET_REG_EXT_INT_STATUS 0xac
  560. +
  561. +#define MISC_INT_MIPS_SI_TIMERINT_MASK BIT(28)
  562. #define MISC_INT_ETHSW BIT(12)
  563. #define MISC_INT_TIMER4 BIT(10)
  564. #define MISC_INT_TIMER3 BIT(9)
  565. @@ -596,6 +668,8 @@
  566. #define QCA955X_BOOTSTRAP_REF_CLK_40 BIT(4)
  567. +#define QCA956X_BOOTSTRAP_REF_CLK_40 BIT(2)
  568. +
  569. #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  570. #define AR934X_PCIE_WMAC_INT_WMAC_TX BIT(1)
  571. #define AR934X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
  572. @@ -663,6 +737,37 @@
  573. QCA955X_EXT_INT_PCIE_RC2_INT1 | QCA955X_EXT_INT_PCIE_RC2_INT2 | \
  574. QCA955X_EXT_INT_PCIE_RC2_INT3)
  575. +#define QCA956X_EXT_INT_WMAC_MISC BIT(0)
  576. +#define QCA956X_EXT_INT_WMAC_TX BIT(1)
  577. +#define QCA956X_EXT_INT_WMAC_RXLP BIT(2)
  578. +#define QCA956X_EXT_INT_WMAC_RXHP BIT(3)
  579. +#define QCA956X_EXT_INT_PCIE_RC1 BIT(4)
  580. +#define QCA956X_EXT_INT_PCIE_RC1_INT0 BIT(5)
  581. +#define QCA956X_EXT_INT_PCIE_RC1_INT1 BIT(6)
  582. +#define QCA956X_EXT_INT_PCIE_RC1_INT2 BIT(7)
  583. +#define QCA956X_EXT_INT_PCIE_RC1_INT3 BIT(8)
  584. +#define QCA956X_EXT_INT_PCIE_RC2 BIT(12)
  585. +#define QCA956X_EXT_INT_PCIE_RC2_INT0 BIT(13)
  586. +#define QCA956X_EXT_INT_PCIE_RC2_INT1 BIT(14)
  587. +#define QCA956X_EXT_INT_PCIE_RC2_INT2 BIT(15)
  588. +#define QCA956X_EXT_INT_PCIE_RC2_INT3 BIT(16)
  589. +#define QCA956X_EXT_INT_USB1 BIT(24)
  590. +#define QCA956X_EXT_INT_USB2 BIT(28)
  591. +
  592. +#define QCA956X_EXT_INT_WMAC_ALL \
  593. + (QCA956X_EXT_INT_WMAC_MISC | QCA956X_EXT_INT_WMAC_TX | \
  594. + QCA956X_EXT_INT_WMAC_RXLP | QCA956X_EXT_INT_WMAC_RXHP)
  595. +
  596. +#define QCA956X_EXT_INT_PCIE_RC1_ALL \
  597. + (QCA956X_EXT_INT_PCIE_RC1 | QCA956X_EXT_INT_PCIE_RC1_INT0 | \
  598. + QCA956X_EXT_INT_PCIE_RC1_INT1 | QCA956X_EXT_INT_PCIE_RC1_INT2 | \
  599. + QCA956X_EXT_INT_PCIE_RC1_INT3)
  600. +
  601. +#define QCA956X_EXT_INT_PCIE_RC2_ALL \
  602. + (QCA956X_EXT_INT_PCIE_RC2 | QCA956X_EXT_INT_PCIE_RC2_INT0 | \
  603. + QCA956X_EXT_INT_PCIE_RC2_INT1 | QCA956X_EXT_INT_PCIE_RC2_INT2 | \
  604. + QCA956X_EXT_INT_PCIE_RC2_INT3)
  605. +
  606. #define REV_ID_MAJOR_MASK 0xfff0
  607. #define REV_ID_MAJOR_AR71XX 0x00a0
  608. #define REV_ID_MAJOR_AR913X 0x00b0
  609. @@ -678,6 +783,8 @@
  610. #define REV_ID_MAJOR_QCA9533_V2 0x0160
  611. #define REV_ID_MAJOR_QCA9556 0x0130
  612. #define REV_ID_MAJOR_QCA9558 0x1130
  613. +#define REV_ID_MAJOR_TP9343 0x0150
  614. +#define REV_ID_MAJOR_QCA956X 0x1150
  615. #define AR71XX_REV_ID_MINOR_MASK 0x3
  616. #define AR71XX_REV_ID_MINOR_AR7130 0x0
  617. @@ -702,6 +809,8 @@
  618. #define QCA955X_REV_ID_REVISION_MASK 0xf
  619. +#define QCA956X_REV_ID_REVISION_MASK 0xf
  620. +
  621. /*
  622. * SPI block
  623. */
  624. @@ -774,6 +883,19 @@
  625. #define QCA955X_GPIO_REG_OUT_FUNC5 0x40
  626. #define QCA955X_GPIO_REG_FUNC 0x6c
  627. +#define QCA956X_GPIO_REG_OUT_FUNC0 0x2c
  628. +#define QCA956X_GPIO_REG_OUT_FUNC1 0x30
  629. +#define QCA956X_GPIO_REG_OUT_FUNC2 0x34
  630. +#define QCA956X_GPIO_REG_OUT_FUNC3 0x38
  631. +#define QCA956X_GPIO_REG_OUT_FUNC4 0x3c
  632. +#define QCA956X_GPIO_REG_OUT_FUNC5 0x40
  633. +#define QCA956X_GPIO_REG_IN_ENABLE0 0x44
  634. +#define QCA956X_GPIO_REG_IN_ENABLE3 0x50
  635. +#define QCA956X_GPIO_REG_FUNC 0x6c
  636. +
  637. +#define QCA956X_GPIO_OUT_MUX_GE0_MDO 32
  638. +#define QCA956X_GPIO_OUT_MUX_GE0_MDC 33
  639. +
  640. #define AR71XX_GPIO_COUNT 16
  641. #define AR7240_GPIO_COUNT 18
  642. #define AR7241_GPIO_COUNT 20
  643. @@ -782,6 +904,7 @@
  644. #define AR934X_GPIO_COUNT 23
  645. #define QCA953X_GPIO_COUNT 18
  646. #define QCA955X_GPIO_COUNT 24
  647. +#define QCA956X_GPIO_COUNT 23
  648. /*
  649. * SRIF block
  650. --- a/arch/mips/include/asm/mach-ath79/ath79.h
  651. +++ b/arch/mips/include/asm/mach-ath79/ath79.h
  652. @@ -35,6 +35,8 @@ enum ath79_soc_type {
  653. ATH79_SOC_QCA9533,
  654. ATH79_SOC_QCA9556,
  655. ATH79_SOC_QCA9558,
  656. + ATH79_SOC_TP9343,
  657. + ATH79_SOC_QCA956X,
  658. };
  659. extern enum ath79_soc_type ath79_soc;
  660. @@ -126,6 +128,26 @@ static inline int soc_is_qca955x(void)
  661. return soc_is_qca9556() || soc_is_qca9558();
  662. }
  663. +static inline int soc_is_tp9343(void)
  664. +{
  665. + return ath79_soc == ATH79_SOC_TP9343;
  666. +}
  667. +
  668. +static inline int soc_is_qca9561(void)
  669. +{
  670. + return ath79_soc == ATH79_SOC_QCA956X;
  671. +}
  672. +
  673. +static inline int soc_is_qca9563(void)
  674. +{
  675. + return ath79_soc == ATH79_SOC_QCA956X;
  676. +}
  677. +
  678. +static inline int soc_is_qca956x(void)
  679. +{
  680. + return soc_is_qca9561() || soc_is_qca9563();
  681. +}
  682. +
  683. void ath79_ddr_set_pci_windows(void);
  684. extern void __iomem *ath79_gpio_base;