Skip to contentSkip to conversation

net: sun8i-emac: Add support for fixed-link phy

PATCH In review Maksim Kiselev 2 participants 2 messages Jan 20, 2024 – Jan 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: sun8i-emac: Add support for fixed-link phy

Make the "phy-handle" property optional, which allows support for a fixed-link phy configuration.

Thus if the "phy-handle" is present in a DT, then driver will work as before. Otherwise, phyaddr initialization will not be necessary, as it is not needed in case of a fixed-link config.

---
 drivers/net/sun8i_emac.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/sun8i_emac.c +2 -5
index a12f7e32e8..8bff4fe9a9 100644
@@ -833,11 +833,8 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev)
 	priv->use_internal_phy = false;
 
 	offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
-	if (offset < 0) {
-		debug("%s: Cannot find PHY address\n", __func__);
-		return -EINVAL;
-	}
-	priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
+	if (offset >= 0)
+		priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
 	pdata->phy_interface = dev_read_phy_mode(dev);
 	debug("phy interface %d\n", pdata->phy_interface);
Signature · 1 line
2.40.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · On Sat, 20 Jan 2024 19:26:24 +0300 Maksim Kiselev <[email protected]> wrote:

Make the "phy-handle" property optional, which allows support for a fixed-link phy configuration.

Thus if the "phy-handle" is present in a DT, then driver will work as before. Otherwise, phyaddr initialization will not be necessary, as it is not needed in case of a fixed-link config.

Thanks, looks good now:

Queued for the first PR.

Cheers,
Andre

Quoted 22 lines
---
 drivers/net/sun8i_emac.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/sun8i_emac.c +2 -5
index a12f7e32e8..8bff4fe9a9 100644
@@ -833,11 +833,8 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev)
 	priv->use_internal_phy = false;
 
 	offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
-	if (offset < 0) {
-		debug("%s: Cannot find PHY address\n", __func__);
-		return -EINVAL;
-	}
-	priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
+	if (offset >= 0)
+		priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
 	pdata->phy_interface = dev_read_phy_mode(dev);
 	debug("phy interface %d\n", pdata->phy_interface);