[net-next PATCH v12 08/13] net: mdio: regmap: add OF support

Christian Marangi posted 13 patches 11 months ago
There is a newer version of this series
[net-next PATCH v12 08/13] net: mdio: regmap: add OF support
Posted by Christian Marangi 11 months ago
Permit to pass the device node pointer to mdio regmap config and permit
mdio registration with an OF node to support DT PHY probe.

With the device node pointer NULL, the normal mdio registration is used.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 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 8bfcd9e415c8..329839ab68e6 100644
--- a/drivers/net/mdio/mdio-regmap.c
+++ b/drivers/net/mdio/mdio-regmap.c
@@ -90,7 +90,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 8c7061e39ccb..23fc2dd9d752 100644
--- a/include/linux/mdio/mdio-regmap.h
+++ b/include/linux/mdio/mdio-regmap.h
@@ -22,6 +22,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
Re: [net-next PATCH v12 08/13] net: mdio: regmap: add OF support
Posted by Russell King (Oracle) 11 months ago
On Sun, Mar 09, 2025 at 06:26:53PM +0100, Christian Marangi wrote:
> Permit to pass the device node pointer to mdio regmap config and permit
> mdio registration with an OF node to support DT PHY probe.
> 
> With the device node pointer NULL, the normal mdio registration is used.

Should this be using a device node, or a fwnode?

It depends _why_ you're adding this, and you omit to state that in the
commit description (hint - it should say why!)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [net-next PATCH v12 08/13] net: mdio: regmap: add OF support
Posted by Christian Marangi 11 months ago
On Sun, Mar 09, 2025 at 05:37:58PM +0000, Russell King (Oracle) wrote:
> On Sun, Mar 09, 2025 at 06:26:53PM +0100, Christian Marangi wrote:
> > Permit to pass the device node pointer to mdio regmap config and permit
> > mdio registration with an OF node to support DT PHY probe.
> > 
> > With the device node pointer NULL, the normal mdio registration is used.
> 
> Should this be using a device node, or a fwnode?
> 
> It depends _why_ you're adding this, and you omit to state that in the
> commit description (hint - it should say why!)
>

Ugh totally forgot... It should be a device node. The use of the of_
variant of mdiobus register permits to autoprobe PHY defined in device
tree.

The current regmap driver only permit manual probe using the mask value
so it's problematic for MFD usage with an abstract regmap and PHY
autoprobe.

Will add additional info in the commit.

-- 
	Ansuel