diff mbox series

[2/5] dt-bindings: net: Add MTIP L2 switch description (fec,mtip-switch.yaml)

Message ID 20250325115736.1732721-3-lukma@denx.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: mtip: Add support for MTIP imx287 L2 switch driver | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Guessed tree name to be net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning WARNING: DT binding documents should be licensed (GPL-2.0-only OR BSD-2-Clause) WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2025-03-25--15-00 (tests: 896)

Commit Message

Lukasz Majewski March 25, 2025, 11:57 a.m. UTC
This patch provides description of the MTIP L2 switch available in some
NXP's SOCs - imx287, vf610.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
 .../bindings/net/fec,mtip-switch.yaml         | 160 ++++++++++++++++++
 1 file changed, 160 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/fec,mtip-switch.yaml

Comments

Krzysztof Kozlowski March 25, 2025, 12:04 p.m. UTC | #1
On 25/03/2025 12:57, Lukasz Majewski wrote:
> This patch provides description of the MTIP L2 switch available in some
> NXP's SOCs - imx287, vf610.
> 
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> ---
>  .../bindings/net/fec,mtip-switch.yaml         | 160 ++++++++++++++++++

Use compatible as filename.

>  1 file changed, 160 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> new file mode 100644
> index 000000000000..cd85385e0f79
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> @@ -0,0 +1,160 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/fsl,mtip-switch.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Freescale MTIP Level 2 (L2) switch
> +
> +maintainers:
> +  - Lukasz Majewski <lukma@denx.de>
> +

description?

> +allOf:
> +  - $ref: ethernet-controller.yaml#
> +
> +properties:
> +  compatible:
> +    oneOf:

Drop, you have only one variant.

> +      - enum:
> +	  - imx287-mtip-switch

This wasn't tested. Except whitespace errors, above compatible does not
have format of compatible. Please look at other NXP bindings.

Missing blank line.

> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 3

Need to list items instead.

> +
> +  clocks:
> +    maxItems: 4
> +    description:
> +      The "ipg", for MAC ipg_clk_s, ipg_clk_mac_s that are for register accessing.
> +      The "ahb", for MAC ipg_clk, ipg_clk_mac that are bus clock.
> +      The "ptp"(option), for IEEE1588 timer clock that requires the clock.
> +      The "enet_out"(option), output clock for external device, like supply clock
> +      for PHY. The clock is required if PHY clock source from SOC.

Same problems. This binding does not look at all as any other binding. I
finish review here, but the code has similar trivial issues all the way,
including incorrect indentation. Start from well reviewed existing
binding or example-schema.

Best regards,
Krzysztof
Lukasz Majewski March 25, 2025, 12:15 p.m. UTC | #2
Hi Krzysztof,

> On 25/03/2025 12:57, Lukasz Majewski wrote:
> > This patch provides description of the MTIP L2 switch available in
> > some NXP's SOCs - imx287, vf610.
> > 
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > ---
> >  .../bindings/net/fec,mtip-switch.yaml         | 160
> > ++++++++++++++++++  
> 
> Use compatible as filename.

I've followed the fsl,fec.yaml as an example. This file has description
for all the device tree sources from fec_main.c

I've considered adding the full name - e.g. fec,imx287-mtip-switch.yaml
but this driver could (and probably will) be extended to vf610.

So what is the advised way to go?

> 
> >  1 file changed, 160 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> > 
> > diff --git
> > a/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> > b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml new
> > file mode 100644 index 000000000000..cd85385e0f79 --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> > @@ -0,0 +1,160 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/fsl,mtip-switch.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Freescale MTIP Level 2 (L2) switch
> > +
> > +maintainers:
> > +  - Lukasz Majewski <lukma@denx.de>
> > +  
> 
> description?

Ok.

> 
> > +allOf:
> > +  - $ref: ethernet-controller.yaml#
> > +
> > +properties:
> > +  compatible:
> > +    oneOf:  
> 
> Drop, you have only one variant.

Ok, for imx287 this can be dropped, and then extended with vf610.

