Skip to contentSkip to conversation

net: phy: realtek: fix RTL8211F interrupt mode

PATCH Applied Heiner Kallweit 6 participants 10 messages Nov 12, 2017 – Dec 2, 2017

Subsystems (4)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 net: phy: realtek: fix RTL8211F interrupt mode

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

It turned out that no interrupts were triggered. Further analysis showed the register INER can't be altered on page 0. Because register INSR needs to be accessed via page 0xa43 I assumed that register INER needs to be accessed via some page too. Some brute force check resulted in page 0xa42 being the right one.

With this patch the phy is working properly in interrupt mode.

---
 drivers/net/phy/realtek.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/phy/realtek.c +2 -0
index d4670ecdb..eda0a6e86 100644
@@ -115,11 +115,13 @@ static int rtl8211f_config_intr(struct phy_device *phydev)
 {
 	int err;
 
+	phy_write(phydev, RTL821x_PAGE_SELECT, 0xa42);
 	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
 		err = phy_write(phydev, RTL821x_INER,
 				RTL8211F_INER_LINK_STATUS);
 	else
 		err = phy_write(phydev, RTL821x_INER, 0);
+	phy_write(phydev, RTL821x_PAGE_SELECT, 0);
 
 	return err;
 }
Signature · 1 line
2.15.0
maintainer
#1 lore raw
Quoted 3 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

Hi Jerome

Please could you test this. I Just want to be sure we don't introduce a regression by breaking the boards you tested on.

Thanks
Andrew

#5 lore raw
In reply to Heiner Kallweit

Hi Heiner,

Quoted 11 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

It turned out that no interrupts were triggered. Further analysis showed the register INER can't be altered on page 0. Because register INSR needs to be accessed via page 0xa43 I assumed that register INER needs to be accessed via some page too. Some brute force check resulted in page 0xa42 being the right one.

With this patch the phy is working properly in interrupt mode.

What would be the appropriate Fixes: tag for that patch?

Quoted 25 lines
---
 drivers/net/phy/realtek.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/phy/realtek.c +2 -0
index d4670ecdb..eda0a6e86 100644
@@ -115,11 +115,13 @@ static int rtl8211f_config_intr(struct phy_device *phydev)
 {
 	int err;
 
+	phy_write(phydev, RTL821x_PAGE_SELECT, 0xa42);
 	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
 		err = phy_write(phydev, RTL821x_INER,
 				RTL8211F_INER_LINK_STATUS);
 	else
 		err = phy_write(phydev, RTL821x_INER, 0);
+	phy_write(phydev, RTL821x_PAGE_SELECT, 0);
 
 	return err;
 }
Signature · 1 line
Florian
reviewer
#2 lore raw
In reply to Andrew Lunn
Quoted 9 lines · Andrew Lunn
Quoted 3 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

Hi Jerome

Please could you test this. I Just want to be sure we don't introduce a regression by breaking the boards you tested on.

Sure I'll try it tomorrow.

When I tested this, I was more focused on the SoC side of it (the interrupt controller itself) and whether the interrupt worked or not. The board (p200) I tested on used a micrel PHY and worked well ... I did not really expect that a problem would come from the phy side. This was clearly a mistake.

Quoted 3 lines

Thanks
Andrew

reviewer
#6 lore raw
In reply to Florian Fainelli
Quoted 13 lines · Florian Fainelli

Hi Heiner,

Quoted 10 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

It turned out that no interrupts were triggered. Further analysis showed the register INER can't be altered on page 0. Because register INSR needs to be accessed via page 0xa43 I assumed that register INER needs to be accessed via some page too. Some brute force check resulted in page 0xa42 being the right one.

Quoted 3 lines
Quoted 1 line

With this patch the phy is working properly in interrupt mode.

What would be the appropriate Fixes: tag for that patch?

Fixes 3447cf2e9a11 ("net/phy: Add support for Realtek RTL8211F")

Seems appropriate

