[4/6] dt-bindings: clock: st,stm32-rcc: support spread spectrum clocking

Message ID 20250105181525.1370822-5-dario.binacchi@amarulasolutions.com
State New
Headers show
Series
  • Support spread spectrum clocking for stm32f{4,7} platforms
Related show

Commit Message

Dario Binacchi Jan. 5, 2025, 6:14 p.m. UTC
The addition of DT bindings for enabling and tuning spread spectrum
clocking generation is available only for the main PLL.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

 .../bindings/clock/st,stm32-rcc.yaml          | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

'Stephen Boyd' via Amarula Linux Jan. 8, 2025, 11:48 p.m. UTC | #1
On Sun, Jan 05, 2025 at 07:14:16PM +0100, Dario Binacchi wrote:
> The addition of DT bindings for enabling and tuning spread spectrum
> clocking generation is available only for the main PLL.
> 
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> ---
> 
>  .../bindings/clock/st,stm32-rcc.yaml          | 27 +++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
> index ae9e5b26d876..c345d3ff3fc4 100644
> --- a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
> +++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
> @@ -77,6 +77,26 @@ properties:
>        Phandle to system configuration controller. It can be used to control the
>        power domain circuitry.
>  
> +  st,ssc-modfreq-hz:
> +    description:
> +      The modulation frequency for main PLL (in Hz)

No constraints?

> +
> +  st,ssc-moddepth-permyriad:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description:
> +      The modulation rate for main PLL (in permyriad, i.e. 0.01%)
> +    minimum: 25
> +    maximum: 200
> +
> +  st,ssc-modmethod:
> +    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
> +    description:
> +      The modulation techniques for main PLL.
> +    items:
> +      enum:
> +        - center-spread
> +        - down-spread

What's the default? If there's only 2 possibilities, then you can use a 
boolean instead. Though I assume you want to support spread-spectrum 
disabled.

Are there dependencies between these properties? 

> +
>  required:
>    - compatible
>    - reg
> @@ -97,6 +117,10 @@ allOf:
>            const: 1
>            description: |
>              The clock index for the specified type.
> +        st,ssc-modfreq-hz: false
> +        st,ssc-moddepth-permyriad: false
> +        st,ssc-modmethod: false
> +
>      else:
>        properties:
>          '#clock-cells':
> @@ -118,6 +142,9 @@ examples:
>          reg = <0x40023800 0x400>;
>          clocks = <&clk_hse>, <&clk_i2s_ckin>;
>          st,syscfg = <&pwrcfg>;
> +        st,ssc-modfreq-hz = <10000>;
> +        st,ssc-moddepth-permyriad = <200>;
> +        st,ssc-modmethod = "center-spread";
>      };
>  
>    - |
> -- 
> 2.43.0
> 

To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
Dario Binacchi Jan. 9, 2025, 9:18 p.m. UTC | #2
Hello Rob,

On Thu, Jan 9, 2025 at 12:48 AM Rob Herring <robh@kernel.org> wrote:
>
> On Sun, Jan 05, 2025 at 07:14:16PM +0100, Dario Binacchi wrote:
> > The addition of DT bindings for enabling and tuning spread spectrum
> > clocking generation is available only for the main PLL.
> >
> > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> > ---
> >
> >  .../bindings/clock/st,stm32-rcc.yaml          | 27 +++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
> > index ae9e5b26d876..c345d3ff3fc4 100644
> > --- a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
> > +++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
> > @@ -77,6 +77,26 @@ properties:
> >        Phandle to system configuration controller. It can be used to control the
> >        power domain circuitry.
> >
> > +  st,ssc-modfreq-hz:
> > +    description:
> > +      The modulation frequency for main PLL (in Hz)
>
> No constraints?

They vary depending on the HSE clock frequency used.

>
> > +
> > +  st,ssc-moddepth-permyriad:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description:
> > +      The modulation rate for main PLL (in permyriad, i.e. 0.01%)
> > +    minimum: 25
> > +    maximum: 200
> > +
> > +  st,ssc-modmethod:
> > +    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
> > +    description:
> > +      The modulation techniques for main PLL.
> > +    items:
> > +      enum:
> > +        - center-spread
> > +        - down-spread
>
> What's the default? If there's only 2 possibilities, then you can use a
> boolean instead. Though I assume you want to support spread-spectrum
> disabled.

Generally, there can also be more than two options. For example, in
the case of the imx8m platform, there are three possibilities:
- down-spread
- center-spread
- up-spread
In our case, using a boolean would hide one of the two pieces of information,
meaning that if I'm not using center-spread, what am I using?

IMHO, I would keep the string type, changing it from
on-unique-string-array to string.

>
> Are there dependencies between these properties?

The values moddepth and modfreq are used to calculate, according to specific
relationships, two values MODPER and INCSTEP, which are bit fields of
a suitable
register for managing the SSCG. There is a constraint between these two values,
namely that MODPER * INCSTEP < 32768. This constraint will be managed
at the driver level.

Thanks and regards,
Dario
>
> > +
> >  required:
> >    - compatible
> >    - reg
> > @@ -97,6 +117,10 @@ allOf:
> >            const: 1
> >            description: |
> >              The clock index for the specified type.
> > +        st,ssc-modfreq-hz: false
> > +        st,ssc-moddepth-permyriad: false
> > +        st,ssc-modmethod: false
> > +
> >      else:
> >        properties:
> >          '#clock-cells':
> > @@ -118,6 +142,9 @@ examples:
> >          reg = <0x40023800 0x400>;
> >          clocks = <&clk_hse>, <&clk_i2s_ckin>;
> >          st,syscfg = <&pwrcfg>;
> > +        st,ssc-modfreq-hz = <10000>;
> > +        st,ssc-moddepth-permyriad = <200>;
> > +        st,ssc-modmethod = "center-spread";
> >      };
> >
> >    - |
> > --
> > 2.43.0
> >

Patch

diff --git a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
index ae9e5b26d876..c345d3ff3fc4 100644
--- a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
+++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml
@@ -77,6 +77,26 @@  properties:
       Phandle to system configuration controller. It can be used to control the
       power domain circuitry.
 
+  st,ssc-modfreq-hz:
+    description:
+      The modulation frequency for main PLL (in Hz)
+
+  st,ssc-moddepth-permyriad:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The modulation rate for main PLL (in permyriad, i.e. 0.01%)
+    minimum: 25
+    maximum: 200
+
+  st,ssc-modmethod:
+    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
+    description:
+      The modulation techniques for main PLL.
+    items:
+      enum:
+        - center-spread
+        - down-spread
+
 required:
   - compatible
   - reg
@@ -97,6 +117,10 @@  allOf:
           const: 1
           description: |
             The clock index for the specified type.
+        st,ssc-modfreq-hz: false
+        st,ssc-moddepth-permyriad: false
+        st,ssc-modmethod: false
+
     else:
       properties:
         '#clock-cells':
@@ -118,6 +142,9 @@  examples:
         reg = <0x40023800 0x400>;
         clocks = <&clk_hse>, <&clk_i2s_ckin>;
         st,syscfg = <&pwrcfg>;
+        st,ssc-modfreq-hz = <10000>;
+        st,ssc-moddepth-permyriad = <200>;
+        st,ssc-modmethod = "center-spread";
     };
 
   - |