Skip to content

Commit 2c60c4c

Browse files
Niklas Söderlundkuba-moo
authored andcommitted
ravb: Add support for an optional MDIO mode
The driver used the DT node of the device itself when registering the MDIO bus. While this works, it creates a problem: it forces any MDIO bus properties to also be set on the devices DT node. This mixes the properties of two distinctly different things and is confusing. This change adds support for an optional mdio node to be defined as a child to the device DT node. The child node can then be used to describe MDIO bus properties that the MDIO core can act on when registering the bus. If no mdio child node is found the driver fallback to the old behavior and register the MDIO bus using the device DT node. This change is backward compatible with old bindings in use. Signed-off-by: Niklas Söderlund <[email protected]> Reviewed-by: Sergey Shtylyov <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a87590c commit 2c60c4c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,7 @@ static int ravb_mdio_init(struct ravb_private *priv)
25642564
{
25652565
struct platform_device *pdev = priv->pdev;
25662566
struct device *dev = &pdev->dev;
2567+
struct device_node *mdio_node;
25672568
struct phy_device *phydev;
25682569
struct device_node *pn;
25692570
int error;
@@ -2583,7 +2584,13 @@ static int ravb_mdio_init(struct ravb_private *priv)
25832584
pdev->name, pdev->id);
25842585

25852586
/* Register MDIO bus */
2586-
error = of_mdiobus_register(priv->mii_bus, dev->of_node);
2587+
mdio_node = of_get_child_by_name(dev->of_node, "mdio");
2588+
if (!mdio_node) {
2589+
/* backwards compatibility for DT lacking mdio subnode */
2590+
mdio_node = of_node_get(dev->of_node);
2591+
}
2592+
error = of_mdiobus_register(priv->mii_bus, mdio_node);
2593+
of_node_put(mdio_node);
25872594
if (error)
25882595
goto out_free_bus;
25892596

0 commit comments

Comments
 (0)