Skip to content

Commit

Permalink
sh: clkfwk: Make recalc return an unsigned long.
Browse files Browse the repository at this point in the history
This is prep work for cleaning up some of the rate propagation bits.
Trivial conversion.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Paul Mundt committed May 11, 2009
1 parent ccc1956 commit b68d820
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 175 deletions.
3 changes: 2 additions & 1 deletion arch/sh/include/asm/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct clk_ops {
void (*init)(struct clk *clk);
void (*enable)(struct clk *clk);
void (*disable)(struct clk *clk);
void (*recalc)(struct clk *clk);
unsigned long (*recalc)(struct clk *clk);
int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
int (*set_parent)(struct clk *clk, struct clk *parent);
long (*round_rate)(struct clk *clk, unsigned long rate);
Expand Down Expand Up @@ -96,4 +96,5 @@ enum clk_sh_algo_id {

IP_N1,
};

#endif /* __ASM_SH_CLOCK_H */
35 changes: 19 additions & 16 deletions arch/sh/kernel/cpu/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static struct clk *onchip_clocks[] = {
&cpu_clk,
};

/* Propagate rate to children */
static void propagate_rate(struct clk *clk)
{
struct clk *clkp;
Expand All @@ -83,7 +84,7 @@ static void propagate_rate(struct clk *clk)
if (likely(clkp->parent != clk))
continue;
if (likely(clkp->ops && clkp->ops->recalc))
clkp->ops->recalc(clkp);
clkp->rate = clkp->ops->recalc(clkp);
if (unlikely(clkp->flags & CLK_RATE_PROPAGATES))
propagate_rate(clkp);
}
Expand Down Expand Up @@ -240,7 +241,7 @@ void clk_recalc_rate(struct clk *clk)
unsigned long flags;

spin_lock_irqsave(&clock_lock, flags);
clk->ops->recalc(clk);
clk->rate = clk->ops->recalc(clk);
spin_unlock_irqrestore(&clock_lock, flags);
}

Expand Down Expand Up @@ -377,20 +378,22 @@ static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state)
switch (state.event) {
case PM_EVENT_ON:
/* Resumeing from hibernation */
if (prev_state.event == PM_EVENT_FREEZE) {
list_for_each_entry(clkp, &clock_list, node)
if (likely(clkp->ops)) {
unsigned long rate = clkp->rate;

if (likely(clkp->ops->set_parent))
clkp->ops->set_parent(clkp,
clkp->parent);
if (likely(clkp->ops->set_rate))
clkp->ops->set_rate(clkp,
rate, NO_CHANGE);
else if (likely(clkp->ops->recalc))
clkp->ops->recalc(clkp);
}
if (prev_state.event != PM_EVENT_FREEZE)
break;

list_for_each_entry(clkp, &clock_list, node) {
if (likely(clkp->ops)) {
unsigned long rate = clkp->rate;

if (likely(clkp->ops->set_parent))
clkp->ops->set_parent(clkp,
clkp->parent);
if (likely(clkp->ops->set_rate))
clkp->ops->set_rate(clkp,
rate, NO_CHANGE);
else if (likely(clkp->ops->recalc))
clkp->rate = clkp->ops->recalc(clkp);
}
}
break;
case PM_EVENT_FREEZE:
Expand Down
13 changes: 6 additions & 7 deletions arch/sh/kernel/cpu/sh2/clock-sh7619.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ static struct clk_ops sh7619_master_clk_ops = {
.init = master_clk_init,
};

static void module_clk_recalc(struct clk *clk)
static unsigned long module_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FREQCR) & 0x0007);
clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh7619_module_clk_ops = {
.recalc = module_clk_recalc,
};

static void bus_clk_recalc(struct clk *clk)
static unsigned long bus_clk_recalc(struct clk *clk)
{
clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
return clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
}

static struct clk_ops sh7619_bus_clk_ops = {
.recalc = bus_clk_recalc,
};

static void cpu_clk_recalc(struct clk *clk)
static unsigned long cpu_clk_recalc(struct clk *clk)
{
clk->rate = clk->parent->rate;
return clk->parent->rate;
}

static struct clk_ops sh7619_cpu_clk_ops = {
Expand All @@ -78,4 +78,3 @@ void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
if (idx < ARRAY_SIZE(sh7619_clk_ops))
*ops = sh7619_clk_ops[idx];
}

14 changes: 7 additions & 7 deletions arch/sh/kernel/cpu/sh2a/clock-sh7201.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,37 @@ static const int pfc_divisors[]={1,2,3,4,6,8,12};

static void master_clk_init(struct clk *clk)
{
clk->rate = 10000000 * PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
return 10000000 * PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
}

static struct clk_ops sh7201_master_clk_ops = {
.init = master_clk_init,
};

static void module_clk_recalc(struct clk *clk)
static unsigned long module_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FREQCR) & 0x0007);
clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh7201_module_clk_ops = {
.recalc = module_clk_recalc,
};

static void bus_clk_recalc(struct clk *clk)
static unsigned long bus_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FREQCR) & 0x0007);
clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh7201_bus_clk_ops = {
.recalc = bus_clk_recalc,
};

static void cpu_clk_recalc(struct clk *clk)
static unsigned long cpu_clk_recalc(struct clk *clk)
{
int idx = ((ctrl_inw(FREQCR) >> 4) & 0x0007);
clk->rate = clk->parent->rate / ifc_divisors[idx];
return clk->parent->rate / ifc_divisors[idx];
}

static struct clk_ops sh7201_cpu_clk_ops = {
Expand Down
12 changes: 6 additions & 6 deletions arch/sh/kernel/cpu/sh2a/clock-sh7203.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ static struct clk_ops sh7203_master_clk_ops = {
.init = master_clk_init,
};

static void module_clk_recalc(struct clk *clk)
static unsigned long module_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FREQCR) & 0x0007);
clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh7203_module_clk_ops = {
.recalc = module_clk_recalc,
};

static void bus_clk_recalc(struct clk *clk)
static unsigned long bus_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FREQCR) & 0x0007);
clk->rate = clk->parent->rate / pfc_divisors[idx-2];
return clk->parent->rate / pfc_divisors[idx-2];
}

static struct clk_ops sh7203_bus_clk_ops = {
.recalc = bus_clk_recalc,
};

static void cpu_clk_recalc(struct clk *clk)
static unsigned long cpu_clk_recalc(struct clk *clk)
{
clk->rate = clk->parent->rate;
return clk->parent->rate;
}

static struct clk_ops sh7203_cpu_clk_ops = {
Expand Down
12 changes: 6 additions & 6 deletions arch/sh/kernel/cpu/sh2a/clock-sh7206.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,29 @@ static struct clk_ops sh7206_master_clk_ops = {
.init = master_clk_init,
};

static void module_clk_recalc(struct clk *clk)
static unsigned long module_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FREQCR) & 0x0007);
clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh7206_module_clk_ops = {
.recalc = module_clk_recalc,
};

static void bus_clk_recalc(struct clk *clk)
static unsigned long bus_clk_recalc(struct clk *clk)
{
clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
return clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
}

static struct clk_ops sh7206_bus_clk_ops = {
.recalc = bus_clk_recalc,
};

static void cpu_clk_recalc(struct clk *clk)
static unsigned long cpu_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FREQCR) & 0x0007);
clk->rate = clk->parent->rate / ifc_divisors[idx];
return clk->parent->rate / ifc_divisors[idx];
}

