diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2016-12-05 00:23:20 -0500 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2016-12-08 19:37:33 -0500 |
commit | 71a2f11511b4d1dc8b8e326e10ec6533b534ddf1 (patch) | |
tree | e6057334500d72bc2637f811ebcb7d761bb7f135 /include/linux/clk.h | |
parent | 16cd77645bddbcee951c63b964f23826dadbfd2e (diff) |
clk: add devm_get_clk_from_child() API
Some driver is using this type of DT bindings for clock (more detail,
see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt).
sound_soc {
...
cpu {
clocks = <&xxx>;
...
};
codec {
clocks = <&xxx>;
...
};
};
Current driver in this case uses of_clk_get() for each node, but there
is no devm_of_clk_get() today.
OTOH, the problem of having devm_of_clk_get() is that it encourages the
use of of_clk_get() when clk_get() is more desirable.
Thus, this patch adds new devm_get_clk_from_chile() which explicitly
reads as get a clock from a child node of this device.
By this function, we can also use this type of DT bindings
sound_soc {
clocks = <&xxx>, <&xxx>;
clock-names = "cpu", "codec";
clock-ranges;
...
cpu {
...
};
codec {
...
};
};
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
[sboyd@codeurora.org: Rename subject to clk + add API]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'include/linux/clk.h')
-rw-r--r-- | include/linux/clk.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/include/linux/clk.h b/include/linux/clk.h index 123c02788807..e9d36b3e49de 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h | |||
@@ -17,8 +17,9 @@ | |||
17 | #include <linux/notifier.h> | 17 | #include <linux/notifier.h> |
18 | 18 | ||
19 | struct device; | 19 | struct device; |
20 | |||
21 | struct clk; | 20 | struct clk; |
21 | struct device_node; | ||
22 | struct of_phandle_args; | ||
22 | 23 | ||
23 | /** | 24 | /** |
24 | * DOC: clk notifier callback types | 25 | * DOC: clk notifier callback types |
@@ -249,6 +250,23 @@ struct clk *clk_get(struct device *dev, const char *id); | |||
249 | struct clk *devm_clk_get(struct device *dev, const char *id); | 250 | struct clk *devm_clk_get(struct device *dev, const char *id); |
250 | 251 | ||
251 | /** | 252 | /** |
253 | * devm_get_clk_from_child - lookup and obtain a managed reference to a | ||
254 | * clock producer from child node. | ||
255 | * @dev: device for clock "consumer" | ||
256 | * @np: pointer to clock consumer node | ||
257 | * @con_id: clock consumer ID | ||
258 | * | ||
259 | * This function parses the clocks, and uses them to look up the | ||
260 | * struct clk from the registered list of clock providers by using | ||
261 | * @np and @con_id | ||
262 | * | ||
263 | * The clock will automatically be freed when the device is unbound | ||
264 | * from the bus. | ||
265 | */ | ||
266 | struct clk *devm_get_clk_from_child(struct device *dev, | ||
267 | struct device_node *np, const char *con_id); | ||
268 | |||
269 | /** | ||
252 | * clk_enable - inform the system when the clock source should be running. | 270 | * clk_enable - inform the system when the clock source should be running. |
253 | * @clk: clock source | 271 | * @clk: clock source |
254 | * | 272 | * |
@@ -432,6 +450,12 @@ static inline struct clk *devm_clk_get(struct device *dev, const char *id) | |||
432 | return NULL; | 450 | return NULL; |
433 | } | 451 | } |
434 | 452 | ||
453 | static inline struct clk *devm_get_clk_from_child(struct device *dev, | ||
454 | struct device_node *np, const char *con_id) | ||
455 | { | ||
456 | return NULL; | ||
457 | } | ||
458 | |||
435 | static inline void clk_put(struct clk *clk) {} | 459 | static inline void clk_put(struct clk *clk) {} |
436 | 460 | ||
437 | static inline void devm_clk_put(struct device *dev, struct clk *clk) {} | 461 | static inline void devm_clk_put(struct device *dev, struct clk *clk) {} |
@@ -501,9 +525,6 @@ static inline void clk_disable_unprepare(struct clk *clk) | |||
501 | clk_unprepare(clk); | 525 | clk_unprepare(clk); |
502 | } | 526 | } |
503 | 527 | ||
504 | struct device_node; | ||
505 | struct of_phandle_args; | ||
506 | |||
507 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) | 528 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) |
508 | struct clk *of_clk_get(struct device_node *np, int index); | 529 | struct clk *of_clk_get(struct device_node *np, int index); |
509 | struct clk *of_clk_get_by_name(struct device_node *np, const char *name); | 530 | struct clk *of_clk_get_by_name(struct device_node *np, const char *name); |