> 
> > +      - enum:
> > +	  - imx287-mtip-switch  
> 
> This wasn't tested. Except whitespace errors, above compatible does
> not have format of compatible. Please look at other NXP bindings.
> 
> Missing blank line.
> 
> > +  reg:
> > +    maxItems: 1
> > +
> > +  interrupts:
> > +    maxItems: 3  
> 
> Need to list items instead.
> 
> > +
> > +  clocks:
> > +    maxItems: 4
> > +    description:
> > +      The "ipg", for MAC ipg_clk_s, ipg_clk_mac_s that are for
> > register accessing.
> > +      The "ahb", for MAC ipg_clk, ipg_clk_mac that are bus clock.
> > +      The "ptp"(option), for IEEE1588 timer clock that requires
> > the clock.
> > +      The "enet_out"(option), output clock for external device,
> > like supply clock
> > +      for PHY. The clock is required if PHY clock source from SOC.
> >  
> 
> Same problems. This binding does not look at all as any other
> binding. I finish review here, but the code has similar trivial
> issues all the way, including incorrect indentation. Start from well
> reviewed existing binding or example-schema.

As I've stated above - this code is reduced copy of fsl,fec.yaml...

> 
> Best regards,
> Krzysztof

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Krzysztof Kozlowski March 25, 2025, 12:24 p.m. UTC | #3
On 25/03/2025 13:15, Lukasz Majewski wrote:
> Hi Krzysztof,
> 
>> On 25/03/2025 12:57, Lukasz Majewski wrote:
>>> This patch provides description of the MTIP L2 switch available in
>>> some NXP's SOCs - imx287, vf610.
>>>
>>> Signed-off-by: Lukasz Majewski <lukma@denx.de>
>>> ---
>>>  .../bindings/net/fec,mtip-switch.yaml         | 160
>>> ++++++++++++++++++  
>>
>> Use compatible as filename.
> 
> I've followed the fsl,fec.yaml as an example. This file has description
> for all the device tree sources from fec_main.c


That's a 14 year old binding, so clear antipattern.

> 
> I've considered adding the full name - e.g. fec,imx287-mtip-switch.yaml
> but this driver could (and probably will) be extended to vf610.

Unless you add vf610 now, this should follow the compatible name.

> 
> So what is the advised way to go?
> 
>>
>>>  1 file changed, 160 insertions(+)
>>>  create mode 100644
>>> Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
>>>
>>> diff --git
>>> a/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
>>> b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml new
>>> file mode 100644 index 000000000000..cd85385e0f79 --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
>>> @@ -0,0 +1,160 @@
>>> +# SPDX-License-Identifier: GPL-2.0-only
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/net/fsl,mtip-switch.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: Freescale MTIP Level 2 (L2) switch
>>> +
>>> +maintainers:
>>> +  - Lukasz Majewski <lukma@denx.de>
>>> +  
>>
>> description?
> 
> Ok.
> 
>>
>>> +allOf:
>>> +  - $ref: ethernet-controller.yaml#
>>> +
>>> +properties:
>>> +  compatible:
>>> +    oneOf:  
>>
>> Drop, you have only one variant.
> 
> Ok, for imx287 this can be dropped, and then extended with vf610.
> 
>>
>>> +      - enum:
>>> +	  - imx287-mtip-switch  
>>
>> This wasn't tested. Except whitespace errors, above compatible does
>> not have format of compatible. Please look at other NXP bindings.
>>
>> Missing blank line.
>>
>>> +  reg:
>>> +    maxItems: 1
>>> +
>>> +  interrupts:
>>> +    maxItems: 3  
>>
>> Need to list items instead.
>>
>>> +
>>> +  clocks:
>>> +    maxItems: 4
>>> +    description:
>>> +      The "ipg", for MAC ipg_clk_s, ipg_clk_mac_s that are for
>>> register accessing.
>>> +      The "ahb", for MAC ipg_clk, ipg_clk_mac that are bus clock.
>>> +      The "ptp"(option), for IEEE1588 timer clock that requires
>>> the clock.
>>> +      The "enet_out"(option), output clock for external device,
>>> like supply clock
>>> +      for PHY. The clock is required if PHY clock source from SOC.
>>>  
>>
>> Same problems. This binding does not look at all as any other
>> binding. I finish review here, but the code has similar trivial
>> issues all the way, including incorrect indentation. Start from well
>> reviewed existing binding or example-schema.
> 
> As I've stated above - this code is reduced copy of fsl,fec.yaml...

