diff options
Diffstat (limited to 'drivers/clk/clk-fixed.c')
-rw-r--r-- | drivers/clk/clk-fixed.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c index 57bf36b39e..6ec2feb84f 100644 --- a/drivers/clk/clk-fixed.c +++ b/drivers/clk/clk-fixed.c @@ -1,18 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * clk-fixed.c - generic barebox clock support. Based on Linux clk support * * Copyright (c) 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #include <common.h> #include <malloc.h> @@ -20,14 +10,14 @@ #include <linux/err.h> struct clk_fixed { - struct clk clk; + struct clk_hw hw; unsigned long rate; }; -static unsigned long clk_fixed_recalc_rate(struct clk *clk, +static unsigned long clk_fixed_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { - struct clk_fixed *fix = container_of(clk, struct clk_fixed, clk); + struct clk_fixed *fix = container_of(hw, struct clk_fixed, hw); return fix->rate; } @@ -37,22 +27,48 @@ 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->hw.clk.ops = &clk_fixed_ops; + fix->hw.clk.name = name; + fix->hw.clk.flags = flags; + + if (parent_name) { + parent_names = kzalloc(sizeof(const char *), GFP_KERNEL); + if (!parent_names) + return ERR_PTR(-ENOMEM); + + parent_names[0] = strdup(parent_name); + if (!parent_names[0]) + return ERR_PTR(-ENOMEM); - ret = clk_register(&fix->clk); + fix->hw.clk.parent_names = parent_names; + fix->hw.clk.num_parents = 1; + } + + ret = bclk_register(&fix->hw.clk); if (ret) { + free(parent_names); free(fix); return ERR_PTR(ret); } - return &fix->clk; + return &fix->hw.clk; +} + +struct clk_hw *clk_hw_register_fixed_rate(struct device *dev, + const char *name, const char *parent_name, + unsigned long flags, unsigned long rate) +{ + return clk_to_clk_hw(clk_register_fixed_rate(xstrdup(name), parent_name, + flags, rate)); } /** |