diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-03-13 10:19:15 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-03-28 21:03:15 +0100 |
commit | 1184234a5ed338f745ec36e425f166cf9d16ae5b (patch) | |
tree | dd4b32e35a0ffae06b184a99a3488029fe21075a /drivers/clk | |
parent | b1cc0d7fc6728acbed7360b315593c3535ce7d75 (diff) | |
download | barebox-1184234a5ed338f745ec36e425f166cf9d16ae5b.tar.gz barebox-1184234a5ed338f745ec36e425f166cf9d16ae5b.tar.xz |
clk: Add parent round/set rate for mux and gate
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk-gate.c | 2 | ||||
-rw-r--r-- | drivers/clk/clk-mux.c | 2 | ||||
-rw-r--r-- | drivers/clk/clk.c | 20 |
3 files changed, 24 insertions, 0 deletions
diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c index f356de7630..b298b193dc 100644 --- a/drivers/clk/clk-gate.c +++ b/drivers/clk/clk-gate.c @@ -77,6 +77,8 @@ static int clk_gate_is_enabled(struct clk *clk) } static struct clk_ops clk_gate_ops = { + .set_rate = clk_parent_set_rate, + .round_rate = clk_parent_round_rate, .enable = clk_gate_enable, .disable = clk_gate_disable, .is_enabled = clk_gate_is_enabled, diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c index 9dcd39c2b9..4ce86f43d1 100644 --- a/drivers/clk/clk-mux.c +++ b/drivers/clk/clk-mux.c @@ -51,6 +51,8 @@ static int clk_mux_set_parent(struct clk *clk, u8 idx) } static struct clk_ops clk_mux_ops = { + .set_rate = clk_parent_set_rate, + .round_rate = clk_parent_round_rate, .get_parent = clk_mux_get_parent, .set_parent = clk_mux_set_parent, }; diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index c67b2f4e48..0d259413a9 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -259,11 +259,31 @@ int clk_is_enabled(struct clk *clk) return clk_is_enabled(clk); } +/* + * Generic struct clk_ops callbacks + */ int clk_is_enabled_always(struct clk *clk) { return 1; } +long clk_parent_round_rate(struct clk *clk, unsigned long rate, + unsigned long *prate) +{ + if (!(clk->flags & CLK_SET_RATE_PARENT)) + return *prate; + + return clk_round_rate(clk_get_parent(clk), rate); +} + +int clk_parent_set_rate(struct clk *clk, unsigned long rate, + unsigned long parent_rate) +{ + if (!(clk->flags & CLK_SET_RATE_PARENT)) + return 0; + return clk_set_rate(clk_get_parent(clk), rate); +} + #if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER) /** * struct of_clk_provider - Clock provider registration structure |