Don't take the worst, old code with all the anti-patterns we point out
on each review, as an example.

Take the most recent, well reviewed binding as an example. Or
example-schema.

Best regards,
Krzysztof
Lukasz Majewski March 25, 2025, 12:39 p.m. UTC | #4
Hi Krzysztof,

> On 25/03/2025 13:15, Lukasz Majewski wrote:
> > Hi Krzysztof,
> >   
> >> On 25/03/2025 12:57, Lukasz Majewski wrote:  
> >>> This patch provides description of the MTIP L2 switch available in
> >>> some NXP's SOCs - imx287, vf610.
> >>>
> >>> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> >>> ---
> >>>  .../bindings/net/fec,mtip-switch.yaml         | 160
> >>> ++++++++++++++++++    
> >>
> >> Use compatible as filename.  
> > 
> > I've followed the fsl,fec.yaml as an example. This file has
> > description for all the device tree sources from fec_main.c  
> 
> 
> That's a 14 year old binding, so clear antipattern.

For some reason it is still there...

> 
> > 
> > I've considered adding the full name - e.g.
> > fec,imx287-mtip-switch.yaml but this driver could (and probably
> > will) be extended to vf610.  
> 
> Unless you add vf610 now, this should follow the compatible name.

Ok.

> 
> > 
> > So what is the advised way to go?
> >   
> >>  
> >>>  1 file changed, 160 insertions(+)
> >>>  create mode 100644
> >>> Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> >>>
> >>> diff --git
> >>> a/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> >>> b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml new
> >>> file mode 100644 index 000000000000..cd85385e0f79 --- /dev/null
> >>> +++ b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> >>> @@ -0,0 +1,160 @@
> >>> +# SPDX-License-Identifier: GPL-2.0-only
> >>> +%YAML 1.2
> >>> +---
> >>> +$id: http://devicetree.org/schemas/net/fsl,mtip-switch.yaml#
> >>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >>> +
> >>> +title: Freescale MTIP Level 2 (L2) switch
> >>> +
> >>> +maintainers:
> >>> +  - Lukasz Majewski <lukma@denx.de>
> >>> +    
> >>
> >> description?  
> > 
> > Ok.
> >   
> >>  
> >>> +allOf:
> >>> +  - $ref: ethernet-controller.yaml#
> >>> +
> >>> +properties:
> >>> +  compatible:
> >>> +    oneOf:    
> >>
> >> Drop, you have only one variant.  
> > 
> > Ok, for imx287 this can be dropped, and then extended with vf610.
> >   
> >>  
> >>> +      - enum:
> >>> +	  - imx287-mtip-switch    
> >>
> >> This wasn't tested. Except whitespace errors, above compatible does
> >> not have format of compatible. Please look at other NXP bindings.
> >>
> >> Missing blank line.
> >>  
> >>> +  reg:
> >>> +    maxItems: 1
> >>> +
> >>> +  interrupts:
> >>> +    maxItems: 3    
> >>
> >> Need to list items instead.
> >>  
> >>> +
> >>> +  clocks:
> >>> +    maxItems: 4
> >>> +    description:
> >>> +      The "ipg", for MAC ipg_clk_s, ipg_clk_mac_s that are for
> >>> register accessing.
> >>> +      The "ahb", for MAC ipg_clk, ipg_clk_mac that are bus clock.
> >>> +      The "ptp"(option), for IEEE1588 timer clock that requires
> >>> the clock.
> >>> +      The "enet_out"(option), output clock for external device,
> >>> like supply clock
> >>> +      for PHY. The clock is required if PHY clock source from
> >>> SOC. 
> >>
> >> Same problems. This binding does not look at all as any other
> >> binding. I finish review here, but the code has similar trivial
> >> issues all the way, including incorrect indentation. Start from
> >> well reviewed existing binding or example-schema.  
> > 
> > As I've stated above - this code is reduced copy of fsl,fec.yaml...
> >  
> 
> Don't take the worst, old code with all the anti-patterns we point out
> on each review, as an example.
> 
> Take the most recent, well reviewed binding as an example. Or
> example-schema.

Ok.

