Skip to content

Commit 902a66e

Browse files
Sven Van Asbroeckkuba-moo
Sven Van Asbroeck
authored andcommitted
lan743x: correctly handle chips with internal PHY
Commit 6f197fb ("lan743x: Added fixed link and RGMII support") assumes that chips with an internal PHY will never have a devicetree entry. This is incorrect: even for these chips, a devicetree entry can be useful e.g. to pass the mac address from bootloader to chip: &pcie { status = "okay"; host@0 { reg = <0 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; lan7430: ethernet@0 { /* LAN7430 with internal PHY */ compatible = "microchip,lan743x"; status = "okay"; reg = <0 0 0 0 0>; /* filled in by bootloader */ local-mac-address = [00 00 00 00 00 00]; }; }; }; If a devicetree entry is present, the driver will not attach the chip to its internal phy, and the chip will be non-operational. Fix by tweaking the phy connection algorithm: - first try to connect to a phy specified in the devicetree (could be 'real' phy, or just a 'fixed-link') - if that doesn't succeed, try to connect to an internal phy, even if the chip has a devnode Tested on a LAN7430 with internal PHY. I cannot test a device using fixed-link, as I do not have access to one. Fixes: 6f197fb ("lan743x: Added fixed link and RGMII support") Tested-by: Sven Van Asbroeck <[email protected]> # lan7430 Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Sven Van Asbroeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 866358e commit 902a66e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,9 +1026,9 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter)
10261026

10271027
netdev = adapter->netdev;
10281028
phynode = of_node_get(adapter->pdev->dev.of_node);
1029-
adapter->phy_mode = PHY_INTERFACE_MODE_GMII;
10301029

10311030
if (phynode) {
1031+
/* try devicetree phy, or fixed link */
10321032
of_get_phy_mode(phynode, &adapter->phy_mode);
10331033

10341034
if (of_phy_is_fixed_link(phynode)) {
@@ -1044,13 +1044,15 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter)
10441044
lan743x_phy_link_status_change, 0,
10451045
adapter->phy_mode);
10461046
of_node_put(phynode);
1047-
if (!phydev)
1048-
goto return_error;
1049-
} else {
1047+
}
1048+
1049+
if (!phydev) {
1050+
/* try internal phy */
10501051
phydev = phy_find_first(adapter->mdiobus);
10511052
if (!phydev)
10521053
goto return_error;
10531054

1055+
adapter->phy_mode = PHY_INTERFACE_MODE_GMII;
10541056
ret = phy_connect_direct(netdev, phydev,
10551057
lan743x_phy_link_status_change,
10561058
adapter->phy_mode);

0 commit comments

Comments
 (0)