aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-08-22 09:36:27 -0400
committerMike Turquette <mturquette@linaro.org>2012-09-07 21:30:19 -0400
commit494bfec99922d54054d2d0873f1017680cfc3f13 (patch)
tree45697d25099ec0a8790ab77451254d29b2b6ce21
parent09b9b2b204751fc23d245d57d420f4973db22a67 (diff)
clk: add of_clk_src_onecell_get() support
For those SoCs that have hundreds of clock outputs, their clock DT bindings could reasonably define #clock-cells as 1 and require the client device specify the index of the clock it consumes in the cell of its "clocks" phandle. Add a generic of_clk_src_onecell_get() function for this purpose. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Reviewed-by: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--drivers/clk/clk.c14
-rw-r--r--include/linux/clk-provider.h5
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index d9cbae06549..56e4495ebeb 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1587,6 +1587,20 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec,
1587} 1587}
1588EXPORT_SYMBOL_GPL(of_clk_src_simple_get); 1588EXPORT_SYMBOL_GPL(of_clk_src_simple_get);
1589 1589
1590struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data)
1591{
1592 struct clk_onecell_data *clk_data = data;
1593 unsigned int idx = clkspec->args[0];
1594
1595 if (idx >= clk_data->clk_num) {
1596 pr_err("%s: invalid clock index %d\n", __func__, idx);
1597 return ERR_PTR(-EINVAL);
1598 }
1599
1600 return clk_data->clks[idx];
1601}
1602EXPORT_SYMBOL_GPL(of_clk_src_onecell_get);
1603
1590/** 1604/**
1591 * of_clk_add_provider() - Register a clock provider for a node 1605 * of_clk_add_provider() - Register a clock provider for a node
1592 * @np: Device node pointer associated with clock provider 1606 * @np: Device node pointer associated with clock provider
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 1b15307cd46..c1273158292 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -361,6 +361,11 @@ int of_clk_add_provider(struct device_node *np,
361void of_clk_del_provider(struct device_node *np); 361void of_clk_del_provider(struct device_node *np);
362struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, 362struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec,
363 void *data); 363 void *data);
364struct clk_onecell_data {
365 struct clk **clks;
366 unsigned int clk_num;
367};
368struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data);
364const char *of_clk_get_parent_name(struct device_node *np, int index); 369const char *of_clk_get_parent_name(struct device_node *np, int index);
365void of_clk_init(const struct of_device_id *matches); 370void of_clk_init(const struct of_device_id *matches);
366 371