netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: realtek: add suspend/resume callbacks for RTL8211B
@ 2018-05-24 20:40 Heiner Kallweit
  2018-05-24 20:53 ` Andrew Lunn
  2018-05-29  3:02 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Heiner Kallweit @ 2018-05-24 20:40 UTC (permalink / raw)
  To: David Miller, Realtek linux nic maintainers, Hau,
	Florian Fainelli, Andrew Lunn
  Cc: netdev@vger.kernel.org, Kevin Hao

Add RTL8211B suspend / resume callbacks.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
This patch is based on my knowledge of the r8169 driver, and on some
guessing. Therefore I'd appreciate a confirmation from Realtek.

The integrated PHY in some chips supported by the r8169 driver uses
a special sequence for power-down/-up. I have a board with a RTL8168D
network chip (one of the chips using the special sequence) and there
the PHY identifies as RTL8211B. So my guess is that this applies also
to external RTL8211B PHY's.

A hint for RTL8211B requiring a special sequence is that no suspend/
resume callbacks are defined yet in the Realtek PHY driver.
Last but not least the non-standard usage of register MII_MMD_DATA
is in line with the description of patch 0231b1a074c6.
("net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b")
---
 drivers/net/phy/realtek.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 9f48ecf9c..082fb40c6 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -145,6 +145,20 @@ static int rtl8211f_config_init(struct phy_device *phydev)
 	return phy_modify_paged(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, val);
 }
 
+static int rtl8211b_suspend(struct phy_device *phydev)
+{
+	phy_write(phydev, MII_MMD_DATA, BIT(9));
+
+	return genphy_suspend(phydev);
+}
+
+static int rtl8211b_resume(struct phy_device *phydev)
+{
+	phy_write(phydev, MII_MMD_DATA, 0);
+
+	return genphy_resume(phydev);
+}
+
 static struct phy_driver realtek_drvs[] = {
 	{
 		.phy_id         = 0x00008201,
@@ -174,6 +188,8 @@ static struct phy_driver realtek_drvs[] = {
 		.config_intr	= &rtl8211b_config_intr,
 		.read_mmd	= &genphy_read_mmd_unsupported,
 		.write_mmd	= &genphy_write_mmd_unsupported,
+		.suspend	= rtl8211b_suspend,
+		.resume		= rtl8211b_resume,
 	}, {
 		.phy_id		= 0x001cc914,
 		.name		= "RTL8211DN Gigabit Ethernet",
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: phy: realtek: add suspend/resume callbacks for RTL8211B
  2018-05-24 20:40 [PATCH net-next] net: phy: realtek: add suspend/resume callbacks for RTL8211B Heiner Kallweit
@ 2018-05-24 20:53 ` Andrew Lunn
  2018-05-24 21:42   ` Heiner Kallweit
  2018-05-29  3:02 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2018-05-24 20:53 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Realtek linux nic maintainers, Hau,
	Florian Fainelli, netdev@vger.kernel.org, Kevin Hao

On Thu, May 24, 2018 at 10:40:12PM +0200, Heiner Kallweit wrote:
> Add RTL8211B suspend / resume callbacks.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> This patch is based on my knowledge of the r8169 driver, and on some
> guessing. Therefore I'd appreciate a confirmation from Realtek.
> 
> The integrated PHY in some chips supported by the r8169 driver uses
> a special sequence for power-down/-up. I have a board with a RTL8168D
> network chip (one of the chips using the special sequence) and there
> the PHY identifies as RTL8211B. So my guess is that this applies also
> to external RTL8211B PHY's.
> 
> A hint for RTL8211B requiring a special sequence is that no suspend/
> resume callbacks are defined yet in the Realtek PHY driver.
> Last but not least the non-standard usage of register MII_MMD_DATA
> is in line with the description of patch 0231b1a074c6.
> ("net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b")
> ---
>  drivers/net/phy/realtek.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 9f48ecf9c..082fb40c6 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -145,6 +145,20 @@ static int rtl8211f_config_init(struct phy_device *phydev)
>  	return phy_modify_paged(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, val);
>  }
>  
> +static int rtl8211b_suspend(struct phy_device *phydev)
> +{
> +	phy_write(phydev, MII_MMD_DATA, BIT(9));

Hi Heiner

Using it like this suggests it is not actually MMD_DATA, it is
something else which just happens to use the same address as the
optional MMD_DATA. To make this clearer, it would be good to add
#defines for both the register address and this BIT(9). Is there any
vendor code you know of which might give you a clue for appropriate
names?

I guess this device also does not support EEE? Does phy_init_eee()
correctly figure this out? Is there a chance calling phy_init_eee()
might trigger a suspend?

       Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: phy: realtek: add suspend/resume callbacks for RTL8211B
  2018-05-24 20:53 ` Andrew Lunn
