Messages in this thread Patch in this message | | | From | Jeremy Linton <> | Subject | [RFC 08/11] net: phy: Allow mdio buses to auto-probe c45 devices | Date | Fri, 22 May 2020 16:30:56 -0500 |
| |
The mdiobus_scan logic is currently hardcoded to only work with c22 devices. This works fairly well in most cases, but its possible a c45 device doesn't respond despite being a standard phy. If the parent hardware is capable, it makes sense to scan for c45 devices before falling back to c22.
As we want this to reflect the capabilities of the STA, lets add a field to the mii_bus structure to represent the capability. That way devices can opt into the extended scanning. Existing users should continue to default to c22 only scanning as long as they are zero'ing the structure before use.
At the moment its a yes/no option, but in the future it may be useful to extend this to c45 only policy, or add additional classes and policies.
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> --- drivers/net/phy/mdio_bus.c | 9 +++++++-- include/linux/phy.h | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 7a4eb3f2cb74..3ab618e15f2c 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -732,10 +732,15 @@ EXPORT_SYMBOL(mdiobus_free); */ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) { - struct phy_device *phydev; + struct phy_device *phydev = ERR_PTR(-ENODEV); int err; - phydev = get_phy_device(bus, addr, false); + if (bus->probe_capabilities == MDIOBUS_C45_FIRST) + phydev = get_phy_device(bus, addr, true); + + if (IS_ERR(phydev)) + phydev = get_phy_device(bus, addr, false); + if (IS_ERR(phydev)) return phydev; diff --git a/include/linux/phy.h b/include/linux/phy.h index 480a6b153227..d68e1ebab484 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -275,6 +275,11 @@ struct mii_bus { int reset_delay_us; /* RESET GPIO descriptor pointer */ struct gpio_desc *reset_gpiod; + /* bus capabilities, used for probing */ + enum { + MDIOBUS_C22_ONLY = 0, + MDIOBUS_C45_FIRST, + } probe_capabilities; }; #define to_mii_bus(d) container_of(d, struct mii_bus, dev) -- 2.26.2
| |