diff mbox series

[net,1/2] net: phy: Use C45 Helpers in phy_read_status()

Message ID 27b3e9f2318c87aac928165b8dfe7d98e272f3d1.1551437561.git.joabreu@synopsys.com
State Changes Requested
Delegated to: David Miller
Headers show
Series Use C45 Helpers when possible | expand

Commit Message

Jose Abreu March 1, 2019, 10:54 a.m. UTC
Currently phy_read_status() considers that either the PHY driver has the
read_status() callback or uses the generic callback.

For C45 PHYs we need to use the gen10g_read_status() callback.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Joao Pinto <joao.pinto@synopsys.com>
---
 include/linux/phy.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Florian Fainelli March 2, 2019, 3:14 a.m. UTC | #1
On 3/1/2019 2:54 AM, Jose Abreu wrote:
> Currently phy_read_status() considers that either the PHY driver has the
> read_status() callback or uses the generic callback.
> 
> For C45 PHYs we need to use the gen10g_read_status() callback.

Right, so we could expect your C45 PHY driver to assign the read_status
callback to gen10g_read_status() if it is appropriate. So far most of
the 10g PHY drivers (cortina, marvell10g, aquantia) have to define their
own read_status() callback to be feature complete. Unlike C22 PHYs that
can really be driven with a simple generic PHY driver model for standard
features, C45 PHYs seem to be quirky enough this does not work anymore.

> 
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Joao Pinto <joao.pinto@synopsys.com>
> ---
>  include/linux/phy.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 333b56d8f746..872899136fdc 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -1030,6 +1030,8 @@ static inline int phy_read_status(struct phy_device *phydev)
>  
>  	if (phydev->drv->read_status)
>  		return phydev->drv->read_status(phydev);
> +	else if (phydev->is_c45)
> +		return gen10g_read_status(phydev);
>  	else
>  		return genphy_read_status(phydev);
>  }
>
Andrew Lunn March 2, 2019, 2:11 p.m. UTC | #2
On Fri, Mar 01, 2019 at 07:14:20PM -0800, Florian Fainelli wrote:
> 
> 
> On 3/1/2019 2:54 AM, Jose Abreu wrote:
> > Currently phy_read_status() considers that either the PHY driver has the
> > read_status() callback or uses the generic callback.
> > 
> > For C45 PHYs we need to use the gen10g_read_status() callback.
> 
> Right, so we could expect your C45 PHY driver to assign the read_status
> callback to gen10g_read_status() if it is appropriate. So far most of
> the 10g PHY drivers (cortina, marvell10g, aquantia) have to define their
> own read_status() callback to be feature complete. Unlike C22 PHYs that
> can really be driven with a simple generic PHY driver model for standard
> features, C45 PHYs seem to be quirky enough this does not work anymore.

Hi Jose

Does your PHY support 1000Base-T? If so you need read_status() because
the registers for that link mode don't appear to be standardized.

    Andrew
Heiner Kallweit March 2, 2019, 2:52 p.m. UTC | #3
On 02.03.2019 15:11, Andrew Lunn wrote:
> On Fri, Mar 01, 2019 at 07:14:20PM -0800, Florian Fainelli wrote:
>>
>>
>> On 3/1/2019 2:54 AM, Jose Abreu wrote:
>>> Currently phy_read_status() considers that either the PHY driver has the
>>> read_status() callback or uses the generic callback.
>>>
>>> For C45 PHYs we need to use the gen10g_read_status() callback.
>>
The gen10g_ functions are deprecated and shouldn't be used in new code.
Consider the (partially brand-new) genphy_c45_ functions instead.
This should be ok because I think the two changes are material for
net-next.

The gen10g functions belong to the old gen10g driver which knows about
10G only. I think sooner or later we'll replace it with a genc45
driver or similar.

>> Right, so we could expect your C45 PHY driver to assign the read_status
>> callback to gen10g_read_status() if it is appropriate. So far most of
>> the 10g PHY drivers (cortina, marvell10g, aquantia) have to define their
>> own read_status() callback to be feature complete. Unlike C22 PHYs that
>> can really be driven with a simple generic PHY driver model for standard
>> features, C45 PHYs seem to be quirky enough this does not work anymore.
> 
> Hi Jose
> 
> Does your PHY support 1000Base-T? If so you need read_status() because
> the registers for that link mode don't appear to be standardized.
> 
>     Andrew
> 
Heiner
diff mbox series

Patch

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 333b56d8f746..872899136fdc 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1030,6 +1030,8 @@  static inline int phy_read_status(struct phy_device *phydev)
 
 	if (phydev->drv->read_status)
 		return phydev->drv->read_status(phydev);
+	else if (phydev->is_c45)
+		return gen10g_read_status(phydev);
 	else
 		return genphy_read_status(phydev);
 }