diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2013-11-09 14:24:21 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-11-11 09:26:59 +0100 |
commit | 56dec39e686b0a69f1ac329dc3085174b954c5a5 (patch) | |
tree | 8eebd84d9c8dad05c7c5c9d63c3bb7b6c8e6dd9d /drivers/clk/clk-fixed.c | |
parent | a7d8384d12c6fe632e1cb013bb7ce8eeaf01a592 (diff) | |
download | barebox-56dec39e686b0a69f1ac329dc3085174b954c5a5.tar.gz barebox-56dec39e686b0a69f1ac329dc3085174b954c5a5.tar.xz |
clk: fixed: add DT init function
This adds a DT init function to clk-fixed and corresponding CLK_OF_DECLARE
to put it into the DT clock provider table.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clk/clk-fixed.c')
-rw-r--r-- | drivers/clk/clk-fixed.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c index e5d36b4ffa..3a38865fbe 100644 --- a/drivers/clk/clk-fixed.c +++ b/drivers/clk/clk-fixed.c @@ -54,3 +54,26 @@ struct clk *clk_fixed(const char *name, int rate) return &fix->clk; } + +#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER) +/** + * of_fixed_clk_setup() - Setup function for simple fixed rate clock + */ +static int of_fixed_clk_setup(struct device_node *node) +{ + struct clk *clk; + const char *clk_name = node->name; + u32 rate; + + if (of_property_read_u32(node, "clock-frequency", &rate)) + return -EINVAL; + + of_property_read_string(node, "clock-output-names", &clk_name); + + clk = clk_fixed(clk_name, rate); + if (IS_ERR(clk)) + return IS_ERR(clk); + return of_clk_add_provider(node, of_clk_src_simple_get, clk); +} +CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup); +#endif |