aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/clk/clk-devres.c21
-rw-r--r--include/linux/clk.h29
2 files changed, 46 insertions, 4 deletions
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
index 8f571548870f..3a218c3a06ae 100644
--- a/drivers/clk/clk-devres.c
+++ b/drivers/clk/clk-devres.c
@@ -53,3 +53,24 @@ void devm_clk_put(struct device *dev, struct clk *clk)
53 WARN_ON(ret); 53 WARN_ON(ret);
54} 54}
55EXPORT_SYMBOL(devm_clk_put); 55EXPORT_SYMBOL(devm_clk_put);
56
57struct clk *devm_get_clk_from_child(struct device *dev,
58 struct device_node *np, const char *con_id)
59{
60 struct clk **ptr, *clk;
61
62 ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
63 if (!ptr)
64 return ERR_PTR(-ENOMEM);
65
66 clk = of_clk_get_by_name(np, con_id);
67 if (!IS_ERR(clk)) {
68 *ptr = clk;
69 devres_add(dev, ptr);
70 } else {
71 devres_free(ptr);
72 }
73
74 return clk;
75}
76EXPORT_SYMBOL(devm_get_clk_from_child);
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
19struct device; 19struct device;
20
21struct clk; 20struct clk;
21struct device_node;
22struct 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);
249struct clk *devm_clk_get(struct device *dev, const char *id); 250struct 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 */
266struct 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
453static 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
435static inline void clk_put(struct clk *clk) {} 459static inline void clk_put(struct clk *clk) {}
436 460
437static inline void devm_clk_put(struct device *dev, struct clk *clk) {} 461static 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
504struct device_node;
505struct of_phandle_args;
506
507#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) 528#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
508struct clk *of_clk_get(struct device_node *np, int index); 529struct clk *of_clk_get(struct device_node *np, int index);
509struct clk *of_clk_get_by_name(struct device_node *np, const char *name); 530struct clk *of_clk_get_by_name(struct device_node *np, const char *name);