@@ -3060,6 +3060,24 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
}
EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
+int of_clk_get_index(struct device_node *np, int index)
+{
+ struct of_phandle_args clkspec;
+ int rc;
+
+ if (index < 0)
+ return -EINVAL;
+
+ rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
+ &clkspec);
+ if (rc)
+ return -EINVAL;
+
+ of_node_put(clkspec.np);
+ return clkspec.args_count ? clkspec.args[0] : -EINVAL;
+}
+EXPORT_SYMBOL_GPL(of_clk_get_index);
+
struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
@@ -625,6 +625,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec,
struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data);
int of_clk_get_parent_count(struct device_node *np);
const char *of_clk_get_parent_name(struct device_node *np, int index);
+int of_clk_get_index(struct device_node *np, int index);
void of_clk_init(const struct of_device_id *matches);
of_clk_get_index can be used to retrieve the clock index/id from the device tree. This can be used in drivers to setup routing between different clock devices. Signed-off-by: Joachim Eastwood <manabian@gmail.com> --- drivers/clk/clk.c | 18 ++++++++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 19 insertions(+)