diff mbox series

[v2,1/5] dt-bindings: phy: imx8mq-usb: add compatible "fsl,imx95-usb-phy"

Message ID 20240806050639.1013152-1-xu.yang_2@nxp.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/5] dt-bindings: phy: imx8mq-usb: add compatible "fsl,imx95-usb-phy" | expand

Commit Message

Xu Yang Aug. 6, 2024, 5:06 a.m. UTC
The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
block. Since i.MX95 usb phy is able to switch SS lanes, this will also
add orientation-switch and port property to the file.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes in v2:
 - replace minItems with description in reg property
 - remove orientation-switch and port
 - refer to usb-switch.yaml
 - use unevaluatedProperties
---
 .../bindings/phy/fsl,imx8mq-usb-phy.yaml      | 42 ++++++++++++++++---
 1 file changed, 37 insertions(+), 5 deletions(-)

Comments

Krzysztof Kozlowski Aug. 6, 2024, 8:29 a.m. UTC | #1
On 06/08/2024 07:06, Xu Yang wrote:
> The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
> compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
> to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
> block. Since i.MX95 usb phy is able to switch SS lanes, this will also
> add orientation-switch and port property to the file.
> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> 
> ---
> Changes in v2:
>  - replace minItems with description in reg property
>  - remove orientation-switch and port
>  - refer to usb-switch.yaml
>  - use unevaluatedProperties
> ---
>  .../bindings/phy/fsl,imx8mq-usb-phy.yaml      | 42 ++++++++++++++++---
>  1 file changed, 37 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> index dc3a3f709fea..6d6d211883ae 100644
> --- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> +++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> @@ -11,12 +11,17 @@ maintainers:
>  
>  properties:
>    compatible:
> -    enum:
> -      - fsl,imx8mq-usb-phy
> -      - fsl,imx8mp-usb-phy
> +    oneOf:
> +      - enum:
> +          - fsl,imx8mq-usb-phy
> +          - fsl,imx8mp-usb-phy
> +      - items:
> +          - const: fsl,imx95-usb-phy
> +          - const: fsl,imx8mp-usb-phy
>  
>    reg:
> -    maxItems: 1
> +    minItems: 1
> +    maxItems: 2
>  
>    "#phy-cells":
>      const: 0
> @@ -89,7 +94,34 @@ required:
>    - clocks
>    - clock-names
>  
> -additionalProperties: false
> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            enum:
> +              - fsl,imx95-usb-phy
> +    then:
> +      properties:
> +        reg:
> +          items:
> +            - description: USB PHY Control range
> +            - description: USB PHY TCA Block range
> +    else:
> +      properties:
> +        reg:
> +          maxItems: 1
> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            enum:
> +              - fsl,imx95-usb-phy
> +    then:
> +      $ref: /schemas/usb/usb-switch.yaml#

ref should be rather in top-level. You can always disallow certain
properties for devices, if they are really not applicable.

Best regards,
Krzysztof
Frank Li Aug. 6, 2024, 4:11 p.m. UTC | #2
On Tue, Aug 06, 2024 at 10:29:47AM +0200, Krzysztof Kozlowski wrote:
> On 06/08/2024 07:06, Xu Yang wrote:
> > The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
> > compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
> > to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
> > block. Since i.MX95 usb phy is able to switch SS lanes, this will also
> > add orientation-switch and port property to the file.
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> >
> > ---
> > Changes in v2:
> >  - replace minItems with description in reg property
> >  - remove orientation-switch and port
> >  - refer to usb-switch.yaml
> >  - use unevaluatedProperties
> > ---
> >  .../bindings/phy/fsl,imx8mq-usb-phy.yaml      | 42 ++++++++++++++++---
> >  1 file changed, 37 insertions(+), 5 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> > index dc3a3f709fea..6d6d211883ae 100644
> > --- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> > +++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> > @@ -11,12 +11,17 @@ maintainers:
> >
> >  properties:
> >    compatible:
> > -    enum:
> > -      - fsl,imx8mq-usb-phy
> > -      - fsl,imx8mp-usb-phy
> > +    oneOf:
> > +      - enum:
> > +          - fsl,imx8mq-usb-phy
> > +          - fsl,imx8mp-usb-phy
> > +      - items:
> > +          - const: fsl,imx95-usb-phy
> > +          - const: fsl,imx8mp-usb-phy
> >
> >    reg:
> > -    maxItems: 1
> > +    minItems: 1
> > +    maxItems: 2
> >
> >    "#phy-cells":
> >      const: 0
> > @@ -89,7 +94,34 @@ required:
> >    - clocks
> >    - clock-names
> >
> > -additionalProperties: false
> > +allOf:
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            enum:
> > +              - fsl,imx95-usb-phy
> > +    then:
> > +      properties:
> > +        reg:
> > +          items:
> > +            - description: USB PHY Control range
> > +            - description: USB PHY TCA Block range
> > +    else:
> > +      properties:
> > +        reg:
> > +          maxItems: 1
> > +
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            enum:
> > +              - fsl,imx95-usb-phy
> > +    then:
> > +      $ref: /schemas/usb/usb-switch.yaml#
>
> ref should be rather in top-level. You can always disallow certain
> properties for devices, if they are really not applicable.

