summaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-04-13 09:51:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-04-15 12:31:23 +0200
commited82a1742aee462cc0093212ea4b8838a98fc4ef (patch)
treec17f03bb5d57c96b7be044f3d1f38d604e2fe146 /drivers/clk
parente9823e711b80a2f7a3eb0f9b592f7b15e597898e (diff)
downloadbarebox-ed82a1742aee462cc0093212ea4b8838a98fc4ef.tar.gz
barebox-ed82a1742aee462cc0093212ea4b8838a98fc4ef.tar.xz
clk: implement clk_register_fixed_rate
We lack a way to instantiate a fixed clock while specifying a parent. This is used in the at91 clock code sync with upstream in a later commit, so prepare by porting clk_register_fixed_rate. It's based on the Linux commit of the same name with the difference that it doesn't use (and thus doesn't require) a struct device_d * as first parameter. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk-fixed.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c
index 57bf36b39e..411f6fe473 100644
--- a/drivers/clk/clk-fixed.c
+++ b/drivers/clk/clk-fixed.c
@@ -37,17 +37,31 @@ static struct clk_ops clk_fixed_ops = {
.is_enabled = clk_is_enabled_always,
};
-struct clk *clk_fixed(const char *name, int rate)
+struct clk *clk_register_fixed_rate(const char *name,
+ const char *parent_name, unsigned long flags,
+ unsigned long rate)
{
struct clk_fixed *fix = xzalloc(sizeof *fix);
+ const char **parent_names = NULL;
int ret;
fix->rate = rate;
fix->clk.ops = &clk_fixed_ops;
fix->clk.name = name;
+ fix->clk.flags = flags;
+
+ if (parent_name) {
+ parent_names = kzalloc(sizeof(const char *), GFP_KERNEL);
+ if (!parent_names)
+ return ERR_PTR(-ENOMEM);
+
+ fix->clk.parent_names = parent_names;
+ fix->clk.num_parents = 1;
+ }
ret = clk_register(&fix->clk);
if (ret) {
+ free(parent_names);
free(fix);
return ERR_PTR(ret);
}