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

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