aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-integrator/impd1.c10
-rw-r--r--arch/arm/mach-integrator/include/mach/clkdev.h4
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c8
-rw-r--r--arch/arm/mach-realview/core.c8
-rw-r--r--arch/arm/mach-realview/include/mach/clkdev.h4
-rw-r--r--arch/arm/mach-versatile/core.c8
-rw-r--r--arch/arm/mach-versatile/include/mach/clkdev.h4
-rw-r--r--arch/arm/plat-versatile/clock.c38
-rw-r--r--arch/arm/plat-versatile/include/plat/clock.h15
9 files changed, 76 insertions, 23 deletions
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index 2f9de622d1fa..1a0ee93e4519 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -71,6 +71,12 @@ static void impd1_setvco(struct clk *clk, struct icst_vco vco)
71#endif 71#endif
72} 72}
73 73
74static const struct clk_ops impd1_clk_ops = {
75 .round = icst_clk_round,
76 .set = icst_clk_set,
77 .setvco = impd1_setvco,
78};
79
74void impd1_tweak_control(struct device *dev, u32 mask, u32 val) 80void impd1_tweak_control(struct device *dev, u32 mask, u32 val)
75{ 81{
76 struct impd1_module *impd1 = dev_get_drvdata(dev); 82 struct impd1_module *impd1 = dev_get_drvdata(dev);
@@ -366,10 +372,10 @@ static int impd1_probe(struct lm_device *dev)
366 (unsigned long)dev->resource.start); 372 (unsigned long)dev->resource.start);
367 373
368 for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++) { 374 for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++) {
375 impd1->vcos[i].ops = &impd1_clk_ops,
369 impd1->vcos[i].owner = THIS_MODULE, 376 impd1->vcos[i].owner = THIS_MODULE,
370 impd1->vcos[i].params = &impd1_vco_params, 377 impd1->vcos[i].params = &impd1_vco_params,
371 impd1->vcos[i].data = impd1, 378 impd1->vcos[i].data = impd1;
372 impd1->vcos[i].setvco = impd1_setvco;
373 } 379 }
374 impd1->vcos[0].vcoreg = impd1->base + IMPD1_OSC1; 380 impd1->vcos[0].vcoreg = impd1->base + IMPD1_OSC1;
375 impd1->vcos[1].vcoreg = impd1->base + IMPD1_OSC2; 381 impd1->vcos[1].vcoreg = impd1->base + IMPD1_OSC2;
diff --git a/arch/arm/mach-integrator/include/mach/clkdev.h b/arch/arm/mach-integrator/include/mach/clkdev.h
index ed67e8edc0d1..bfe07679faec 100644
--- a/arch/arm/mach-integrator/include/mach/clkdev.h
+++ b/arch/arm/mach-integrator/include/mach/clkdev.h
@@ -2,14 +2,14 @@
2#define __ASM_MACH_CLKDEV_H 2#define __ASM_MACH_CLKDEV_H
3 3
4#include <linux/module.h> 4#include <linux/module.h>
5#include <asm/hardware/icst.h> 5#include <plat/clock.h>
6 6
7struct clk { 7struct clk {
8 unsigned long rate; 8 unsigned long rate;
9 const struct clk_ops *ops;
9 struct module *owner; 10 struct module *owner;
10 const struct icst_params *params; 11 const struct icst_params *params;
11 void __iomem *vcoreg; 12 void __iomem *vcoreg;
12 void (*setvco)(struct clk *, struct icst_vco vco);
13 void *data; 13 void *data;
14}; 14};
15 15
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 590858004ef6..54edb6b8504f 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -293,10 +293,16 @@ static void cp_auxvco_set(struct clk *clk, struct icst_vco vco)
293 writel(0, CM_LOCK); 293 writel(0, CM_LOCK);
294} 294}
295 295
296static const struct clk_ops cp_auxclk_ops = {
297 .round = icst_clk_round,
298 .set = icst_clk_set,
299 .setvco = cp_auxvco_set,
300};
301
296static struct clk cp_auxclk = { 302static struct clk cp_auxclk = {
303 .ops = &cp_auxclk_ops,
297 .params = &cp_auxvco_params, 304 .params = &cp_auxvco_params,
298 .vcoreg = CM_AUXOSC, 305 .vcoreg = CM_AUXOSC,
299 .setvco = cp_auxvco_set,
300}; 306};
301 307
302static struct clk_lookup cp_lookups[] = { 308static struct clk_lookup cp_lookups[] = {
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 043b93bab7df..1b468bd490af 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -281,9 +281,15 @@ static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
281 writel(0, sys_lock); 281 writel(0, sys_lock);
282} 282}
283 283
284static const struct clk_ops oscvco_clk_ops = {
285 .round = icst_clk_round,
286 .set = icst_clk_set,
287 .setvco = realview_oscvco_set,
288};
289
284static struct clk oscvco_clk = { 290static struct clk oscvco_clk = {
291 .ops = &oscvco_clk_ops,
285 .params = &realview_oscvco_params, 292 .params = &realview_oscvco_params,
286 .setvco = realview_oscvco_set,
287}; 293};
288 294
289/* 295/*
diff --git a/arch/arm/mach-realview/include/mach/clkdev.h b/arch/arm/mach-realview/include/mach/clkdev.h
index baea03c9ad45..e58d0771b64e 100644
--- a/arch/arm/mach-realview/include/mach/clkdev.h
+++ b/arch/arm/mach-realview/include/mach/clkdev.h
@@ -1,13 +1,13 @@
1#ifndef __ASM_MACH_CLKDEV_H 1#ifndef __ASM_MACH_CLKDEV_H
2#define __ASM_MACH_CLKDEV_H 2#define __ASM_MACH_CLKDEV_H
3 3
4#include <asm/hardware/icst.h> 4#include <plat/clock.h>
5 5
6struct clk { 6struct clk {
7 unsigned long rate; 7 unsigned long rate;
8 const struct clk_ops *ops;
8 const struct icst_params *params; 9 const struct icst_params *params;
9 void __iomem *vcoreg; 10 void __iomem *vcoreg;
10 void (*setvco)(struct clk *, struct icst_vco vco);
11}; 11};
12 12
13#define __clk_get(clk) ({ 1; }) 13#define __clk_get(clk) ({ 1; })
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 957bbde83d34..60baba65635e 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -381,9 +381,15 @@ static void versatile_oscvco_set(struct clk *clk, struct icst_vco vco)
381 writel(0, sys_lock); 381 writel(0, sys_lock);
382} 382}
383 383
384static const struct clk_ops osc4_clk_ops = {
385 .round = icst_clk_round,
386 .set = icst_clk_set,
387 .setvco = versatile_oscvco_set,
388};
389
384static struct clk osc4_clk = { 390static struct clk osc4_clk = {
391 .ops = &osc4_clk_ops,
385 .params = &versatile_oscvco_params, 392 .params = &versatile_oscvco_params,
386 .setvco = versatile_oscvco_set,
387}; 393};
388 394
389/* 395/*
diff --git a/arch/arm/mach-versatile/include/mach/clkdev.h b/arch/arm/mach-versatile/include/mach/clkdev.h
index baea03c9ad45..e58d0771b64e 100644
--- a/arch/arm/mach-versatile/include/mach/clkdev.h
+++ b/arch/arm/mach-versatile/include/mach/clkdev.h
@@ -1,13 +1,13 @@
1#ifndef __ASM_MACH_CLKDEV_H 1#ifndef __ASM_MACH_CLKDEV_H
2#define __ASM_MACH_CLKDEV_H 2#define __ASM_MACH_CLKDEV_H
3 3
4#include <asm/hardware/icst.h> 4#include <plat/clock.h>
5 5
6struct clk { 6struct clk {
7 unsigned long rate; 7 unsigned long rate;
8 const struct clk_ops *ops;
8 const struct icst_params *params; 9 const struct icst_params *params;
9 void __iomem *vcoreg; 10 void __iomem *vcoreg;
10 void (*setvco)(struct clk *, struct icst_vco vco);
11}; 11};
12 12
13#define __clk_get(clk) ({ 1; }) 13#define __clk_get(clk) ({ 1; })
diff --git a/arch/arm/plat-versatile/clock.c b/arch/arm/plat-versatile/clock.c
index 2fa34de92325..5c8b6564fdc2 100644
--- a/arch/arm/plat-versatile/clock.c
+++ b/arch/arm/plat-versatile/clock.c
@@ -37,24 +37,38 @@ EXPORT_SYMBOL(clk_get_rate);
37 37
38long clk_round_rate(struct clk *clk, unsigned long rate) 38long clk_round_rate(struct clk *clk, unsigned long rate)
39{ 39{
40 struct icst_vco vco; 40 long ret = -EIO;
41 vco = icst_hz_to_vco(clk->params, rate); 41 if (clk->ops && clk->ops->round)
42 return icst_hz(clk->params, vco); 42 ret = clk->ops->round(clk, rate);
43 return ret;
43} 44}
44EXPORT_SYMBOL(clk_round_rate); 45EXPORT_SYMBOL(clk_round_rate);
45 46
46int clk_set_rate(struct clk *clk, unsigned long rate) 47int clk_set_rate(struct clk *clk, unsigned long rate)
47{ 48{
48 int ret = -EIO; 49 int ret = -EIO;
49 50 if (clk->ops && clk->ops->set)
50 if (clk->setvco) { 51 ret = clk->ops->set(clk, rate);
51 struct icst_vco vco;
52
53 vco = icst_hz_to_vco(clk->params, rate);
54 clk->rate = icst_hz(clk->params, vco);
55 clk->setvco(clk, vco);
56 ret = 0;
57 }
58 return ret; 52 return ret;
59} 53}
60EXPORT_SYMBOL(clk_set_rate); 54EXPORT_SYMBOL(clk_set_rate);
55
56long icst_clk_round(struct clk *clk, unsigned long rate)
57{
58 struct icst_vco vco;
59 vco = icst_hz_to_vco(clk->params, rate);
60 return icst_hz(clk->params, vco);
61}
62EXPORT_SYMBOL(icst_clk_round);
63
64int icst_clk_set(struct clk *clk, unsigned long rate)
65{
66 struct icst_vco vco;
67
68 vco = icst_hz_to_vco(clk->params, rate);
69 clk->rate = icst_hz(clk->params, vco);
70 clk->ops->setvco(clk, vco);
71
72 return 0;
73}
74EXPORT_SYMBOL(icst_clk_set);
diff --git a/arch/arm/plat-versatile/include/plat/clock.h b/arch/arm/plat-versatile/include/plat/clock.h
new file mode 100644
index 000000000000..3cfb024ccd70
--- /dev/null
+++ b/arch/arm/plat-versatile/include/plat/clock.h
@@ -0,0 +1,15 @@
1#ifndef PLAT_CLOCK_H
2#define PLAT_CLOCK_H
3
4#include <asm/hardware/icst.h>
5
6struct clk_ops {
7 long (*round)(struct clk *, unsigned long);
8 int (*set)(struct clk *, unsigned long);
9 void (*setvco)(struct clk *, struct icst_vco);
10};
11
12int icst_clk_set(struct clk *, unsigned long);
13long icst_clk_round(struct clk *, unsigned long);
14
15#endif