All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: Tony Lindgren <tony@atomide.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: <devicetree@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	<linux-omap@vger.kernel.org>, Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH] clk: ti: clkctrl: Fix hidden dependency to node name with reg-names
Date: Thu, 19 Sep 2019 09:46:02 +0300	[thread overview]
Message-ID: <256788c4-ae09-3c72-b563-b9707c4751b4@ti.com> (raw)
In-Reply-To: <20190905215532.8357-1-tony@atomide.com>

On 06/09/2019 00:55, Tony Lindgren wrote:
> We currently have a hidden dependency to the device tree node name for
> the clkctrl clocks. Instead of using standard node name like "clock", we
> must use "l4-per-clkctrl" naming so the clock driver can find the
> associated clock domain. Further, if "clk" is specified for a clock node
> name, the driver sets TI_CLK_CLKCTRL_COMPAT flag that uses different
> logic with earlier naming for the clock node name.
> 
> If the clock node naming dependency is not understood, the related
> clockdomain is not found, or a wrong one can get used if a clock manager
> instance has multiple domains.
> 
> As each clkctrl instance represents a single clock domain with it's
> reg property describing the clocks available in that clock domain,
> we can simply use "reg-names" property for the clock domain.
> 
> This simplifies things and removes the hidden dependency to the node
> name. And then later on, we should be able to drop the related code
> for parsing the node names.
> 
> Let's also update the binding to use standard "clock" node naming
> instead of "clk".
> 
> Cc: devicetree@vger.kernel.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>   Documentation/devicetree/bindings/clock/ti-clkctrl.txt |  6 +++++-
>   drivers/clk/ti/clkctrl.c                               | 10 ++++++++--
>   2 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/clock/ti-clkctrl.txt b/Documentation/devicetree/bindings/clock/ti-clkctrl.txt
> --- a/Documentation/devicetree/bindings/clock/ti-clkctrl.txt
> +++ b/Documentation/devicetree/bindings/clock/ti-clkctrl.txt
> @@ -20,15 +20,19 @@ Required properties :
>   - #clock-cells : shall contain 2 with the first entry being the instance
>   		 offset from the clock domain base and the second being the
>   		 clock index
> +- reg : clock registers
> +- reg-names : clock register names for the clock, should be same as the
> +	      domain name

Hmm, I think using the reg-names property like this is kind of wrong. 
Basically, reg and reg-names have pretty much nothing in common. 
Shouldn't you instead use something like ti,clkdm-name? This also breaks 
with SoCs like am3, which have mutant clkctrl entries like the one here:

                 l4ls_clkctrl: l4ls-clkctrl@38 {
                         compatible = "ti,clkctrl";
                         reg = <0x38 0x2c>, <0x6c 0x28>, <0xac 0xc>, 
<0xc0 0x1c>, <0xec 0xc>, <0x10c 0x8>, <0x130 0x4>;
                         #clock-cells = <2>;
                 };

What would you think single entry in reg-names would mean in this case?

Other than that, I think the approach taken in this patch looks fine.

-Tero

>   
>   Example: Clock controller node on omap 4430:
>   
>   &cm2 {
>   	l4per: cm@1400 {
>   		cm_l4per@0 {
> -			cm_l4per_clkctrl: clk@20 {
> +			cm_l4per_clkctrl: clock@20 {
>   				compatible = "ti,clkctrl";
>   				reg = <0x20 0x1b0>;
> +				reg-names = "l4_per";
>   				#clock-cells = <2>;
>   			};
>   		};
> diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c
> --- a/drivers/clk/ti/clkctrl.c
> +++ b/drivers/clk/ti/clkctrl.c
> @@ -446,6 +446,7 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
>   	struct clk_hw_omap *hw;
>   	struct clk *clk;
>   	struct omap_clkctrl_clk *clkctrl_clk;
> +	const char *clkdm_name;
>   	const __be32 *addrp;
>   	u32 addr;
>   	int ret;
> @@ -534,7 +535,12 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
>   
>   	provider->base = of_iomap(node, 0);
>   
> -	if (ti_clk_get_features()->flags & TI_CLK_CLKCTRL_COMPAT) {
> +	ret = of_property_read_string_index(node, "reg-names", 0, &clkdm_name);
> +	if (!ret) {
> +		provider->clkdm_name = kasprintf(GFP_KERNEL, "%s_clkdm",
> +						 clkdm_name);
> +		goto clkdm_found;
> +	} else if (ti_clk_get_features()->flags & TI_CLK_CLKCTRL_COMPAT) {
>   		provider->clkdm_name = kasprintf(GFP_KERNEL, "%pOFnxxx", node->parent);
>   		if (!provider->clkdm_name) {
>   			kfree(provider);
> @@ -570,7 +576,7 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
>   			*c = '_';
>   		c++;
>   	}
> -
> +clkdm_found:
>   	INIT_LIST_HEAD(&provider->clocks);
>   
>   	/* Generate clocks */
> 

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  parent reply	other threads:[~2019-09-19  6:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 21:55 [PATCH] clk: ti: clkctrl: Fix hidden dependency to node name with reg-names Tony Lindgren
2019-09-07  3:55 ` Stephen Boyd
2019-09-08 19:42   ` Tony Lindgren
2019-09-18 18:07     ` Stephen Boyd
2019-09-18 20:53       ` Tony Lindgren
2019-09-18 23:28         ` Stephen Boyd
2019-09-19  0:01           ` Tony Lindgren
2019-09-19  6:46 ` Tero Kristo [this message]
2019-09-19 14:12   ` Tony Lindgren
2019-09-19 16:50     ` Stephen Boyd
2019-09-19 17:06       ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=256788c4-ae09-3c72-b563-b9707c4751b4@ti.com \
    --to=t-kristo@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.