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/init.h>
12 #include <linux/clk.h>
16 #include <asm/div64.h>
18 #include <lantiq_soc.h>
22 static unsigned int ram_clocks
[] = {
23 CLOCK_167M
, CLOCK_133M
, CLOCK_111M
, CLOCK_83M
};
24 #define DDR_HZ ram_clocks[ltq_cgu_r32(CGU_SYS) & 0x3]
26 /* legacy xway clock */
30 #define CGU_SYS_VR9 0x0c
31 #define CGU_IF_CLK_VR9 0x24
33 unsigned long ltq_danube_fpi_hz(void)
35 unsigned long ddr_clock
= DDR_HZ
;
37 if (ltq_cgu_r32(CGU_SYS
) & 0x40)
38 return ddr_clock
>> 1;
42 unsigned long ltq_danube_cpu_hz(void)
44 switch (ltq_cgu_r32(CGU_SYS
) & 0xc) {
56 unsigned long ltq_danube_pp32_hz(void)
58 unsigned int clksys
= (ltq_cgu_r32(CGU_SYS
) >> 7) & 3;
79 unsigned long ltq_ar9_sys_hz(void)
81 if (((ltq_cgu_r32(CGU_SYS
) >> 3) & 0x3) == 0x2)
86 unsigned long ltq_ar9_fpi_hz(void)
88 unsigned long sys
= ltq_ar9_sys_hz();
90 if (ltq_cgu_r32(CGU_SYS
) & BIT(0))
95 unsigned long ltq_ar9_cpu_hz(void)
97 if (ltq_cgu_r32(CGU_SYS
) & BIT(2))
98 return ltq_ar9_fpi_hz();
100 return ltq_ar9_sys_hz();
103 unsigned long ltq_vr9_cpu_hz(void)
105 unsigned int cpu_sel
;
108 cpu_sel
= (ltq_cgu_r32(CGU_SYS_VR9
) >> 4) & 0xf;
125 clk
= CLOCK_196_608M
;
143 unsigned long ltq_vr9_fpi_hz(void)
145 unsigned int ocp_sel
, cpu_clk
;
148 cpu_clk
= ltq_vr9_cpu_hz();
149 ocp_sel
= ltq_cgu_r32(CGU_SYS_VR9
) & 0x3;
162 clk
= (cpu_clk
* 2) / 5;
176 unsigned long ltq_vr9_pp32_hz(void)
178 unsigned int clksys
= (ltq_cgu_r32(CGU_SYS
) >> 16) & 3;