Skip to contentSkip to conversation

Add an MDIO sub-node under MACB

PATCH Superseded Codrin Ciubotariu 4 participants 23 messages Jul 21, 2020 – Jul 24, 2020

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add an MDIO sub-node under MACB

Adding the PHY nodes directly under the Ethernet node became deprecated, so the aim of this patch series is to make MACB use an MDIO node as container for MDIO devices.
This patch series starts with a small patch to use the device-managed devm_mdiobus_alloc(). In the next two patches we update the bindings and adapt macb driver to parse the device-tree PHY nodes from under an MDIO node. The last patches add the MDIO node in the device-trees of sama5d2, sama5d3, samad4 and sam9x60 boards.

Changes in v2:
- renamed patch 2/7 from "macb: bindings doc: use an MDIO node as a container for PHY nodes" to "dt-bindings: net: macb: use an MDIO node as a container for PHY nodes"
- added back a newline removed by mistake in patch 3/7

Codrin Ciubotariu (7):
net: macb: use device-managed devm_mdiobus_alloc()
dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
net: macb: parse PHY nodes found under an MDIO node
ARM: dts: at91: sama5d2: add an mdio sub-node to macb
ARM: dts: at91: sama5d3: add an mdio sub-node to macb
ARM: dts: at91: sama5d4: add an mdio sub-node to macb
ARM: dts: at91: sam9x60: add an mdio sub-node to macb

 Documentation/devicetree/bindings/net/macb.txt | 15 ++++++++++++---
 arch/arm/boot/dts/at91-sam9x60ek.dts           |  8 ++++++--
 arch/arm/boot/dts/at91-sama5d27_som1.dtsi      | 16 ++++++++++------
 arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi    | 17 ++++++++++-------
 arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts      | 13 ++++++++-----
 arch/arm/boot/dts/at91-sama5d2_xplained.dts    | 12 ++++++++----
 arch/arm/boot/dts/at91-sama5d3_xplained.dts    | 16 ++++++++++++----
 arch/arm/boot/dts/at91-sama5d4_xplained.dts    | 12 ++++++++----
 drivers/net/ethernet/cadence/macb_main.c       | 18 ++++++++++++------
 9 files changed, 86 insertions(+), 41 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/7 net: macb: use device-managed devm_mdiobus_alloc()

Use the device-managed variant for the allocating the MDIO bus. This cleans-up the code a little on the remove and error paths.

---

Changes in v2:
- none

 drivers/net/ethernet/cadence/macb_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +2 -6
index a6a35e1b0115..89fe7af5e408 100644
@@ -769,7 +769,7 @@ static int macb_mii_init(struct macb *bp)
 	/* Enable management port */
 	macb_writel(bp, NCR, MACB_BIT(MPE));
 
-	bp->mii_bus = mdiobus_alloc();
+	bp->mii_bus = devm_mdiobus_alloc(&bp->pdev->dev);
 	if (!bp->mii_bus) {
 		err = -ENOMEM;
 		goto err_out;
@@ -787,7 +787,7 @@ static int macb_mii_init(struct macb *bp)
 
 	err = macb_mdiobus_register(bp);
 	if (err)
-		goto err_out_free_mdiobus;
+		goto err_out;
 
 	err = macb_mii_probe(bp->dev);
 	if (err)
@@ -797,8 +797,6 @@ static int macb_mii_init(struct macb *bp)
 
 err_out_unregister_bus:
 	mdiobus_unregister(bp->mii_bus);
-err_out_free_mdiobus:
-	mdiobus_free(bp->mii_bus);
 err_out:
 	return err;
 }
@@ -4571,7 +4569,6 @@ static int macb_probe(struct platform_device *pdev)
 
 err_out_unregister_mdio:
 	mdiobus_unregister(bp->mii_bus);
-	mdiobus_free(bp->mii_bus);
 
 err_out_free_netdev:
 	free_netdev(dev);
