public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] rtc: rzn1: support XTAL clk and SCMP method
@ 2025-03-19 11:03 Wolfram Sang
  2025-03-19 11:03 ` [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2025-03-19 11:03 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: Wolfram Sang, Alexandre Belloni, Conor Dooley, devicetree,
	Geert Uytterhoeven, Krzysztof Kozlowski, linux-rtc, Magnus Damm,
	Miquel Raynal, Rob Herring

So far, the code and the binding for the RZ/N1D RTC assumed an input
clock of 32768Hz, so it was not explicitly described. It makes sense to
do this, though. For one reason, clocks with other frequencies might be
used. This RTC supports that via the SCMP counting method. The other
reason is, the upcoming R-Car Gen5 has only the SCMP method described,
so we need to use it there later.

This series lets the driver handle the optional "xtal" clock and switch
to the SCMP method if suitable. It has been tested on a Renesas RZ/N1D
board with hacked devicetree values.

A branch with updated DTs can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/n1d/rtc

Looking forward to comments!


Changes since RFC:
* add binding tag from Krzysztof (Thanks!)
* new patch to disable controller before initially modifying CTL0
* cosmetic changes

Wolfram Sang (3):
  dt-bindings: rtc: rzn1: add optional second clock
  rtc: rzn1: Disable controller before initialization
  rtc: rzn1: support input frequencies other than 32768Hz

 .../bindings/rtc/renesas,rzn1-rtc.yaml        |  8 ++-
 drivers/rtc/rtc-rzn1.c                        | 59 +++++++++++++++----
 2 files changed, 53 insertions(+), 14 deletions(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock
  2025-03-19 11:03 [PATCH 0/3] rtc: rzn1: support XTAL clk and SCMP method Wolfram Sang
@ 2025-03-19 11:03 ` Wolfram Sang
  2025-04-10 15:08   ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2025-03-19 11:03 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: Wolfram Sang, Krzysztof Kozlowski, Miquel Raynal,
	Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Magnus Damm, linux-rtc, devicetree

The external crystal can be a second clock input. It is needed for the
SCMP counting method which allows using crystals different than 32768Hz.
It is also needed for an upcoming SoC which only supports the SCMP
method.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 .../devicetree/bindings/rtc/renesas,rzn1-rtc.yaml         | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml b/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
index f6e0c613af67..f6fdcc7090b6 100644
--- a/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
+++ b/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
@@ -33,10 +33,14 @@ properties:
       - const: pps
 
   clocks:
-    maxItems: 1
+    minItems: 1
+    maxItems: 2
 
   clock-names:
-    const: hclk
+    minItems: 1
+    items:
+      - const: hclk
+      - const: xtal
 
   power-domains:
     maxItems: 1
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock
  2025-03-19 11:03 ` [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock Wolfram Sang
@ 2025-04-10 15:08   ` Geert Uytterhoeven
  2025-04-10 15:29     ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2025-04-10 15:08 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-renesas-soc, Krzysztof Kozlowski, Miquel Raynal,
	Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Magnus Damm, linux-rtc, devicetree

Hi Wolfram,

On Wed, 19 Mar 2025 at 12:03, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> The external crystal can be a second clock input. It is needed for the
> SCMP counting method which allows using crystals different than 32768Hz.
> It is also needed for an upcoming SoC which only supports the SCMP
> method.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
> +++ b/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
> @@ -33,10 +33,14 @@ properties:
>        - const: pps
>
>    clocks:
> -    maxItems: 1
> +    minItems: 1
> +    maxItems: 2
>
>    clock-names:
> -    const: hclk
> +    minItems: 1
> +    items:
> +      - const: hclk
> +      - const: xtal

Shouldn't the second clock become required? Or do you plan to make
that change after all upstream DTS files have been updated?

This is orthogonal to the driver considering it optional to maintain
compatibility with old DTBs.

