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

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