aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2013-01-19 03:54:24 -0500
committerJohn Crispin <blogic@openwrt.org>2013-02-16 18:15:17 -0500
commit740c606e8e79c3e3800afbc32b4e6123da403d6c (patch)
treed8fad6b56dcdcdfba522011bab2e114d221ba6a3 /arch/mips
parent3d18c17e4f1699c3a4f47d2483c5d4c3ab3a242b (diff)
MIPS: lantiq: adds static clock for PP32
The Lantiq DSL SoCs have an internal networking processor. Add code to read the static clock rate. Signed-off-by: John Crispin <blogic@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4815/
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/include/asm/mach-lantiq/lantiq.h1
-rw-r--r--arch/mips/lantiq/clk.c12
-rw-r--r--arch/mips/lantiq/clk.h7
-rw-r--r--arch/mips/lantiq/falcon/sysctrl.c4
-rw-r--r--arch/mips/lantiq/xway/clk.c43
-rw-r--r--arch/mips/lantiq/xway/sysctrl.c12
6 files changed, 69 insertions, 10 deletions
diff --git a/arch/mips/include/asm/mach-lantiq/lantiq.h b/arch/mips/include/asm/mach-lantiq/lantiq.h
index 5e8a6e965756..76be7a09b9aa 100644
--- a/arch/mips/include/asm/mach-lantiq/lantiq.h
+++ b/arch/mips/include/asm/mach-lantiq/lantiq.h
@@ -41,6 +41,7 @@ extern void clk_deactivate(struct clk *clk);
41extern struct clk *clk_get_cpu(void); 41extern struct clk *clk_get_cpu(void);
42extern struct clk *clk_get_fpi(void); 42extern struct clk *clk_get_fpi(void);
43extern struct clk *clk_get_io(void); 43extern struct clk *clk_get_io(void);
44extern struct clk *clk_get_ppe(void);
44 45
45/* find out what bootsource we have */ 46/* find out what bootsource we have */
46extern unsigned char ltq_boot_select(void); 47extern unsigned char ltq_boot_select(void);
diff --git a/arch/mips/lantiq/clk.c b/arch/mips/lantiq/clk.c
index ce2f129b081f..d90356004027 100644
--- a/arch/mips/lantiq/clk.c
+++ b/arch/mips/lantiq/clk.c
@@ -26,13 +26,15 @@
26#include "prom.h" 26#include "prom.h"
27 27
28/* lantiq socs have 3 static clocks */ 28/* lantiq socs have 3 static clocks */
29static struct clk cpu_clk_generic[3]; 29static struct clk cpu_clk_generic[4];
30 30
31void clkdev_add_static(unsigned long cpu, unsigned long fpi, unsigned long io) 31void clkdev_add_static(unsigned long cpu, unsigned long fpi,
32 unsigned long io, unsigned long ppe)
32{ 33{
33 cpu_clk_generic[0].rate = cpu; 34 cpu_clk_generic[0].rate = cpu;
34 cpu_clk_generic[1].rate = fpi; 35 cpu_clk_generic[1].rate = fpi;
35 cpu_clk_generic[2].rate = io; 36 cpu_clk_generic[2].rate = io;
37 cpu_clk_generic[3].rate = ppe;
36} 38}
37 39
38struct clk *clk_get_cpu(void) 40struct clk *clk_get_cpu(void)
@@ -51,6 +53,12 @@ struct clk *clk_get_io(void)
51 return &cpu_clk_generic[2]; 53 return &cpu_clk_generic[2];
52} 54}
53 55
56struct clk *clk_get_ppe(void)
57{
58 return &cpu_clk_generic[3];
59}
60EXPORT_SYMBOL_GPL(clk_get_ppe);
61
54static inline int clk_good(struct clk *clk) 62static inline int clk_good(struct clk *clk)
55{ 63{
56 return clk && !IS_ERR(clk); 64 return clk && !IS_ERR(clk);
diff --git a/arch/mips/lantiq/clk.h b/arch/mips/lantiq/clk.h
index fa670602b91b..77e4bdb1fe8c 100644
--- a/arch/mips/lantiq/clk.h
+++ b/arch/mips/lantiq/clk.h
@@ -27,12 +27,15 @@
27#define CLOCK_167M 166666667 27#define CLOCK_167M 166666667
28#define CLOCK_196_608M 196608000 28#define CLOCK_196_608M 196608000
29#define CLOCK_200M 200000000 29#define CLOCK_200M 200000000
30#define CLOCK_222M 222000000
31#define CLOCK_240M 240000000
30#define CLOCK_250M 250000000 32#define CLOCK_250M 250000000
31#define CLOCK_266M 266666666 33#define CLOCK_266M 266666666
32#define CLOCK_300M 300000000 34#define CLOCK_300M 300000000
33#define CLOCK_333M 333333333 35#define CLOCK_333M 333333333
34#define CLOCK_393M 393215332 36#define CLOCK_393M 393215332
35#define CLOCK_400M 400000000 37#define CLOCK_400M 400000000
38#define CLOCK_450M 450000000
36#define CLOCK_500M 500000000 39#define CLOCK_500M 500000000
37#define CLOCK_600M 600000000 40#define CLOCK_600M 600000000
38 41
@@ -64,15 +67,17 @@ struct clk {
64}; 67};
65 68
66extern void clkdev_add_static(unsigned long cpu, unsigned long fpi, 69extern void clkdev_add_static(unsigned long cpu, unsigned long fpi,
67 unsigned long io); 70 unsigned long io, unsigned long ppe);
68 71
69extern unsigned long ltq_danube_cpu_hz(void); 72extern unsigned long ltq_danube_cpu_hz(void);
70extern unsigned long ltq_danube_fpi_hz(void); 73extern unsigned long ltq_danube_fpi_hz(void);
74extern unsigned long ltq_danube_pp32_hz(void);
71 75
72extern unsigned long ltq_ar9_cpu_hz(void); 76extern unsigned long ltq_ar9_cpu_hz(void);
73extern unsigned long ltq_ar9_fpi_hz(void); 77extern unsigned long ltq_ar9_fpi_hz(void);
74 78
75extern unsigned long ltq_vr9_cpu_hz(void); 79extern unsigned long ltq_vr9_cpu_hz(void);
76extern unsigned long ltq_vr9_fpi_hz(void); 80extern unsigned long ltq_vr9_fpi_hz(void);
81extern unsigned long ltq_vr9_pp32_hz(void);
77 82
78#endif 83#endif
diff --git a/arch/mips/lantiq/falcon/sysctrl.c b/arch/mips/lantiq/falcon/sysctrl.c
index 2d4ced332b37..ff4894a833ee 100644
--- a/arch/mips/lantiq/falcon/sysctrl.c
+++ b/arch/mips/lantiq/falcon/sysctrl.c
@@ -241,9 +241,9 @@ void __init ltq_soc_init(void)
241 241
242 /* get our 3 static rates for cpu, fpi and io clocks */ 242 /* get our 3 static rates for cpu, fpi and io clocks */
243 if (ltq_sys1_r32(SYS1_CPU0CC) & CPU0CC_CPUDIV) 243 if (ltq_sys1_r32(SYS1_CPU0CC) & CPU0CC_CPUDIV)
244 clkdev_add_static(CLOCK_200M, CLOCK_100M, CLOCK_200M); 244 clkdev_add_static(CLOCK_200M, CLOCK_100M, CLOCK_200M, 0);
245 else 245 else
246 clkdev_add_static(CLOCK_400M, CLOCK_100M, CLOCK_200M); 246 clkdev_add_static(CLOCK_400M, CLOCK_100M, CLOCK_200M, 0);
247 247
248 /* add our clock domains */ 248 /* add our clock domains */
249 clkdev_add_sys("1d810000.gpio", SYSCTL_SYSETH, ACTS_P0); 249 clkdev_add_sys("1d810000.gpio", SYSCTL_SYSETH, ACTS_P0);
diff --git a/arch/mips/lantiq/xway/clk.c b/arch/mips/lantiq/xway/clk.c
index 9aa17f79a742..1ab576dc9bd1 100644
--- a/arch/mips/lantiq/xway/clk.c
+++ b/arch/mips/lantiq/xway/clk.c
@@ -53,6 +53,29 @@ unsigned long ltq_danube_cpu_hz(void)
53 } 53 }
54} 54}
55 55
56unsigned long ltq_danube_pp32_hz(void)
57{
58 unsigned int clksys = (ltq_cgu_r32(CGU_SYS) >> 7) & 3;
59 unsigned long clk;
60
61 switch (clksys) {
62 case 1:
63 clk = CLOCK_240M;
64 break;
65 case 2:
66 clk = CLOCK_222M;
67 break;
68 case 3:
69 clk = CLOCK_133M;
70 break;
71 default:
72 clk = CLOCK_266M;
73 break;
74 }
75
76 return clk;
77}
78
56unsigned long ltq_ar9_sys_hz(void) 79unsigned long ltq_ar9_sys_hz(void)
57{ 80{
58 if (((ltq_cgu_r32(CGU_SYS) >> 3) & 0x3) == 0x2) 81 if (((ltq_cgu_r32(CGU_SYS) >> 3) & 0x3) == 0x2)
@@ -149,3 +172,23 @@ unsigned long ltq_vr9_fpi_hz(void)
149 172
150 return clk; 173 return clk;
151} 174}
175
176unsigned long ltq_vr9_pp32_hz(void)
177{
178 unsigned int clksys = (ltq_cgu_r32(CGU_SYS) >> 16) & 3;
179 unsigned long clk;
180
181 switch (clksys) {
182 case 1:
183 clk = CLOCK_450M;
184 break;
185 case 2:
186 clk = CLOCK_300M;
187 break;
188 default:
189 clk = CLOCK_500M;
190 break;
191 }
192
193 return clk;
194}
diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
index 1aaa726aad47..3390fcd6ee56 100644
--- a/arch/mips/lantiq/xway/sysctrl.c
+++ b/arch/mips/lantiq/xway/sysctrl.c
@@ -356,14 +356,16 @@ void __init ltq_soc_init(void)
356 356
357 if (of_machine_is_compatible("lantiq,ase")) { 357 if (of_machine_is_compatible("lantiq,ase")) {
358 if (ltq_cgu_r32(CGU_SYS) & (1 << 5)) 358 if (ltq_cgu_r32(CGU_SYS) & (1 << 5))
359 clkdev_add_static(CLOCK_266M, CLOCK_133M, CLOCK_133M); 359 clkdev_add_static(CLOCK_266M, CLOCK_133M,
360 CLOCK_133M, CLOCK_266M);
360 else 361 else
361 clkdev_add_static(CLOCK_133M, CLOCK_133M, CLOCK_133M); 362 clkdev_add_static(CLOCK_133M, CLOCK_133M,
363 CLOCK_133M, CLOCK_133M);
362 clkdev_add_cgu("1e180000.etop", "ephycgu", CGU_EPHY), 364 clkdev_add_cgu("1e180000.etop", "ephycgu", CGU_EPHY),
363 clkdev_add_pmu("1e180000.etop", "ephy", 0, PMU_EPHY); 365 clkdev_add_pmu("1e180000.etop", "ephy", 0, PMU_EPHY);
364 } else if (of_machine_is_compatible("lantiq,vr9")) { 366 } else if (of_machine_is_compatible("lantiq,vr9")) {
365 clkdev_add_static(ltq_vr9_cpu_hz(), ltq_vr9_fpi_hz(), 367 clkdev_add_static(ltq_vr9_cpu_hz(), ltq_vr9_fpi_hz(),
366 ltq_vr9_fpi_hz()); 368 ltq_vr9_fpi_hz(), ltq_vr9_pp32_hz());
367 clkdev_add_pmu("1d900000.pcie", "phy", 1, PMU1_PCIE_PHY); 369 clkdev_add_pmu("1d900000.pcie", "phy", 1, PMU1_PCIE_PHY);
368 clkdev_add_pmu("1d900000.pcie", "bus", 0, PMU_PCIE_CLK); 370 clkdev_add_pmu("1d900000.pcie", "bus", 0, PMU_PCIE_CLK);
369 clkdev_add_pmu("1d900000.pcie", "msi", 1, PMU1_PCIE_MSI); 371 clkdev_add_pmu("1d900000.pcie", "msi", 1, PMU1_PCIE_MSI);
@@ -376,10 +378,10 @@ void __init ltq_soc_init(void)
376 PMU_PPE_QSB | PMU_PPE_TOP); 378 PMU_PPE_QSB | PMU_PPE_TOP);
377 } else if (of_machine_is_compatible("lantiq,ar9")) { 379 } else if (of_machine_is_compatible("lantiq,ar9")) {
378 clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(), 380 clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(),
379 ltq_ar9_fpi_hz()); 381 ltq_ar9_fpi_hz(), CLOCK_250M);
380 clkdev_add_pmu("1e180000.etop", "switch", 0, PMU_SWITCH); 382 clkdev_add_pmu("1e180000.etop", "switch", 0, PMU_SWITCH);
381 } else { 383 } else {
382 clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(), 384 clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(),
383 ltq_danube_fpi_hz()); 385 ltq_danube_fpi_hz(), ltq_danube_pp32_hz());
384 } 386 }
385} 387}