[net-next,1/3] dt-bindings: net: dp83822: support configuring RMII master/slave mode

Message ID 20240222103117.526955-2-jeremie.dautheribes@bootlin.com
State New
Headers
Series Add support for TI DP83826 configuration |

Commit Message

Jérémie Dautheribes Feb. 22, 2024, 10:31 a.m. UTC
  Add property ti,rmii-mode to support selecting the RMII operation mode
between:
	- master mode (PHY operates from a 25MHz clock reference)
	- slave mode (PHY operates from a 50MHz clock reference)

If not set, the operation mode is configured by hardware straps.

Signed-off-by: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com>
---
 .../devicetree/bindings/net/ti,dp83822.yaml      | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
  

Comments

Krzysztof Kozlowski Feb. 22, 2024, 3:09 p.m. UTC | #1
On 22/02/2024 11:31, Jérémie Dautheribes wrote:
> Add property ti,rmii-mode to support selecting the RMII operation mode
> between:
> 	- master mode (PHY operates from a 25MHz clock reference)
> 	- slave mode (PHY operates from a 50MHz clock reference)
> 
> If not set, the operation mode is configured by hardware straps.
> 
> Signed-off-by: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com>
> ---

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

Best regards,
Krzysztof
  
Andrew Lunn Feb. 26, 2024, 3:28 p.m. UTC | #2
On Thu, Feb 22, 2024 at 11:31:15AM +0100, Jérémie Dautheribes wrote:
> Add property ti,rmii-mode to support selecting the RMII operation mode
> between:
> 	- master mode (PHY operates from a 25MHz clock reference)
> 	- slave mode (PHY operates from a 50MHz clock reference)
> 
> If not set, the operation mode is configured by hardware straps.
> 
> Signed-off-by: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com>
> ---
>  .../devicetree/bindings/net/ti,dp83822.yaml      | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/ti,dp83822.yaml b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
> index 8f4350be689c..8f23254c0458 100644
> --- a/Documentation/devicetree/bindings/net/ti,dp83822.yaml
> +++ b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
> @@ -80,6 +80,22 @@ properties:
>             10625, 11250, 11875, 12500, 13125, 13750, 14375, 15000]
>      default: 10000
>  
> +  ti,rmii-mode:
> +    description: |
> +       If present, select the RMII operation mode. Two modes are
> +       available:
> +         - RMII master, where the PHY operates from a 25MHz clock reference,
> +         provided by a crystal or a CMOS-level oscillator
> +         - RMII slave, where the PHY operates from a 50MHz clock reference,
> +         provided by a CMOS-level oscillator

What has master and slave got to do with this?

Sometimes, the MAC provides a clock to the PHY, and all data transfer
over the RMII bus is timed by that.

Sometimes, the PHY provides a clock to the MAC, and all data transfer
over the RMII bus is timed by that.

Here there is a clear master/slave relationship, who is providing the
clock, who is consuming the clock. However, what you describe does not
fit that. Maybe look at other PHY bindings, and copy what they do for
clocks.

	Andrew
  
Jérémie Dautheribes Feb. 29, 2024, 8:46 p.m. UTC | #3
Hi Andrew,

On 26/02/2024 16:28, Andrew Lunn wrote:
> On Thu, Feb 22, 2024 at 11:31:15AM +0100, Jérémie Dautheribes wrote:
>> Add property ti,rmii-mode to support selecting the RMII operation mode
>> between:
>> 	- master mode (PHY operates from a 25MHz clock reference)
>> 	- slave mode (PHY operates from a 50MHz clock reference)
>>
>> If not set, the operation mode is configured by hardware straps.
>>
>> Signed-off-by: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com>
>> ---
>>   .../devicetree/bindings/net/ti,dp83822.yaml      | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/net/ti,dp83822.yaml b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
>> index 8f4350be689c..8f23254c0458 100644
>> --- a/Documentation/devicetree/bindings/net/ti,dp83822.yaml
>> +++ b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
>> @@ -80,6 +80,22 @@ properties:
>>              10625, 11250, 11875, 12500, 13125, 13750, 14375, 15000]
>>       default: 10000
>>   
>> +  ti,rmii-mode:
>> +    description: |
>> +       If present, select the RMII operation mode. Two modes are
>> +       available:
>> +         - RMII master, where the PHY operates from a 25MHz clock reference,
>> +         provided by a crystal or a CMOS-level oscillator
>> +         - RMII slave, where the PHY operates from a 50MHz clock reference,
>> +         provided by a CMOS-level oscillator
> 
> What has master and slave got to do with this?
> 
> Sometimes, the MAC provides a clock to the PHY, and all data transfer
> over the RMII bus is timed by that.
> 
> Sometimes, the PHY provides a clock to the MAC, and all data transfer
> over the RMII bus is timed by that.
> 
> Here there is a clear master/slave relationship, who is providing the
> clock, who is consuming the clock. However, what you describe does not
> fit that. Maybe look at other PHY bindings, and copy what they do for
> clocks.

