Commit 7b38d1b2 authored by Stephen Boyd's avatar Stephen Boyd Committed by Stephen Boyd

clk: nomadik: Migrate to clk_hw based OF and registration APIs

Now that we have clk_hw based provider APIs to register clks, we
can get rid of struct clk pointers while registering clks in
these drivers, allowing us to move closer to a clear split of
consumer and provider clk APIs.
Signed-off-by: default avatarStephen Boyd <stephen.boyd@linaro.org>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 8e66cc05
...@@ -253,11 +253,11 @@ static const struct clk_ops pll_clk_ops = { ...@@ -253,11 +253,11 @@ static const struct clk_ops pll_clk_ops = {
.recalc_rate = pll_clk_recalc_rate, .recalc_rate = pll_clk_recalc_rate,
}; };
static struct clk * __init static struct clk_hw * __init
pll_clk_register(struct device *dev, const char *name, pll_clk_register(struct device *dev, const char *name,
const char *parent_name, u32 id) const char *parent_name, u32 id)
{ {
struct clk *clk; int ret;
struct clk_pll *pll; struct clk_pll *pll;
struct clk_init_data init; struct clk_init_data init;
...@@ -281,11 +281,13 @@ pll_clk_register(struct device *dev, const char *name, ...@@ -281,11 +281,13 @@ pll_clk_register(struct device *dev, const char *name,
pr_debug("register PLL1 clock \"%s\"\n", name); pr_debug("register PLL1 clock \"%s\"\n", name);
clk = clk_register(dev, &pll->hw); ret = clk_hw_register(dev, &pll->hw);
if (IS_ERR(clk)) if (ret) {
kfree(pll); kfree(pll);
return ERR_PTR(ret);
}
return clk; return &pll->hw;
} }
/* /*
...@@ -345,11 +347,11 @@ static const struct clk_ops src_clk_ops = { ...@@ -345,11 +347,11 @@ static const struct clk_ops src_clk_ops = {
.recalc_rate = src_clk_recalc_rate, .recalc_rate = src_clk_recalc_rate,
}; };
static struct clk * __init static struct clk_hw * __init
src_clk_register(struct device *dev, const char *name, src_clk_register(struct device *dev, const char *name,
const char *parent_name, u8 id) const char *parent_name, u8 id)
{ {
struct clk *clk; int ret;
struct clk_src *sclk; struct clk_src *sclk;
struct clk_init_data init; struct clk_init_data init;
...@@ -376,11 +378,13 @@ src_clk_register(struct device *dev, const char *name, ...@@ -376,11 +378,13 @@ src_clk_register(struct device *dev, const char *name,
pr_debug("register clock \"%s\" ID: %d group: %d bits: %08x\n", pr_debug("register clock \"%s\" ID: %d group: %d bits: %08x\n",
name, id, sclk->group1, sclk->clkbit); name, id, sclk->group1, sclk->clkbit);
clk = clk_register(dev, &sclk->hw); ret = clk_hw_register(dev, &sclk->hw);
if (IS_ERR(clk)) if (ret) {
kfree(sclk); kfree(sclk);
return ERR_PTR(ret);
}
return clk; return &sclk->hw;
} }
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
...@@ -508,7 +512,7 @@ device_initcall(nomadik_src_clk_init_debugfs); ...@@ -508,7 +512,7 @@ device_initcall(nomadik_src_clk_init_debugfs);
static void __init of_nomadik_pll_setup(struct device_node *np) static void __init of_nomadik_pll_setup(struct device_node *np)
{ {
struct clk *clk = ERR_PTR(-EINVAL); struct clk_hw *hw;
const char *clk_name = np->name; const char *clk_name = np->name;
const char *parent_name; const char *parent_name;
u32 pll_id; u32 pll_id;
...@@ -522,16 +526,16 @@ static void __init of_nomadik_pll_setup(struct device_node *np) ...@@ -522,16 +526,16 @@ static void __init of_nomadik_pll_setup(struct device_node *np)
return; return;
} }
parent_name = of_clk_get_parent_name(np, 0); parent_name = of_clk_get_parent_name(np, 0);
clk = pll_clk_register(NULL, clk_name, parent_name, pll_id); hw = pll_clk_register(NULL, clk_name, parent_name, pll_id);
if (!IS_ERR(clk)) if (!IS_ERR(hw))
of_clk_add_provider(np, of_clk_src_simple_get, clk); of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
} }
CLK_OF_DECLARE(nomadik_pll_clk, CLK_OF_DECLARE(nomadik_pll_clk,
"st,nomadik-pll-clock", of_nomadik_pll_setup); "st,nomadik-pll-clock", of_nomadik_pll_setup);
static void __init of_nomadik_hclk_setup(struct device_node *np) static void __init of_nomadik_hclk_setup(struct device_node *np)
{ {
struct clk *clk = ERR_PTR(-EINVAL); struct clk_hw *hw;
const char *clk_name = np->name; const char *clk_name = np->name;
const char *parent_name; const char *parent_name;
...@@ -542,20 +546,20 @@ static void __init of_nomadik_hclk_setup(struct device_node *np) ...@@ -542,20 +546,20 @@ static void __init of_nomadik_hclk_setup(struct device_node *np)
/* /*
* The HCLK divides PLL1 with 1 (passthru), 2, 3 or 4. * The HCLK divides PLL1 with 1 (passthru), 2, 3 or 4.
*/ */
clk = clk_register_divider(NULL, clk_name, parent_name, hw = clk_hw_register_divider(NULL, clk_name, parent_name,
0, src_base + SRC_CR, 0, src_base + SRC_CR,
13, 2, 13, 2,
CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO, CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
&src_lock); &src_lock);
if (!IS_ERR(clk)) if (!IS_ERR(hw))
of_clk_add_provider(np, of_clk_src_simple_get, clk); of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
} }
CLK_OF_DECLARE(nomadik_hclk_clk, CLK_OF_DECLARE(nomadik_hclk_clk,
"st,nomadik-hclk-clock", of_nomadik_hclk_setup); "st,nomadik-hclk-clock", of_nomadik_hclk_setup);
static void __init of_nomadik_src_clk_setup(struct device_node *np) static void __init of_nomadik_src_clk_setup(struct device_node *np)
{ {
struct clk *clk = ERR_PTR(-EINVAL); struct clk_hw *hw;
const char *clk_name = np->name; const char *clk_name = np->name;
const char *parent_name; const char *parent_name;
u32 clk_id; u32 clk_id;
...@@ -569,9 +573,9 @@ static void __init of_nomadik_src_clk_setup(struct device_node *np) ...@@ -569,9 +573,9 @@ static void __init of_nomadik_src_clk_setup(struct device_node *np)
return; return;
} }
parent_name = of_clk_get_parent_name(np, 0); parent_name = of_clk_get_parent_name(np, 0);
clk = src_clk_register(NULL, clk_name, parent_name, clk_id); hw = src_clk_register(NULL, clk_name, parent_name, clk_id);
if (!IS_ERR(clk)) if (!IS_ERR(hw))
of_clk_add_provider(np, of_clk_src_simple_get, clk); of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
} }
CLK_OF_DECLARE(nomadik_src_clk, CLK_OF_DECLARE(nomadik_src_clk,
"st,nomadik-src-clock", of_nomadik_src_clk_setup); "st,nomadik-src-clock", of_nomadik_src_clk_setup);
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