linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB
@ 2020-07-21 17:13 Codrin Ciubotariu
  2020-07-21 17:13 ` [PATCH net-next v2 1/7] net: macb: use device-managed devm_mdiobus_alloc() Codrin Ciubotariu
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, 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.

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(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH net-next v2 1/7] net: macb: use device-managed devm_mdiobus_alloc()
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
@ 2020-07-21 17:13 ` Codrin Ciubotariu
  2020-07-23 18:55   ` Florian Fainelli
  2020-07-21 17:13 ` [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes Codrin Ciubotariu
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, Codrin Ciubotariu

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

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---

Changes in v2:
 - none

 drivers/net/ethernet/cadence/macb_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index a6a35e1b0115..89fe7af5e408 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
  2020-07-21 17:13 ` [PATCH net-next v2 1/7] net: macb: use device-managed devm_mdiobus_alloc() Codrin Ciubotariu
@ 2020-07-21 17:13 ` Codrin Ciubotariu
  2020-07-23 17:51   ` Rob Herring
  2020-07-23 18:56   ` Florian Fainelli
  2020-07-21 17:13 ` [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node Codrin Ciubotariu
                   ` (5 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, 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).

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---

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(-)

diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
index 0b61a90f1592..88d5199c2279 100644
--- a/Documentation/devicetree/bindings/net/macb.txt
+++ b/Documentation/devicetree/bindings/net/macb.txt
@@ -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>;
+			};
 		};
 	};
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
  2020-07-21 17:13 ` [PATCH net-next v2 1/7] net: macb: use device-managed devm_mdiobus_alloc() Codrin Ciubotariu
  2020-07-21 17:13 ` [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes Codrin Ciubotariu
@ 2020-07-21 17:13 ` Codrin Ciubotariu
  2020-07-23 18:59   ` Florian Fainelli
  2020-07-21 17:13 ` [PATCH net-next v2 4/7] ARM: dts: at91: sama5d2: add an mdio sub-node to macb Codrin Ciubotariu
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, 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.

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---

Changes in v2:
 - readded newline removed by mistake;

 drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 89fe7af5e408..b25c64b45148 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH net-next v2 4/7] ARM: dts: at91: sama5d2: add an mdio sub-node to macb
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
                   ` (2 preceding siblings ...)
  2020-07-21 17:13 ` [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node Codrin Ciubotariu
@ 2020-07-21 17:13 ` Codrin Ciubotariu
  2020-07-23 18:59   ` Florian Fainelli
  2020-07-21 17:13 ` [PATCH net-next v2 5/7] ARM: dts: at91: sama5d3: " Codrin Ciubotariu
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, Codrin Ciubotariu

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

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---

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(-)

diff --git a/arch/arm/boot/dts/at91-sama5d27_som1.dtsi b/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
index b1f994c0ae79..dfcee23dcce0 100644
--- a/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
+++ b/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
@@ -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>;
+					};
 				};
 			};
 
diff --git a/arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi b/arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi
index a06700e53e4c..9c4dce29d2fe 100644
--- a/arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi
+++ b/arch/arm/boot/dts/at91-sama5d27_wlsom1.dtsi
@@ -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>;
+		};
 	};
 };
 
diff --git a/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts b/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts
index c894c7c788a9..fc3375c43ef6 100644
--- a/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts
@@ -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>;
+					};
 				};
 			};
 
diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index a927165ea7c2..a62f475d9d0a 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -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>;
+					};
 				};
 			};
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH net-next v2 5/7] ARM: dts: at91: sama5d3: add an mdio sub-node to macb
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
                   ` (3 preceding siblings ...)
  2020-07-21 17:13 ` [PATCH net-next v2 4/7] ARM: dts: at91: sama5d2: add an mdio sub-node to macb Codrin Ciubotariu
@ 2020-07-21 17:13 ` Codrin Ciubotariu
  2020-07-23 19:00   ` Florian Fainelli
  2020-07-21 17:13 ` [PATCH net-next v2 6/7] ARM: dts: at91: sama5d4: " Codrin Ciubotariu
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, Codrin Ciubotariu

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

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---

Changes in v2:
 - none;

 arch/arm/boot/dts/at91-sama5d3_xplained.dts | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/at91-sama5d3_xplained.dts b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
index 61f068a7b362..25d2646ce4cb 100644
--- a/arch/arm/boot/dts/at91-sama5d3_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
@@ -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>;
+					};
 				};
 			};
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH net-next v2 6/7] ARM: dts: at91: sama5d4: add an mdio sub-node to macb
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
                   ` (4 preceding siblings ...)
  2020-07-21 17:13 ` [PATCH net-next v2 5/7] ARM: dts: at91: sama5d3: " Codrin Ciubotariu
@ 2020-07-21 17:13 ` Codrin Ciubotariu
  2020-07-23 19:00   ` Florian Fainelli
  2020-07-21 17:13 ` [PATCH net-next v2 7/7] ARM: dts: at91: sam9x60: " Codrin Ciubotariu
  2020-07-22 10:32 ` [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Claudiu.Beznea
  7 siblings, 1 reply; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, Codrin Ciubotariu

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

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---

Changes in v2:
 - none

 arch/arm/boot/dts/at91-sama5d4_xplained.dts | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/at91-sama5d4_xplained.dts b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
index 924d9491780d..62598d06aead 100644
--- a/arch/arm/boot/dts/at91-sama5d4_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
@@ -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>;
+					};
 				};
 			};
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH net-next v2 7/7] ARM: dts: at91: sam9x60: add an mdio sub-node to macb
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
                   ` (5 preceding siblings ...)
  2020-07-21 17:13 ` [PATCH net-next v2 6/7] ARM: dts: at91: sama5d4: " Codrin Ciubotariu
@ 2020-07-21 17:13 ` Codrin Ciubotariu
  2020-07-23 19:00   ` Florian Fainelli
  2020-07-22 10:32 ` [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Claudiu.Beznea
  7 siblings, 1 reply; 23+ messages in thread
From: Codrin Ciubotariu @ 2020-07-21 17:13 UTC (permalink / raw)
  To: netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, f.fainelli,
	robh+dt, alexandre.belloni, ludovic.desroches, Codrin Ciubotariu

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

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---

Changes in v2:
 - none

 arch/arm/boot/dts/at91-sam9x60ek.dts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91-sam9x60ek.dts b/arch/arm/boot/dts/at91-sam9x60ek.dts
index a5f5718c711a..ba871ebe10d4 100644
--- a/arch/arm/boot/dts/at91-sam9x60ek.dts
+++ b/arch/arm/boot/dts/at91-sam9x60ek.dts
@@ -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>;
+		};
 	};
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB
  2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
                   ` (6 preceding siblings ...)
  2020-07-21 17:13 ` [PATCH net-next v2 7/7] ARM: dts: at91: sam9x60: " Codrin Ciubotariu
@ 2020-07-22 10:32 ` Claudiu.Beznea
  2020-07-22 11:38   ` Codrin.Ciubotariu
  7 siblings, 1 reply; 23+ messages in thread
From: Claudiu.Beznea @ 2020-07-22 10:32 UTC (permalink / raw)
  To: Codrin.Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: Nicolas.Ferre, davem, kuba, andrew, f.fainelli, robh+dt,
	alexandre.belloni, Ludovic.Desroches



On 21.07.2020 20:13, Codrin Ciubotariu wrote:
> 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:
Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Claudiu Beznea <claudiu.beznea@microchip.com>

Thank you,
Claudiu Beznea

