提交 7a0fc1a3 编写于 作者: B Ben Dooks 提交者: Mike Turquette

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: NBen Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: NMike Turquette <mturquette@linaro.org>
上级 29d43ddf
...@@ -44,6 +44,23 @@ For example: ...@@ -44,6 +44,23 @@ For example:
clocks by index. The names should reflect the clock output signal clocks by index. The names should reflect the clock output signal
names for the device. names for the device.
clock-indices: If the identifyng number for the clocks in the node
is not linear from zero, then the this mapping allows
the mapping of identifiers into the clock-output-names
array.
For example, if we have two clocks <&oscillator 1> and <&oscillator 3>:
oscillator {
compatible = "myclocktype";
#clock-cells = <1>;
clock-indices = <1>, <3>;
clock-output-names = "clka", "clkb";
}
This ensures we do not have any empty nodes in clock-output-names
==Clock consumers== ==Clock consumers==
Required properties: Required properties:
......
...@@ -2496,8 +2496,12 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_count); ...@@ -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) const char *of_clk_get_parent_name(struct device_node *np, int index)
{ {
struct of_phandle_args clkspec; struct of_phandle_args clkspec;
struct property *prop;
const char *clk_name; const char *clk_name;
const __be32 *vp;
u32 pv;
int rc; int rc;
int count;
if (index < 0) if (index < 0)
return NULL; return NULL;
...@@ -2507,8 +2511,22 @@ const char *of_clk_get_parent_name(struct device_node *np, int index) ...@@ -2507,8 +2511,22 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
if (rc) if (rc)
return NULL; 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", if (of_property_read_string_index(clkspec.np, "clock-output-names",
clkspec.args_count ? clkspec.args[0] : 0, index,
&clk_name) < 0) &clk_name) < 0)
clk_name = clkspec.np->name; clk_name = clkspec.np->name;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册