diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-10-12 16:14:28 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-12-15 09:42:49 +0100 |
commit | 384d977d74f434ea089e9419fa9233fcfa18602b (patch) | |
tree | 65b8b046b4f4a4113b13d3545a50def1ec9114f5 | |
parent | 179c8fb3c2a6cc86cc746e6d071be00f611328de (diff) | |
download | linux-384d977d74f434ea089e9419fa9233fcfa18602b.tar.bz2 |
clk: versatile-icst: refactor to allocate regmap separately
Break out the registration function so it creates a regmap and
pass to the setup function, so the latter can be shared with
a device tree probe function that already has a regmap.
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/clk/versatile/clk-icst.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c index 80e955ac6ef5..87bd4667b126 100644 --- a/drivers/clk/versatile/clk-icst.c +++ b/drivers/clk/versatile/clk-icst.c @@ -20,6 +20,7 @@ #include <linux/clk-provider.h> #include <linux/io.h> #include <linux/regmap.h> +#include <linux/mfd/syscon.h> #include "clk-icst.h" @@ -140,21 +141,16 @@ static const struct clk_ops icst_ops = { .set_rate = icst_set_rate, }; -struct clk *icst_clk_register(struct device *dev, - const struct clk_icst_desc *desc, - const char *name, - const char *parent_name, - void __iomem *base) +static struct clk *icst_clk_setup(struct device *dev, + const struct clk_icst_desc *desc, + const char *name, + const char *parent_name, + struct regmap *map) { struct clk *clk; struct clk_icst *icst; struct clk_init_data init; struct icst_params *pclone; - struct regmap_config icst_regmap_conf = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, - }; icst = kzalloc(sizeof(struct clk_icst), GFP_KERNEL); if (!icst) { @@ -174,15 +170,7 @@ struct clk *icst_clk_register(struct device *dev, init.flags = CLK_IS_ROOT; init.parent_names = (parent_name ? &parent_name : NULL); init.num_parents = (parent_name ? 1 : 0); - icst->map = regmap_init_mmio(dev, base, &icst_regmap_conf); - if (IS_ERR(icst->map)) { - int ret; - - pr_err("could not initialize ICST regmap\n"); - ret = PTR_ERR(icst->map); - kfree(icst); - return ERR_PTR(ret); - } + icst->map = map; icst->hw.init = &init; icst->params = pclone; icst->vcoreg_off = desc->vco_offset; @@ -196,4 +184,25 @@ struct clk *icst_clk_register(struct device *dev, return clk; } + +struct clk *icst_clk_register(struct device *dev, + const struct clk_icst_desc *desc, + const char *name, + const char *parent_name, + void __iomem *base) +{ + struct regmap_config icst_regmap_conf = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + }; + struct regmap *map; + + map = regmap_init_mmio(dev, base, &icst_regmap_conf); + if (IS_ERR(map)) { + pr_err("could not initialize ICST regmap\n"); + return ERR_CAST(map); + } + return icst_clk_setup(dev, desc, name, parent_name, map); +} EXPORT_SYMBOL_GPL(icst_clk_register); |