There are some "required" in usb-switch.yaml,

oneOf:
  - required:
      - port
  - required:
      - ports

If put on the top, it may cause DTB check warning for other compatible
strings, which have not support usb-switch.

Frank
>
> Best regards,
> Krzysztof
>
Xu Yang Aug. 7, 2024, 2:24 a.m. UTC | #3
On Tue, Aug 06, 2024 at 12:11:55PM -0400, Frank Li wrote:
> On Tue, Aug 06, 2024 at 10:29:47AM +0200, Krzysztof Kozlowski wrote:
> > On 06/08/2024 07:06, Xu Yang wrote:
> > > The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
> > > compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
> > > to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
> > > block. Since i.MX95 usb phy is able to switch SS lanes, this will also
> > > add orientation-switch and port property to the file.
> > >
> > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > >
> > > ---
> > > Changes in v2:
> > >  - replace minItems with description in reg property
> > >  - remove orientation-switch and port
> > >  - refer to usb-switch.yaml
> > >  - use unevaluatedProperties
> > > ---
> > >  .../bindings/phy/fsl,imx8mq-usb-phy.yaml      | 42 ++++++++++++++++---
> > >  1 file changed, 37 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> > > index dc3a3f709fea..6d6d211883ae 100644
> > > --- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> > > +++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> > > @@ -11,12 +11,17 @@ maintainers:
> > >
> > >  properties:
> > >    compatible:
> > > -    enum:
> > > -      - fsl,imx8mq-usb-phy
> > > -      - fsl,imx8mp-usb-phy
> > > +    oneOf:
> > > +      - enum:
> > > +          - fsl,imx8mq-usb-phy
> > > +          - fsl,imx8mp-usb-phy
> > > +      - items:
> > > +          - const: fsl,imx95-usb-phy
> > > +          - const: fsl,imx8mp-usb-phy
> > >
> > >    reg:
> > > -    maxItems: 1
> > > +    minItems: 1
> > > +    maxItems: 2
> > >
> > >    "#phy-cells":
> > >      const: 0
> > > @@ -89,7 +94,34 @@ required:
> > >    - clocks
> > >    - clock-names
> > >
> > > -additionalProperties: false
> > > +allOf:
> > > +  - if:
> > > +      properties:
> > > +        compatible:
> > > +          contains:
> > > +            enum:
> > > +              - fsl,imx95-usb-phy
> > > +    then:
> > > +      properties:
> > > +        reg:
> > > +          items:
> > > +            - description: USB PHY Control range
> > > +            - description: USB PHY TCA Block range
> > > +    else:
> > > +      properties:
> > > +        reg:
> > > +          maxItems: 1
> > > +
> > > +  - if:
> > > +      properties:
> > > +        compatible:
> > > +          contains:
> > > +            enum:
> > > +              - fsl,imx95-usb-phy
> > > +    then:
> > > +      $ref: /schemas/usb/usb-switch.yaml#
> >
> > ref should be rather in top-level. You can always disallow certain
> > properties for devices, if they are really not applicable.
> 
> There are some "required" in usb-switch.yaml,
> 
> oneOf:
>   - required:
>       - port
>   - required:
>       - ports
> 
> If put on the top, it may cause DTB check warning for other compatible
> strings, which have not support usb-switch.

Yes, even though I move usb-switch to top and set false for certain properties,
dtbinding check still has below error:

/home/nxf75279/work/usb/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.example.dtb: phy@381f0040: 'oneOf' conditional failed, one must be fixed:
        'port' is a required property
        'ports' is a required property
        from schema $id: http://devicetree.org/schemas/phy/fsl,imx8mq-usb-phy.yaml#

Thanks,
Xu Yang

