diff mbox series

[03/27] clk: ti: add support for clkctrl aliases

Message ID 1509368685-29112-4-git-send-email-t-kristo@ti.com
State New
Headers show
Series clk: ti: clkctrl fixes and support for additional SoCs | expand

Commit Message

Tero Kristo Oct. 30, 2017, 1:04 p.m. UTC
hwmod core still depends on certain clocks being found by name, so we
need to add support for adding clkctrl clock aliases. This patch can
be reverted when no longer needed by hwmod core code.

Signed-off-by: Tero Kristo <t-kristo@ti.com>

---
 drivers/clk/ti/clk.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 55 insertions(+), 3 deletions(-)

-- 
1.9.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Stephen Boyd Nov. 3, 2017, 3:27 p.m. UTC | #1
On 10/30, Tero Kristo wrote:
> +		}

> +

> +		if (num_args && clkctrl_nodes_missing)

> +			continue;

> +

> +		node = of_find_node_by_name(NULL, buf);

> +		if (num_args)

> +			node = of_find_node_by_name(node, "clk");

>  		clkspec.np = node;

> +		clkspec.args_count = num_args;

> +		for (i = 0; i < num_args; i++) {

> +			ret = kstrtoint(tags[i], i ? 10 : 16, clkspec.args + i);


Is this some sort of DT checker?

> +			if (ret) {

> +				pr_warn("Bad tag in %s at %d: %s\n",

> +					c->node_name, i, tags[i]);

> +				return;

> +			}

> +		}

>  		clk = of_clk_get_from_provider(&clkspec);

>  


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tero Kristo Nov. 6, 2017, 7:46 a.m. UTC | #2
On 03/11/17 17:27, Stephen Boyd wrote:
> On 10/30, Tero Kristo wrote:

>> +		}

>> +

>> +		if (num_args && clkctrl_nodes_missing)

>> +			continue;

>> +

>> +		node = of_find_node_by_name(NULL, buf);

>> +		if (num_args)

>> +			node = of_find_node_by_name(node, "clk");

>>   		clkspec.np = node;

>> +		clkspec.args_count = num_args;

>> +		for (i = 0; i < num_args; i++) {

>> +			ret = kstrtoint(tags[i], i ? 10 : 16, clkspec.args + i);

> 

> Is this some sort of DT checker?


Not really, it just parses a string of format:

<clkctrl_provider>:<hex-offset>:<bit-offset>.

... so that it can find a matching clock. Needed temporarily for 
omap_hwmod backwards compatibility. This piece can be removed once hwmod 
is gone.

I can add some comment along these lines to the code if you want.

-Tero

> 

>> +			if (ret) {

>> +				pr_warn("Bad tag in %s at %d: %s\n",

>> +					c->node_name, i, tags[i]);

>> +				return;

>> +			}

>> +		}

>>   		clk = of_clk_get_from_provider(&clkspec);

>>   

> 


--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Boyd Nov. 6, 2017, 10:07 p.m. UTC | #3
On 11/06, Tero Kristo wrote:
> On 03/11/17 17:27, Stephen Boyd wrote:

> >On 10/30, Tero Kristo wrote:

> >>+		}

> >>+

> >>+		if (num_args && clkctrl_nodes_missing)

> >>+			continue;

> >>+

> >>+		node = of_find_node_by_name(NULL, buf);

> >>+		if (num_args)

> >>+			node = of_find_node_by_name(node, "clk");

> >>  		clkspec.np = node;

> >>+		clkspec.args_count = num_args;

> >>+		for (i = 0; i < num_args; i++) {

> >>+			ret = kstrtoint(tags[i], i ? 10 : 16, clkspec.args + i);

> >

> >Is this some sort of DT checker?

> 

> Not really, it just parses a string of format:

> 

> <clkctrl_provider>:<hex-offset>:<bit-offset>.

> 

> ... so that it can find a matching clock. Needed temporarily for

> omap_hwmod backwards compatibility. This piece can be removed once

> hwmod is gone.

> 

> I can add some comment along these lines to the code if you want.

> 


No need. Thanks.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index e5a1c82..10a7045 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -108,18 +108,70 @@  void __init ti_dt_clocks_register(struct ti_dt_clk oclks[])
 	struct device_node *node;
 	struct clk *clk;
 	struct of_phandle_args clkspec;
+	char buf[64];
+	char *ptr;
+	char *tags[2];
+	int i;
+	int num_args;
+	int ret;
+	static bool clkctrl_nodes_missing;
+	static bool has_clkctrl_data;
 
 	for (c = oclks; c->node_name != NULL; c++) {
-		node = of_find_node_by_name(NULL, c->node_name);
+		strcpy(buf, c->node_name);
+		ptr = buf;
+		for (i = 0; i < 2; i++)
+			tags[i] = NULL;
+		num_args = 0;
+		while (*ptr) {
+			if (*ptr == ':') {
+				if (num_args >= 2) {
+					pr_warn("Bad number of tags on %s\n",
+						c->node_name);
+					return;
+				}
+				tags[num_args++] = ptr + 1;
+				*ptr = 0;
+			}
+			ptr++;
+		}
+
+		if (num_args && clkctrl_nodes_missing)
+			continue;
+
+		node = of_find_node_by_name(NULL, buf);
+		if (num_args)
+			node = of_find_node_by_name(node, "clk");
 		clkspec.np = node;
+		clkspec.args_count = num_args;
+		for (i = 0; i < num_args; i++) {
+			ret = kstrtoint(tags[i], i ? 10 : 16, clkspec.args + i);
+			if (ret) {
+				pr_warn("Bad tag in %s at %d: %s\n",
+					c->node_name, i, tags[i]);
+				return;
+			}
+		}
 		clk = of_clk_get_from_provider(&clkspec);
 
 		if (!IS_ERR(clk)) {
 			c->lk.clk = clk;
 			clkdev_add(&c->lk);
 		} else {
-			pr_warn("failed to lookup clock node %s\n",
-				c->node_name);
+			if (num_args && !has_clkctrl_data) {
+				if (of_find_compatible_node(NULL, NULL,
+							    "ti,clkctrl")) {
+					has_clkctrl_data = true;
+				} else {
+					clkctrl_nodes_missing = true;
+
+					pr_warn("missing clkctrl nodes, please update your dts.\n");
+					continue;
+				}
+			}
+
+			pr_warn("failed to lookup clock node %s, ret=%ld\n",
+				c->node_name, PTR_ERR(clk));
 		}
 	}
 }