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

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