> 
> Frank
> >
> > Best regards,
> > Krzysztof
> >
Krzysztof Kozlowski Aug. 7, 2024, 5:48 a.m. UTC | #4
On 06/08/2024 18:11, Frank Li wrote:
> On Tue, Aug 06, 2024 at 10:29:47AM +0200, Krzysztof Kozlowski wrote:
>> On 06/08/2024 07:06, Xu Yang wrote:
>>> The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
>>> compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
>>> to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
>>> block. Since i.MX95 usb phy is able to switch SS lanes, this will also
>>> add orientation-switch and port property to the file.
>>>
>>> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>>>
>>> ---
>>> Changes in v2:
>>>  - replace minItems with description in reg property
>>>  - remove orientation-switch and port
>>>  - refer to usb-switch.yaml
>>>  - use unevaluatedProperties
>>> ---
>>>  .../bindings/phy/fsl,imx8mq-usb-phy.yaml      | 42 ++++++++++++++++---
>>>  1 file changed, 37 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
>>> index dc3a3f709fea..6d6d211883ae 100644
>>> --- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
>>> +++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
>>> @@ -11,12 +11,17 @@ maintainers:
>>>
>>>  properties:
>>>    compatible:
>>> -    enum:
>>> -      - fsl,imx8mq-usb-phy
>>> -      - fsl,imx8mp-usb-phy
>>> +    oneOf:
>>> +      - enum:
>>> +          - fsl,imx8mq-usb-phy
>>> +          - fsl,imx8mp-usb-phy
>>> +      - items:
>>> +          - const: fsl,imx95-usb-phy
>>> +          - const: fsl,imx8mp-usb-phy
>>>
>>>    reg:
>>> -    maxItems: 1
>>> +    minItems: 1
>>> +    maxItems: 2
>>>
>>>    "#phy-cells":
>>>      const: 0
>>> @@ -89,7 +94,34 @@ required:
>>>    - clocks
>>>    - clock-names
>>>
>>> -additionalProperties: false
>>> +allOf:
>>> +  - if:
>>> +      properties:
>>> +        compatible:
>>> +          contains:
>>> +            enum:
>>> +              - fsl,imx95-usb-phy
>>> +    then:
>>> +      properties:
>>> +        reg:
>>> +          items:
>>> +            - description: USB PHY Control range
>>> +            - description: USB PHY TCA Block range
>>> +    else:
>>> +      properties:
>>> +        reg:
>>> +          maxItems: 1
>>> +
>>> +  - if:
>>> +      properties:
>>> +        compatible:
>>> +          contains:
>>> +            enum:
>>> +              - fsl,imx95-usb-phy
>>> +    then:
>>> +      $ref: /schemas/usb/usb-switch.yaml#
>>
>> ref should be rather in top-level. You can always disallow certain
>> properties for devices, if they are really not applicable.
> 
> There are some "required" in usb-switch.yaml,
> 
> oneOf:
>   - required:
>       - port
>   - required:
>       - ports
> 
> If put on the top, it may cause DTB check warning for other compatible
> strings, which have not support usb-switch.

Hm, indeed, that's unusual case to have such different devices in one
schema. Did you test that above $ref in if: actually works?

