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