In fact, I hesitated a lot before choosing this master/slave designation 
because of the same reasoning as you. But the TI DP83826 datasheet [1] 
uses this name for two orthogonal yet connected meanings, here's a copy 
of the corresponding § (in section 9.3.10):

"The DP83826 offers two types of RMII operations: RMII Slave and RMII 
Master. In RMII Master operation, the DP83826 operates from either a 
25-MHz CMOS-level oscillator connected to XI pin, a 25-MHz crystal 
connected across XI and XO pins. A 50-MHz output clock referenced from 
DP83826 can be connected to the MAC. In RMII Slave operation, the 
DP83826 operates from a 50-MHz CMOS-level oscillator connected to the XI 
pin and shares the same clock as the MAC. Alternatively, in RMII slave 
mode, the PHY can operate from a 50-MHz clock provided by the Host MAC."

So it seems that in some cases this also fits the master/slave 
relationship you describe.

That said, would you like me to include this description (or some parts) 
in the binding in addition to what I've already written? Or would you 
prefer me to use a more meaningful property name?

BTW, this series has already been merged into the net-next tree, I'm not 
sure what procedure to follow in such cases.


Best regards,

Jérémie

[1] 
https://www.ti.com/lit/ds/symlink/dp83826i.pdf?ts=1708075771406&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FDP83826I
  
Andrew Lunn Feb. 29, 2024, 9:23 p.m. UTC | #4
> > > --- a/Documentation/devicetree/bindings/net/ti,dp83822.yaml
> > > +++ b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
> > > @@ -80,6 +80,22 @@ properties:
> > >              10625, 11250, 11875, 12500, 13125, 13750, 14375, 15000]
> > >       default: 10000
> > > +  ti,rmii-mode:
> > > +    description: |
> > > +       If present, select the RMII operation mode. Two modes are
> > > +       available:
> > > +         - RMII master, where the PHY operates from a 25MHz clock reference,
> > > +         provided by a crystal or a CMOS-level oscillator
> > > +         - RMII slave, where the PHY operates from a 50MHz clock reference,
> > > +         provided by a CMOS-level oscillator
> > 
> > What has master and slave got to do with this?
> > 
> > Sometimes, the MAC provides a clock to the PHY, and all data transfer
> > over the RMII bus is timed by that.
> > 
> > Sometimes, the PHY provides a clock to the MAC, and all data transfer
> > over the RMII bus is timed by that.
> > 
> > Here there is a clear master/slave relationship, who is providing the
> > clock, who is consuming the clock. However, what you describe does not
> > fit that. Maybe look at other PHY bindings, and copy what they do for
> > clocks.
> 
> In fact, I hesitated a lot before choosing this master/slave designation
> because of the same reasoning as you. But the TI DP83826 datasheet [1] uses
> this name for two orthogonal yet connected meanings, here's a copy of the
> corresponding § (in section 9.3.10):
> 
> "The DP83826 offers two types of RMII operations: RMII Slave and RMII
> Master. In RMII Master operation, the DP83826 operates from either a 25-MHz
> CMOS-level oscillator connected to XI pin, a 25-MHz crystal connected across
> XI and XO pins. A 50-MHz output clock referenced from DP83826 can be
> connected to the MAC. In RMII Slave operation, the DP83826 operates from a
> 50-MHz CMOS-level oscillator connected to the XI pin and shares the same
> clock as the MAC. Alternatively, in RMII slave mode, the PHY can operate
> from a 50-MHz clock provided by the Host MAC."
> 
> So it seems that in some cases this also fits the master/slave relationship
> you describe.

We are normally interested in this 50Mhz reference clock. So i would
drop all references to 25Mhz. It is not relevant to the binding, since
it is nothing to do with connecting the PHY to the MAC, and it has a
fixed value.

So you can simplify this down to:

RMII Master: Outputs a 50Mhz Reference clock which can be connected to the MAC.