> 
> Best regards,
> Krzysztof


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Krzysztof Kozlowski March 25, 2025, 12:43 p.m. UTC | #5
On 25/03/2025 13:39, Lukasz Majewski wrote:
> Hi Krzysztof,
> 
>> On 25/03/2025 13:15, Lukasz Majewski wrote:
>>> Hi Krzysztof,
>>>   
>>>> On 25/03/2025 12:57, Lukasz Majewski wrote:  
>>>>> This patch provides description of the MTIP L2 switch available in
>>>>> some NXP's SOCs - imx287, vf610.
>>>>>
>>>>> Signed-off-by: Lukasz Majewski <lukma@denx.de>
>>>>> ---
>>>>>  .../bindings/net/fec,mtip-switch.yaml         | 160
>>>>> ++++++++++++++++++    
>>>>
>>>> Use compatible as filename.  
>>>
>>> I've followed the fsl,fec.yaml as an example. This file has
>>> description for all the device tree sources from fec_main.c  
>>
>>
>> That's a 14 year old binding, so clear antipattern.
> 
> For some reason it is still there...

And it will be there for very long time. Bindings are not removed just
because they are old, because they are an ABI. That's still not a reason
to use something old as starting point.

It's the same with drivers, although driver can be easier changed and
old pattern can be dropped. You cannot easily drop old, anti-patterns
from the binding.

Best regards,
Krzysztof
Rob Herring (Arm) March 25, 2025, 1:25 p.m. UTC | #6
On Tue, 25 Mar 2025 12:57:33 +0100, Lukasz Majewski wrote:
> This patch provides description of the MTIP L2 switch available in some
> NXP's SOCs - imx287, vf610.
> 
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> ---
>  .../bindings/net/fec,mtip-switch.yaml         | 160 ++++++++++++++++++
>  1 file changed, 160 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:
./Documentation/devicetree/bindings/net/fec,mtip-switch.yaml:19:1: [error] syntax error: found character '\t' that cannot start any token (syntax)

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml: ignoring, error parsing file
./Documentation/devicetree/bindings/net/fec,mtip-switch.yaml:19:1: found character '\t' that cannot start any token
make[2]: *** Deleting file 'Documentation/devicetree/bindings/net/fec,mtip-switch.example.dts'
Documentation/devicetree/bindings/net/fec,mtip-switch.yaml:19:1: found character '\t' that cannot start any token
make[2]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/net/fec,mtip-switch.example.dts] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1511: dt_binding_check] Error 2
make: *** [Makefile:251: __sub-make] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250325115736.1732721-3-lukma@denx.de

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
Lukasz Majewski March 25, 2025, 2:27 p.m. UTC | #7
Hi Krzysztof,

> On 25/03/2025 13:39, Lukasz Majewski wrote:
> > Hi Krzysztof,
> >   
> >> On 25/03/2025 13:15, Lukasz Majewski wrote:  
> >>> Hi Krzysztof,
> >>>     
> >>>> On 25/03/2025 12:57, Lukasz Majewski wrote:    
> >>>>> This patch provides description of the MTIP L2 switch available
> >>>>> in some NXP's SOCs - imx287, vf610.
> >>>>>
> >>>>> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> >>>>> ---
> >>>>>  .../bindings/net/fec,mtip-switch.yaml         | 160
> >>>>> ++++++++++++++++++      
> >>>>
> >>>> Use compatible as filename.    
> >>>
> >>> I've followed the fsl,fec.yaml as an example. This file has
> >>> description for all the device tree sources from fec_main.c    
> >>
> >>
> >> That's a 14 year old binding, so clear antipattern.  
> > 
> > For some reason it is still there...  
> 
> And it will be there for very long time. Bindings are not removed just
> because they are old, because they are an ABI. That's still not a
> reason to use something old as starting point.

It was unintentional - if I would know that fsl,fec.yaml is so old, I
would use another one as a starting point.

I will use more recent one to provide proper bindings for this driver.

> 
> It's the same with drivers, although driver can be easier changed and
> old pattern can be dropped. You cannot easily drop old, anti-patterns
> from the binding.

Yes, I'm fully aware of the problem.

> 
> Best regards,
> Krzysztof




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Andrew Lunn March 25, 2025, 3:05 p.m. UTC | #8
> +  phy-reset-gpios:
> +    deprecated: true
> +    description:
> +      Should specify the gpio for phy reset.