> 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(-)
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB
  2020-07-22 10:32 ` [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Claudiu.Beznea
@ 2020-07-22 11:38   ` Codrin.Ciubotariu
  2020-07-23  7:51     ` Claudiu.Beznea
  0 siblings, 1 reply; 23+ messages in thread
From: Codrin.Ciubotariu @ 2020-07-22 11:38 UTC (permalink / raw)
  To: Claudiu.Beznea, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: Nicolas.Ferre, davem, kuba, andrew, f.fainelli, robh+dt,
	alexandre.belloni, Ludovic.Desroches

On 22.07.2020 13:32, Claudiu Beznea - M18063 wrote:
> 
> 
> On 21.07.2020 20:13, Codrin Ciubotariu wrote:
>> 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:
> Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> Acked-by: Claudiu Beznea <claudiu.beznea@microchip.com>

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

> 
> Thank you,
> Claudiu Beznea
> 
>> 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(-)


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB
  2020-07-22 11:38   ` Codrin.Ciubotariu
@ 2020-07-23  7:51     ` Claudiu.Beznea
  2020-07-23 13:18       ` Codrin.Ciubotariu
  0 siblings, 1 reply; 23+ messages in thread
From: Claudiu.Beznea @ 2020-07-23  7:51 UTC (permalink / raw)
  To: Codrin.Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: Nicolas.Ferre, davem, kuba, andrew, f.fainelli, robh+dt,
	alexandre.belloni, Ludovic.Desroches



On 22.07.2020 14:38, Codrin Ciubotariu - M19940 wrote:
> On 22.07.2020 13:32, Claudiu Beznea - M18063 wrote:
>>
>>
>> On 21.07.2020 20:13, Codrin Ciubotariu wrote:
>>> 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:
>> Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
>> Acked-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> 
> 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 {
> 			...
> 		};
> 	};
> };

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

> 
> 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
> 
>>
>> Thank you,
>> Claudiu Beznea
>>
>>> 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(-)
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB
  2020-07-23  7:51     ` Claudiu.Beznea
@ 2020-07-23 13:18       ` Codrin.Ciubotariu
  0 siblings, 0 replies; 23+ messages in thread
From: Codrin.Ciubotariu @ 2020-07-23 13:18 UTC (permalink / raw)
  To: Claudiu.Beznea, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: Nicolas.Ferre, davem, kuba, andrew, f.fainelli, robh+dt,
	alexandre.belloni, Ludovic.Desroches

On 23.07.2020 10:51, Claudiu Beznea - M18063 wrote:
> 
> 
> On 22.07.2020 14:38, Codrin Ciubotariu - M19940 wrote:
>> On 22.07.2020 13:32, Claudiu Beznea - M18063 wrote:
>>>
>>>
>>> On 21.07.2020 20:13, Codrin Ciubotariu wrote:
>>>> 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:
>>> Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
>>> Acked-by: Claudiu Beznea <claudiu.beznea@microchip.com>
>>
>> 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 {
>> 			...
>> 		};
>> 	};
>> };
> 
> 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.

> 
>>
>> 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
>>
>>>
>>> Thank you,
>>> Claudiu Beznea
>>>
>>>> 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(-)


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
  2020-07-21 17:13 ` [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes Codrin Ciubotariu
@ 2020-07-23 17:51   ` Rob Herring
  2020-07-23 18:56   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Rob Herring @ 2020-07-23 17:51 UTC (permalink / raw)
  To: Codrin Ciubotariu
  Cc: f.fainelli, kuba, davem, alexandre.belloni, devicetree,
	linux-arm-kernel, netdev, ludovic.desroches, robh+dt,
	linux-kernel, claudiu.beznea, andrew

On Tue, 21 Jul 2020 20:13:11 +0300, Codrin Ciubotariu wrote:
> 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).
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
> ---
> 
> 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: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 1/7] net: macb: use device-managed devm_mdiobus_alloc()
  2020-07-21 17:13 ` [PATCH net-next v2 1/7] net: macb: use device-managed devm_mdiobus_alloc() Codrin Ciubotariu
@ 2020-07-23 18:55   ` Florian Fainelli
  0 siblings, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 18:55 UTC (permalink / raw)
  To: Codrin Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, ludovic.desroches

On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
> Use the device-managed variant for the allocating the MDIO bus. This
> cleans-up the code a little on the remove and error paths.
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes
  2020-07-21 17:13 ` [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes Codrin Ciubotariu
  2020-07-23 17:51   ` Rob Herring
