Message ID | 20241019084738.3370489-4-claudiu.beznea.uj@bp.renesas.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Add RTC support for the Renesas RZ/G3S SoC | expand |
On Sat, Oct 19, 2024 at 11:47:29AM +0300, Claudiu wrote: > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> > > The VBATTB IP of the Renesas RZ/G3S SoC controls the clock for RTC, > the tamper detector and a small general usage memory of 128B. > > The VBATTB controller controls the clock for the RTC on the Renesas > RZ/G3S. The HW block diagram for the clock logic is as follows: > > +----------+ XC `\ > RTXIN --->| |----->| \ +----+ VBATTCLK > | 32K clock| | |----->|gate|-----------> > | osc | XBYP | | +----+ Messed indent. Switch to spaces. > RTXOUT --->| |----->| / > +----------+ ,/ > > One could connect as input to this HW block either a crystal or > an external clock device. > > After discussions w/ Stephen Boyd the clock tree associated with this > hardware block was exported in Linux as: > > input-xtal > xbyp > xc > mux > vbattclk > > where: > - input-xtal is the input clock (connected to RTXIN, RTXOUT pins) > - xc, xbyp are mux inputs > - mux is the internal mux > - vbattclk is the gate clock that feeds in the end the RTC > > to allow selecting the input of the MUX though assigned-clock DT > properties, using the already existing clock drivers and avoid adding > other DT properties. > > This allows select the input of the mux based on the type of the > connected input clock: > - if the 32768 crystal is connected as input for the VBATTB, > the input of the mux should be xc > - if an external clock device is connected as input for the VBATTB the > input of the mux should be xbyp > + clocks: > + items: > + - description: VBATTB module clock > + - description: RTC input clock (crystal or external clock device) > + > + clock-names: > + items: > + - const: bclk > + - const: rtx > + > + '#clock-cells': > + const: 1 > + > + power-domains: > + maxItems: 1 > + > + resets: > + items: > + - description: VBATTB module reset > + > + quartz-load-femtofarads: > + description: load capacitance of the on board crystal > + enum: [ 4000, 7000, 9000, 12500 ] It's not required, so: default: ? > + > +required: > + - compatible > + - reg > + - interrupts > + - clocks > + - clock-names > + - '#clock-cells' > + - power-domains > + - resets > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/clock/r9a08g045-cpg.h> > + #include <dt-bindings/clock/renesas,r9a08g045-vbattb.h> > + #include <dt-bindings/interrupt-controller/arm-gic.h> > + #include <dt-bindings/interrupt-controller/irq.h> > + > + clock-controller@1005c000 { > + compatible = "renesas,r9a08g045-vbattb"; > + reg = <0x1005c000 0x1000>; > + interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>; > + clocks = <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb_xtal>; > + clock-names = "bclk", "rtx"; > + assigned-clocks = <&vbattb VBATTB_MUX>; > + assigned-clock-parents = <&vbattb VBATTB_XC>; Why are you configuring internal clocks to internal parents? That's part internal to this device, not DTS... or at least some explanation would be useful. Best regards, Krzysztof
On Mon, Oct 21, 2024 at 09:32:37AM +0200, Krzysztof Kozlowski wrote: > > +additionalProperties: false > > + > > +examples: > > + - | > > + #include <dt-bindings/clock/r9a08g045-cpg.h> > > + #include <dt-bindings/clock/renesas,r9a08g045-vbattb.h> > > + #include <dt-bindings/interrupt-controller/arm-gic.h> > > + #include <dt-bindings/interrupt-controller/irq.h> > > + > > + clock-controller@1005c000 { > > + compatible = "renesas,r9a08g045-vbattb"; > > + reg = <0x1005c000 0x1000>; > > + interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>; > > + clocks = <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb_xtal>; > > + clock-names = "bclk", "rtx"; > > + assigned-clocks = <&vbattb VBATTB_MUX>; > > + assigned-clock-parents = <&vbattb VBATTB_XC>; > > Why are you configuring internal clocks to internal parents? That's part > internal to this device, not DTS... or at least some explanation would > be useful. From DTS I see this belongs to the board, not SoC, so makes sense. Best regards, Krzysztof
On 21.10.2024 10:32, Krzysztof Kozlowski wrote: > On Sat, Oct 19, 2024 at 11:47:29AM +0300, Claudiu wrote: >> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> >> >> The VBATTB IP of the Renesas RZ/G3S SoC controls the clock for RTC, >> the tamper detector and a small general usage memory of 128B. >> >> The VBATTB controller controls the clock for the RTC on the Renesas >> RZ/G3S. The HW block diagram for the clock logic is as follows: >> >> +----------+ XC `\ >> RTXIN --->| |----->| \ +----+ VBATTCLK >> | 32K clock| | |----->|gate|-----------> >> | osc | XBYP | | +----+ > > Messed indent. Switch to spaces. > >> RTXOUT --->| |----->| / >> +----------+ ,/ >> >> One could connect as input to this HW block either a crystal or >> an external clock device. >> >> After discussions w/ Stephen Boyd the clock tree associated with this >> hardware block was exported in Linux as: >> >> input-xtal >> xbyp >> xc >> mux >> vbattclk >> >> where: >> - input-xtal is the input clock (connected to RTXIN, RTXOUT pins) >> - xc, xbyp are mux inputs >> - mux is the internal mux >> - vbattclk is the gate clock that feeds in the end the RTC >> >> to allow selecting the input of the MUX though assigned-clock DT >> properties, using the already existing clock drivers and avoid adding >> other DT properties. >> >> This allows select the input of the mux based on the type of the >> connected input clock: >> - if the 32768 crystal is connected as input for the VBATTB, >> the input of the mux should be xc >> - if an external clock device is connected as input for the VBATTB the >> input of the mux should be xbyp > >> + clocks: >> + items: >> + - description: VBATTB module clock >> + - description: RTC input clock (crystal or external clock device) >> + >> + clock-names: >> + items: >> + - const: bclk >> + - const: rtx >> + >> + '#clock-cells': >> + const: 1 >> + >> + power-domains: >> + maxItems: 1 >> + >> + resets: >> + items: >> + - description: VBATTB module reset >> + >> + quartz-load-femtofarads: >> + description: load capacitance of the on board crystal >> + enum: [ 4000, 7000, 9000, 12500 ] > > It's not required, so: > default: ? OK, I'll add the default. > >> + >> +required: >> + - compatible >> + - reg >> + - interrupts >> + - clocks >> + - clock-names >> + - '#clock-cells' >> + - power-domains >> + - resets >> + >> +additionalProperties: false >> + >> +examples: >> + - | >> + #include <dt-bindings/clock/r9a08g045-cpg.h> >> + #include <dt-bindings/clock/renesas,r9a08g045-vbattb.h> >> + #include <dt-bindings/interrupt-controller/arm-gic.h> >> + #include <dt-bindings/interrupt-controller/irq.h> >> + >> + clock-controller@1005c000 { >> + compatible = "renesas,r9a08g045-vbattb"; >> + reg = <0x1005c000 0x1000>; >> + interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>; >> + clocks = <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb_xtal>; >> + clock-names = "bclk", "rtx"; >> + assigned-clocks = <&vbattb VBATTB_MUX>; >> + assigned-clock-parents = <&vbattb VBATTB_XC>; > > Why are you configuring internal clocks to internal parents? That's part > internal to this device, not DTS... or at least some explanation would > be useful. > > Best regards, > Krzysztof >
On 21.10.2024 10:34, Krzysztof Kozlowski wrote: > On Mon, Oct 21, 2024 at 09:32:37AM +0200, Krzysztof Kozlowski wrote: >>> +additionalProperties: false >>> + >>> +examples: >>> + - | >>> + #include <dt-bindings/clock/r9a08g045-cpg.h> >>> + #include <dt-bindings/clock/renesas,r9a08g045-vbattb.h> >>> + #include <dt-bindings/interrupt-controller/arm-gic.h> >>> + #include <dt-bindings/interrupt-controller/irq.h> >>> + >>> + clock-controller@1005c000 { >>> + compatible = "renesas,r9a08g045-vbattb"; >>> + reg = <0x1005c000 0x1000>; >>> + interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>; >>> + clocks = <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb_xtal>; >>> + clock-names = "bclk", "rtx"; >>> + assigned-clocks = <&vbattb VBATTB_MUX>; >>> + assigned-clock-parents = <&vbattb VBATTB_XC>; >> >> Why are you configuring internal clocks to internal parents? That's part >> internal to this device, not DTS... or at least some explanation would >> be useful. > > From DTS I see this belongs to the board, not SoC, so makes sense. That's true. This configuration depends on the type of the input clock connected to the RTXIN, RTXOUT pins which is board specific (see below diagram): +----------+ XC `\ RTXIN --->| |----->| \ +----+ VBATTCLK | 32K clock| | |----->|gate|-----------> | osc | XBYP | | +----+ RTXOUT --->| |----->| / +----------+ ,/ Thank you, Claudiu Beznea > > Best regards, > Krzysztof >
On Sat, Oct 19, 2024 at 10:47 AM Claudiu <claudiu.beznea@tuxon.dev> wrote: > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> > > The VBATTB IP of the Renesas RZ/G3S SoC controls the clock for RTC, > the tamper detector and a small general usage memory of 128B. > > The VBATTB controller controls the clock for the RTC on the Renesas > RZ/G3S. The HW block diagram for the clock logic is as follows: > > +----------+ XC `\ > RTXIN --->| |----->| \ +----+ VBATTCLK > | 32K clock| | |----->|gate|-----------> > | osc | XBYP | | +----+ > RTXOUT --->| |----->| / > +----------+ ,/ > > One could connect as input to this HW block either a crystal or > an external clock device. > > After discussions w/ Stephen Boyd the clock tree associated with this > hardware block was exported in Linux as: > > input-xtal > xbyp > xc > mux > vbattclk > > where: > - input-xtal is the input clock (connected to RTXIN, RTXOUT pins) > - xc, xbyp are mux inputs > - mux is the internal mux > - vbattclk is the gate clock that feeds in the end the RTC > > to allow selecting the input of the MUX though assigned-clock DT > properties, using the already existing clock drivers and avoid adding > other DT properties. > > This allows select the input of the mux based on the type of the > connected input clock: > - if the 32768 crystal is connected as input for the VBATTB, > the input of the mux should be xc > - if an external clock device is connected as input for the VBATTB the > input of the mux should be xbyp > > Add bindings for the VBATTB controller. > > Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> > --- > > Changes in v4: > - squashed with patch "Add clock IDs for the VBATTB controller" from v3 > - removed "oscillator" word from commit description > - added assigned-clocks, assigned-clock-parents to the documentation example > - used clock-controller for the node name > - used "quartz-load-femtofarads" property for the load capacitance > - renamed include/dt-bindings/clock/r9a08g045-vbattb.h to > include/dt-bindings/clock/renesas,r9a08g045-vbattb.h Thanks for the update! Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> 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
diff --git a/Documentation/devicetree/bindings/clock/renesas,r9a08g045-vbattb.yaml b/Documentation/devicetree/bindings/clock/renesas,r9a08g045-vbattb.yaml new file mode 100644 index 000000000000..4c78b4b1fcd0 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/renesas,r9a08g045-vbattb.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/renesas,r9a08g045-vbattb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas Battery Backup Function (VBATTB) + +description: + Renesas VBATTB is an always on powered module (backed by battery) which + controls the RTC clock (VBATTCLK), tamper detection logic and a small + general usage memory (128B). + +maintainers: + - Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> + +properties: + compatible: + const: renesas,r9a08g045-vbattb + + reg: + maxItems: 1 + + interrupts: + items: + - description: tamper detector interrupt + + clocks: + items: + - description: VBATTB module clock + - description: RTC input clock (crystal or external clock device) + + clock-names: + items: + - const: bclk + - const: rtx + + '#clock-cells': + const: 1 + + power-domains: + maxItems: 1 + + resets: + items: + - description: VBATTB module reset + + quartz-load-femtofarads: + description: load capacitance of the on board crystal + enum: [ 4000, 7000, 9000, 12500 ] + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - '#clock-cells' + - power-domains + - resets + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/r9a08g045-cpg.h> + #include <dt-bindings/clock/renesas,r9a08g045-vbattb.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + clock-controller@1005c000 { + compatible = "renesas,r9a08g045-vbattb"; + reg = <0x1005c000 0x1000>; + interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb_xtal>; + clock-names = "bclk", "rtx"; + assigned-clocks = <&vbattb VBATTB_MUX>; + assigned-clock-parents = <&vbattb VBATTB_XC>; + #clock-cells = <1>; + power-domains = <&cpg>; + resets = <&cpg R9A08G045_VBAT_BRESETN>; + quartz-load-femtofarads = <12500>; + }; diff --git a/include/dt-bindings/clock/renesas,r9a08g045-vbattb.h b/include/dt-bindings/clock/renesas,r9a08g045-vbattb.h new file mode 100644 index 000000000000..67774eafad06 --- /dev/null +++ b/include/dt-bindings/clock/renesas,r9a08g045-vbattb.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + * + * Copyright (C) 2024 Renesas Electronics Corp. + */ +#ifndef __DT_BINDINGS_CLOCK_R9A08G045_VBATTB_H__ +#define __DT_BINDINGS_CLOCK_R9A08G045_VBATTB_H__ + +#define VBATTB_XC 0 +#define VBATTB_XBYP 1 +#define VBATTB_MUX 2 +#define VBATTB_VBATTCLK 3 + +#endif /* __DT_BINDINGS_CLOCK_R9A08G045_VBATTB_H__ */