diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-02 11:54:47 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-07 12:46:13 +0200 |
commit | 1e414657fca5afbc02b62068a9f456cf0907ce43 (patch) | |
tree | 2b11db45925930ce43075cd17330ee312d66a34b /drivers/clk/at91/clk-system.c | |
parent | f173bcb384dde795641a990dda55893ad78c4548 (diff) | |
download | barebox-1e414657fca5afbc02b62068a9f456cf0907ce43.tar.gz barebox-1e414657fca5afbc02b62068a9f456cf0907ce43.tar.xz |
clk: introduce struct clk_hw
In Linux the ops in struct clk_ops take a struct clk_hw * argument
instead of a struct clk * argument as in barebox. With this taking
new clk drivers from Linux requires a lot of mechanical conversions.
Instead of doing this over and over again swallow the pill once and
convert the existing barebox code over to clk_hw.
The implementation is a little different from Linux. In Linux struct clk
is only known to the core clock code. In barebox struct clk is
publically known and it is embedded into struct clk_hw. This allows
us to still use struct clk members in the clock drivers which we
currently still need, because otherwise this patch would be even
bigger.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.barebox.org/20210602095507.24609-5-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clk/at91/clk-system.c')
-rw-r--r-- | drivers/clk/at91/clk-system.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c index db9d7b3d61..9a15d5b04a 100644 --- a/drivers/clk/at91/clk-system.c +++ b/drivers/clk/at91/clk-system.c @@ -17,9 +17,9 @@ #define SYSTEM_MAX_NAME_SZ 32 -#define to_clk_system(clk) container_of(clk, struct clk_system, clk) +#define to_clk_system(_hw) container_of(_hw, struct clk_system, hw) struct clk_system { - struct clk clk; + struct clk_hw hw; struct regmap *regmap; u8 id; const char *parent_name; @@ -39,9 +39,9 @@ static inline bool clk_system_ready(struct regmap *regmap, int id) return status & (1 << id) ? 1 : 0; } -static int clk_system_enable(struct clk *clk) +static int clk_system_enable(struct clk_hw *hw) { - struct clk_system *sys = to_clk_system(clk); + struct clk_system *sys = to_clk_system(hw); regmap_write(sys->regmap, AT91_PMC_SCER, 1 << sys->id); @@ -54,16 +54,16 @@ static int clk_system_enable(struct clk *clk) return 0; } -static void clk_system_disable(struct clk *clk) +static void clk_system_disable(struct clk_hw *hw) { - struct clk_system *sys = to_clk_system(clk); + struct clk_system *sys = to_clk_system(hw); regmap_write(sys->regmap, AT91_PMC_SCDR, 1 << sys->id); } -static int clk_system_is_enabled(struct clk *clk) +static int clk_system_is_enabled(struct clk_hw *hw) { - struct clk_system *sys = to_clk_system(clk); + struct clk_system *sys = to_clk_system(hw); unsigned int status; regmap_read(sys->regmap, AT91_PMC_SCSR, &status); @@ -96,20 +96,20 @@ at91_clk_register_system(struct regmap *regmap, const char *name, return ERR_PTR(-EINVAL); sys = xzalloc(sizeof(*sys)); - sys->clk.name = name; - sys->clk.ops = &system_ops; + sys->hw.clk.name = name; + sys->hw.clk.ops = &system_ops; sys->parent_name = parent_name; - sys->clk.parent_names = &sys->parent_name; - sys->clk.num_parents = 1; + sys->hw.clk.parent_names = &sys->parent_name; + sys->hw.clk.num_parents = 1; /* init.flags = CLK_SET_RATE_PARENT; */ sys->id = id; sys->regmap = regmap; - ret = bclk_register(&sys->clk); + ret = bclk_register(&sys->hw.clk); if (ret) { kfree(sys); return ERR_PTR(ret); } - return &sys->clk; + return &sys->hw.clk; } |