It seem odd that a new binding has deprecated properties. Maybe add a
comment in the commit message as to why they are there. I assume this
is because you are re-using part of the FEC code as is, and it
implements them?

	   Andrew
Krzysztof Kozlowski March 25, 2025, 3:11 p.m. UTC | #9
On 25/03/2025 16:05, Andrew Lunn wrote:
>> +  phy-reset-gpios:
>> +    deprecated: true
>> +    description:
>> +      Should specify the gpio for phy reset.
> 
> It seem odd that a new binding has deprecated properties. Maybe add a
> comment in the commit message as to why they are there. I assume this
> is because you are re-using part of the FEC code as is, and it
> implements them?

Re-using existing driver code should not be a reason to use deprecated
properties, because you can change that common driver parts to support
both: old FEC style and new MTIP-L2-FEC switch.

Best regards,
Krzysztof
Lukasz Majewski March 25, 2025, 4:12 p.m. UTC | #10
Hi Andrew,

> > +  phy-reset-gpios:
> > +    deprecated: true
> > +    description:
> > +      Should specify the gpio for phy reset.  
> 
> It seem odd that a new binding has deprecated properties. Maybe add a
> comment in the commit message as to why they are there. I assume this
> is because you are re-using part of the FEC code as is, and it
> implements them?

+1

> 
> 	   Andrew
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Lukasz Majewski March 26, 2025, 1:43 p.m. UTC | #11
Hi Andrew,

> > +  phy-reset-gpios:
> > +    deprecated: true
> > +    description:
> > +      Should specify the gpio for phy reset.  
> 
> It seem odd that a new binding has deprecated properties. Maybe add a
> comment in the commit message as to why they are there. I assume this
> is because you are re-using part of the FEC code as is, and it
> implements them?
> 

In the case of MTIP L2 switch, the reset gpio line (in my case, but
also on e.g. imx28-evk, and vf610) is single for both PHYs.

I could move the reset to mdio child nodes, but this would be
problematic, as asserting reset on one PHY would reset the second one.

That is why there is a single 'phy-reset-gpios' property for the switch
driver.

I do believe that for FEC it may be deprecated, but for the HW
configurations I'm aware of it fits best. 

> 	   Andrew
> 


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Krzysztof Kozlowski March 26, 2025, 2:15 p.m. UTC | #12
On 26/03/2025 14:43, Lukasz Majewski wrote:
> Hi Andrew,
> 
>>> +  phy-reset-gpios:
>>> +    deprecated: true
>>> +    description:
>>> +      Should specify the gpio for phy reset.  
>>
>> It seem odd that a new binding has deprecated properties. Maybe add a
>> comment in the commit message as to why they are there. I assume this
>> is because you are re-using part of the FEC code as is, and it
>> implements them?
>>
> 
> In the case of MTIP L2 switch, the reset gpio line (in my case, but
> also on e.g. imx28-evk, and vf610) is single for both PHYs.

That's kind of proof that property was not placed in correct place.

> 
> I could move the reset to mdio child nodes, but this would be
> problematic, as asserting reset on one PHY would reset the second one.

It wouldn't if you used reset controller framework for that GPIO. Please
move the GPIOs to the device actually having the line, so the GPIOs.

Since a year such workarounds are not allowed in kernel anymore.

Best regards,
Krzysztof
Andrew Lunn March 26, 2025, 3:24 p.m. UTC | #13
On Wed, Mar 26, 2025 at 02:43:16PM +0100, Lukasz Majewski wrote:
> Hi Andrew,
> 
> > > +  phy-reset-gpios:
> > > +    deprecated: true
> > > +    description:
> > > +      Should specify the gpio for phy reset.  
> > 
> > It seem odd that a new binding has deprecated properties. Maybe add a
> > comment in the commit message as to why they are there. I assume this
> > is because you are re-using part of the FEC code as is, and it
> > implements them?
> > 
> 
> In the case of MTIP L2 switch, the reset gpio line (in my case, but
> also on e.g. imx28-evk, and vf610) is single for both PHYs.

So this is known as an MDIO bus reset, not a PHY reset.

Documentation/devicetree/bindings/net/mdio.yaml

  reset-gpios:
    maxItems: 1
    description:
      The phandle and specifier for the GPIO that controls the RESET
      lines of all devices on that MDIO bus.