Best regards,
Krzysztof
Xu Yang Aug. 7, 2024, 5:57 a.m. UTC | #5
On Wed, Aug 07, 2024 at 07:48:43AM +0200, Krzysztof Kozlowski wrote:
> On 06/08/2024 18:11, Frank Li wrote:
> > On Tue, Aug 06, 2024 at 10:29:47AM +0200, Krzysztof Kozlowski wrote:
> >> On 06/08/2024 07:06, Xu Yang wrote:
> >>> The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
> >>> compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
> >>> to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
> >>> block. Since i.MX95 usb phy is able to switch SS lanes, this will also
> >>> add orientation-switch and port property to the file.
> >>>
> >>> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> >>>
> >>> ---
> >>> Changes in v2:
> >>>  - replace minItems with description in reg property
> >>>  - remove orientation-switch and port
> >>>  - refer to usb-switch.yaml
> >>>  - use unevaluatedProperties
> >>> ---
> >>>  .../bindings/phy/fsl,imx8mq-usb-phy.yaml      | 42 ++++++++++++++++---
> >>>  1 file changed, 37 insertions(+), 5 deletions(-)
> >>>
> >>> diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> >>> index dc3a3f709fea..6d6d211883ae 100644
> >>> --- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> >>> +++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
> >>> @@ -11,12 +11,17 @@ maintainers:
> >>>
> >>>  properties:
> >>>    compatible:
> >>> -    enum:
> >>> -      - fsl,imx8mq-usb-phy
> >>> -      - fsl,imx8mp-usb-phy
> >>> +    oneOf:
> >>> +      - enum:
> >>> +          - fsl,imx8mq-usb-phy
> >>> +          - fsl,imx8mp-usb-phy
> >>> +      - items:
> >>> +          - const: fsl,imx95-usb-phy
> >>> +          - const: fsl,imx8mp-usb-phy
> >>>
> >>>    reg:
> >>> -    maxItems: 1
> >>> +    minItems: 1
> >>> +    maxItems: 2
> >>>
> >>>    "#phy-cells":
> >>>      const: 0
> >>> @@ -89,7 +94,34 @@ required:
> >>>    - clocks
> >>>    - clock-names
> >>>
> >>> -additionalProperties: false
> >>> +allOf:
> >>> +  - if:
> >>> +      properties:
> >>> +        compatible:
> >>> +          contains:
> >>> +            enum:
> >>> +              - fsl,imx95-usb-phy
> >>> +    then:
> >>> +      properties:
> >>> +        reg:
> >>> +          items:
> >>> +            - description: USB PHY Control range
> >>> +            - description: USB PHY TCA Block range
> >>> +    else:
> >>> +      properties:
> >>> +        reg:
> >>> +          maxItems: 1
> >>> +
> >>> +  - if:
> >>> +      properties:
> >>> +        compatible:
> >>> +          contains:
> >>> +            enum:
> >>> +              - fsl,imx95-usb-phy
> >>> +    then:
> >>> +      $ref: /schemas/usb/usb-switch.yaml#
> >>
> >> ref should be rather in top-level. You can always disallow certain
> >> properties for devices, if they are really not applicable.
> > 
> > There are some "required" in usb-switch.yaml,
> > 
> > oneOf:
> >   - required:
> >       - port
> >   - required:
> >       - ports
> > 
> > If put on the top, it may cause DTB check warning for other compatible
> > strings, which have not support usb-switch.
> 
> Hm, indeed, that's unusual case to have such different devices in one
> schema. Did you test that above $ref in if: actually works?

Yes, it works and this yaml pass dt_binding_check and dtbs_check. 

Thanks,
Xu Yang

> 
> Best regards,
> Krzysztof
>
Krzysztof Kozlowski Aug. 7, 2024, 5:59 a.m. UTC | #6
On 07/08/2024 07:57, Xu Yang wrote:
> On Wed, Aug 07, 2024 at 07:48:43AM +0200, Krzysztof Kozlowski wrote:
>> On 06/08/2024 18:11, Frank Li wrote:
>>> On Tue, Aug 06, 2024 at 10:29:47AM +0200, Krzysztof Kozlowski wrote:
>>>> On 06/08/2024 07:06, Xu Yang wrote:
>>>>> The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
>>>>> compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
>>>>> to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
>>>>> block. Since i.MX95 usb phy is able to switch SS lanes, this will also
>>>>> add orientation-switch and port property to the file.
>>>>>
>>>>> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>>>>>
>>>>> ---
>>>>> Changes in v2:
>>>>>  - replace minItems with description in reg property
>>>>>  - remove orientation-switch and port
>>>>>  - refer to usb-switch.yaml
>>>>>  - use unevaluatedProperties
>>>>> ---
>>>>>  .../bindings/phy/fsl,imx8mq-usb-phy.yaml      | 42 ++++++++++++++++---
>>>>>  1 file changed, 37 insertions(+), 5 deletions(-)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
>>>>> index dc3a3f709fea..6d6d211883ae 100644
>>>>> --- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
>>>>> +++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
>>>>> @@ -11,12 +11,17 @@ maintainers:
>>>>>
>>>>>  properties:
>>>>>    compatible:
>>>>> -    enum:
>>>>> -      - fsl,imx8mq-usb-phy
>>>>> -      - fsl,imx8mp-usb-phy
>>>>> +    oneOf:
>>>>> +      - enum:
>>>>> +          - fsl,imx8mq-usb-phy
>>>>> +          - fsl,imx8mp-usb-phy
>>>>> +      - items:
>>>>> +          - const: fsl,imx95-usb-phy
>>>>> +          - const: fsl,imx8mp-usb-phy
>>>>>
>>>>>    reg:
>>>>> -    maxItems: 1
>>>>> +    minItems: 1
>>>>> +    maxItems: 2
>>>>>
>>>>>    "#phy-cells":
>>>>>      const: 0
>>>>> @@ -89,7 +94,34 @@ required:
>>>>>    - clocks
>>>>>    - clock-names
>>>>>
>>>>> -additionalProperties: false
>>>>> +allOf:
>>>>> +  - if:
>>>>> +      properties:
>>>>> +        compatible:
>>>>> +          contains:
>>>>> +            enum:
>>>>> +              - fsl,imx95-usb-phy
>>>>> +    then:
>>>>> +      properties:
>>>>> +        reg:
>>>>> +          items:
>>>>> +            - description: USB PHY Control range
>>>>> +            - description: USB PHY TCA Block range
>>>>> +    else:
>>>>> +      properties:
>>>>> +        reg:
>>>>> +          maxItems: 1
>>>>> +
>>>>> +  - if:
>>>>> +      properties:
>>>>> +        compatible:
>>>>> +          contains:
>>>>> +            enum:
>>>>> +              - fsl,imx95-usb-phy
>>>>> +    then:
>>>>> +      $ref: /schemas/usb/usb-switch.yaml#
>>>>
>>>> ref should be rather in top-level. You can always disallow certain
>>>> properties for devices, if they are really not applicable.
>>>
>>> There are some "required" in usb-switch.yaml,
>>>
>>> oneOf:
>>>   - required:
>>>       - port
>>>   - required:
>>>       - ports
>>>
>>> If put on the top, it may cause DTB check warning for other compatible
>>> strings, which have not support usb-switch.
>>
>> Hm, indeed, that's unusual case to have such different devices in one
>> schema. Did you test that above $ref in if: actually works?
> 
> Yes, it works and this yaml pass dt_binding_check and dtbs_check. 

