Commit 235d2aaa authored by Stephen Boyd's avatar Stephen Boyd Committed by Stephen Boyd

clk: axm5516: 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. Make thing simple by using the
existing clk_hw array and implementing a custom DT clk provider
get function to map the clk spec id to a clk_hw pointer.

Cc: Anders Berg <anders.berg@lsi.com>
Signed-off-by: default avatarStephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent e0d30bb9
...@@ -516,6 +516,19 @@ static struct axxia_clk *axmclk_clocks[] = { ...@@ -516,6 +516,19 @@ static struct axxia_clk *axmclk_clocks[] = {
[AXXIA_CLK_MMC] = &clk_mmc_mux.aclk, [AXXIA_CLK_MMC] = &clk_mmc_mux.aclk,
}; };
static struct clk_hw *
of_clk_axmclk_get(struct of_phandle_args *clkspec, void *unused)
{
unsigned int idx = clkspec->args[0];
if (idx >= ARRAY_SIZE(axmclk_clocks)) {
pr_err("%s: invalid index %u\n", __func__, idx);
return ERR_PTR(-EINVAL);
}
return &axmclk_clocks[idx]->hw;
}
static const struct regmap_config axmclk_regmap_config = { static const struct regmap_config axmclk_regmap_config = {
.reg_bits = 32, .reg_bits = 32,
.reg_stride = 4, .reg_stride = 4,
...@@ -530,21 +543,14 @@ static const struct of_device_id axmclk_match_table[] = { ...@@ -530,21 +543,14 @@ static const struct of_device_id axmclk_match_table[] = {
}; };
MODULE_DEVICE_TABLE(of, axmclk_match_table); MODULE_DEVICE_TABLE(of, axmclk_match_table);
struct axmclk_priv {
struct clk_onecell_data onecell;
struct clk *clks[];
};
static int axmclk_probe(struct platform_device *pdev) static int axmclk_probe(struct platform_device *pdev)
{ {
void __iomem *base; void __iomem *base;
struct resource *res; struct resource *res;
int i, ret; int i, ret;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct clk *clk;
struct regmap *regmap; struct regmap *regmap;
size_t num_clks; size_t num_clks;
struct axmclk_priv *priv;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(dev, res); base = devm_ioremap_resource(dev, res);
...@@ -557,29 +563,18 @@ static int axmclk_probe(struct platform_device *pdev) ...@@ -557,29 +563,18 @@ static int axmclk_probe(struct platform_device *pdev)
num_clks = ARRAY_SIZE(axmclk_clocks); num_clks = ARRAY_SIZE(axmclk_clocks);
pr_info("axmclk: supporting %zu clocks\n", num_clks); pr_info("axmclk: supporting %zu clocks\n", num_clks);
priv = devm_kzalloc(dev, sizeof(*priv) + sizeof(*priv->clks) * num_clks,
GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->onecell.clks = priv->clks;
priv->onecell.clk_num = num_clks;
/* Update each entry with the allocated regmap and register the clock /* Update each entry with the allocated regmap and register the clock
* with the common clock framework * with the common clock framework
*/ */
for (i = 0; i < num_clks; i++) { for (i = 0; i < num_clks; i++) {
axmclk_clocks[i]->regmap = regmap; axmclk_clocks[i]->regmap = regmap;
clk = devm_clk_register(dev, &axmclk_clocks[i]->hw); ret = devm_clk_hw_register(dev, &axmclk_clocks[i]->hw);
if (IS_ERR(clk)) if (ret)
return PTR_ERR(clk); return ret;
priv->clks[i] = clk;
} }
ret = of_clk_add_provider(dev->of_node, return of_clk_add_hw_provider(dev->of_node, of_clk_axmclk_get, NULL);
of_clk_src_onecell_get, &priv->onecell);
return ret;
} }
static int axmclk_remove(struct platform_device *pdev) static int axmclk_remove(struct platform_device *pdev)
......
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