Commit 91c0c979 authored by Paul Walmsley's avatar Paul Walmsley Committed by Tony Lindgren

OMAP2/3 clock: simplify omap2_clksel_get_src_field()

Get rid of void __iomem * usage in omap2_clksel_get_src_field.
Prepend the function name with an underscore to highlight that it is a
static function.
Signed-off-by: default avatarPaul Walmsley <paul@pwsan.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent af0ea23f
...@@ -803,18 +803,14 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate) ...@@ -803,18 +803,14 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate)
/* /*
* Converts encoded control register address into a full address * Converts encoded control register address into a full address
* On error, *src_addr will be returned as 0. * On error, the return value (parent_div) will be 0.
*/ */
static u32 omap2_clksel_get_src_field(void __iomem **src_addr, static u32 _omap2_clksel_get_src_field(struct clk *src_clk, struct clk *clk,
struct clk *src_clk, u32 *field_mask, u32 *field_val)
struct clk *clk, u32 *parent_div)
{ {
const struct clksel *clks; const struct clksel *clks;
const struct clksel_rate *clkr; const struct clksel_rate *clkr;
*parent_div = 0;
*src_addr = NULL;
clks = omap2_get_clksel_by_parent(clk, src_clk); clks = omap2_get_clksel_by_parent(clk, src_clk);
if (!clks) if (!clks)
return 0; return 0;
...@@ -834,17 +830,14 @@ static u32 omap2_clksel_get_src_field(void __iomem **src_addr, ...@@ -834,17 +830,14 @@ static u32 omap2_clksel_get_src_field(void __iomem **src_addr,
/* Should never happen. Add a clksel mask to the struct clk. */ /* Should never happen. Add a clksel mask to the struct clk. */
WARN_ON(clk->clksel_mask == 0); WARN_ON(clk->clksel_mask == 0);
*field_mask = clk->clksel_mask; *field_val = clkr->val;
*src_addr = clk->clksel_reg;
*parent_div = clkr->div;
return clkr->val; return clkr->div;
} }
int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent) int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
{ {
void __iomem *src_addr; u32 field_val, v, parent_div;
u32 field_val, field_mask, v, parent_div;
if (clk->flags & CONFIG_PARTICIPANT) if (clk->flags & CONFIG_PARTICIPANT)
return -EINVAL; return -EINVAL;
...@@ -852,18 +845,18 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent) ...@@ -852,18 +845,18 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
if (!clk->clksel) if (!clk->clksel)
return -EINVAL; return -EINVAL;
field_val = omap2_clksel_get_src_field(&src_addr, new_parent, parent_div = _omap2_clksel_get_src_field(new_parent, clk, &field_val);
&field_mask, clk, &parent_div); if (!parent_div)
if (src_addr == NULL)
return -EINVAL; return -EINVAL;
if (clk->usecount > 0) if (clk->usecount > 0)
_omap2_clk_disable(clk); _omap2_clk_disable(clk);
/* Set new source value (previous dividers if any in effect) */ /* Set new source value (previous dividers if any in effect) */
v = __raw_readl(src_addr) & ~field_mask; v = __raw_readl(clk->clksel_reg);
v |= (field_val << __ffs(field_mask)); v &= ~clk->clksel_mask;
__raw_writel(v, src_addr); v |= field_val << __ffs(clk->clksel_mask);
__raw_writel(v, clk->clksel_reg);
wmb(); wmb();
if (clk->flags & DELAYED_APP && cpu_is_omap24xx()) { if (clk->flags & DELAYED_APP && cpu_is_omap24xx()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment