[PATCH net-next 2/9] dt-bindings: phy-common-props: create a reusable "protocol-names" definition

Vladimir Oltean posted 9 patches 2 months, 2 weeks ago
[PATCH net-next 2/9] dt-bindings: phy-common-props: create a reusable "protocol-names" definition
Posted by Vladimir Oltean 2 months, 2 weeks ago
Other properties also need to be defined per protocol than just
tx-p2p-microvolt-names. Create a common definition to avoid copying a 55
line property.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 .../bindings/phy/phy-common-props.yaml        | 34 +++++++++++--------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/phy-common-props.yaml b/Documentation/devicetree/bindings/phy/phy-common-props.yaml
index 255205ac09cd..775f4dfe3cc3 100644
--- a/Documentation/devicetree/bindings/phy/phy-common-props.yaml
+++ b/Documentation/devicetree/bindings/phy/phy-common-props.yaml
@@ -13,22 +13,12 @@ description:
 maintainers:
   - Marek Behún <kabel@kernel.org>
 
-properties:
-  tx-p2p-microvolt:
+$defs:
+  protocol-names:
     description:
-      Transmit amplitude voltages in microvolts, peak-to-peak. If this property
-      contains multiple values for various PHY modes, the
-      'tx-p2p-microvolt-names' property must be provided and contain
-      corresponding mode names.
-
-  tx-p2p-microvolt-names:
-    description: |
-      Names of the modes corresponding to voltages in the 'tx-p2p-microvolt'
-      property. Required only if multiple voltages are provided.
-
-      If a value of 'default' is provided, the system should use it for any PHY
-      mode that is otherwise not defined here. If 'default' is not provided, the
-      system should use manufacturer default value.
+      Names of the PHY modes. If a value of 'default' is provided, the system
+      should use it for any PHY mode that is otherwise not defined here. If
+      'default' is not provided, the system should use manufacturer default value.
     minItems: 1
     maxItems: 16
     items:
@@ -89,6 +79,20 @@ properties:
         - mipi-dphy-univ
         - mipi-dphy-v2.5-univ
 
+properties:
+  tx-p2p-microvolt:
+    description:
+      Transmit amplitude voltages in microvolts, peak-to-peak. If this property
+      contains multiple values for various PHY modes, the
+      'tx-p2p-microvolt-names' property must be provided and contain
+      corresponding mode names.
+
+  tx-p2p-microvolt-names:
+    description:
+      Names of the modes corresponding to voltages in the 'tx-p2p-microvolt'
+      property. Required only if multiple voltages are provided.
+    $ref: "#/$defs/protocol-names"
+
 dependencies:
   tx-p2p-microvolt-names: [ tx-p2p-microvolt ]
 
-- 
2.34.1

Re: [PATCH net-next 2/9] dt-bindings: phy-common-props: create a reusable "protocol-names" definition
Posted by Rob Herring 2 months, 1 week ago
On Sat, Nov 22, 2025 at 09:33:34PM +0200, Vladimir Oltean wrote:
> Other properties also need to be defined per protocol than just
> tx-p2p-microvolt-names. Create a common definition to avoid copying a 55
> line property.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  .../bindings/phy/phy-common-props.yaml        | 34 +++++++++++--------
>  1 file changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/phy-common-props.yaml b/Documentation/devicetree/bindings/phy/phy-common-props.yaml
> index 255205ac09cd..775f4dfe3cc3 100644
> --- a/Documentation/devicetree/bindings/phy/phy-common-props.yaml
> +++ b/Documentation/devicetree/bindings/phy/phy-common-props.yaml
> @@ -13,22 +13,12 @@ description:
>  maintainers:
>    - Marek Behún <kabel@kernel.org>
>  
> -properties:
> -  tx-p2p-microvolt:
> +$defs:
> +  protocol-names:
>      description:
> -      Transmit amplitude voltages in microvolts, peak-to-peak. If this property
> -      contains multiple values for various PHY modes, the
> -      'tx-p2p-microvolt-names' property must be provided and contain
> -      corresponding mode names.
> -
> -  tx-p2p-microvolt-names:
> -    description: |
> -      Names of the modes corresponding to voltages in the 'tx-p2p-microvolt'
> -      property. Required only if multiple voltages are provided.
> -
> -      If a value of 'default' is provided, the system should use it for any PHY
> -      mode that is otherwise not defined here. If 'default' is not provided, the
> -      system should use manufacturer default value.
> +      Names of the PHY modes. If a value of 'default' is provided, the system
> +      should use it for any PHY mode that is otherwise not defined here. If
> +      'default' is not provided, the system should use manufacturer default value.
>      minItems: 1
>      maxItems: 16
>      items:
> @@ -89,6 +79,20 @@ properties:
>          - mipi-dphy-univ
>          - mipi-dphy-v2.5-univ
>  
> +properties:
> +  tx-p2p-microvolt:
> +    description:
> +      Transmit amplitude voltages in microvolts, peak-to-peak. If this property
> +      contains multiple values for various PHY modes, the
> +      'tx-p2p-microvolt-names' property must be provided and contain
> +      corresponding mode names.
> +
> +  tx-p2p-microvolt-names:
> +    description:
> +      Names of the modes corresponding to voltages in the 'tx-p2p-microvolt'
> +      property. Required only if multiple voltages are provided.
> +    $ref: "#/$defs/protocol-names"

The default for .*-names is the entries don't have to be unique. That's 
for the exception, but unfortunately everyone else has to define the 
type (type.yaml#/definitons/string).

Each user needs to define the names of the entries which will enforce 
the length. So defining the length 1-16 here doesn't do much. So I think 
you can drop that and then the $defs is not needed either.

Rob
Re: [PATCH net-next 2/9] dt-bindings: phy-common-props: create a reusable "protocol-names" definition
Posted by Rob Herring 2 months, 1 week ago
On Thu, Dec 04, 2025 at 09:52:19AM -0600, Rob Herring wrote:
> On Sat, Nov 22, 2025 at 09:33:34PM +0200, Vladimir Oltean wrote:
> > Other properties also need to be defined per protocol than just
> > tx-p2p-microvolt-names. Create a common definition to avoid copying a 55
> > line property.
> > 
> > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > ---
> >  .../bindings/phy/phy-common-props.yaml        | 34 +++++++++++--------
> >  1 file changed, 19 insertions(+), 15 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/phy/phy-common-props.yaml b/Documentation/devicetree/bindings/phy/phy-common-props.yaml
> > index 255205ac09cd..775f4dfe3cc3 100644
> > --- a/Documentation/devicetree/bindings/phy/phy-common-props.yaml
> > +++ b/Documentation/devicetree/bindings/phy/phy-common-props.yaml
> > @@ -13,22 +13,12 @@ description:
> >  maintainers:
> >    - Marek Behún <kabel@kernel.org>
> >  
> > -properties:
> > -  tx-p2p-microvolt:
> > +$defs:
> > +  protocol-names:
> >      description:
> > -      Transmit amplitude voltages in microvolts, peak-to-peak. If this property
> > -      contains multiple values for various PHY modes, the
> > -      'tx-p2p-microvolt-names' property must be provided and contain
> > -      corresponding mode names.
> > -
> > -  tx-p2p-microvolt-names:
> > -    description: |
> > -      Names of the modes corresponding to voltages in the 'tx-p2p-microvolt'
> > -      property. Required only if multiple voltages are provided.
> > -
> > -      If a value of 'default' is provided, the system should use it for any PHY
> > -      mode that is otherwise not defined here. If 'default' is not provided, the
> > -      system should use manufacturer default value.
> > +      Names of the PHY modes. If a value of 'default' is provided, the system
> > +      should use it for any PHY mode that is otherwise not defined here. If
> > +      'default' is not provided, the system should use manufacturer default value.
> >      minItems: 1
> >      maxItems: 16
> >      items:
> > @@ -89,6 +79,20 @@ properties:
> >          - mipi-dphy-univ
> >          - mipi-dphy-v2.5-univ
> >  
> > +properties:
> > +  tx-p2p-microvolt:
> > +    description:
> > +      Transmit amplitude voltages in microvolts, peak-to-peak. If this property
> > +      contains multiple values for various PHY modes, the
> > +      'tx-p2p-microvolt-names' property must be provided and contain
> > +      corresponding mode names.
> > +
> > +  tx-p2p-microvolt-names:
> > +    description:
> > +      Names of the modes corresponding to voltages in the 'tx-p2p-microvolt'
> > +      property. Required only if multiple voltages are provided.
> > +    $ref: "#/$defs/protocol-names"
> 
> The default for .*-names is the entries don't have to be unique. That's 
> for the exception, but unfortunately everyone else has to define the 
> type (type.yaml#/definitons/string).
> 
> Each user needs to define the names of the entries which will enforce 
> the length. So defining the length 1-16 here doesn't do much. So I think 
> you can drop that and then the $defs is not needed either.

I missed that all the names are defined here. Nevermind on the 2nd 
point. We probably still need either a $ref or 'uniqueItems: true'. 
Either way should work.

Rob