net: thunder_bgx: convert fwnode to OF
Subsystems (3)
v2 cover net: thunder_bgx: convert fwnode to OF
NVMEM support addition and fwnode removals in favor of OF
v2: split up patch
Rosen Penev (2):
net: thunder_bgx: check for MAC probe defer
net: thunder_bgx: use OF loop instead of fwnode
.../net/ethernet/cavium/thunder/thunder_bgx.c | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-)
Signature · 1 line
2.51.0
PATCH v2 1/2 net: thunder_bgx: check for MAC probe defer
of_get_mac_address supports NVMEM, which can load after the driver. Check for it and defer in such a case.
--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +4 -1
@@ -1471,6 +1471,7 @@ static int bgx_init_of_phy(struct bgx *bgx)struct fwnode_handle *fwn;struct device_node *node =NULL ;u8 lmac =0 ; +int err;device_for_each_child_node (&bgx->pdev->dev, fwn) {struct phy_device *pd;
@@ -1483,7 +1484,9 @@ static int bgx_init_of_phy(struct bgx *bgx)if (!node)break ; -of_get_mac_address (node, bgx->lmac[lmac].mac); + err =of_get_mac_address (node, bgx->lmac[lmac].mac); +if (err == -EPROBE_DEFER ) + goto defer;SET_NETDEV_DEV (bgx->lmac[lmac].netdev, &bgx->pdev->dev); bgx->lmac[lmac].lmacid = lmac;
Signature · 1 line
2.51.0
Re: [PATCHv2 net-next 1/2] net: thunder_bgx: check for MAC probe defer
Quoted 4 lines · Rosen Penev
of_get_mac_addresssupports NVMEM, which can load after the driver. Check for it and defer in such a case.Signed-off-by Rosen Penev <[email protected]>
Andrew
PATCH v2 2/2 net: thunder_bgx: use OF loop instead of fwnode
In reply to Rosen PenevThis is implemented under CONFIG_OF_MDIO, which already assumes an OF node. Also the loop already checks to see if of_node is NULL before proceeding.
--- .../net/ethernet/cavium/thunder/thunder_bgx.c | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +8 -15
@@ -1468,30 +1468,23 @@ static int bgx_init_acpi_phy(struct bgx *bgx)static int bgx_init_of_phy (struct bgx *bgx) { -struct fwnode_handle *fwn; -struct device_node *node =NULL ; +struct device_node *node = bgx->pdev->dev.of_node; +struct device_node *child;u8 lmac =0 ; -int err; -device_for_each_child_node (&bgx->pdev->dev, fwn) { +for_each_child_of_node (node, child) {struct phy_device *pd;struct device_node *phy_np; +int err; -/* Should always be an OF node. But if it is not, we -* cannot handle it, so exit the loop. -*/ - node =to_of_node (fwn); -if (!node) -break ; - - err =of_get_mac_address (node, bgx->lmac[lmac].mac); + err =of_get_mac_address (child, bgx->lmac[lmac].mac);if (err == -EPROBE_DEFER ) goto defer;SET_NETDEV_DEV (bgx->lmac[lmac].netdev, &bgx->pdev->dev); bgx->lmac[lmac].lmacid = lmac; - phy_np =of_parse_phandle (node,"phy-handle" ,0 ); + phy_np =of_parse_phandle (child,"phy-handle" ,0 );/* If there is no phy or defective firmware presents * this cortina phy, for which there is no driver * support, ignore it.
@@ -1511,7 +1504,7 @@ static int bgx_init_of_phy(struct bgx *bgx) lmac++;if (lmac == bgx->max_lmac) { -of_node_put (node); +of_node_put (child);break ; } }
@@ -1528,7 +1521,7 @@ static int bgx_init_of_phy(struct bgx *bgx) bgx->lmac[lmac].phydev =NULL ; } } -of_node_put (node); +of_node_put (child);return -EPROBE_DEFER ; }
Signature · 1 line
2.51.0
Re: [PATCHv2 net-next 2/2] net: thunder_bgx: use OF loop instead of fwnode
Quoted 2 lines · Rosen Penev
This is implemented under
CONFIG_OF_MDIO, which already assumes an OF node.
I'm not sure that is correct.
bgx_probe() -> bgx_init_phy() -> bgx_init_of_phy()
static int bgx_init_phy(struct bgx *bgx)
{
if (!acpi_disabled)
return bgx_init_acpi_phy(bgx);
return bgx_init_of_phy(bgx);
}There is no check made to see if this is an ACPI node and so bgx_init_acpi_phy() is called. So it might be an ACPI node is passed to bgx_init_of_phy().
How have you tested this code? On an ACPI machine, or only a DT machine?
Andrew