diff mbox series

[net-next,1/3] dt-bindings: net: add new properties for of_get_mac_address from nvmem

Message ID 20210409090711.27358-2-qiangqing.zhang@nxp.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: add new properties for of_get_mac_address from nvmem | expand

Checks

Context Check Description
netdev/apply fail Patch does not apply to net-next
netdev/tree_selection success Clearly marked for net-next

Commit Message

Joakim Zhang April 9, 2021, 9:07 a.m. UTC
From: Fugang Duan <fugang.duan@nxp.com>

Currently, of_get_mac_address supports NVMEM, some platforms
MAC address that read from NVMEM efuse requires to swap bytes
order, so add new property "nvmem_macaddr_swap" to specify the
behavior. If the MAC address is valid from NVMEM, add new property
"nvmem-mac-address" in ethernet node.

Update these two properties in the binding documentation.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 .../bindings/net/ethernet-controller.yaml          | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Rob Herring April 9, 2021, 1:49 p.m. UTC | #1
On Fri, Apr 9, 2021 at 4:07 AM Joakim Zhang <qiangqing.zhang@nxp.com> wrote:
>
> From: Fugang Duan <fugang.duan@nxp.com>
>
> Currently, of_get_mac_address supports NVMEM, some platforms

What's of_get_mac_address? This is a binding patch. Don't mix Linux
things in it.

> MAC address that read from NVMEM efuse requires to swap bytes
> order, so add new property "nvmem_macaddr_swap" to specify the
> behavior. If the MAC address is valid from NVMEM, add new property
> "nvmem-mac-address" in ethernet node.
>
> Update these two properties in the binding documentation.
>
> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> ---
>  .../bindings/net/ethernet-controller.yaml          | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> index e8f04687a3e0..c868c295aabf 100644
> --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> @@ -32,6 +32,15 @@ properties:
>        - minItems: 6
>          maxItems: 6
>
> +  nvmem-mac-address:
> +    allOf:
> +      - $ref: /schemas/types.yaml#definitions/uint8-array
> +      - minItems: 6
> +        maxItems: 6
> +    description:
> +      Specifies the MAC address that was read from nvmem-cells and dynamically
> +      add the property in device node;

Why can't you use local-mac-address or mac-address? Those too can come
from some other source.

> +
>    max-frame-size:
>      $ref: /schemas/types.yaml#/definitions/uint32
>      description:
> @@ -52,6 +61,11 @@ properties:
>    nvmem-cell-names:
>      const: mac-address
>
> +  nvmem_macaddr_swap:
> +    $ref: /schemas/types.yaml#/definitions/flag
> +    description:
> +      swap bytes order for the 6 bytes of MAC address

So 'nvmem-mac-address' needs to be swapped or it's swapped before
writing? In any case, this belongs in the nvmem provider.

Rob
Joakim Zhang April 12, 2021, 6:38 a.m. UTC | #2
Hi Rob,

> -----Original Message-----
> From: Rob Herring <robh+dt@kernel.org>
> Sent: 2021年4月9日 21:50
> To: Joakim Zhang <qiangqing.zhang@nxp.com>
> Cc: David Miller <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>;
> Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit <hkallweit1@gmail.com>;
> Russell King <linux@armlinux.org.uk>; Frank Rowand
> <frowand.list@gmail.com>; netdev <netdev@vger.kernel.org>;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>
> Subject: Re: [PATCH net-next 1/3] dt-bindings: net: add new properties for
> of_get_mac_address from nvmem
> 
> On Fri, Apr 9, 2021 at 4:07 AM Joakim Zhang <qiangqing.zhang@nxp.com>
> wrote:
> >
> > From: Fugang Duan <fugang.duan@nxp.com>
> >
> > Currently, of_get_mac_address supports NVMEM, some platforms
> 
> What's of_get_mac_address? This is a binding patch. Don't mix Linux things in
> it.

Ok, will improve it.

> > MAC address that read from NVMEM efuse requires to swap bytes order,
> > so add new property "nvmem_macaddr_swap" to specify the behavior. If
> > the MAC address is valid from NVMEM, add new property
> > "nvmem-mac-address" in ethernet node.
> >
> > Update these two properties in the binding documentation.
> >
> > Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
> > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> > ---
> >  .../bindings/net/ethernet-controller.yaml          | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> >
> > diff --git
> > a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> > b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> > index e8f04687a3e0..c868c295aabf 100644
> > --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> > +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> > @@ -32,6 +32,15 @@ properties:
> >        - minItems: 6
> >          maxItems: 6
> >
> > +  nvmem-mac-address:
> > +    allOf:
> > +      - $ref: /schemas/types.yaml#definitions/uint8-array
> > +      - minItems: 6
> > +        maxItems: 6
> > +    description:
> > +      Specifies the MAC address that was read from nvmem-cells and
> dynamically
> > +      add the property in device node;
> 
> Why can't you use local-mac-address or mac-address? Those too can come
> from some other source.

I also don't understand what Andy's do for this, per his commit message "If the MAC address is valid from NVMEM, add new property "nvmem-mac-address" in ethernet node.".
He said this done _DYNAMICALLY_, but I have not found where ""nvmem-mac-address" property been added, and can't find it from ethernet node. So I send out patch first to see if reviewers
can give a hint, or point out this is actually incorrect.
  
> > +
> >    max-frame-size:
> >      $ref: /schemas/types.yaml#/definitions/uint32
> >      description:
> > @@ -52,6 +61,11 @@ properties:
> >    nvmem-cell-names:
> >      const: mac-address
> >
> > +  nvmem_macaddr_swap:
> > +    $ref: /schemas/types.yaml#/definitions/flag
> > +    description:
> > +      swap bytes order for the 6 bytes of MAC address
> 
> So 'nvmem-mac-address' needs to be swapped or it's swapped before writing?
> In any case, this belongs in the nvmem provider.

MAC address read from NVMEM cell needs to be swapped. The order of bytes that NVMEM provider provided is fixed, so I think we should swap at the NVMEM consumer side.
It is more reasonable and common add a property in Documentation/devicetree/bindings/nvmem/nvmem-consumer.yaml, and swap the data in nvmem_cell_read() function.

Best Regards,
Joakim Zhang
> Rob
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index e8f04687a3e0..c868c295aabf 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -32,6 +32,15 @@  properties:
       - minItems: 6
         maxItems: 6
 
+  nvmem-mac-address:
+    allOf:
+      - $ref: /schemas/types.yaml#definitions/uint8-array
+      - minItems: 6
+        maxItems: 6
+    description:
+      Specifies the MAC address that was read from nvmem-cells and dynamically
+      add the property in device node;
+
   max-frame-size:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
@@ -52,6 +61,11 @@  properties:
   nvmem-cell-names:
     const: mac-address
 
+  nvmem_macaddr_swap:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      swap bytes order for the 6 bytes of MAC address
+
   phy-connection-type:
     description:
       Specifies interface type between the Ethernet device and a physical