@ 2020-07-23 18:56   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 18:56 UTC (permalink / raw)
  To: Codrin Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, ludovic.desroches

On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
> 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).
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node
  2020-07-21 17:13 ` [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node Codrin Ciubotariu
@ 2020-07-23 18:59   ` Florian Fainelli
  2020-07-23 22:08     ` Codrin.Ciubotariu
  2020-07-24  7:28     ` Claudiu.Beznea
  0 siblings, 2 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 18:59 UTC (permalink / raw)
  To: Codrin Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, ludovic.desroches

On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
> 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.
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
> ---
> 
> Changes in v2:
>  - readded newline removed by mistake;
> 
>  drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 89fe7af5e408..b25c64b45148 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -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.

>  
> +	/* 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
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 4/7] ARM: dts: at91: sama5d2: add an mdio sub-node to macb
  2020-07-21 17:13 ` [PATCH net-next v2 4/7] ARM: dts: at91: sama5d2: add an mdio sub-node to macb Codrin Ciubotariu
@ 2020-07-23 18:59   ` Florian Fainelli
  0 siblings, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 18:59 UTC (permalink / raw)
  To: Codrin Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, ludovic.desroches

On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
> Use the new macb bindings and add an mdio sub-node to contain all the
> phy nodes.
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 5/7] ARM: dts: at91: sama5d3: add an mdio sub-node to macb
  2020-07-21 17:13 ` [PATCH net-next v2 5/7] ARM: dts: at91: sama5d3: " Codrin Ciubotariu
@ 2020-07-23 19:00   ` Florian Fainelli
  0 siblings, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 19:00 UTC (permalink / raw)
  To: Codrin Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, ludovic.desroches

On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
> Use the new macb bindings and add an mdio sub-node to contain all the
> phy nodes.
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 6/7] ARM: dts: at91: sama5d4: add an mdio sub-node to macb
  2020-07-21 17:13 ` [PATCH net-next v2 6/7] ARM: dts: at91: sama5d4: " Codrin Ciubotariu
@ 2020-07-23 19:00   ` Florian Fainelli
  0 siblings, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 19:00 UTC (permalink / raw)
  To: Codrin Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, ludovic.desroches

On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
> Use the new macb bindings and add an mdio sub-node to contain all the
> phy nodes.
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 7/7] ARM: dts: at91: sam9x60: add an mdio sub-node to macb
  2020-07-21 17:13 ` [PATCH net-next v2 7/7] ARM: dts: at91: sam9x60: " Codrin Ciubotariu
@ 2020-07-23 19:00   ` Florian Fainelli
  0 siblings, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 19:00 UTC (permalink / raw)
  To: Codrin Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: nicolas.ferre, claudiu.beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, ludovic.desroches

On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
> Use the new macb bindings and add an mdio sub-node to contain all the
> phy nodes.
> 
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node
  2020-07-23 18:59   ` Florian Fainelli
@ 2020-07-23 22:08     ` Codrin.Ciubotariu
  2020-07-23 22:33       ` Florian Fainelli
  2020-07-24  7:28     ` Claudiu.Beznea
  1 sibling, 1 reply; 23+ messages in thread
From: Codrin.Ciubotariu @ 2020-07-23 22:08 UTC (permalink / raw)
  To: f.fainelli, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: Nicolas.Ferre, Claudiu.Beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, Ludovic.Desroches

On 23.07.2020 21:59, Florian Fainelli wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
>> 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.
>>
>> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
>> ---
>>
>> Changes in v2:
>>   - readded newline removed by mistake;
>>
>>   drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>> index 89fe7af5e408..b25c64b45148 100644
>> --- a/drivers/net/ethernet/cadence/macb_main.c
>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>> @@ -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.

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

> 
>>
>> +     /* 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
>>
> 
> 
> --
> Florian
> 


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node
  2020-07-23 22:08     ` Codrin.Ciubotariu
@ 2020-07-23 22:33       ` Florian Fainelli
  0 siblings, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2020-07-23 22:33 UTC (permalink / raw)
  To: Codrin.Ciubotariu, netdev, devicetree, linux-arm-kernel, linux-kernel
  Cc: Nicolas.Ferre, Claudiu.Beznea, davem, kuba, andrew, robh+dt,
	alexandre.belloni, Ludovic.Desroches

On 7/23/20 3:08 PM, Codrin.Ciubotariu@microchip.com wrote:
> On 23.07.2020 21:59, Florian Fainelli wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>
>> On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
>>> 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.
>>>
>>> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
>>> ---
>>>
>>> Changes in v2:
>>>   - readded newline removed by mistake;
>>>
>>>   drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
>>>   1 file changed, 10 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>>> index 89fe7af5e408..b25c64b45148 100644
>>> --- a/drivers/net/ethernet/cadence/macb_main.c
>>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>>> @@ -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.
> 
> 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.

> 
> Thank you for your review(s)!

Of course.
-- 
Florian

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node
  2020-07-23 18:59   ` Florian Fainelli
  2020-07-23 22:08     ` Codrin.Ciubotariu
@ 2020-07-24  7:28     ` Claudiu.Beznea
  1 sibling, 0 replies; 23+ messages in thread
From: Claudiu.Beznea @ 2020-07-24  7:28 UTC (permalink / raw)
  To: f.fainelli, Codrin.Ciubotariu, netdev, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: Nicolas.Ferre, davem, kuba, andrew, robh+dt, alexandre.belloni,
	Ludovic.Desroches



On 23.07.2020 21:59, Florian Fainelli wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 7/21/20 10:13 AM, Codrin Ciubotariu wrote:
>> 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.
>>
>> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
>> ---
>>
>> Changes in v2:
>>  - readded newline removed by mistake;
>>
>>  drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>> index 89fe7af5e408..b25c64b45148 100644
>> --- a/drivers/net/ethernet/cadence/macb_main.c
>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>> @@ -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.

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

> 
>>
>> +     /* 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
>>
> 
> 
> --
> Florian
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2020-07-24  7:28 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 17:13 [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Codrin Ciubotariu
2020-07-21 17:13 ` [PATCH net-next v2 1/7] net: macb: use device-managed devm_mdiobus_alloc() Codrin Ciubotariu
2020-07-23 18:55   ` Florian Fainelli
2020-07-21 17:13 ` [PATCH net-next v2 2/7] dt-bindings: net: macb: use an MDIO node as a container for PHY nodes Codrin Ciubotariu
2020-07-23 17:51   ` Rob Herring
2020-07-23 18:56   ` Florian Fainelli
2020-07-21 17:13 ` [PATCH net-next v2 3/7] net: macb: parse PHY nodes found under an MDIO node Codrin Ciubotariu
2020-07-23 18:59   ` Florian Fainelli
2020-07-23 22:08     ` Codrin.Ciubotariu
2020-07-23 22:33       ` Florian Fainelli
2020-07-24  7:28     ` Claudiu.Beznea
2020-07-21 17:13 ` [PATCH net-next v2 4/7] ARM: dts: at91: sama5d2: add an mdio sub-node to macb Codrin Ciubotariu
2020-07-23 18:59   ` Florian Fainelli
2020-07-21 17:13 ` [PATCH net-next v2 5/7] ARM: dts: at91: sama5d3: " Codrin Ciubotariu
2020-07-23 19:00   ` Florian Fainelli
2020-07-21 17:13 ` [PATCH net-next v2 6/7] ARM: dts: at91: sama5d4: " Codrin Ciubotariu
2020-07-23 19:00   ` Florian Fainelli
2020-07-21 17:13 ` [PATCH net-next v2 7/7] ARM: dts: at91: sam9x60: " Codrin Ciubotariu
2020-07-23 19:00   ` Florian Fainelli
2020-07-22 10:32 ` [PATCH net-next v2 0/7] Add an MDIO sub-node under MACB Claudiu.Beznea
2020-07-22 11:38   ` Codrin.Ciubotariu
2020-07-23  7:51     ` Claudiu.Beznea
2020-07-23 13:18       ` Codrin.Ciubotariu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).