>
>    power-domains:
>      maxItems: 1

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock
  2025-04-10 15:08   ` Geert Uytterhoeven
@ 2025-04-10 15:29     ` Geert Uytterhoeven
  2025-04-10 20:23       ` Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2025-04-10 15:29 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-renesas-soc, Krzysztof Kozlowski, Miquel Raynal,
	Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Magnus Damm, linux-rtc, devicetree

Hi Wolfram,

On Thu, 10 Apr 2025 at 17:08, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, 19 Mar 2025 at 12:03, Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> > The external crystal can be a second clock input. It is needed for the
> > SCMP counting method which allows using crystals different than 32768Hz.
> > It is also needed for an upcoming SoC which only supports the SCMP
> > method.
> >
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>
> Thanks for your patch!
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> > --- a/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
> > +++ b/Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
> > @@ -33,10 +33,14 @@ properties:
> >        - const: pps
> >
> >    clocks:
> > -    maxItems: 1
> > +    minItems: 1
> > +    maxItems: 2
> >
> >    clock-names:
> > -    const: hclk
> > +    minItems: 1
> > +    items:
> > +      - const: hclk
> > +      - const: xtal
>
> Shouldn't the second clock become required? Or do you plan to make
> that change after all upstream DTS files have been updated?

Upon second thought: this xtal clock is documented to be the "rtc"
input to the RZ/N1 system controller[1], so it looks like the original
idea was to obtain it through the system controller.  Unfortunately
the clock driver[2] does not use the rtc input clock, nor provides it
to consumers.

So either we fix that, or we go with your solution...

[1] https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/clock/renesas,r9a06g032-sysctrl.yaml#L32
[2] https://elixir.bootlin.com/linux/latest/source/drivers/clk/renesas/r9a06g032-clocks.c

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock
  2025-04-10 15:29     ` Geert Uytterhoeven
@ 2025-04-10 20:23       ` Wolfram Sang
  2025-04-11  6:20         ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2025-04-10 20:23 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-renesas-soc, Krzysztof Kozlowski, Miquel Raynal,
	Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Magnus Damm, linux-rtc, devicetree

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]


> > >    clock-names:
> > > -    const: hclk
> > > +    minItems: 1
> > > +    items:
> > > +      - const: hclk
> > > +      - const: xtal
> >
> > Shouldn't the second clock become required? Or do you plan to make
> > that change after all upstream DTS files have been updated?

True, we should make the second clock a requirement from now on.

> Upon second thought: this xtal clock is documented to be the "rtc"
> input to the RZ/N1 system controller[1], so it looks like the original
> idea was to obtain it through the system controller.  Unfortunately
> the clock driver[2] does not use the rtc input clock, nor provides it
> to consumers.

So, it would basically be a pass-through? I don't see any register in
SYSCTRL handling the external RTC clock.

> So either we fix that, or we go with your solution...

If it is a pass-through, I wonder what it would gain us, but I can do
that if there are reasons for it.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock
  2025-04-10 20:23       ` Wolfram Sang
@ 2025-04-11  6:20         ` Geert Uytterhoeven
  2025-04-11  6:38           ` Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2025-04-11  6:20 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-renesas-soc, Krzysztof Kozlowski, Miquel Raynal,
	Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Magnus Damm, linux-rtc, devicetree

Hi Wolfram,

On Thu, 10 Apr 2025 at 22:23, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> > > >    clock-names:
> > > > -    const: hclk
> > > > +    minItems: 1
> > > > +    items:
> > > > +      - const: hclk
> > > > +      - const: xtal
> > >
> > > Shouldn't the second clock become required? Or do you plan to make
> > > that change after all upstream DTS files have been updated?
>
> True, we should make the second clock a requirement from now on.
>
> > Upon second thought: this xtal clock is documented to be the "rtc"
> > input to the RZ/N1 system controller[1], so it looks like the original
> > idea was to obtain it through the system controller.  Unfortunately
> > the clock driver[2] does not use the rtc input clock, nor provides it
> > to consumers.
>
> So, it would basically be a pass-through? I don't see any register in
> SYSCTRL handling the external RTC clock.

I assume you are right, I didn't study RZ/N1D in detail.

> > So either we fix that, or we go with your solution...
>
> If it is a pass-through, I wonder what it would gain us, but I can do
> that if there are reasons for it.

Let's go for your solution.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock
  2025-04-11  6:20         ` Geert Uytterhoeven
@ 2025-04-11  6:38           ` Wolfram Sang
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2025-04-11  6:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-renesas-soc, Krzysztof Kozlowski, Miquel Raynal,
	Alexandre Belloni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Magnus Damm, linux-rtc, devicetree

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]


> > If it is a pass-through, I wonder what it would gain us, but I can do
> > that if there are reasons for it.
> 
> Let's go for your solution.

Thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-04-11  6:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 11:03 [PATCH 0/3] rtc: rzn1: support XTAL clk and SCMP method Wolfram Sang
2025-03-19 11:03 ` [PATCH 1/3] dt-bindings: rtc: rzn1: add optional second clock Wolfram Sang
2025-04-10 15:08   ` Geert Uytterhoeven
2025-04-10 15:29     ` Geert Uytterhoeven
2025-04-10 20:23       ` Wolfram Sang
2025-04-11  6:20         ` Geert Uytterhoeven
2025-04-11  6:38           ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox