ARM: PNX4008: provide clock enable/disable methods and initialization

Acked-by: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
Russell King 2009-11-20 11:28:59 +00:00
parent 5413f7464e
commit 0c452df9f0
2 changed files with 26 additions and 13 deletions

View File

@ -57,18 +57,19 @@ static void propagate_rate(struct clk *clk)
}
}
static inline void clk_reg_disable(struct clk *clk)
static void clk_reg_disable(struct clk *clk)
{
if (clk->enable_reg)
__raw_writel(__raw_readl(clk->enable_reg) &
~(1 << clk->enable_shift), clk->enable_reg);
}
static inline void clk_reg_enable(struct clk *clk)
static int clk_reg_enable(struct clk *clk)
{
if (clk->enable_reg)
__raw_writel(__raw_readl(clk->enable_reg) |
(1 << clk->enable_shift), clk->enable_reg);
return 0;
}
static inline void clk_reg_disable1(struct clk *clk)
@ -814,7 +815,9 @@ static void local_clk_disable(struct clk *clk)
return;
if (!(--clk->usecount)) {
if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate)
if (clk->disable)
clk->disable(clk);
else if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate)
clk->set_rate(clk, 0);
if (clk->parent)
local_clk_disable(clk->parent);
@ -832,7 +835,9 @@ static int local_clk_enable(struct clk *clk)
goto out;
}
if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
if (clk->enable)
ret = clk->enable(clk);
else if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
&& clk->user_rate)
ret = clk->set_rate(clk, clk->user_rate);
@ -960,15 +965,21 @@ static int __init clk_init(void)
for (clkp = onchip_clks; clkp < onchip_clks + ARRAY_SIZE(onchip_clks);
clkp++) {
if (((*clkp)->flags & NEEDS_INITIALIZATION)
&& ((*clkp)->set_rate)) {
(*clkp)->user_rate = (*clkp)->rate;
local_set_rate((*clkp), (*clkp)->user_rate);
if ((*clkp)->set_parent)
(*clkp)->set_parent((*clkp), (*clkp)->parent);
struct clk *clk = *clkp;
if (clk->flags & NEEDS_INITIALIZATION) {
if (clk->set_rate) {
clk->user_rate = clk->rate;
local_set_rate(clk, clk->user_rate);
if (clk->set_parent)
clk->set_parent(clk, clk->parent);
}
if (clk->enable && clk->usecount)
clk->enable(clk);
if (clk->disable && !clk->usecount)
clk->disable(clk);
}
pr_debug("%s: clock %s, rate %ld\n",
__func__, (*clkp)->name, (*clkp)->rate);
__func__, clk->name, clk->rate);
}
local_clk_enable(&ck_pll4);

View File

@ -30,6 +30,8 @@ struct clk {
u32(*round_rate) (struct clk *, u32);
int (*set_rate) (struct clk *, u32);
int (*set_parent) (struct clk * clk, struct clk * parent);
int (*enable)(struct clk *);
void (*disable)(struct clk *);
};
/* Flags */