RMII Slave: Expects a 50MHz Reference clock input, shared with the
MAC.

> That said, would you like me to include this description (or some parts) in
> the binding in addition to what I've already written? Or would you prefer me
> to use a more meaningful property name?

We don't really have any vendor agnostic consistent naming. dp83867
and dp83869 seems to call this ti,clk-output-sel. Since this is
another dp83xxx device, it would be nice if there was consistency
between all these TI devices. So could you check if the concept is the
same, and if so, change dp83826 to follow what other TI devices do.

> BTW, this series has already been merged into the net-next tree, I'm not
> sure what procedure to follow in such cases.

KAPI don't become fixed until published as a release kernel. We can
rework bindings until then. So just submit patches on top of what is
already in net-next.

	Andrew
  
Jérémie Dautheribes March 4, 2024, 3:12 p.m. UTC | #5
Hi Andrew,

On 29/02/2024 22:23, Andrew Lunn wrote:
>>>> --- a/Documentation/devicetree/bindings/net/ti,dp83822.yaml
>>>> +++ b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
>>>> @@ -80,6 +80,22 @@ properties:
>>>>               10625, 11250, 11875, 12500, 13125, 13750, 14375, 15000]
>>>>        default: 10000
>>>> +  ti,rmii-mode:
>>>> +    description: |
>>>> +       If present, select the RMII operation mode. Two modes are
>>>> +       available:
>>>> +         - RMII master, where the PHY operates from a 25MHz clock reference,
>>>> +         provided by a crystal or a CMOS-level oscillator
>>>> +         - RMII slave, where the PHY operates from a 50MHz clock reference,
>>>> +         provided by a CMOS-level oscillator
>>>
>>> What has master and slave got to do with this?
>>>
>>> Sometimes, the MAC provides a clock to the PHY, and all data transfer
>>> over the RMII bus is timed by that.
>>>
>>> Sometimes, the PHY provides a clock to the MAC, and all data transfer
>>> over the RMII bus is timed by that.
>>>
>>> Here there is a clear master/slave relationship, who is providing the
>>> clock, who is consuming the clock. However, what you describe does not
>>> fit that. Maybe look at other PHY bindings, and copy what they do for
>>> clocks.
>>
>> In fact, I hesitated a lot before choosing this master/slave designation
>> because of the same reasoning as you. But the TI DP83826 datasheet [1] uses
>> this name for two orthogonal yet connected meanings, here's a copy of the
>> corresponding § (in section 9.3.10):
>>
>> "The DP83826 offers two types of RMII operations: RMII Slave and RMII
>> Master. In RMII Master operation, the DP83826 operates from either a 25-MHz
>> CMOS-level oscillator connected to XI pin, a 25-MHz crystal connected across
>> XI and XO pins. A 50-MHz output clock referenced from DP83826 can be
>> connected to the MAC. In RMII Slave operation, the DP83826 operates from a
>> 50-MHz CMOS-level oscillator connected to the XI pin and shares the same
>> clock as the MAC. Alternatively, in RMII slave mode, the PHY can operate
>> from a 50-MHz clock provided by the Host MAC."
>>
>> So it seems that in some cases this also fits the master/slave relationship
>> you describe.
> 
> We are normally interested in this 50Mhz reference clock. So i would
> drop all references to 25Mhz. It is not relevant to the binding, since
> it is nothing to do with connecting the PHY to the MAC, and it has a
> fixed value.
> 
> So you can simplify this down to:
> 
> RMII Master: Outputs a 50Mhz Reference clock which can be connected to the MAC.
> 
> RMII Slave: Expects a 50MHz Reference clock input, shared with the
> MAC.
> 
>> That said, would you like me to include this description (or some parts) in
>> the binding in addition to what I've already written? Or would you prefer me
>> to use a more meaningful property name?
> 
> We don't really have any vendor agnostic consistent naming. dp83867
> and dp83869 seems to call this ti,clk-output-sel. Since this is
> another dp83xxx device, it would be nice if there was consistency
> between all these TI devices. So could you check if the concept is the
> same, and if so, change dp83826 to follow what other TI devices do.


So I had a look at this ti,clk-output-sel property on the TI DP8386x 
bindings, but unfortunately it does not correspond to our use case. In 
their case, it is used to select one of the various internal clocks to 
output on the CLK_OUT pin.
In our case, we would prefer to describe the direction of the clock (OUT 
in master mode, IN in slave mode).