I know it passes, I am asking whether it actually works. Is the $ref
actually effective? Is it properly applied?

Best regards,
Krzysztof
Xu Yang Aug. 7, 2024, 7:11 a.m. UTC | #7
On Wed, Aug 07, 2024 at 07:59:02AM +0200, Krzysztof Kozlowski wrote:
> On 07/08/2024 07:57, Xu Yang wrote:
> > On Wed, Aug 07, 2024 at 07:48:43AM +0200, Krzysztof Kozlowski wrote:
> >> On 06/08/2024 18:11, Frank Li wrote:
> >>> On Tue, Aug 06, 2024 at 10:29:47AM +0200, Krzysztof Kozlowski wrote:
> >>>> On 06/08/2024 07:06, Xu Yang wrote:
> >>>>> The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
> >>>>> compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
> >>>>> to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
> >>>>> block. Since i.MX95 usb phy is able to switch SS lanes, this will also
> >>>>> add orientation-switch and port property to the file.
> >>>>>
> >>>>> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> >>>>>
> >>>>> ---
> >>>>> Changes in v2:
> >>>>>  - replace minItems with description in reg property
> >>>>>  - remove orientation-switch and port
> >>>>>  - refer to usb-switch.yaml
> >>>>>  - use unevaluatedProperties
> >>>>>
[...]
> >>>>
> >>>> ref should be rather in top-level. You can always disallow certain
> >>>> properties for devices, if they are really not applicable.
> >>>
> >>> There are some "required" in usb-switch.yaml,
> >>>
> >>> oneOf:
> >>>   - required:
> >>>       - port
> >>>   - required:
> >>>       - ports
> >>>
> >>> If put on the top, it may cause DTB check warning for other compatible
> >>> strings, which have not support usb-switch.
> >>
> >> Hm, indeed, that's unusual case to have such different devices in one
> >> schema. Did you test that above $ref in if: actually works?
> > 
> > Yes, it works and this yaml pass dt_binding_check and dtbs_check. 
> 
> I know it passes, I am asking whether it actually works. Is the $ref
> actually effective? Is it properly applied?

If imx95 usb phy node doesn't contain "orientation-switch" and "port", dtb check will
show below error:

usb/arch/arm64/boot/dts/freescale/imx95-19x19-evk.dtb: phy@4c1f0040: 'oneOf' conditional failed, one must be fixed:
        'port' is a required property
        'ports' is a required property
        from schema $id: http://devicetree.org/schemas/phy/fsl,imx8mq-usb-phy.yaml#

Do you want other test results?

Thanks,
Xu Yang

