aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-02-15 08:38:17 -0500
committerJohn Crispin <blogic@openwrt.org>2013-02-19 03:36:25 -0500
commit41583c05c15cd3adb848f9ee8316bf8084c961cb (patch)
tree2526f8df6b38945a7193ec4de582c48d85c5b407 /arch/mips
parent2e6c91e392fd7be2ef0ba1e9a20e0ebe8ab79cf3 (diff)
MIPS: ath79: add clock setup code for the QCA955X SoCs
The patch adds code to get various clock frequencies from the PLLs used in the QCA955x SoCs. Cc: Rodriguez, Luis <rodrigue@qca.qualcomm.com> Cc: Giori, Kathy <kgiori@qca.qualcomm.com> Cc: QCA Linux Team <qca-linux-team@qca.qualcomm.com> Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4945/ Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/ath79/clock.c78
-rw-r--r--arch/mips/include/asm/mach-ath79/ar71xx_regs.h39
2 files changed, 117 insertions, 0 deletions
diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c
index 579f452c0b45..555e603de619 100644
--- a/arch/mips/ath79/clock.c
+++ b/arch/mips/ath79/clock.c
@@ -295,6 +295,82 @@ static void __init ar934x_clocks_init(void)
295 iounmap(dpll_base); 295 iounmap(dpll_base);
296} 296}
297 297
298static void __init qca955x_clocks_init(void)
299{
300 u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
301 u32 cpu_pll, ddr_pll;
302 u32 bootstrap;
303
304 bootstrap = ath79_reset_rr(QCA955X_RESET_REG_BOOTSTRAP);
305 if (bootstrap & QCA955X_BOOTSTRAP_REF_CLK_40)
306 ath79_ref_clk.rate = 40 * 1000 * 1000;
307 else
308 ath79_ref_clk.rate = 25 * 1000 * 1000;
309
310 pll = ath79_pll_rr(QCA955X_PLL_CPU_CONFIG_REG);
311 out_div = (pll >> QCA955X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
312 QCA955X_PLL_CPU_CONFIG_OUTDIV_MASK;
313 ref_div = (pll >> QCA955X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
314 QCA955X_PLL_CPU_CONFIG_REFDIV_MASK;
315 nint = (pll >> QCA955X_PLL_CPU_CONFIG_NINT_SHIFT) &
316 QCA955X_PLL_CPU_CONFIG_NINT_MASK;
317 frac = (pll >> QCA955X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
318 QCA955X_PLL_CPU_CONFIG_NFRAC_MASK;
319
320 cpu_pll = nint * ath79_ref_clk.rate / ref_div;
321 cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 6));
322 cpu_pll /= (1 << out_div);
323
324 pll = ath79_pll_rr(QCA955X_PLL_DDR_CONFIG_REG);
325 out_div = (pll >> QCA955X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
326 QCA955X_PLL_DDR_CONFIG_OUTDIV_MASK;
327 ref_div = (pll >> QCA955X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
328 QCA955X_PLL_DDR_CONFIG_REFDIV_MASK;
329 nint = (pll >> QCA955X_PLL_DDR_CONFIG_NINT_SHIFT) &
330 QCA955X_PLL_DDR_CONFIG_NINT_MASK;
331 frac = (pll >> QCA955X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
332 QCA955X_PLL_DDR_CONFIG_NFRAC_MASK;
333
334 ddr_pll = nint * ath79_ref_clk.rate / ref_div;
335 ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 10));
336 ddr_pll /= (1 << out_div);
337
338 clk_ctrl = ath79_pll_rr(QCA955X_PLL_CLK_CTRL_REG);
339
340 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
341 QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
342
343 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
344 ath79_cpu_clk.rate = ath79_ref_clk.rate;
345 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
346 ath79_cpu_clk.rate = ddr_pll / (postdiv + 1);
347 else
348 ath79_cpu_clk.rate = cpu_pll / (postdiv + 1);
349
350 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
351 QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
352
353 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
354 ath79_ddr_clk.rate = ath79_ref_clk.rate;
355 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
356 ath79_ddr_clk.rate = cpu_pll / (postdiv + 1);
357 else
358 ath79_ddr_clk.rate = ddr_pll / (postdiv + 1);
359
360 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
361 QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
362
363 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
364 ath79_ahb_clk.rate = ath79_ref_clk.rate;
365 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
366 ath79_ahb_clk.rate = ddr_pll / (postdiv + 1);
367 else
368 ath79_ahb_clk.rate = cpu_pll / (postdiv + 1);
369
370 ath79_wdt_clk.rate = ath79_ref_clk.rate;
371 ath79_uart_clk.rate = ath79_ref_clk.rate;
372}
373
298void __init ath79_clocks_init(void) 374void __init ath79_clocks_init(void)
299{ 375{
300 if (soc_is_ar71xx()) 376 if (soc_is_ar71xx())
@@ -307,6 +383,8 @@ void __init ath79_clocks_init(void)
307 ar933x_clocks_init(); 383 ar933x_clocks_init();
308 else if (soc_is_ar934x()) 384 else if (soc_is_ar934x())
309 ar934x_clocks_init(); 385 ar934x_clocks_init();
386 else if (soc_is_qca955x())
387 qca955x_clocks_init();
310 else 388 else
311 BUG(); 389 BUG();
312 390
diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
index 63a9f2b600b8..7b00e12afc1c 100644
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -225,6 +225,41 @@
225#define AR934X_PLL_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21) 225#define AR934X_PLL_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
226#define AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24) 226#define AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
227 227
228#define QCA955X_PLL_CPU_CONFIG_REG 0x00
229#define QCA955X_PLL_DDR_CONFIG_REG 0x04
230#define QCA955X_PLL_CLK_CTRL_REG 0x08
231
232#define QCA955X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
233#define QCA955X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
234#define QCA955X_PLL_CPU_CONFIG_NINT_SHIFT 6
235#define QCA955X_PLL_CPU_CONFIG_NINT_MASK 0x3f
236#define QCA955X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
237#define QCA955X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
238#define QCA955X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
239#define QCA955X_PLL_CPU_CONFIG_OUTDIV_MASK 0x3
240
241#define QCA955X_PLL_DDR_CONFIG_NFRAC_SHIFT 0
242#define QCA955X_PLL_DDR_CONFIG_NFRAC_MASK 0x3ff
243#define QCA955X_PLL_DDR_CONFIG_NINT_SHIFT 10
244#define QCA955X_PLL_DDR_CONFIG_NINT_MASK 0x3f
245#define QCA955X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
246#define QCA955X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
247#define QCA955X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
248#define QCA955X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
249
250#define QCA955X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
251#define QCA955X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
252#define QCA955X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
253#define QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
254#define QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
255#define QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
256#define QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
257#define QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
258#define QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
259#define QCA955X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL BIT(20)
260#define QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
261#define QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
262
228/* 263/*
229 * USB_CONFIG block 264 * USB_CONFIG block
230 */ 265 */
@@ -264,6 +299,8 @@
264#define AR934X_RESET_REG_BOOTSTRAP 0xb0 299#define AR934X_RESET_REG_BOOTSTRAP 0xb0
265#define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac 300#define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
266 301
302#define QCA955X_RESET_REG_BOOTSTRAP 0xb0
303
267#define MISC_INT_ETHSW BIT(12) 304#define MISC_INT_ETHSW BIT(12)
268#define MISC_INT_TIMER4 BIT(10) 305#define MISC_INT_TIMER4 BIT(10)
269#define MISC_INT_TIMER3 BIT(9) 306#define MISC_INT_TIMER3 BIT(9)
@@ -341,6 +378,8 @@
341#define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1) 378#define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
342#define AR934X_BOOTSTRAP_DDR1 BIT(0) 379#define AR934X_BOOTSTRAP_DDR1 BIT(0)
343 380
381#define QCA955X_BOOTSTRAP_REF_CLK_40 BIT(4)
382
344#define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0) 383#define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
345#define AR934X_PCIE_WMAC_INT_WMAC_TX BIT(1) 384#define AR934X_PCIE_WMAC_INT_WMAC_TX BIT(1)
346#define AR934X_PCIE_WMAC_INT_WMAC_RXLP BIT(2) 385#define AR934X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)