Thread (35 messages) 35 messages, 7 authors, 2015-01-13

Re: [RFC 07/15] clk: add DT parsing function

From: Mike Turquette <hidden>
Date: 2015-01-13 19:24:59
Also in: lkml

+Stephen Boyd

Quoting Andrzej Hajda (2014-12-10 07:48:25)
quoted hunk ↗ jump to hunk
The patch adds function for parsing Device Tree to get
clock specifier. The function could be ultimately used
by clock core.

Signed-off-by: Andrzej Hajda <redacted>
---
 drivers/clk/clkdev.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index da4bda8..bd22750 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -120,6 +120,29 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
        return clk;
 }
 EXPORT_SYMBOL(of_clk_get_by_name);
+
+static int of_get_clock_spec(struct device *dev, const char *name,
+               struct of_phandle_args *spec)
+{
+       struct device_node *np = dev->of_node;
+
+       while (np) {
+               int idx = 0;
+
+               if (name)
+                       idx = of_property_match_string(np, "clock-names", name);
+
+               if (!of_parse_phandle_with_args(np, "clocks", "#clock-cells",
+                                               idx, spec))
+                       return 0;
+
+               np = np->parent;
+               if (np && !of_get_property(np, "clock-ranges", NULL))
+                       break;
+       }
+
+       return -ENOENT;
+}
 #endif
 
 /*
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help