static struct clk_ops sh7206_cpu_clk_ops = {
Expand Down
12 changes: 6 additions & 6 deletions arch/sh/kernel/cpu/sh3/clock-sh3.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,36 @@ static struct clk_ops sh3_master_clk_ops = {
.init = master_clk_init,
};

static void module_clk_recalc(struct clk *clk)
static unsigned long module_clk_recalc(struct clk *clk)
{
int frqcr = ctrl_inw(FRQCR);
int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);

clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh3_module_clk_ops = {
.recalc = module_clk_recalc,
};

static void bus_clk_recalc(struct clk *clk)
static unsigned long bus_clk_recalc(struct clk *clk)
{
int frqcr = ctrl_inw(FRQCR);
int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);

clk->rate = clk->parent->rate / stc_multipliers[idx];
return clk->parent->rate / stc_multipliers[idx];
}

static struct clk_ops sh3_bus_clk_ops = {
.recalc = bus_clk_recalc,
};

static void cpu_clk_recalc(struct clk *clk)
static unsigned long cpu_clk_recalc(struct clk *clk)
{
int frqcr = ctrl_inw(FRQCR);
int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);

clk->rate = clk->parent->rate / ifc_divisors[idx];
return clk->parent->rate / ifc_divisors[idx];
}

static struct clk_ops sh3_cpu_clk_ops = {
Expand Down
12 changes: 6 additions & 6 deletions arch/sh/kernel/cpu/sh3/clock-sh7705.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,30 @@ static struct clk_ops sh7705_master_clk_ops = {
.init = master_clk_init,
};

static void module_clk_recalc(struct clk *clk)
static unsigned long module_clk_recalc(struct clk *clk)
{
int idx = ctrl_inw(FRQCR) & 0x0003;
clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh7705_module_clk_ops = {
.recalc = module_clk_recalc,
};

static void bus_clk_recalc(struct clk *clk)
static unsigned long bus_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FRQCR) & 0x0300) >> 8;
clk->rate = clk->parent->rate / stc_multipliers[idx];
return clk->parent->rate / stc_multipliers[idx];
}

static struct clk_ops sh7705_bus_clk_ops = {
.recalc = bus_clk_recalc,
};

static void cpu_clk_recalc(struct clk *clk)
static unsigned long cpu_clk_recalc(struct clk *clk)
{
int idx = (ctrl_inw(FRQCR) & 0x0030) >> 4;
clk->rate = clk->parent->rate / ifc_divisors[idx];
return clk->parent->rate / ifc_divisors[idx];
}

static struct clk_ops sh7705_cpu_clk_ops = {
Expand Down
12 changes: 6 additions & 6 deletions arch/sh/kernel/cpu/sh3/clock-sh7706.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,36 @@ static struct clk_ops sh7706_master_clk_ops = {
.init = master_clk_init,
};

static void module_clk_recalc(struct clk *clk)
static unsigned long module_clk_recalc(struct clk *clk)
{
int frqcr = ctrl_inw(FRQCR);
int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);

clk->rate = clk->parent->rate / pfc_divisors[idx];
return clk->parent->rate / pfc_divisors[idx];
}

static struct clk_ops sh7706_module_clk_ops = {
.recalc = module_clk_recalc,
};

static void bus_clk_recalc(struct clk *clk)
static unsigned long bus_clk_recalc(struct clk *clk)
{
int frqcr = ctrl_inw(FRQCR);
int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);

clk->rate = clk->parent->rate / stc_multipliers[idx];
return clk->parent->rate / stc_multipliers[idx];
}

static struct clk_ops sh7706_bus_clk_ops = {
.recalc = bus_clk_recalc,
};

static void cpu_clk_recalc(struct clk *clk)
static unsigned long cpu_clk_recalc(struct clk *clk)
{
int frqcr = ctrl_inw(FRQCR);
int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);

clk->rate = clk->parent->rate / ifc_divisors[idx];
return clk->parent->rate / ifc_divisors[idx];
}

static struct clk_ops sh7706_cpu_clk_ops = {
Expand Down
Loading

0 comments on commit b68d820

Please sign in to comment.