2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
10 #include <linux/export.h>
11 #include <linux/clk.h>
15 #include <asm/div64.h>
17 #include <lantiq_soc.h>
21 static unsigned int ram_clocks
[] = {
22 CLOCK_167M
, CLOCK_133M
, CLOCK_111M
, CLOCK_83M
};
23 #define DDR_HZ ram_clocks[ltq_cgu_r32(CGU_SYS) & 0x3]
25 /* legacy xway clock */
29 #define CGU_SYS_VR9 0x0c
30 #define CGU_IF_CLK_VR9 0x24
32 unsigned long ltq_danube_fpi_hz(void)
34 unsigned long ddr_clock
= DDR_HZ
;
36 if (ltq_cgu_r32(CGU_SYS
) & 0x40)
37 return ddr_clock
>> 1;
41 unsigned long ltq_danube_cpu_hz(void)
43 switch (ltq_cgu_r32(CGU_SYS
) & 0xc) {
55 unsigned long ltq_danube_pp32_hz(void)
57 unsigned int clksys
= (ltq_cgu_r32(CGU_SYS
) >> 7) & 3;
78 unsigned long ltq_ar9_sys_hz(void)
80 if (((ltq_cgu_r32(CGU_SYS
) >> 3) & 0x3) == 0x2)
85 unsigned long ltq_ar9_fpi_hz(void)
87 unsigned long sys
= ltq_ar9_sys_hz();
89 if (ltq_cgu_r32(CGU_SYS
) & BIT(0))
94 unsigned long ltq_ar9_cpu_hz(void)
96 if (ltq_cgu_r32(CGU_SYS
) & BIT(2))
97 return ltq_ar9_fpi_hz();
99 return ltq_ar9_sys_hz();
102 unsigned long ltq_vr9_cpu_hz(void)
104 unsigned int cpu_sel
;
107 cpu_sel
= (ltq_cgu_r32(CGU_SYS_VR9
) >> 4) & 0xf;
124 clk
= CLOCK_196_608M
;
142 unsigned long ltq_vr9_fpi_hz(void)
144 unsigned int ocp_sel
, cpu_clk
;
147 cpu_clk
= ltq_vr9_cpu_hz();
148 ocp_sel
= ltq_cgu_r32(CGU_SYS_VR9
) & 0x3;
161 clk
= (cpu_clk
* 2) / 5;
175 unsigned long ltq_vr9_pp32_hz(void)
177 unsigned int clksys
= (ltq_cgu_r32(CGU_SYS
) >> 16) & 3;