[net-next PATCH v13 09/14] net: mdio: regmap: add OF support

From: Christian Marangi
Date: Sat Mar 15 2025 - 11:47:57 EST


Permit to pass a device tree node to mdio regmap config and use
the OF variant of mdiobus_register.

This is done to autoprobe PHY defined in device tree as the current
mdiobus_register only permits probing PHY using the MDIO mask value.

Previous implementation is not changed as of_mdiobus_register fallback
to mdiobus_register if the passed device tree pointer is NULL.

Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
---
drivers/net/mdio/mdio-regmap.c | 2 +-
include/linux/mdio/mdio-regmap.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio/mdio-regmap.c b/drivers/net/mdio/mdio-regmap.c
index ed0443eb039f..8e89068c844d 100644
--- a/drivers/net/mdio/mdio-regmap.c
+++ b/drivers/net/mdio/mdio-regmap.c
@@ -143,7 +143,7 @@ struct mii_bus *devm_mdio_regmap_register(struct device *dev,
else
mii->phy_mask = ~0;

- rc = devm_mdiobus_register(dev, mii);
+ rc = devm_of_mdiobus_register(dev, mii, config->np);
if (rc) {
dev_err(config->parent, "Cannot register MDIO bus![%s] (%d)\n", mii->id, rc);
return ERR_PTR(rc);
diff --git a/include/linux/mdio/mdio-regmap.h b/include/linux/mdio/mdio-regmap.h
index bb0e7dc9c0dc..228f12e90750 100644
--- a/include/linux/mdio/mdio-regmap.h
+++ b/include/linux/mdio/mdio-regmap.h
@@ -14,6 +14,7 @@ struct regmap;

struct mdio_regmap_config {
struct device *parent;
+ struct device_node *np;
struct regmap *regmap;
char name[MII_BUS_ID_SIZE];
u8 valid_addr;
--
2.48.1