summary refs log tree commit diff
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorBen Dooks <ben.dooks@codethink.co.uk>2014-02-13 18:02:49 +0000
committerMike Turquette <mturquette@linaro.org>2014-02-23 12:40:20 -0800
commit7a0fc1a3df82d29e00b4c9f88a6b37450d6711f1 (patch)
tree2489148971978cbf398fea553c8ef5773e9aa121 /drivers/clk/clk.c
parent29d43ddf7355b8f93fa9b5d18a605dd8517bed71 (diff)
downloadlinux-7a0fc1a3df82d29e00b4c9f88a6b37450d6711f1.tar.gz
clk: add clock-indices support
Add a property called clock-indices to allow clock-output-names
to be used where the index used to lookup a clock is not a 1:1
mapping to the array position in the clock-output-names

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ea2ca9ff2677..a6f079d23eaa 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2496,8 +2496,12 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_count);
 const char *of_clk_get_parent_name(struct device_node *np, int index)
 {
 	struct of_phandle_args clkspec;
+	struct property *prop;
 	const char *clk_name;
+	const __be32 *vp;
+	u32 pv;
 	int rc;
+	int count;
 
 	if (index < 0)
 		return NULL;
@@ -2507,8 +2511,22 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
 	if (rc)
 		return NULL;
 
+	index = clkspec.args_count ? clkspec.args[0] : 0;
+	count = 0;
+
+	/* if there is an indices property, use it to transfer the index
+	 * specified into an array offset for the clock-output-names property.
+	 */
+	of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) {
+		if (index == pv) {
+			index = count;
+			break;
+		}
+		count++;
+	}
+
 	if (of_property_read_string_index(clkspec.np, "clock-output-names",
-					  clkspec.args_count ? clkspec.args[0] : 0,
+					  index,
 					  &clk_name) < 0)
 		clk_name = clkspec.np->name;