Skip to content

Commit 9bf5b2e

Browse files
author
Russell King
committed
ARM: Indirect round/set_rate operations through clk structure
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 3081e43 commit 9bf5b2e

9 files changed

Lines changed: 76 additions & 23 deletions

File tree

‎arch/arm/mach-integrator/impd1.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ static void impd1_setvco(struct clk *clk, struct icst_vco vco)
7171
#endif
7272
}
7373

74+
static const struct clk_ops impd1_clk_ops = {
75+
.round = icst_clk_round,
76+
.set = icst_clk_set,
77+
.setvco = impd1_setvco,
78+
};
79+
7480
void impd1_tweak_control(struct device *dev, u32 mask, u32 val)
7581
{
7682
struct impd1_module *impd1 = dev_get_drvdata(dev);
@@ -366,10 +372,10 @@ static int impd1_probe(struct lm_device *dev)
366372
(unsigned long)dev->resource.start);
367373

368374
for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++) {
375+
impd1->vcos[i].ops = &impd1_clk_ops,
369376
impd1->vcos[i].owner = THIS_MODULE,
370377
impd1->vcos[i].params = &impd1_vco_params,
371-
impd1->vcos[i].data = impd1,
372-
impd1->vcos[i].setvco = impd1_setvco;
378+
impd1->vcos[i].data = impd1;
373379
}
374380
impd1->vcos[0].vcoreg = impd1->base + IMPD1_OSC1;
375381
impd1->vcos[1].vcoreg = impd1->base + IMPD1_OSC2;

‎arch/arm/mach-integrator/include/mach/clkdev.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
#define __ASM_MACH_CLKDEV_H
33

44
#include <linux/module.h>
5-
#include <asm/hardware/icst.h>
5+
#include <plat/clock.h>
66

77
struct clk {
88
unsigned long rate;
9+
const struct clk_ops *ops;
910
struct module *owner;
1011
const struct icst_params *params;
1112
void __iomem *vcoreg;
12-
void (*setvco)(struct clk *, struct icst_vco vco);
1313
void *data;
1414
};
1515

‎arch/arm/mach-integrator/integrator_cp.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,16 @@ static void cp_auxvco_set(struct clk *clk, struct icst_vco vco)
293293
writel(0, CM_LOCK);
294294
}
295295

296+
static const struct clk_ops cp_auxclk_ops = {
297+
.round = icst_clk_round,
298+
.set = icst_clk_set,
299+
.setvco = cp_auxvco_set,
300+
};
301+
296302
static struct clk cp_auxclk = {
303+
.ops = &cp_auxclk_ops,
297304
.params = &cp_auxvco_params,
298305
.vcoreg = CM_AUXOSC,
299-
.setvco = cp_auxvco_set,
300306
};
301307

302308
static struct clk_lookup cp_lookups[] = {

‎arch/arm/mach-realview/core.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,15 @@ static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
281281
writel(0, sys_lock);
282282
}
283283

284+
static const struct clk_ops oscvco_clk_ops = {
285+
.round = icst_clk_round,
286+
.set = icst_clk_set,
287+
.setvco = realview_oscvco_set,
288+
};
289+
284290
static struct clk oscvco_clk = {
291+
.ops = &oscvco_clk_ops,
285292
.params = &realview_oscvco_params,
286-
.setvco = realview_oscvco_set,
287293
};
288294

289295
/*

‎arch/arm/mach-realview/include/mach/clkdev.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#ifndef __ASM_MACH_CLKDEV_H
22
#define __ASM_MACH_CLKDEV_H
33

4-
#include <asm/hardware/icst.h>
4+
#include <plat/clock.h>
55

66
struct clk {
77
unsigned long rate;
8+
const struct clk_ops *ops;
89
const struct icst_params *params;
910
void __iomem *vcoreg;
10-
void (*setvco)(struct clk *, struct icst_vco vco);
1111
};
1212

1313
#define __clk_get(clk) ({ 1; })

‎arch/arm/mach-versatile/core.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,15 @@ static void versatile_oscvco_set(struct clk *clk, struct icst_vco vco)
381381
writel(0, sys_lock);
382382
}
383383

384+
static const struct clk_ops osc4_clk_ops = {
385+
.round = icst_clk_round,
386+
.set = icst_clk_set,
387+
.setvco = versatile_oscvco_set,
388+
};
389+
384390
static struct clk osc4_clk = {
391+
.ops = &osc4_clk_ops,
385392
.params = &versatile_oscvco_params,
386-
.setvco = versatile_oscvco_set,
387393
};
388394

389395
/*

‎arch/arm/mach-versatile/include/mach/clkdev.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#ifndef __ASM_MACH_CLKDEV_H
22
#define __ASM_MACH_CLKDEV_H
33

4-
#include <asm/hardware/icst.h>
4+
#include <plat/clock.h>
55

66
struct clk {
77
unsigned long rate;
8+
const struct clk_ops *ops;
89
const struct icst_params *params;
910
void __iomem *vcoreg;
10-
void (*setvco)(struct clk *, struct icst_vco vco);
1111
};
1212

1313
#define __clk_get(clk) ({ 1; })

‎arch/arm/plat-versatile/clock.c‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,38 @@ EXPORT_SYMBOL(clk_get_rate);
3737

3838
long clk_round_rate(struct clk *clk, unsigned long rate)
3939
{
40-
struct icst_vco vco;
41-
vco = icst_hz_to_vco(clk->params, rate);
42-
return icst_hz(clk->params, vco);
40+
long ret = -EIO;
41+
if (clk->ops && clk->ops->round)
42+
ret = clk->ops->round(clk, rate);
43+
return ret;
4344
}
4445
EXPORT_SYMBOL(clk_round_rate);
4546

4647
int clk_set_rate(struct clk *clk, unsigned long rate)
4748
{
4849
int ret = -EIO;
49-
50-
if (clk->setvco) {
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-
}
50+
if (clk->ops && clk->ops->set)
51+
ret = clk->ops->set(clk, rate);
5852
return ret;
5953
}
6054
EXPORT_SYMBOL(clk_set_rate);
55+
56+
long 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+
}
62+
EXPORT_SYMBOL(icst_clk_round);
63+
64+
int 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+
}
74+
EXPORT_SYMBOL(icst_clk_set);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef PLAT_CLOCK_H
2+
#define PLAT_CLOCK_H
3+
4+
#include <asm/hardware/icst.h>
5+
6+
struct 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+
12+
int icst_clk_set(struct clk *, unsigned long);
13+
long icst_clk_round(struct clk *, unsigned long);
14+
15+
#endif

0 commit comments

Comments
 (0)