> 
> Best regards,
> Krzysztof
>
Krzysztof Kozlowski Aug. 7, 2024, 7:20 a.m. UTC | #8
On 07/08/2024 09:11, Xu Yang wrote:
> On Wed, Aug 07, 2024 at 07:59:02AM +0200, Krzysztof Kozlowski wrote:
>> On 07/08/2024 07:57, Xu Yang wrote:
>>> On Wed, Aug 07, 2024 at 07:48:43AM +0200, Krzysztof Kozlowski wrote:
>>>> On 06/08/2024 18:11, Frank Li wrote:
>>>>> On Tue, Aug 06, 2024 at 10:29:47AM +0200, Krzysztof Kozlowski wrote:
>>>>>> On 06/08/2024 07:06, Xu Yang wrote:
>>>>>>> The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
>>>>>>> compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
>>>>>>> to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
>>>>>>> block. Since i.MX95 usb phy is able to switch SS lanes, this will also
>>>>>>> add orientation-switch and port property to the file.
>>>>>>>
>>>>>>> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>>>>>>>
>>>>>>> ---
>>>>>>> Changes in v2:
>>>>>>>  - replace minItems with description in reg property
>>>>>>>  - remove orientation-switch and port
>>>>>>>  - refer to usb-switch.yaml
>>>>>>>  - use unevaluatedProperties
>>>>>>>
> [...]
>>>>>>
>>>>>> ref should be rather in top-level. You can always disallow certain
>>>>>> properties for devices, if they are really not applicable.
>>>>>
>>>>> There are some "required" in usb-switch.yaml,
>>>>>
>>>>> oneOf:
>>>>>   - required:
>>>>>       - port
>>>>>   - required:
>>>>>       - ports
>>>>>
>>>>> If put on the top, it may cause DTB check warning for other compatible
>>>>> strings, which have not support usb-switch.
>>>>
>>>> Hm, indeed, that's unusual case to have such different devices in one
>>>> schema. Did you test that above $ref in if: actually works?
>>>
>>> Yes, it works and this yaml pass dt_binding_check and dtbs_check. 
>>
>> I know it passes, I am asking whether it actually works. Is the $ref
>> actually effective? Is it properly applied?
> 
> If imx95 usb phy node doesn't contain "orientation-switch" and "port", dtb check will
> show below error:
> 
> usb/arch/arm64/boot/dts/freescale/imx95-19x19-evk.dtb: phy@4c1f0040: 'oneOf' conditional failed, one must be fixed:
>         'port' is a required property
>         'ports' is a required property
>         from schema $id: http://devicetree.org/schemas/phy/fsl,imx8mq-usb-phy.yaml#
> 
> Do you want other test results?

Thank you for confirmation, it's enough.

Best regards,
Krzysztof
Krzysztof Kozlowski Aug. 7, 2024, 7:20 a.m. UTC | #9
On 06/08/2024 07:06, Xu Yang wrote:
> The usb phy in i.MX95 is compatible with i.MX8MP's, this will add a
> compatible "fsl,imx95-usb-phy" for i.MX95. Also change reg maxItems
> to 2 since i.MX95 needs another regmap to control Type-C Assist (TCA)
> block. Since i.MX95 usb phy is able to switch SS lanes, this will also
> add orientation-switch and port property to the file.
> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
index dc3a3f709fea..6d6d211883ae 100644
--- a/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.yaml
@@ -11,12 +11,17 @@  maintainers:
 
 properties:
   compatible:
-    enum:
-      - fsl,imx8mq-usb-phy
-      - fsl,imx8mp-usb-phy
+    oneOf:
+      - enum:
+          - fsl,imx8mq-usb-phy
+          - fsl,imx8mp-usb-phy
+      - items:
+          - const: fsl,imx95-usb-phy
+          - const: fsl,imx8mp-usb-phy
 
   reg:
-    maxItems: 1
+    minItems: 1
+    maxItems: 2
 
   "#phy-cells":
     const: 0
@@ -89,7 +94,34 @@  required:
   - clocks
   - clock-names
 
-additionalProperties: false
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - fsl,imx95-usb-phy
+    then:
+      properties:
+        reg:
+          items:
+            - description: USB PHY Control range
+            - description: USB PHY TCA Block range
+    else:
+      properties:
+        reg:
+          maxItems: 1
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - fsl,imx95-usb-phy
+    then:
+      $ref: /schemas/usb/usb-switch.yaml#
+
+unevaluatedProperties: false
 
 examples:
   - |