diff options
Diffstat (limited to 'drivers/clk/at91/clk-h32mx.c')
-rw-r--r-- | drivers/clk/at91/clk-h32mx.c | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c index e0daa4a31f..31906a9e29 100644 --- a/drivers/clk/at91/clk-h32mx.c +++ b/drivers/clk/at91/clk-h32mx.c @@ -12,25 +12,27 @@ * */ -#include <linux/clk-provider.h> -#include <linux/clkdev.h> +#include <common.h> +#include <clock.h> +#include <linux/list.h> +#include <linux/clk.h> #include <linux/clk/at91_pmc.h> -#include <linux/of.h> -#include <linux/regmap.h> -#include <linux/mfd/syscon.h> +#include <regmap.h> + #include "pmc.h" #define H32MX_MAX_FREQ 90000000 struct clk_sama5d4_h32mx { - struct clk_hw hw; + struct clk hw; struct regmap *regmap; + const char *parent; }; #define to_clk_sama5d4_h32mx(hw) container_of(hw, struct clk_sama5d4_h32mx, hw) -static unsigned long clk_sama5d4_h32mx_recalc_rate(struct clk_hw *hw, +static unsigned long clk_sama5d4_h32mx_recalc_rate(struct clk *hw, unsigned long parent_rate) { struct clk_sama5d4_h32mx *h32mxclk = to_clk_sama5d4_h32mx(hw); @@ -45,7 +47,7 @@ static unsigned long clk_sama5d4_h32mx_recalc_rate(struct clk_hw *hw, return parent_rate; } -static long clk_sama5d4_h32mx_round_rate(struct clk_hw *hw, unsigned long rate, +static long clk_sama5d4_h32mx_round_rate(struct clk *hw, unsigned long rate, unsigned long *parent_rate) { unsigned long div; @@ -62,7 +64,7 @@ static long clk_sama5d4_h32mx_round_rate(struct clk_hw *hw, unsigned long rate, return *parent_rate; } -static int clk_sama5d4_h32mx_set_rate(struct clk_hw *hw, unsigned long rate, +static int clk_sama5d4_h32mx_set_rate(struct clk *hw, unsigned long rate, unsigned long parent_rate) { struct clk_sama5d4_h32mx *h32mxclk = to_clk_sama5d4_h32mx(hw); @@ -86,40 +88,31 @@ static const struct clk_ops h32mx_ops = { .set_rate = clk_sama5d4_h32mx_set_rate, }; -static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np) +struct clk * +at91_clk_register_h32mx(struct regmap *regmap, const char *name, + const char *parent_name) { struct clk_sama5d4_h32mx *h32mxclk; - struct clk_init_data init; - const char *parent_name; - struct regmap *regmap; int ret; - regmap = syscon_node_to_regmap(of_get_parent(np)); - if (IS_ERR(regmap)) - return; - h32mxclk = kzalloc(sizeof(*h32mxclk), GFP_KERNEL); if (!h32mxclk) - return; - - parent_name = of_clk_get_parent_name(np, 0); + return ERR_PTR(-ENOMEM); - init.name = np->name; - init.ops = &h32mx_ops; - init.parent_names = parent_name ? &parent_name : NULL; - init.num_parents = parent_name ? 1 : 0; - init.flags = CLK_SET_RATE_GATE; + h32mxclk->parent = parent_name; + h32mxclk->hw.name = name; + h32mxclk->hw.ops = &h32mx_ops; + h32mxclk->hw.parent_names = &h32mxclk->parent; + h32mxclk->hw.num_parents = 1; + /* h32mxclk.hw.flags = CLK_SET_RATE_GATE; */ - h32mxclk->hw.init = &init; h32mxclk->regmap = regmap; - ret = clk_hw_register(NULL, &h32mxclk->hw); + ret = clk_register(&h32mxclk->hw); if (ret) { kfree(h32mxclk); - return; + return ERR_PTR(ret); } - of_clk_add_hw_provider(np, of_clk_hw_simple_get, &h32mxclk->hw); + return &h32mxclk->hw; } -CLK_OF_DECLARE(of_sama5d4_clk_h32mx_setup, "atmel,sama5d4-clk-h32mx", - of_sama5d4_clk_h32mx_setup); |