[18/43] dt-bindings: net: Add DT bindings ep93xx eth

Message ID 20230424123522.18302-19-nikita.shubin@maquefel.me
State New
Headers
Series ep93xx device tree conversion |

Commit Message

Nikita Shubin April 24, 2023, 12:34 p.m. UTC
  Add YAML bindings for ep93xx SoC.

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
 .../bindings/net/cirrus,ep93xx_eth.yaml       | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml
  

Comments

Rob Herring April 24, 2023, 4:11 p.m. UTC | #1
On Mon, Apr 24, 2023 at 03:34:34PM +0300, Nikita Shubin wrote:
> Add YAML bindings for ep93xx SoC.
> 
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
> ---
>  .../bindings/net/cirrus,ep93xx_eth.yaml       | 51 +++++++++++++++++++
>  1 file changed, 51 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml b/Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml
> new file mode 100644
> index 000000000000..7e73cf0ddde9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml
> @@ -0,0 +1,51 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/cirrus,ep93xx_eth.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: The ethernet hardware included in EP93xx CPUs module Device Tree Bindings
> +
> +maintainers:
> +  - Hartley Sweeten <hsweeten@visionengravers.com>

Should be referencing ethernet-controller.yaml.

> +
> +properties:
> +  compatible:
> +    const: cirrus,ep9301-eth
> +
> +  reg:
> +    items:
> +      - description: The physical base address and size of IO range
> +
> +  interrupts:
> +    items:
> +      - description: Combined signal for various interrupt events
> +
> +  copy_addr:
> +    type: boolean
> +    description:
> +      Flag indicating that the MAC address should be copied
> +      from the IndAd registers (as programmed by the bootloader)

The bootloader is supposed to fill in local-mac-address if it sets the 
MAC address.

> +
> +  phy_id:
> +    description: MII phy_id to use

type?

There's standard properties for dealing with phy connections. Surely 
they work for this.

> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    eth0: eth@80010000 {

ethernet@...

> +        compatible = "cirrus,ep9301-eth";
> +        reg = <0x80010000 0x10000>;
> +        interrupt-parent = <&vic1>;
> +        interrupts = <7>;
> +        copy_addr;
> +        phy_id = < 1 >;
> +    };
> +
> +...
> -- 
> 2.39.2
>
  
Nikita Shubin May 15, 2023, 1:42 p.m. UTC | #2
Hello Andrew!

On Mon, 2023-04-24 at 15:39 +0200, Andrew Lunn wrote:
> > +  copy_addr:
> > +    type: boolean
> > +    description:
> > +      Flag indicating that the MAC address should be copied
> > +      from the IndAd registers (as programmed by the bootloader)
> 
> Looking at ep93xx_register_eth(), all callers are setting copy_addr
> to
> 1. So i don't think you need this.

Agreed. Dropped copy_addr entirely.

> 
> > +
> > +  phy_id:
> > +    description: MII phy_id to use
> 
> The eEP93xx Ethernet driver is a very old driver, so it is doing MDIO
> and PHY the old way. Ideally you should be using ep93xx_mdio_read()
> and ep93xx_mdio_write() to create an MDIO bus with
> of_mdiobus_regsiter, and then use a phy-handle to point to the PHY on
> the bus. It will then be the same as all other ethernet drivers using
> DT.

I've tinkered with the preferred way, however this involves turning on 

- CONFIG_PHYLIB
- CONFIG_MDIO_DEVICE

And maybe CONFIG_MICREL_PHY (at least for me, unless i can use some
common phy driver) which implies a kernel size increase - which is
undesirable for us.

Can we slip by with something like:

+       np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+       if (!np) {
+               dev_err(&pdev->dev, "Please provide \"phy-handle\"\n");
+               return -ENODEV;
+       }
+
+       if (of_property_read_u32(np, "reg", &phy_id)) {
+               dev_err(&pdev->dev, "Failed to locate \"phy_id\"\n");
+               return -ENOENT;
+       }

And standard device tree bindings ?:

+    ethernet@80010000 {
+      compatible = "cirrus,ep9301-eth";
+      reg = <0x80010000 0x10000>;
+      interrupt-parent = <&vic1>;
+      interrupts = <7>;
+      phy-handle = <&phy0>;
+      mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        phy0: ethernet-phy@1 {
+          reg = <1>;
+          device_type = "ethernet-phy";
+        };
+      };
+    };


> 
>     Andrew
  

Patch

diff --git a/Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml b/Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml
new file mode 100644
index 000000000000..7e73cf0ddde9
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/cirrus,ep93xx_eth.yaml
@@ -0,0 +1,51 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/cirrus,ep93xx_eth.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: The ethernet hardware included in EP93xx CPUs module Device Tree Bindings
+
+maintainers:
+  - Hartley Sweeten <hsweeten@visionengravers.com>
+
+properties:
+  compatible:
+    const: cirrus,ep9301-eth
+
+  reg:
+    items:
+      - description: The physical base address and size of IO range
+
+  interrupts:
+    items:
+      - description: Combined signal for various interrupt events
+
+  copy_addr:
+    type: boolean
+    description:
+      Flag indicating that the MAC address should be copied
+      from the IndAd registers (as programmed by the bootloader)
+
+  phy_id:
+    description: MII phy_id to use
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    eth0: eth@80010000 {
+        compatible = "cirrus,ep9301-eth";
+        reg = <0x80010000 0x10000>;
+        interrupt-parent = <&vic1>;
+        interrupts = <7>;
+        copy_addr;
+        phy_id = < 1 >;
+    };
+
+...