linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dario Binacchi <dariobin@libero.it>
To: Tero Kristo <kristo@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Tony Lindgren <tony@atomide.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Bin Meng <bmeng.cn@gmail.com>,
	Frank Rowand <frowand.list@gmail.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	devicetree@vger.kernel.org, linux-clk <linux-clk@vger.kernel.org>,
	linux-omap <linux-omap@vger.kernel.org>
Subject: Re: [PATCH 0/2] fdt: translate address if #size-cells = <0>
Date: Thu, 8 Apr 2021 22:24:02 +0200 (CEST)	[thread overview]
Message-ID: <116337570.107804.1617913442196@mail1.libero.it> (raw)
In-Reply-To: <a197b5d8-621b-6655-e571-2877d007cd4c@kernel.org>


> Il 07/04/2021 15:21 Tero Kristo <kristo@kernel.org> ha scritto:
> 
>  
> On 07/04/2021 15:52, Rob Herring wrote:
> > On Wed, Apr 7, 2021 at 2:07 AM Dario Binacchi <dariobin@libero.it> wrote:
> >>
> >>
> >>> Il 07/04/2021 03:16 Rob Herring <robh+dt@kernel.org> ha scritto:
> >>>
> >>>
> >>> On Tue, Apr 6, 2021 at 5:02 PM Dario Binacchi <dariobin@libero.it> wrote:
> >>>>
> >>>>
> >>>>> Il 06/04/2021 16:06 Rob Herring <robh+dt@kernel.org> ha scritto:
> >>>>>
> >>>>>
> >>>>> On Fri, Apr 2, 2021 at 2:21 PM Dario Binacchi <dariobin@libero.it> wrote:
> >>>>>>
> >>>>>>
> >>>>>> The series comes from my commit in U-boot
> >>>>>> d64b9cdcd4 ("fdt: translate address if #size-cells = <0>")
> >>>>>> and from the subsequent exchange of emails at the end of which I was
> >>>>>> suggested to send the patch to the linux kernel
> >>>>>> (https://patchwork.ozlabs.org/project/uboot/patch/1614324949-61314-1-git-send-email-bmeng.cn@gmail.com/).
> >>>>>
> >>>>> It's 'ranges' that determines translatable which is missing from the
> >>>>> DT. This should have not had a 0 size either though maybe we could
> >>>>> support that.
> >>>>
> >>>> I have replied to the email you sent to the u-boot mailing list
> >>>>
> >>>>>
> >>>>> Does the DT have to be updated anyways for your spread spectrum support?
> >>>>
> >>>> The spread spectrum support patch does not need this patch to work. They belong
> >>>> to two different series.
> >>>
> >>> That's not what I asked. Is the spread spectrum support forcing a DT
> >>> update for users?
> >>
> >> Yes, the deltam and modfreq registers must be added to the DPLL clocks.
> > 
> > That's a shame given this dts has been mostly untouched since 2013.
> > 
> 
> I think technically it would be possible to map these registers within 
> the driver also, seeing there are like a handful of the DPLLs for both 
> am3/am4 which are impacted. Just add a new compatible or something, or 
> alternatively parse the register addresses and populate the 
> deltam/modfreq registers based on that.

I have not added new compatibles, but I have added the offset of the delta and modfreq 
registers to the data structures used by the DPLL drivers and I have set them in the 
related setup functions.
https://lore.kernel.org/patchwork/patch/1406590/

> 
> >>> If the DT has to be changed anyways (not really
> >>> great policy), then you could fix this in the DT at the same time.
> >>
> >> I could put the fix to the device tree in that series, although I wouldn't
> >> create a single patch to fix and add the SSC registers. First the size-cells = <0>
> >> fix patch and then the SSC patch.
> >> Do you agree?
> > 
> > By at the same time, I really just meant within 1 release.
> > 
> > But I'd like to hear TI maintainers' thoughts on this.
> 
> I did post a comment on patch #1 questioning the approach from TI clock 
> driver perspective, imho I can't see why these two patches would be 
> needed right now.

Because U-boot maintainers asked me after I sent them my patch on this issue. 
I believe that the email exchange that took place in the U-boot (https://patchwork.ozlabs.org/project/uboot/patch/1614324949-61314-1-git-send-email-bmeng.cn@gmail.com/)
and Linux kernel mailing lists showed that:
- The patch 'fdt: translate address if # size-cells = <0>' is wrong (U-boot has accepted 
  it, and it will have to be reverted).
- However, the same patch highlighted that it is wrong to use the size-cells = <0> property 
  in the prcm_clocks and scm_clocks nodes of device tree.
- Rob agrees that in the case of the am3xx this is the right choice:
diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4.dtsi
index 1fb22088caeb..59b0a0cf211e 100644
--- a/arch/arm/boot/dts/am33xx-l4.dtsi
+++ b/arch/arm/boot/dts/am33xx-l4.dtsi
@@ -110,7 +110,8 @@
 
                                prcm_clocks: clocks {
                                        #address-cells = <1>;
-                                       #size-cells = <0>;
+                                       #size-cells = <1>;
+                                       ranges = <0 0 0x2000>;
                                };
 
                                prcm_clockdomains: clockdomains {
@@ -320,7 +321,8 @@
 
                                        scm_clocks: clocks {
                                                #address-cells = <1>;
-                                               #size-cells = <0>;
+                                               #size-cells = <1>;
+                                               ranges = <0 0 0x800>;
                                        };
                                };

--- a/arch/arm/boot/dts/am33xx-clocks.dtsi
+++ b/arch/arm/boot/dts/am33xx-clocks.dtsi
@@ -10,7 +10,7 @@
                compatible = "ti,mux-clock";
                clocks = <&virt_19200000_ck>, <&virt_24000000_ck>, <&virt_25000000_ck>, <&virt_26000000_ck>;
                ti,bit-shift = <22>;
-               reg = <0x0040>;
+               reg = <0x0040 0x4>;
        };
 
        adc_tsc_fck: adc_tsc_fck {
@@ -98,7 +98,7 @@
                compatible = "ti,gate-clock";
                clocks = <&l4ls_gclk>;
                ti,bit-shift = <0>;
-               reg = <0x0664>;
+               reg = <0x0664 0x04>;
        };
[...]

- U-boot rightly wants to use the same device tree as the Kernel.
- IMHO, if I'm not missing something, I think using a #size-cells = <1>; for clocks 
  it requires only one code change in the ti_clk_get_reg_addr():

--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -265,9 +265,27 @@ int __init ti_clk_retry_init(struct device_node *node, void *user,
 int ti_clk_get_reg_addr(struct device_node *node, int index,
                        struct clk_omap_reg *reg)

-       if (of_property_read_u32_index(node, "reg", index, &val)) {
+       if (of_property_read_u32_index(node, "reg", index * 2, &val)) {

   The other changes to develop affect device trees of architectures which, like am3, currently
   use #size-cells = <0>.

IMHO, all this would lead to an improvement of the device trees with minimal impact on the code. 
It would benefit U-boot, which would not have to develop special platform code and any new 
architectures that would inherit from these DTs.

If you think it might be worth it, I am available to develop this patch.

Thanks and regards,
Dario

> 
> -Tero

  reply	other threads:[~2021-04-08 20:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 19:20 [PATCH 0/2] fdt: translate address if #size-cells = <0> Dario Binacchi
2021-04-02 19:20 ` [PATCH 2/2] clk: ti: get register address from device tree Dario Binacchi
2021-04-06  6:02   ` Tero Kristo
2021-04-06 14:06 ` [PATCH 0/2] fdt: translate address if #size-cells = <0> Rob Herring
2021-04-06 22:02   ` Dario Binacchi
2021-04-07  1:16     ` Rob Herring
2021-04-07  7:07       ` Dario Binacchi
2021-04-07 12:52         ` Rob Herring
2021-04-07 13:21           ` Tero Kristo
2021-04-08 20:24             ` Dario Binacchi [this message]
2021-04-09 10:32               ` Tero Kristo
2021-04-11 19:30                 ` Dario Binacchi
2021-04-12  7:41                   ` Tero Kristo
2021-04-14 20:39                     ` Dario Binacchi
2021-04-17  8:37                       ` 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=116337570.107804.1617913442196@mail1.libero.it \
    --to=dariobin@libero.it \
    --cc=bmeng.cn@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=kristo@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).