aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2018-04-16 13:26:09 -0400
committerTony Lindgren <tony@atomide.com>2018-04-30 15:04:51 -0400
commit8b2830ba170356aed364ae145ca86120f510ec41 (patch)
tree1798c596e3e95485be7fa2ec9b7ea7317c31b1d4
parentc4bebea8c5fd7d94dc7ef60ac208a0668ba43796 (diff)
bus: ti-sysc: Make child clock alias handling more generic
In order to prepare supporting clkctrl optional clocks, we need to make the current child clock handling more generic so we can use the clock role names for the optional clocks in the following patch. Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--drivers/bus/ti-sysc.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 25c0e4ae9f1d..e12d1580f21d 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -811,29 +811,38 @@ static int sysc_init_syss_mask(struct sysc *ddata)
811} 811}
812 812
813/* 813/*
814 * Many child device drivers need to have fck available to get the clock 814 * Many child device drivers need to have fck and opt clocks available
815 * rate for device internal configuration. 815 * to get the clock rate for device internal configuration etc.
816 */ 816 */
817static int sysc_child_add_fck(struct sysc *ddata, 817static int sysc_child_add_named_clock(struct sysc *ddata,
818 struct device *child) 818 struct device *child,
819 const char *name)
819{ 820{
820 struct clk *fck; 821 struct clk *clk;
821 struct clk_lookup *l; 822 struct clk_lookup *l;
822 const char *name = clock_names[SYSC_FCK]; 823 int error = 0;
823 824
824 if (IS_ERR_OR_NULL(ddata->clocks[SYSC_FCK])) 825 if (!name)
825 return 0; 826 return 0;
826 827
827 fck = clk_get(child, name); 828 clk = clk_get(child, name);
828 if (!IS_ERR(fck)) { 829 if (!IS_ERR(clk)) {
829 clk_put(fck); 830 clk_put(clk);
830 831
831 return -EEXIST; 832 return -EEXIST;
832 } 833 }
833 834
834 l = clkdev_create(ddata->clocks[SYSC_FCK], name, dev_name(child)); 835 clk = clk_get(ddata->dev, name);
836 if (IS_ERR(clk))
837 return -ENODEV;
838
839 l = clkdev_create(clk, name, dev_name(child));
840 if (!l)
841 error = -ENOMEM;
835 842
836 return l ? 0 : -ENODEV; 843 clk_put(clk);
844
845 return error;
837} 846}
838 847
839static struct device_type sysc_device_type = { 848static struct device_type sysc_device_type = {
@@ -983,7 +992,8 @@ static int sysc_notifier_call(struct notifier_block *nb,
983 992
984 switch (event) { 993 switch (event) {
985 case BUS_NOTIFY_ADD_DEVICE: 994 case BUS_NOTIFY_ADD_DEVICE:
986 error = sysc_child_add_fck(ddata, dev); 995 error = sysc_child_add_named_clock(ddata, dev,
996 clock_names[SYSC_FCK]);
987 if (error && error != -EEXIST) 997 if (error && error != -EEXIST)
988 dev_warn(ddata->dev, "could not add %s fck: %i\n", 998 dev_warn(ddata->dev, "could not add %s fck: %i\n",
989 dev_name(dev), error); 999 dev_name(dev), error);