@ 2018-05-24 21:42   ` Heiner Kallweit
  0 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2018-05-24 21:42 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David Miller, Realtek linux nic maintainers, Hau,
	Florian Fainelli, netdev@vger.kernel.org, Kevin Hao

Am 24.05.2018 um 22:53 schrieb Andrew Lunn:
> On Thu, May 24, 2018 at 10:40:12PM +0200, Heiner Kallweit wrote:
>> Add RTL8211B suspend / resume callbacks.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> This patch is based on my knowledge of the r8169 driver, and on some
>> guessing. Therefore I'd appreciate a confirmation from Realtek.
>>
>> The integrated PHY in some chips supported by the r8169 driver uses
>> a special sequence for power-down/-up. I have a board with a RTL8168D
>> network chip (one of the chips using the special sequence) and there
>> the PHY identifies as RTL8211B. So my guess is that this applies also
>> to external RTL8211B PHY's.
>>
>> A hint for RTL8211B requiring a special sequence is that no suspend/
>> resume callbacks are defined yet in the Realtek PHY driver.
>> Last but not least the non-standard usage of register MII_MMD_DATA
>> is in line with the description of patch 0231b1a074c6.
>> ("net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b")
>> ---
>>  drivers/net/phy/realtek.c | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
>> index 9f48ecf9c..082fb40c6 100644
>> --- a/drivers/net/phy/realtek.c
>> +++ b/drivers/net/phy/realtek.c
>> @@ -145,6 +145,20 @@ static int rtl8211f_config_init(struct phy_device *phydev)
>>  	return phy_modify_paged(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, val);
>>  }
>>  
>> +static int rtl8211b_suspend(struct phy_device *phydev)
>> +{
>> +	phy_write(phydev, MII_MMD_DATA, BIT(9));
> 
> Hi Heiner
> 
> Using it like this suggests it is not actually MMD_DATA, it is
> something else which just happens to use the same address as the
> optional MMD_DATA. To make this clearer, it would be good to add
> #defines for both the register address and this BIT(9). Is there any
> vendor code you know of which might give you a clue for appropriate
> names?
> 
Vendor code (Realtek r8168 driver) just writes value 0x0200 to
register 0x0E. I also would have preferred to assign proper
names to register and bit. Maybe the Realtek people on cc can
provide some information.

> I guess this device also does not support EEE? Does phy_init_eee()
> correctly figure this out? Is there a chance calling phy_init_eee()
> might trigger a suspend?
> 
Right, EEE isn't supported. phy_init_eee() figures this out correctly
because read_mmd callback is set to new genphy_read_mmd_unsupported.

Heiner

>        Andrew
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: phy: realtek: add suspend/resume callbacks for RTL8211B
  2018-05-24 20:40 [PATCH net-next] net: phy: realtek: add suspend/resume callbacks for RTL8211B Heiner Kallweit
  2018-05-24 20:53 ` Andrew Lunn
@ 2018-05-29  3:02 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2018-05-29  3:02 UTC (permalink / raw)
  To: hkallweit1; +Cc: nic_swsd, hau, f.fainelli, andrew, netdev, haokexin

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Thu, 24 May 2018 22:40:12 +0200

> Add RTL8211B suspend / resume callbacks.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-29  3:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-24 20:40 [PATCH net-next] net: phy: realtek: add suspend/resume callbacks for RTL8211B Heiner Kallweit
2018-05-24 20:53 ` Andrew Lunn
2018-05-24 21:42   ` Heiner Kallweit
2018-05-29  3:02 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).