Skip to content

Commit d1914c7

Browse files
author
Russell King
committed
ARM: Make Integrator/Versatile/Reaview VCO code similar
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent f5fc008 commit d1914c7

7 files changed

Lines changed: 26 additions & 32 deletions

File tree

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,10 @@ static const struct icst_params impd1_vco_params = {
5555
static void impd1_setvco(struct clk *clk, struct icst_vco vco)
5656
{
5757
struct impd1_module *impd1 = clk->data;
58-
int vconr = clk - impd1->vcos;
59-
u32 val;
60-
61-
val = vco.v | (vco.r << 9) | (vco.s << 16);
58+
u32 val = vco.v | (vco.r << 9) | (vco.s << 16);
6259

6360
writel(0xa05f, impd1->base + IMPD1_LOCK);
64-
switch (vconr) {
65-
case 0:
66-
writel(val, impd1->base + IMPD1_OSC1);
67-
break;
68-
case 1:
69-
writel(val, impd1->base + IMPD1_OSC2);
70-
break;
71-
}
61+
writel(val, clk->vcoreg);
7262
writel(0, impd1->base + IMPD1_LOCK);
7363

7464
#ifdef DEBUG
@@ -381,6 +371,8 @@ static int impd1_probe(struct lm_device *dev)
381371
impd1->vcos[i].data = impd1,
382372
impd1->vcos[i].setvco = impd1_setvco;
383373
}
374+
impd1->vcos[0].vcoreg = impd1->base + IMPD1_OSC1;
375+
impd1->vcos[1].vcoreg = impd1->base + IMPD1_OSC2;
384376

385377
impd1->clks[0] = clkdev_alloc(&impd1->vcos[0], NULL, "lm%x:01000",
386378
dev->id);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ struct clk {
88
unsigned long rate;
99
struct module *owner;
1010
const struct icst_params *params;
11-
void *data;
11+
void __iomem *vcoreg;
1212
void (*setvco)(struct clk *, struct icst_vco vco);
13+
void *data;
1314
};
1415

1516
static inline int __clk_get(struct clk *clk)

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ static void __init intcp_init_irq(void)
266266
/*
267267
* Clock handling
268268
*/
269-
#define CM_LOCK IO_ADDRESS(INTEGRATOR_HDR_LOCK)
270-
#define CM_AUXOSC IO_ADDRESS(INTEGRATOR_HDR_BASE + 0x1c)
269+
#define CM_LOCK (__io_address(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_LOCK_OFFSET)
270+
#define CM_AUXOSC (__io_address(INTEGRATOR_HDR_BASE)+0x1c)
271271

272272
static const struct icst_params cp_auxvco_params = {
273273
.ref = 24000000,
@@ -285,16 +285,17 @@ static void cp_auxvco_set(struct clk *clk, struct icst_vco vco)
285285
{
286286
u32 val;
287287

288-
val = readl(CM_AUXOSC) & ~0x7ffff;
288+
val = readl(clk->vcoreg) & ~0x7ffff;
289289
val |= vco.v | (vco.r << 9) | (vco.s << 16);
290290

291291
writel(0xa05f, CM_LOCK);
292-
writel(val, CM_AUXOSC);
292+
writel(val, clk->vcoreg);
293293
writel(0, CM_LOCK);
294294
}
295295

296296
static struct clk cp_auxclk = {
297297
.params = &cp_auxvco_params,
298+
.vcoreg = CM_AUXOSC,
298299
.setvco = cp_auxvco_set,
299300
};
300301

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,13 @@ static const struct icst_params realview_oscvco_params = {
271271
static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
272272
{
273273
void __iomem *sys_lock = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LOCK_OFFSET;
274-
void __iomem *sys_osc;
275274
u32 val;
276275

277-
if (machine_is_realview_pb1176())
278-
sys_osc = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC0_OFFSET;
279-
else
280-
sys_osc = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC4_OFFSET;
281-
282-
val = readl(sys_osc) & ~0x7ffff;
276+
val = readl(clk->vcoreg) & ~0x7ffff;
283277
val |= vco.v | (vco.r << 9) | (vco.s << 16);
284278

285279
writel(0xa05f, sys_lock);
286-
writel(val, sys_osc);
280+
writel(val, clk->vcoreg);
287281
writel(0, sys_lock);
288282
}
289283

@@ -332,7 +326,13 @@ static struct clk_lookup lookups[] = {
332326

333327
static int __init clk_init(void)
334328
{
329+
if (machine_is_realview_pb1176())
330+
oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC0_OFFSET;
331+
else
332+
oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC4_OFFSET;
333+
335334
clkdev_add_table(lookups, ARRAY_SIZE(lookups));
335+
336336
return 0;
337337
}
338338
arch_initcall(clk_init);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
struct clk {
77
unsigned long rate;
88
const struct icst_params *params;
9-
u32 oscoff;
9+
void __iomem *vcoreg;
1010
void (*setvco)(struct clk *, struct icst_vco vco);
1111
};
1212

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,21 +370,19 @@ static const struct icst_params versatile_oscvco_params = {
370370

371371
static void versatile_oscvco_set(struct clk *clk, struct icst_vco vco)
372372
{
373-
void __iomem *sys = __io_address(VERSATILE_SYS_BASE);
374-
void __iomem *sys_lock = sys + VERSATILE_SYS_LOCK_OFFSET;
373+
void __iomem *sys_lock = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET;
375374
u32 val;
376375

377-
val = readl(sys + clk->oscoff) & ~0x7ffff;
376+
val = readl(clk->vcoreg) & ~0x7ffff;
378377
val |= vco.v | (vco.r << 9) | (vco.s << 16);
379378

380379
writel(0xa05f, sys_lock);
381-
writel(val, sys + clk->oscoff);
380+
writel(val, clk->vcoreg);
382381
writel(0, sys_lock);
383382
}
384383

385384
static struct clk osc4_clk = {
386385
.params = &versatile_oscvco_params,
387-
.oscoff = VERSATILE_SYS_OSCCLCD_OFFSET,
388386
.setvco = versatile_oscvco_set,
389387
};
390388

@@ -831,6 +829,8 @@ void __init versatile_init(void)
831829
{
832830
int i;
833831

832+
osc4_clk.vcoreg = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSCCLCD_OFFSET;
833+
834834
clkdev_add_table(lookups, ARRAY_SIZE(lookups));
835835

836836
platform_device_register(&versatile_flash_device);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
struct clk {
77
unsigned long rate;
88
const struct icst_params *params;
9-
u32 oscoff;
9+
void __iomem *vcoreg;
1010
void (*setvco)(struct clk *, struct icst_vco vco);
1111
};
1212

0 commit comments

Comments
 (0)