diff mbox series

[net-next,1/1] net: phy: Allow mdio buses to probe C45 before falling back to C22

Message ID 20201109124347.13087-1-vee.khee.wong@intel.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/1] net: phy: Allow mdio buses to probe C45 before falling back to C22 | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 650 this patch: 650
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 565 this patch: 565
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Wong, Vee Khee Nov. 9, 2020, 12:43 p.m. UTC
This patch makes mdiobus_scan() to try on C45 first as C45 can access
all devices. This allows the function available for the PHY that
supports for both C45 and C22.

Reviewed-by: Voon Weifeng <weifeng.voon@intel.com>
Reviewed-by: Ong Boon Leong <boon.leong.ong@intel.com>
Signed-off-by: Wong Vee Khee <vee.khee.wong@intel.com>
---
 drivers/net/phy/mdio_bus.c | 5 +++++
 include/linux/phy.h        | 1 +
 2 files changed, 6 insertions(+)

Comments

Andrew Lunn Nov. 9, 2020, 1:32 p.m. UTC | #1
On Mon, Nov 09, 2020 at 08:43:47PM +0800, Wong Vee Khee wrote:
> This patch makes mdiobus_scan() to try on C45 first as C45 can access
> all devices. This allows the function available for the PHY that
> supports for both C45 and C22.
> 
> Reviewed-by: Voon Weifeng <weifeng.voon@intel.com>
> Reviewed-by: Ong Boon Leong <boon.leong.ong@intel.com>
> Signed-off-by: Wong Vee Khee <vee.khee.wong@intel.com>

Hi

You need to add a user of this.

And i would like to see a more detailed explanation of why it is
needed. The PHY driver is free to do either C45 or C22 transfers.
Why does it care how the device was found?
Plus you can generally access C45 registers via the C45 over C22.  If
the PHY does not allow C45 over C22, then i expect the driver needs to
be aware of if the PHY can be access either way, and it needs to do
different things. And there is no PHY driver that i know of which does
this.

So before this goes any further, we need to see the bigger picture.

   Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 56094dd6bf26..372d0d088f7e 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -691,6 +691,11 @@  struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
 		if (IS_ERR(phydev))
 			phydev = get_phy_device(bus, addr, true);
 		break;
+	case MDIOBUS_C45_C22:
+		phydev = get_phy_device(bus, addr, true);
+		if (IS_ERR(phydev))
+			phydev = get_phy_device(bus, addr, false);
+		break;
 	}
 
 	if (IS_ERR(phydev))
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 189bc9881ea6..73d9be2c00f4 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -360,6 +360,7 @@  struct mii_bus {
 		MDIOBUS_C22,
 		MDIOBUS_C45,
 		MDIOBUS_C22_C45,
+		MDIOBUS_C45_C22,
 	} probe_capabilities;
 
 	/** @shared_lock: protect access to the shared element */