summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-02-23 22:05:56 +0100
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-03-09 01:40:19 +0100
commit4919682a8877c82b0b3893016630a29c7d863bad (patch)
tree312150b4d2bb932f628c47a47f33f2e64f45cccf /drivers
parentc1549925c561ccf4f1ce5ffd7ba7ddca9b5da53c (diff)
clk: clk-uclass: add clk_get_by_output_name
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/clk/clk-uclass.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 6fcfd6997c..a6a65b2a66 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -10,6 +10,7 @@
#include <clk.h>
#include <clk-uclass.h>
#include <dm.h>
+#include <dm/uclass-internal.h>
#include <dt-structs.h>
#include <errno.h>
@@ -113,6 +114,35 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
return clk_get_by_index(dev, index, clk);
}
+
+int clk_get_by_output_name(const char *output_name, struct clk *clk)
+{
+ struct udevice *dev;
+ int idx;
+ int ret;
+
+ debug("%s(output=%s, clk==%p)\n", __func__, output_name, clk);
+
+ /* Try to find the clock among the already registered devices */
+ for (ret = uclass_find_first_device(UCLASS_CLK, &dev); dev;
+ ret = uclass_find_next_device(&dev)) {
+ if (ret)
+ continue;
+
+ idx = fdt_stringlist_search(gd->fdt_blob,
+ dev_of_offset(dev),
+ "clock-output-names",
+ output_name);
+ if (idx < 0)
+ continue;
+
+ clk->dev = dev;
+ clk->id = idx;
+ return idx;
+ }
+
+ return -ENOENT;
+}
#endif /* OF_CONTROL */
int clk_request(struct udevice *dev, struct clk *clk)