@@ -4599,7 +4596,6 @@ static int macb_remove(struct platform_device *pdev)
 	if (dev) {
 		bp = netdev_priv(dev);
 		mdiobus_unregister(bp->mii_bus);
-		mdiobus_free(bp->mii_bus);
 
 		unregister_netdev(dev);
 		tasklet_kill(&bp->hresp_err_tasklet);
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 2/7 dt-bindings: net: macb: use an MDIO node as a container for PHY nodes

In reply to Codrin Ciubotariu

The MACB driver embeds an MDIO bus controller and for this reason there was no need for an MDIO sub-node present to contain the PHY nodes. Adding MDIO devies directly under an Ethernet node is deprecated, so an MDIO node is included to contain of the PHY nodes (and other MDIO devices' nodes).

---

Changes in v2:
- patch renamed from "macb: bindings doc: use an MDIO node as a container for PHY nodes" to "dt-bindings: net: macb: use an MDIO node as a container for PHY nodes"

 Documentation/devicetree/bindings/net/macb.txt | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/macb.txt +12 -3
index 0b61a90f1592..88d5199c2279 100644
@@ -32,6 +32,11 @@ Required properties:
 The MAC address will be determined using the optional properties
 defined in ethernet.txt.
 
+Optional subnodes:
+- mdio : specifies the MDIO bus in the MACB, used as a container for PHY nodes or other
+  nodes of devices present on the MDIO bus. Please see ethernet-phy.yaml in the same
+  directory for more details.
+
 Optional properties for PHY child node:
 - reset-gpios : Should specify the gpio for phy reset
 - magic-packet : If present, indicates that the hardware supports waking
@@ -48,8 +53,12 @@ Examples:
 		local-mac-address = [3a 0e 03 04 05 06];
 		clock-names = "pclk", "hclk", "tx_clk";
 		clocks = <&clkc 30>, <&clkc 30>, <&clkc 13>;
-		ethernet-phy@1 {
-			reg = <0x1>;
-			reset-gpios = <&pioE 6 1>;
+		mdio {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			ethernet-phy@1 {
+				reg = <0x1>;
+				reset-gpios = <&pioE 6 1>;
+			};
 		};
 	};
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 2/7
#4 lore raw

Re: [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes

Quoted 8 lines · Codrin Ciubotariu

The MACB driver embeds an MDIO bus controller and for this reason there was no need for an MDIO sub-node present to contain the PHY nodes. Adding MDIO devies directly under an Ethernet node is deprecated, so an MDIO node is included to contain of the PHY nodes (and other MDIO devices' nodes).

---

Quoted 8 lines

Changes in v2:
- patch renamed from "macb: bindings doc: use an MDIO node as a container for PHY nodes" to "dt-bindings: net: macb: use an MDIO node as a container for PHY nodes"

 Documentation/devicetree/bindings/net/macb.txt | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
Reviewed-by on v2 2/7
#5 lore raw

Re: [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes

In reply to Codrin Ciubotariu
Quoted 6 lines · Codrin Ciubotariu

The MACB driver embeds an MDIO bus controller and for this reason there was no need for an MDIO sub-node present to contain the PHY nodes. Adding MDIO devies directly under an Ethernet node is deprecated, so an MDIO node is included to contain of the PHY nodes (and other MDIO devices' nodes).

Signature · 1 line
Florian
#6 lore raw

PATCH v2 3/7 net: macb: parse PHY nodes found under an MDIO node

In reply to Codrin Ciubotariu

The MACB embeds an MDIO bus controller. For this reason, the PHY nodes were represented as sub-nodes in the MACB node. Generally, the Ethernet controller is different than the MDIO controller, so the PHYs are probed by a separate MDIO driver. Since adding the PHY nodes directly under the ETH node became deprecated, we adjust the MACB driver to look for an MDIO node and register the subnode MDIO devices.

---

Changes in v2:
- readded newline removed by mistake;

 drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +10 -0
index 89fe7af5e408..b25c64b45148 100644
@@ -740,10 +740,20 @@ static int macb_mii_probe(struct net_device *dev)
 static int macb_mdiobus_register(struct macb *bp)
 {
 	struct device_node *child, *np = bp->pdev->dev.of_node;
+	struct device_node *mdio_node;
+	int ret;
 
 	if (of_phy_is_fixed_link(np))
 		return mdiobus_register(bp->mii_bus);
 
+	/* if an MDIO node is present, it should contain the PHY nodes */
+	mdio_node = of_get_child_by_name(np, "mdio");
+	if (mdio_node) {
+		ret = of_mdiobus_register(bp->mii_bus, mdio_node);
+		of_node_put(mdio_node);
+		return ret;
+	}
+
 	/* Only create the PHY from the device tree if at least one PHY is
 	 * described. Otherwise scan the entire MDIO bus. We do this to support
 	 * old device tree that did not follow the best practices and did not
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node

Quoted 21 lines · Codrin Ciubotariu

The MACB embeds an MDIO bus controller. For this reason, the PHY nodes were represented as sub-nodes in the MACB node. Generally, the Ethernet controller is different than the MDIO controller, so the PHYs are probed by a separate MDIO driver. Since adding the PHY nodes directly under the ETH node became deprecated, we adjust the MACB driver to look for an MDIO node and register the subnode MDIO devices.

---

Changes in v2:
- readded newline removed by mistake;

 drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index 89fe7af5e408..b25c64b45148 100644

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev) · line 747

Quoted 8 lines
drivers/net/ethernet/cadence/macb_main.c +2 -0
@@ -740,10 +740,20 @@ static int macb_mii_probe(struct net_device *dev)
 static int macb_mdiobus_register(struct macb *bp)
 {
 	struct device_node *child, *np = bp->pdev->dev.of_node;
+	struct device_node *mdio_node;
+	int ret;
 
 	if (of_phy_is_fixed_link(np))
 		return mdiobus_register(bp->mii_bus);

Does not this need changing as well? Consider the use case of having your MACB Ethernet node have a fixed-link property to describe how it connects to a switch, and your MACB MDIO controller, expressed as a sub-node, describing the MDIO attached switch it connects to.

Quoted 13 lines
drivers/net/ethernet/cadence/macb_main.c +8 -0
+	/* if an MDIO node is present, it should contain the PHY nodes */
+	mdio_node = of_get_child_by_name(np, "mdio");
+	if (mdio_node) {
+		ret = of_mdiobus_register(bp->mii_bus, mdio_node);
+		of_node_put(mdio_node);
+		return ret;
+	}
+
 	/* Only create the PHY from the device tree if at least one PHY is
 	 * described. Otherwise scan the entire MDIO bus. We do this to support
 	 * old device tree that did not follow the best practices and did not
 
Signature · 1 line
Florian
#8 lore raw

Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node

Quoted 30 lines · Florian Fainelli

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 27 lines · Codrin Ciubotariu

The MACB embeds an MDIO bus controller. For this reason, the PHY nodes were represented as sub-nodes in the MACB node. Generally, the Ethernet controller is different than the MDIO controller, so the PHYs are probed by a separate MDIO driver. Since adding the PHY nodes directly under the ETH node became deprecated, we adjust the MACB driver to look for an MDIO node and register the subnode MDIO devices.

---

Changes in v2:
- readded newline removed by mistake;

  drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +2 -0
index 89fe7af5e408..b25c64b45148 100644
@@ -740,10 +740,20 @@ static int macb_mii_probe(struct net_device *dev)
  static int macb_mdiobus_register(struct macb *bp)
  {
       struct device_node *child, *np = bp->pdev->dev.of_node;
+     struct device_node *mdio_node;
+     int ret;
 
Quoted 7 lines

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev) · line 747

Quoted 2 lines
drivers/net/ethernet/cadence/macb_main.c +0 -0
       if (of_phy_is_fixed_link(np))
               return mdiobus_register(bp->mii_bus);

Does not this need changing as well? Consider the use case of having your MACB Ethernet node have a fixed-link property to describe how it connects to a switch, and your MACB MDIO controller, expressed as a sub-node, describing the MDIO attached switch it connects to.

Right, this is what I was discussing with Claudiu on the other thread. I am thinking to just move the look for mdio before checking for fixed-link. This will probe the MDIO devices and simple mdiobus_register will be called only if the mdio node is missing.

Thank you for your review(s)!

Best regards,
Codrin

Quoted 19 lines
Quoted 4 lines
drivers/net/ethernet/cadence/macb_main.c +2 -0
+     /* if an MDIO node is present, it should contain the PHY nodes */
+     mdio_node = of_get_child_by_name(np, "mdio");

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev)

Quoted 10 lines
drivers/net/ethernet/cadence/macb_main.c +6 -0
+     if (mdio_node) {
+             ret = of_mdiobus_register(bp->mii_bus, mdio_node);
+             of_node_put(mdio_node);
+             return ret;
+     }
+
       /* Only create the PHY from the device tree if at least one PHY is
        * described. Otherwise scan the entire MDIO bus. We do this to support
        * old device tree that did not follow the best practices and did not
 

--
Florian

#9 lore raw

Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node

Quoted 39 lines · On 7/23/20 3:08 PM, [email protected] wrote:
Quoted 30 lines · Florian Fainelli

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 27 lines · Codrin Ciubotariu

The MACB embeds an MDIO bus controller. For this reason, the PHY nodes were represented as sub-nodes in the MACB node. Generally, the Ethernet controller is different than the MDIO controller, so the PHYs are probed by a separate MDIO driver. Since adding the PHY nodes directly under the ETH node became deprecated, we adjust the MACB driver to look for an MDIO node and register the subnode MDIO devices.

---

Changes in v2:
- readded newline removed by mistake;

  drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +2 -0
index 89fe7af5e408..b25c64b45148 100644
@@ -740,10 +740,20 @@ static int macb_mii_probe(struct net_device *dev)
  static int macb_mdiobus_register(struct macb *bp)
  {
       struct device_node *child, *np = bp->pdev->dev.of_node;
+     struct device_node *mdio_node;
+     int ret;
 
Quoted 7 lines

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev) · line 747

Quoted 2 lines
drivers/net/ethernet/cadence/macb_main.c +0 -0
       if (of_phy_is_fixed_link(np))
               return mdiobus_register(bp->mii_bus);

Does not this need changing as well? Consider the use case of having your MACB Ethernet node have a fixed-link property to describe how it connects to a switch, and your MACB MDIO controller, expressed as a sub-node, describing the MDIO attached switch it connects to.

Quoted 4 lines

Right, this is what I was discussing with Claudiu on the other thread. I am thinking to just move the look for mdio before checking for fixed-link. This will probe the MDIO devices and simple mdiobus_register will be called only if the mdio node is missing.

Found it after I had sent this email. What you propose sounds reasonable, looking forward to v3.

Quoted 2 lines

Thank you for your review(s)!

Of course.

Signature · 1 line
Florian
#10 lore raw

Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node

In reply to Florian Fainelli
Quoted 30 lines · Florian Fainelli

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 27 lines · Codrin Ciubotariu

The MACB embeds an MDIO bus controller. For this reason, the PHY nodes were represented as sub-nodes in the MACB node. Generally, the Ethernet controller is different than the MDIO controller, so the PHYs are probed by a separate MDIO driver. Since adding the PHY nodes directly under the ETH node became deprecated, we adjust the MACB driver to look for an MDIO node and register the subnode MDIO devices.

---

Changes in v2:
- readded newline removed by mistake;

 drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +2 -0
index 89fe7af5e408..b25c64b45148 100644
@@ -740,10 +740,20 @@ static int macb_mii_probe(struct net_device *dev)
 static int macb_mdiobus_register(struct macb *bp)
 {
      struct device_node *child, *np = bp->pdev->dev.of_node;
+     struct device_node *mdio_node;
+     int ret;
 
Quoted 7 lines

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev) · line 747

Quoted 2 lines
drivers/net/ethernet/cadence/macb_main.c +0 -0
      if (of_phy_is_fixed_link(np))
              return mdiobus_register(bp->mii_bus);

Does not this need changing as well? Consider the use case of having your MACB Ethernet node have a fixed-link property to describe how it connects to a switch, and your MACB MDIO controller, expressed as a sub-node, describing the MDIO attached switch it connects to.

Just asking, does this worth having/changing it as long as there is no in kernel board/configuration that could benefit off?

Thank you,
Claudiu Beznea

Quoted 19 lines
Quoted 4 lines
drivers/net/ethernet/cadence/macb_main.c +2 -0
+     /* if an MDIO node is present, it should contain the PHY nodes */
+     mdio_node = of_get_child_by_name(np, "mdio");

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev)

Quoted 10 lines
drivers/net/ethernet/cadence/macb_main.c +6 -0
+     if (mdio_node) {
+             ret = of_mdiobus_register(bp->mii_bus, mdio_node);
+             of_node_put(mdio_node);
+             return ret;
+     }
+
      /* Only create the PHY from the device tree if at least one PHY is
       * described. Otherwise scan the entire MDIO bus. We do this to support
       * old device tree that did not follow the best practices and did not
 

--
Florian

#11 lore raw

PATCH v2 4/7 ARM: dts: at91: sama5d2: add an mdio sub-node to macb

In reply to Codrin Ciubotariu

Use the new macb bindings and add an mdio sub-node to contain all the phy nodes.

---

Changes in v2:
- none

 arch/arm/boot/dts/at91-sama5d27_som1.dtsi   | 16 ++++++++++------
 arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi | 17 ++++++++++-------
 arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts   | 13 ++++++++-----
 arch/arm/boot/dts/at91-sama5d2_xplained.dts | 12 ++++++++----
 4 files changed, 36 insertions(+), 22 deletions(-)
arch/arm/boot/dts/at91-sama5d27_som1.dtsi +10 -6
index b1f994c0ae79..dfcee23dcce0 100644
@@ -84,12 +84,16 @@ macb0: ethernet@f8008000 {
 				pinctrl-0 = <&pinctrl_macb0_default>;
 				phy-mode = "rmii";
 
-				ethernet-phy@0 {
-					reg = <0x0>;
-					interrupt-parent = <&pioA>;
-					interrupts = <PIN_PD31 IRQ_TYPE_LEVEL_LOW>;
-					pinctrl-names = "default";
-					pinctrl-0 = <&pinctrl_macb0_phy_irq>;
+				mdio {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					ethernet-phy@0 {
+						reg = <0x0>;
+						interrupt-parent = <&pioA>;
+						interrupts = <PIN_PD31 IRQ_TYPE_LEVEL_LOW>;
+						pinctrl-names = "default";
+						pinctrl-0 = <&pinctrl_macb0_phy_irq>;
+					};
 				};
 			};
 
arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi +10 -7
index a06700e53e4c..9c4dce29d2fe 100644
@@ -181,13 +181,16 @@ &macb0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_macb0_default>;
 	phy-mode = "rmii";
-
-	ethernet-phy@0 {
-		reg = <0x0>;
-		interrupt-parent = <&pioA>;
-		interrupts = <PIN_PB24 IRQ_TYPE_LEVEL_LOW>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&pinctrl_macb0_phy_irq>;
+	mdio {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		ethernet-phy@0 {
+			reg = <0x0>;
+			interrupt-parent = <&pioA>;
+			interrupts = <PIN_PB24 IRQ_TYPE_LEVEL_LOW>;
+			pinctrl-names = "default";
+			pinctrl-0 = <&pinctrl_macb0_phy_irq>;
+		};
 	};
 };
 
arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts +8 -5
index c894c7c788a9..fc3375c43ef6 100644
@@ -140,11 +140,14 @@ macb0: ethernet@f8008000 {
 				pinctrl-0 = <&pinctrl_macb0_default &pinctrl_macb0_phy_irq>;
 				phy-mode = "rmii";
 				status = "okay";
-
-				ethernet-phy@1 {
-					reg = <0x1>;
-					interrupt-parent = <&pioA>;
-					interrupts = <56 IRQ_TYPE_LEVEL_LOW>;
+				mdio {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					ethernet-phy@1 {
+						reg = <0x1>;
+						interrupt-parent = <&pioA>;
+						interrupts = <56 IRQ_TYPE_LEVEL_LOW>;
+					};
 				};
 			};
 
arch/arm/boot/dts/at91-sama5d2_xplained.dts +8 -4
index a927165ea7c2..a62f475d9d0a 100644
@@ -149,10 +149,14 @@ macb0: ethernet@f8008000 {
 				phy-mode = "rmii";
 				status = "okay";
 
-				ethernet-phy@1 {
-					reg = <0x1>;
-					interrupt-parent = <&pioA>;
-					interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
+				mdio {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					ethernet-phy@1 {
+						reg = <0x1>;
+						interrupt-parent = <&pioA>;
+						interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
+					};
 				};
 			};
 
Signature · 1 line
2.25.1
#13 lore raw

PATCH v2 5/7 ARM: dts: at91: sama5d3: add an mdio sub-node to macb

In reply to Codrin Ciubotariu

Use the new macb bindings and add an mdio sub-node to contain all the phy nodes.

---

Changes in v2:
- none;

 arch/arm/boot/dts/at91-sama5d3_xplained.dts | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
arch/arm/boot/dts/at91-sama5d3_xplained.dts +12 -4
index 61f068a7b362..25d2646ce4cb 100644
@@ -133,8 +133,12 @@ macb0: ethernet@f0028000 {
 				#size-cells = <0>;
 				status = "okay";
 
-				ethernet-phy@7 {
-					reg = <0x7>;
+				mdio {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					ethernet-phy@7 {
+						reg = <0x7>;
+					};
 				};
 			};
 
@@ -200,8 +204,12 @@ macb1: ethernet@f802c000 {
 				#size-cells = <0>;
 				status = "okay";
 
-				ethernet-phy@1 {
-					reg = <0x1>;
+				mdio {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					ethernet-phy@1 {
+						reg = <0x1>;
+					};
 				};
 			};
 
Signature · 1 line
2.25.1
#15 lore raw

PATCH v2 6/7 ARM: dts: at91: sama5d4: add an mdio sub-node to macb

In reply to Codrin Ciubotariu

Use the new macb bindings and add an mdio sub-node to contain all the phy nodes.

---

Changes in v2:
- none

 arch/arm/boot/dts/at91-sama5d4_xplained.dts | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
arch/arm/boot/dts/at91-sama5d4_xplained.dts +8 -4
index 924d9491780d..62598d06aead 100644
@@ -59,10 +59,14 @@ macb0: ethernet@f8020000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <&pinctrl_macb0_rmii &pinctrl_macb0_phy_irq>;
 
-				phy0: ethernet-phy@1 {
-					interrupt-parent = <&pioE>;
-					interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
-					reg = <1>;
+				mdio {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					phy0: ethernet-phy@1 {
+						interrupt-parent = <&pioE>;
+						interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
+						reg = <1>;
+					};
 				};
 			};
 
Signature · 1 line
2.25.1
#17 lore raw

PATCH v2 7/7 ARM: dts: at91: sam9x60: add an mdio sub-node to macb

In reply to Codrin Ciubotariu

Use the new macb bindings and add an mdio sub-node to contain all the phy nodes.

---

Changes in v2:
- none

 arch/arm/boot/dts/at91-sam9x60ek.dts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/boot/dts/at91-sam9x60ek.dts +6 -2
index a5f5718c711a..ba871ebe10d4 100644
@@ -324,8 +324,12 @@ &macb0 {
 	pinctrl-0 = <&pinctrl_macb0_rmii>;
 	status = "okay";
 
-	ethernet-phy@0 {
-		reg = <0x0>;
+	mdio {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		ethernet-phy@0 {
+			reg = <0x0>;
+		};
 	};
 };
 
Signature · 1 line
2.25.1
Tested-by Acked-by on the v2 series
#19 lore raw
In reply to Codrin Ciubotariu
Quoted 9 lines · Codrin Ciubotariu

Adding the PHY nodes directly under the Ethernet node became deprecated, so the aim of this patch series is to make MACB use an MDIO node as container for MDIO devices.
This patch series starts with a small patch to use the device-managed devm_mdiobus_alloc(). In the next two patches we update the bindings and adapt macb driver to parse the device-tree PHY nodes from under an MDIO node. The last patches add the MDIO node in the device-trees of sama5d2, sama5d3, samad4 and sam9x60 boards.

Tested this series on sama5d2_xplained in the following scenarios:

1/ PHY bindings from patch 4/7:

mdio {
	#address-cells = <1>;
	#size-cells = <0>;
	ethernet-phy@1 {
		reg = <0x1>;
		interrupt-parent = <&pioA>;
		interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};

2/ PHY bindings before this series:

ethernet-phy@1 {
	reg = <0x1>;
	interrupt-parent = <&pioA>;
	interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};

3/ No PHY bindings at all.

All 3 cases went OK.

You can add:

Thank you,
Claudiu Beznea

Quoted 26 lines

Changes in v2:
- renamed patch 2/7 from "macb: bindings doc: use an MDIO node as a container for PHY nodes" to "dt-bindings: net: macb: use an MDIO node as a container for PHY nodes"
- added back a newline removed by mistake in patch 3/7

Codrin Ciubotariu (7):
net: macb: use device-managed devm_mdiobus_alloc()
dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
net: macb: parse PHY nodes found under an MDIO node
ARM: dts: at91: sama5d2: add an mdio sub-node to macb
ARM: dts: at91: sama5d3: add an mdio sub-node to macb
ARM: dts: at91: sama5d4: add an mdio sub-node to macb
ARM: dts: at91: sam9x60: add an mdio sub-node to macb

 Documentation/devicetree/bindings/net/macb.txt | 15 ++++++++++++---
 arch/arm/boot/dts/at91-sam9x60ek.dts           |  8 ++++++--
 arch/arm/boot/dts/at91-sama5d27_som1.dtsi      | 16 ++++++++++------
 arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi    | 17 ++++++++++-------
 arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts      | 13 ++++++++-----
 arch/arm/boot/dts/at91-sama5d2_xplained.dts    | 12 ++++++++----
 arch/arm/boot/dts/at91-sama5d3_xplained.dts    | 16 ++++++++++++----
 arch/arm/boot/dts/at91-sama5d4_xplained.dts    | 12 ++++++++----
 drivers/net/ethernet/cadence/macb_main.c       | 18 ++++++++++++------
 9 files changed, 86 insertions(+), 41 deletions(-)
#20 lore raw
Quoted 32 lines · On 22.07.2020 13:32, Claudiu Beznea - M18063 wrote:
Quoted 9 lines · Codrin Ciubotariu

Adding the PHY nodes directly under the Ethernet node became deprecated, so the aim of this patch series is to make MACB use an MDIO node as container for MDIO devices.
This patch series starts with a small patch to use the device-managed devm_mdiobus_alloc(). In the next two patches we update the bindings and adapt macb driver to parse the device-tree PHY nodes from under an MDIO node. The last patches add the MDIO node in the device-trees of sama5d2, sama5d3, samad4 and sam9x60 boards.

Tested this series on sama5d2_xplained in the following scenarios:

1/ PHY bindings from patch 4/7:

mdio {
	#address-cells = <1>;
	#size-cells = <0>;
	ethernet-phy@1 {
		reg = <0x1>;
		interrupt-parent = <&pioA>;
		interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};

2/ PHY bindings before this series:

ethernet-phy@1 {
	reg = <0x1>;
	interrupt-parent = <&pioA>;
	interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};
Quoted 7 lines

3/ No PHY bindings at all.

All 3 cases went OK.

You can add:

Thank you very much Claudiu!
There is still one more case in my mind. macb could be a fixed-link with an MDIO DSA switch. While the macb would have a fixed connection with a port from the DSA switch, the switch could be configured using macb's MDIO. The dt would be something like:

macb {
	fixed-link {
		...
	};
	mdio {
		switch@0 {
			...
		};
	};
};

To support this, in patch 3/7 I should first check for the mdio node to return of_mdiobus_register() and then check if it's a fixed-link to return simple mdiobus_register(). I will address this in v3...

Thanks and best regards,
Codrin

Quoted 29 lines

Thank you,
Claudiu Beznea

Quoted 25 lines

Changes in v2:
- renamed patch 2/7 from "macb: bindings doc: use an MDIO node as a container for PHY nodes" to "dt-bindings: net: macb: use an MDIO node as a container for PHY nodes"
- added back a newline removed by mistake in patch 3/7

Codrin Ciubotariu (7):
net: macb: use device-managed devm_mdiobus_alloc()
dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
net: macb: parse PHY nodes found under an MDIO node
ARM: dts: at91: sama5d2: add an mdio sub-node to macb
ARM: dts: at91: sama5d3: add an mdio sub-node to macb
ARM: dts: at91: sama5d4: add an mdio sub-node to macb
ARM: dts: at91: sam9x60: add an mdio sub-node to macb

  Documentation/devicetree/bindings/net/macb.txt | 15 ++++++++++++---
  arch/arm/boot/dts/at91-sam9x60ek.dts           |  8 ++++++--
  arch/arm/boot/dts/at91-sama5d27_som1.dtsi      | 16 ++++++++++------
  arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi    | 17 ++++++++++-------
  arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts      | 13 ++++++++-----
  arch/arm/boot/dts/at91-sama5d2_xplained.dts    | 12 ++++++++----
  arch/arm/boot/dts/at91-sama5d3_xplained.dts    | 16 ++++++++++++----
  arch/arm/boot/dts/at91-sama5d4_xplained.dts    | 12 ++++++++----
  drivers/net/ethernet/cadence/macb_main.c       | 18 ++++++++++++------
  9 files changed, 86 insertions(+), 41 deletions(-)
#21 lore raw
Quoted 47 lines · On 22.07.2020 14:38, Codrin Ciubotariu - M19940 wrote:
Quoted 32 lines · On 22.07.2020 13:32, Claudiu Beznea - M18063 wrote:
Quoted 9 lines · Codrin Ciubotariu

Adding the PHY nodes directly under the Ethernet node became deprecated, so the aim of this patch series is to make MACB use an MDIO node as container for MDIO devices.
This patch series starts with a small patch to use the device-managed devm_mdiobus_alloc(). In the next two patches we update the bindings and adapt macb driver to parse the device-tree PHY nodes from under an MDIO node. The last patches add the MDIO node in the device-trees of sama5d2, sama5d3, samad4 and sam9x60 boards.

Tested this series on sama5d2_xplained in the following scenarios:

1/ PHY bindings from patch 4/7:

mdio {
	#address-cells = <1>;
	#size-cells = <0>;
	ethernet-phy@1 {
		reg = <0x1>;
		interrupt-parent = <&pioA>;
		interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};

2/ PHY bindings before this series:

ethernet-phy@1 {
	reg = <0x1>;
	interrupt-parent = <&pioA>;
	interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};
Quoted 7 lines

3/ No PHY bindings at all.

All 3 cases went OK.

You can add:

Thank you very much Claudiu!
There is still one more case in my mind. macb could be a fixed-link with an MDIO DSA switch. While the macb would have a fixed connection with a port from the DSA switch, the switch could be configured using macb's MDIO. The dt would be something like:

Quoted 10 lines
macb {
	fixed-link {
		...
	};
	mdio {
		switch@0 {
			...
		};
	};
};

Do you have a setup for testing this? At the moment I don't know a configuration like this that macb is working with.

Quoted 37 lines

To support this, in patch 3/7 I should first check for the mdio node to return of_mdiobus_register() and then check if it's a fixed-link to return simple mdiobus_register(). I will address this in v3...> Thanks and best regards,
Codrin

Quoted 29 lines

Thank you,
Claudiu Beznea

Quoted 25 lines

Changes in v2:
- renamed patch 2/7 from "macb: bindings doc: use an MDIO node as a container for PHY nodes" to "dt-bindings: net: macb: use an MDIO node as a container for PHY nodes"
- added back a newline removed by mistake in patch 3/7

Codrin Ciubotariu (7):
net: macb: use device-managed devm_mdiobus_alloc()
dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
net: macb: parse PHY nodes found under an MDIO node
ARM: dts: at91: sama5d2: add an mdio sub-node to macb
ARM: dts: at91: sama5d3: add an mdio sub-node to macb
ARM: dts: at91: sama5d4: add an mdio sub-node to macb
ARM: dts: at91: sam9x60: add an mdio sub-node to macb

  Documentation/devicetree/bindings/net/macb.txt | 15 ++++++++++++---
  arch/arm/boot/dts/at91-sam9x60ek.dts           |  8 ++++++--
  arch/arm/boot/dts/at91-sama5d27_som1.dtsi      | 16 ++++++++++------
  arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi    | 17 ++++++++++-------
  arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts      | 13 ++++++++-----
  arch/arm/boot/dts/at91-sama5d2_xplained.dts    | 12 ++++++++----
  arch/arm/boot/dts/at91-sama5d3_xplained.dts    | 16 ++++++++++++----
  arch/arm/boot/dts/at91-sama5d4_xplained.dts    | 12 ++++++++----
  drivers/net/ethernet/cadence/macb_main.c       | 18 ++++++++++++------
  9 files changed, 86 insertions(+), 41 deletions(-)
#22 lore raw
Quoted 61 lines · On 23.07.2020 10:51, Claudiu Beznea - M18063 wrote:
Quoted 47 lines · On 22.07.2020 14:38, Codrin Ciubotariu - M19940 wrote:
Quoted 32 lines · On 22.07.2020 13:32, Claudiu Beznea - M18063 wrote:
Quoted 9 lines · Codrin Ciubotariu

Adding the PHY nodes directly under the Ethernet node became deprecated, so the aim of this patch series is to make MACB use an MDIO node as container for MDIO devices.
This patch series starts with a small patch to use the device-managed devm_mdiobus_alloc(). In the next two patches we update the bindings and adapt macb driver to parse the device-tree PHY nodes from under an MDIO node. The last patches add the MDIO node in the device-trees of sama5d2, sama5d3, samad4 and sam9x60 boards.

Tested this series on sama5d2_xplained in the following scenarios:

1/ PHY bindings from patch 4/7:

mdio {
	#address-cells = <1>;
	#size-cells = <0>;
	ethernet-phy@1 {
		reg = <0x1>;
		interrupt-parent = <&pioA>;
		interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};

2/ PHY bindings before this series:

ethernet-phy@1 {
	reg = <0x1>;
	interrupt-parent = <&pioA>;
	interrupts = <PIN_PC9 IRQ_TYPE_LEVEL_LOW>;
};
Quoted 7 lines

3/ No PHY bindings at all.

All 3 cases went OK.

You can add:

Thank you very much Claudiu!
There is still one more case in my mind. macb could be a fixed-link with an MDIO DSA switch. While the macb would have a fixed connection with a port from the DSA switch, the switch could be configured using macb's MDIO. The dt would be something like:

Quoted 10 lines
macb {
	fixed-link {
		...
	};
	mdio {
		switch@0 {
			...
		};
	};
};
Quoted 2 lines

Do you have a setup for testing this? At the moment I don't know a configuration like this that macb is working with.

There isn't one that I am aware of, but we should address it.

Quoted 37 lines
Quoted 37 lines

To support this, in patch 3/7 I should first check for the mdio node to return of_mdiobus_register() and then check if it's a fixed-link to return simple mdiobus_register(). I will address this in v3...> Thanks and best regards,
Codrin

Quoted 29 lines

Thank you,
Claudiu Beznea

Quoted 25 lines

Changes in v2:
- renamed patch 2/7 from "macb: bindings doc: use an MDIO node as a container for PHY nodes" to "dt-bindings: net: macb: use an MDIO node as a container for PHY nodes"
- added back a newline removed by mistake in patch 3/7

Codrin Ciubotariu (7):
net: macb: use device-managed devm_mdiobus_alloc()
dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
net: macb: parse PHY nodes found under an MDIO node
ARM: dts: at91: sama5d2: add an mdio sub-node to macb
ARM: dts: at91: sama5d3: add an mdio sub-node to macb
ARM: dts: at91: sama5d4: add an mdio sub-node to macb
ARM: dts: at91: sam9x60: add an mdio sub-node to macb

   Documentation/devicetree/bindings/net/macb.txt | 15 ++++++++++++---
   arch/arm/boot/dts/at91-sam9x60ek.dts           |  8 ++++++--
   arch/arm/boot/dts/at91-sama5d27_som1.dtsi      | 16 ++++++++++------
   arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi    | 17 ++++++++++-------
   arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts      | 13 ++++++++-----
   arch/arm/boot/dts/at91-sama5d2_xplained.dts    | 12 ++++++++----
   arch/arm/boot/dts/at91-sama5d3_xplained.dts    | 16 ++++++++++++----
   arch/arm/boot/dts/at91-sama5d4_xplained.dts    | 12 ++++++++----
   drivers/net/ethernet/cadence/macb_main.c       | 18 ++++++++++++------
   9 files changed, 86 insertions(+), 41 deletions(-)