diff options
Diffstat (limited to 'arch/mips/ath79/clock.c')
-rw-r--r-- | arch/mips/ath79/clock.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c index 8c1b8bf9b32f..765ef30e3e1c 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 | ||
298 | static 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 | |||
298 | void __init ath79_clocks_init(void) | 374 | void __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 | ||