Given this, should we stick to "ti,rmii-mode" which is consistent with 
the datasheet terminology, or consider perhaps something like 
ti,clock-dir-sel (with possible values of in/out)?"

Best regards,
Jérémie
  
Andrew Lunn March 4, 2024, 4:06 p.m. UTC | #6
> > We are normally interested in this 50Mhz reference clock. So i would
> > drop all references to 25Mhz. It is not relevant to the binding, since
> > it is nothing to do with connecting the PHY to the MAC, and it has a
> > fixed value.
> > 
> > So you can simplify this down to:
> > 
> > RMII Master: Outputs a 50Mhz Reference clock which can be connected to the MAC.
> > 
> > RMII Slave: Expects a 50MHz Reference clock input, shared with the
> > MAC.
> > 
> > > That said, would you like me to include this description (or some parts) in
> > > the binding in addition to what I've already written? Or would you prefer me
> > > to use a more meaningful property name?
> > 
> > We don't really have any vendor agnostic consistent naming. dp83867
> > and dp83869 seems to call this ti,clk-output-sel. Since this is
> > another dp83xxx device, it would be nice if there was consistency
> > between all these TI devices. So could you check if the concept is the
> > same, and if so, change dp83826 to follow what other TI devices do.
> 
> 
> So I had a look at this ti,clk-output-sel property on the TI DP8386x
> bindings, but unfortunately it does not correspond to our use case. In their
> case, it is used to select one of the various internal clocks to output on
> the CLK_OUT pin.
> In our case, we would prefer to describe the direction of the clock (OUT in
> master mode, IN in slave mode).

I would suggest we keep with the current property name, but simplify
the description. Focus on the reference clock, and ignore the crystal.

    Andrew
  
Jérémie Dautheribes March 4, 2024, 4:31 p.m. UTC | #7
>>> We are normally interested in this 50Mhz reference clock. So i would
>>> drop all references to 25Mhz. It is not relevant to the binding, since
>>> it is nothing to do with connecting the PHY to the MAC, and it has a
>>> fixed value.
>>>
>>> So you can simplify this down to:
>>>
>>> RMII Master: Outputs a 50Mhz Reference clock which can be connected to the MAC.
>>>
>>> RMII Slave: Expects a 50MHz Reference clock input, shared with the
>>> MAC.
>>>
>>>> That said, would you like me to include this description (or some parts) in
>>>> the binding in addition to what I've already written? Or would you prefer me
>>>> to use a more meaningful property name?
>>>
>>> We don't really have any vendor agnostic consistent naming. dp83867
>>> and dp83869 seems to call this ti,clk-output-sel. Since this is
>>> another dp83xxx device, it would be nice if there was consistency
>>> between all these TI devices. So could you check if the concept is the
>>> same, and if so, change dp83826 to follow what other TI devices do.
>>
>>
>> So I had a look at this ti,clk-output-sel property on the TI DP8386x
>> bindings, but unfortunately it does not correspond to our use case. In their
>> case, it is used to select one of the various internal clocks to output on
>> the CLK_OUT pin.
>> In our case, we would prefer to describe the direction of the clock (OUT in
>> master mode, IN in slave mode).
> 
> I would suggest we keep with the current property name, but simplify
> the description. Focus on the reference clock, and ignore the crystal.


Ok noted, thanks for your feedback! I will send a v2 containing a 
simplified description + implement your suggested changes on patch 2.

Jérémie
  

Patch

diff --git a/Documentation/devicetree/bindings/net/ti,dp83822.yaml b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
index 8f4350be689c..8f23254c0458 100644
--- a/Documentation/devicetree/bindings/net/ti,dp83822.yaml
+++ b/Documentation/devicetree/bindings/net/ti,dp83822.yaml
@@ -80,6 +80,22 @@  properties:
            10625, 11250, 11875, 12500, 13125, 13750, 14375, 15000]
     default: 10000
 
+  ti,rmii-mode:
+    description: |
+       If present, select the RMII operation mode. Two modes are
+       available:
+         - RMII master, where the PHY operates from a 25MHz clock reference,
+         provided by a crystal or a CMOS-level oscillator
+         - RMII slave, where the PHY operates from a 50MHz clock reference,
+         provided by a CMOS-level oscillator
+       The RMII operation mode can also be configured by its straps.
+       If the strap pin is not set correctly or not set at all, then this can be
+       used to configure it.
+    $ref: /schemas/types.yaml#/definitions/string
+    enum:
+      - master
+      - slave
+
 required:
   - reg