diff mbox series

[v3,net-next,3/4] net: macb: Add phy-handle DT support

Message ID 20180312171001.129209-4-brad.mouring@ni.com
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series macb: Introduce phy-handle DT functionality | expand

Commit Message

Brad Mouring March 12, 2018, 5:10 p.m. UTC
This optional binding (as described in the ethernet DT bindings doc)
directs the netdev to the phydev to use. This is useful for a phy
chip that has >1 phy in it, and two netdevs are using the same phy
chip (i.e. the second mac's phy lives on the first mac's MDIO bus)

The devicetree snippet would look something like this:

ethernet@feedf00d {
	...
	phy-handle = <&phy0> // the first netdev is physically wired to phy0
	...
	phy0: phy@0 {
		...
		reg = <0x0> // MDIO address 0
		...
	}
	phy1: phy@1 {
		...
		reg = <0x1> // MDIO address 1
		...
	}
...
}

ethernet@deadbeef {
	...
	phy-handle = <&phy1> // tells the driver to use phy1 on the
						 // first mac's mdio bus (it's wired thusly)
	...
}

The work done to add the phy_node in the first place (dacdbb4dfc1a1:
"net: macb: add fixed-link node support") will consume the
device_node (if found).

Signed-off-by: Brad Mouring <brad.mouring@ni.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andrew Lunn March 12, 2018, 5:59 p.m. UTC | #1
> @@ -488,6 +488,9 @@ static int macb_mii_probe(struct net_device *dev)
>  			}
>  			bp->phy_node = of_node_get(np);
>  		} else {
> +			/* attempt to find a phy-handle */
> +			bp->phy_node = of_parse_phandle(np, "phy-handle", 0);
> +

Hi Brad

It seems like you should check the return value here, any only
continue with the fallback if there was not a phy-handle.

>  			/* fallback to standard phy registration if no phy were
>  			 * found during dt phy registration
>  			 */

	 Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index db1dc301bed3..b0700a531f3e 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -488,6 +488,9 @@  static int macb_mii_probe(struct net_device *dev)
 			}
 			bp->phy_node = of_node_get(np);
 		} else {
+			/* attempt to find a phy-handle */
+			bp->phy_node = of_parse_phandle(np, "phy-handle", 0);
+
 			/* fallback to standard phy registration if no phy were
 			 * found during dt phy registration
 			 */