We have moved the handling of such reset lines into core code, which
is why per driver properties are deprecated, and you should use the
properties defined in the core.

	Andrew
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
new file mode 100644
index 000000000000..cd85385e0f79
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/fec,mtip-switch.yaml
@@ -0,0 +1,160 @@ 
+# SPDX-License-Identifier: GPL-2.0-only
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/fsl,mtip-switch.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Freescale MTIP Level 2 (L2) switch
+
+maintainers:
+  - Lukasz Majewski <lukma@denx.de>
+
+allOf:
+  - $ref: ethernet-controller.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - enum:
+	  - imx287-mtip-switch
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 3
+
+  clocks:
+    maxItems: 4
+    description:
+      The "ipg", for MAC ipg_clk_s, ipg_clk_mac_s that are for register accessing.
+      The "ahb", for MAC ipg_clk, ipg_clk_mac that are bus clock.
+      The "ptp"(option), for IEEE1588 timer clock that requires the clock.
+      The "enet_out"(option), output clock for external device, like supply clock
+      for PHY. The clock is required if PHY clock source from SOC.
+
+  clock-names:
+    minItems: 4
+    maxItems: 4
+    items:
+      enum:
+	- ipg
+	- ahb
+	- ptp
+	- enet_out
+
+  phy-supply:
+    description:
+      Regulator that powers the Ethernet PHY.
+
+  phy-reset-gpios:
+    deprecated: true
+    description:
+      Should specify the gpio for phy reset.
+
+  phy-reset-duration:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description:
+      Reset duration in milliseconds.  Should present only if property
+      "phy-reset-gpios" is available.  Missing the property will have the
+      duration be 1 millisecond.  Numbers greater than 1000 are invalid
+      and 1 millisecond will be used instead.
+
+  phy-reset-post-delay:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description:
+      Post reset delay in milliseconds. If present then a delay of phy-reset-post-delay
+      milliseconds will be observed after the phy-reset-gpios has been toggled.
+      Can be omitted thus no delay is observed. Delay is in range of 1ms to 1000ms.
+      Other delays are invalid.
+
+  mdio:
+    $ref: mdio.yaml#
+    unevaluatedProperties: false
+    description:
+      Specifies the mdio bus in the FEC, used as a container for phy nodes.
+
+  ethernet-ports:
+    type: object
+    additionalProperties: false
+
+    patternProperties:
+      "^port@[0-9a-f]+$":
+	$ref: /schemas/net/ethernet-switch-controller.yaml#
+	unevaluatedProperties: false
+
+	properties:
+	  reg:
+	    description: Switch port number
+
+	required:
+	  - reg
+	  - phy-mode
+	  - phy-handle
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - mdio
+  - ethernet-ports
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    switch@800f0000 {
+	compatible = "fsl,imx287-mtip-switch";
+	pinctrl-names = "default";
+	pinctrl-0 = <&mac0_pins_a>, <&mac1_pins_a>;
+	phy-supply = <&reg_fec_3v3>;
+	phy-reset-duration = <25>;
+	phy-reset-post-delay = <10>;
+	interrupts = <100>, <101>, <102>;
+	clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>;
+	clock-names = "ipg", "ahb", "enet_out", "ptp";
+	status = "okay";
+
+	ethernet-ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mtip_port1: port@1 {
+			reg = <1>;
+			label = "lan0";
+			local-mac-address = [ 00 00 00 00 00 00 ];
+			phy-mode = "rmii";
+			phy-handle = <&ethphy0>;
+		};
+
+		mtip_port2: port@2 {
+			reg = <2>;
+			label = "lan1";
+			local-mac-address = [ 00 00 00 00 00 00 ];
+			phy-mode = "rmii";
+			phy-handle = <&ethphy1>;
+		};
+	};
+
+	mdio {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ethphy0: ethernet-phy@0 {
+			reg = <0>;
+			smsc,disable-energy-detect;
+			/* Both PHYs (i.e. 0,1) have the same, single GPIO, */
+			/* line to handle both, their interrupts (AND'ed) */
+			interrupt-parent = <&gpio4>;
+			interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+		};
+
+		ethphy1: ethernet-phy@1 {
+			reg = <1>;
+			smsc,disable-energy-detect;
+			interrupt-parent = <&gpio4>;
+			interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+		};
+	};
+    };