maintainer
#3 lore raw
In reply to Jerome Brunet
Quoted 8 lines · Jerome Brunet
Quoted 7 lines · Andrew Lunn
Quoted 3 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

Hi Jerome

Quoted 8 lines
Quoted 2 lines

Please could you test this. I Just want to be sure we don't introduce a regression by breaking the boards you tested on.

Sure I'll try it tomorrow.

When I tested this, I was more focused on the SoC side of it (the interrupt controller itself) and whether the interrupt worked or not. The board (p200) I tested on used a micrel PHY and worked well ...

Hi Jerome

Ah, O.K. Do you have a board with a RTL8211? If all your boards use a different PHY, there is no chance of a regression for you.

Thanks
Andrew

reviewer
#4 lore raw
Quoted 14 lines · Andrew Lunn
Quoted 13 lines · Jerome Brunet
Quoted 9 lines · Andrew Lunn
Quoted 3 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

Hi Jerome

Please could you test this. I Just want to be sure we don't introduce a regression by breaking the boards you tested on.

Sure I'll try it tomorrow.

Quoted 8 lines
Quoted 4 lines

When I tested this, I was more focused on the SoC side of it (the interrupt controller itself) and whether the interrupt worked or not. The board (p200) I
tested on used a micrel PHY and worked well ...

Hi Jerome

Ah, O.K. Do you have a board with a RTL8211?

I do have some. I'll confirm Heiner's report and fix tomorrow.

Quoted 2 lines

If all your boards use a
different PHY, there is no chance of a regression for you.

I'm not expecting any, quite the contrary actually

Quoted 3 lines

Thanks
Andrew

reviewer Tested-by on v1 1/1
#7 lore raw
In reply to Heiner Kallweit
Quoted 10 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

It turned out that no interrupts were triggered. Further analysis showed the register INER can't be altered on page 0. Because register INSR needs to be accessed via page 0xa43 I assumed that register INER needs to be accessed via some page too. Some brute force check resulted in page 0xa42 being the right one.

Quoted 3 lines

With this patch the phy is working properly in interrupt mode.

maintainer Applied
#8 lore raw
In reply to Heiner Kallweit

From: Heiner Kallweit <[email protected]>
Date: Sun, 12 Nov 2017 16:16:04 +0100

Quoted 10 lines

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

It turned out that no interrupts were triggered. Further analysis showed the register INER can't be altered on page 0. Because register INSR needs to be accessed via page 0xa43 I assumed that register INER needs to be accessed via some page too. Some brute force check resulted in page 0xa42 being the right one.

Quoted 3 lines

With this patch the phy is working properly in interrupt mode.

Applied.

#9 lore raw
In reply to Heiner Kallweit

Hi Heiner,

Quoted 9 lines · Heiner Kallweit

After commit b94d22d94ad22 "ARM64: dts: meson-gx: add external PHY interrupt on some platforms" ethernet stopped working on my Odroid-C2 which has a RTL8211F phy.

It turned out that no interrupts were triggered. Further analysis showed the register INER can't be altered on page 0. Because register INSR needs to be accessed via page 0xa43 I assumed that register INER needs to be accessed via some page too. Some brute force check resulted in page 0xa42 being the right one.

unfortunately there's no public datasheet for the RTL8211F. I contacted Realtek to see if we could get a datasheet. unfortunately an NDA is required for that
however, they were kind enough to share some information from the RTL8211F datasheet with me

RTL821x_INER is called INER (Interrupt Enable Register) in the datasheet. it is located at page 0xa42, address (the register after selecting the page) 0x12 (RTL821x_INER is also 0x12)

in other words: your findings were correct!
(I know that my mail is too late to make it into the commit message - but with this mail it's "documented" online now)

RTL8211E also uses RTL821x_INER (0x12) register, but according to the information I got from Realtek it is located in page 0x0 (so no special page has to be selected before changing that register on RTL8211E)

Regards
Martin