diff mbox series

[RFC,net-next,1/2] net: phy: allow mdio bus to probe for c45 devices before c22

Message ID 20210525055839.22496-1-vee.khee.wong@linux.intel.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Introduce MDIO probe order C45 over 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/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 461 this patch: 462
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, 7 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 377 this patch: 378
netdev/header_inline success Link

Commit Message

Wong Vee Khee May 25, 2021, 5:58 a.m. UTC
Some MAC controllers that is able to pair with  external PHY devices
such as the Synopsys MAC Controller (STMMAC) support both Clause-22 and
Clause-45 access.

When paired with PHY devices that only accessible via Clause-45, such as
the Marvell 88E2110, any attempts to access the PHY devices via
Clause-22 will get a PHY ID of all zeroes.

To fix this, we introduce MDIOBUS_C45_C22 which the MAC controller will
try with Clause-45 access before going to Clause-22.

Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
---
 include/linux/phy.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Russell King (Oracle) May 25, 2021, 8:31 a.m. UTC | #1
On Tue, May 25, 2021 at 01:58:39PM +0800, Wong Vee Khee wrote:
> Some MAC controllers that is able to pair with  external PHY devices
> such as the Synopsys MAC Controller (STMMAC) support both Clause-22 and
> Clause-45 access.
> 
> When paired with PHY devices that only accessible via Clause-45, such as
> the Marvell 88E2110, any attempts to access the PHY devices via
> Clause-22 will get a PHY ID of all zeroes.
> 
> To fix this, we introduce MDIOBUS_C45_C22 which the MAC controller will
> try with Clause-45 access before going to Clause-22.
> 
> Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
> ---
>  include/linux/phy.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 60d2b26026a2..9b0e2c76e19b 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -368,6 +368,7 @@ struct mii_bus {
>  		MDIOBUS_C22,
>  		MDIOBUS_C45,
>  		MDIOBUS_C22_C45,
> +		MDIOBUS_C45_C22,
>  	} probe_capabilities;
>  
>  	/** @shared_lock: protect access to the shared element */

The new definition doesn't seem to be used anywhere, so this patch
merely adds the definition. It doesn't do what it says in the subject
line. Any driver that sets the capabilities to MDIOBUS_C45_C22 will
end up not doing any probing of the PHY.
Wong Vee Khee June 1, 2021, 10:52 a.m. UTC | #2
On Tue, May 25, 2021 at 09:31:17AM +0100, Russell King (Oracle) wrote:
> On Tue, May 25, 2021 at 01:58:39PM +0800, Wong Vee Khee wrote:
> > Some MAC controllers that is able to pair with  external PHY devices
> > such as the Synopsys MAC Controller (STMMAC) support both Clause-22 and
> > Clause-45 access.
> > 
> > When paired with PHY devices that only accessible via Clause-45, such as
> > the Marvell 88E2110, any attempts to access the PHY devices via
> > Clause-22 will get a PHY ID of all zeroes.
> > 
> > To fix this, we introduce MDIOBUS_C45_C22 which the MAC controller will
> > try with Clause-45 access before going to Clause-22.
> > 
> > Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
> > ---
> >  include/linux/phy.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/include/linux/phy.h b/include/linux/phy.h
> > index 60d2b26026a2..9b0e2c76e19b 100644
> > --- a/include/linux/phy.h
> > +++ b/include/linux/phy.h
> > @@ -368,6 +368,7 @@ struct mii_bus {
> >  		MDIOBUS_C22,
> >  		MDIOBUS_C45,
> >  		MDIOBUS_C22_C45,
> > +		MDIOBUS_C45_C22,
> >  	} probe_capabilities;
> >  
> >  	/** @shared_lock: protect access to the shared element */
> 
> The new definition doesn't seem to be used anywhere, so this patch
> merely adds the definition. It doesn't do what it says in the subject
> line. Any driver that sets the capabilities to MDIOBUS_C45_C22 will
> end up not doing any probing of the PHY.
>

You are right. I left out the required changes in drivers/net/mdio_bus.c:-

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6045ad3def12..fbf9b8f1f47c 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -684,6 +684,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))


VK
diff mbox series

Patch

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 60d2b26026a2..9b0e2c76e19b 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -368,6 +368,7 @@  struct mii_bus {
 		MDIOBUS_C22,
 		MDIOBUS_C45,
 		MDIOBUS_C22_C45,
+		MDIOBUS_C45_C22,
 	} probe_capabilities;
 
 	/** @shared_lock: protect access to the shared element */