Skip to contentSkip to conversation

ARM: shmobile: Lager: add Micrel KSZ8041 PHY fixup

PATCH In review Sergei Shtylyov 3 participants 6 messages Sep 14, 2013 – Sep 26, 2013

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: shmobile: Lager: add Micrel KSZ8041 PHY fixup

Currently on the Lager board NFS timeouts/delays are seen when booting. That turned out to happen because the SoC's ETH_LINK signal turns on and off after each packet. It is connected to Micrel KSZ8041 PHY's LED0 signal. Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds to non-default 01 setting of the PHY control register 1 bits 14-15. The 'sh_eth' driver resets the PHY when opening the network device, so we have to set the mentioned bits back to 01 from the default 00 value which causes bouncing of ETH_LINK. That can be achieved using the PHY platform fixup mechanism if we also modify the driver to use it..

---
This patch is against the recent Linus' tree. Its effect on NFS issue depends on the 'sh_eth' driver patch I've posted earlier.
Simon, please update your 'master' and/or 'fixes' branches since currently it's impossible to apply fixes to your tree.

 arch/arm/mach-shmobile/board-lager.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
arch/arm/mach-shmobile/board-lager.c +26 -1
Index: linux/arch/arm/mach-shmobile/board-lager.c
===================================================================
@@ -29,6 +29,7 @@
 #include <linux/pinctrl/machine.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_device.h>
+#include <linux/phy.h>
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 #include <linux/sh_eth.h>
@@ -155,6 +156,30 @@ static void __init lager_add_standard_de
 					  &ether_pdata, sizeof(ether_pdata));
 }
 
+/*
+ * Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds
+ * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
+ * 14-15. We have to set them back to 01 from the default 00 value each time
+ * the PHY is reset. It's also important because the PHY's LED0 signal is
+ * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
+ * bounce on and off after each packet, which we apparently want to avoid.
+ */
+static int lager_ksz8041_fixup(struct phy_device *phydev)
+{
+	u16 phyctrl1 = phy_read(phydev, 0x1e);
+
+	phyctrl1 &= ~0xc000;
+	phyctrl1 |= 0x4000;
+	return phy_write(phydev, 0x1e, phyctrl1);
+}
+
+static void __init lager_init(void)
+{
+	lager_add_standard_devices();
+
+	phy_register_fixup_for_id("r8a7790-ether-ff:01", lager_ksz8041_fixup);
+}
+
 static const char *lager_boards_compat_dt[] __initdata = {
 	"renesas,lager",
 	NULL,
@@ -163,6 +188,6 @@ static const char *lager_boards_compat_d
 DT_MACHINE_START(LAGER_DT, "lager")
 	.init_early	= r8a7790_init_delay,
 	.init_time	= r8a7790_timer_init,
-	.init_machine	= lager_add_standard_devices,
+	.init_machine	= lager_init,
 	.dt_compat	= lager_boards_compat_dt,
 MACHINE_END
#1 lore raw
Quoted 10 lines · Sergei Shtylyov

Currently on the Lager board NFS timeouts/delays are seen when booting. That turned out to happen because the SoC's ETH_LINK signal turns on and off after each packet. It is connected to Micrel KSZ8041 PHY's LED0 signal. Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds to non-default 01 setting of the PHY control register 1 bits 14-15. The 'sh_eth' driver resets the PHY when opening the network device, so we have to set the mentioned bits back to 01 from the default 00 value which causes bouncing of ETH_LINK. That can be achieved using the PHY platform fixup mechanism if we also modify the driver to use it..

Quoted 7 lines

---
This patch is against the recent Linus' tree. Its effect on NFS issue depends on the 'sh_eth' driver patch I've posted earlier.
Simon, please update your 'master' and/or 'fixes' branches since currently it's impossible to apply fixes to your tree.

Now that rc-1 is out I plan to rebase my tree.
But as I am travelling this week it will have to wait until next week.

Quoted 60 lines
 arch/arm/mach-shmobile/board-lager.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Index: linux/arch/arm/mach-shmobile/board-lager.c
===================================================================

arch/arm/mach-shmobile/board-lager.c +26 -2
@@ -29,6 +29,7 @@
 #include <linux/pinctrl/machine.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_device.h>
+#include <linux/phy.h>
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 #include <linux/sh_eth.h>
@@ -155,6 +156,30 @@ static void __init lager_add_standard_de
 					  &ether_pdata, sizeof(ether_pdata));
 }
 
+/*
+ * Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds
+ * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
+ * 14-15. We have to set them back to 01 from the default 00 value each time
+ * the PHY is reset. It's also important because the PHY's LED0 signal is
+ * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
+ * bounce on and off after each packet, which we apparently want to avoid.
+ */
+static int lager_ksz8041_fixup(struct phy_device *phydev)
+{
+	u16 phyctrl1 = phy_read(phydev, 0x1e);
+
+	phyctrl1 &= ~0xc000;
+	phyctrl1 |= 0x4000;
+	return phy_write(phydev, 0x1e, phyctrl1);
+}
+
+static void __init lager_init(void)
+{
+	lager_add_standard_devices();
+
+	phy_register_fixup_for_id("r8a7790-ether-ff:01", lager_ksz8041_fixup);
+}
+
 static const char *lager_boards_compat_dt[] __initdata = {
 	"renesas,lager",
 	NULL,
@@ -163,6 +188,6 @@ static const char *lager_boards_compat_d
 DT_MACHINE_START(LAGER_DT, "lager")
 	.init_early	= r8a7790_init_delay,
 	.init_time	= r8a7790_timer_init,
-	.init_machine	= lager_add_standard_devices,
+	.init_machine	= lager_init,
 	.dt_compat	= lager_boards_compat_dt,
 MACHINE_END
--

To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Sergei Shtylyov
Quoted 12 lines · Sergei Shtylyov

Currently on the Lager board NFS timeouts/delays are seen when booting. That turned out to happen because the SoC's ETH_LINK signal turns on and off after each packet. It is connected to Micrel KSZ8041 PHY's LED0 signal. Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds to non-default 01 setting of the PHY control register 1 bits 14-15. The 'sh_eth' driver resets the PHY when opening the network device, so we have to set the mentioned bits back to 01 from the default 00 value which causes bouncing of ETH_LINK. That can be achieved using the PHY platform fixup mechanism if we also modify the driver to use it..

Quoted 8 lines

---
This patch is against the recent Linus' tree. Its effect on NFS issue depends on the 'sh_eth' driver patch I've posted earlier.
Simon, please update your 'master' and/or 'fixes' branches since currently it's impossible to apply fixes to your tree.

 arch/arm/mach-shmobile/board-lager.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Thanks, I have rebased my tree and applied this change to the fixes-for-v3.12 branch.

And I will push the new tree either in the next
half hour or some time next week - I have to jump on a plane shortly.

maintainer
#3 lore raw
In reply to Sergei Shtylyov
Quoted 11 lines · Sergei Shtylyov

Currently on the Lager board NFS timeouts/delays are seen when booting. That turned out to happen because the SoC's ETH_LINK signal turns on and off after each packet. It is connected to Micrel KSZ8041 PHY's LED0 signal. Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds to non-default 01 setting of the PHY control register 1 bits 14-15. The 'sh_eth' driver resets the PHY when opening the network device, so we have to set the mentioned bits back to 01 from the default 00 value which causes bouncing of ETH_LINK. That can be achieved using the PHY platform fixup mechanism if we also modify the driver to use it..

Hi Sergei,

Thanks for your efforts on this. Nice to see that Ethernet for Lager board support is improving.

Can you please share with us with link speeds you tested? I suspect that this patch is only needed for some case, like for instance 100 MBit Full Duplex. Fixing the PHY settings makes sense even though only a single mode needs it, but knowing which link speeds that are known to work would help a lot.

Cheers,

/ magnus

#4 lore raw

Hello.

Quoted 10 lines · Magnus Damm
Quoted 9 lines

Currently on the Lager board NFS timeouts/delays are seen when booting. That turned out to happen because the SoC's ETH_LINK signal turns on and off after each packet. It is connected to Micrel KSZ8041 PHY's LED0 signal. Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds to non-default 01 setting of the PHY control register 1 bits 14-15. The 'sh_eth' driver resets the PHY when opening the network device, so we have to set the mentioned bits back to 01 from the default 00 value which causes bouncing of ETH_LINK. That can be achieved using the PHY platform fixup mechanism if we also modify the driver to use it..

Quoted 8 lines
Quoted 1 line

Hi Sergei,

Thanks for your efforts on this. Nice to see that Ethernet for Lager board support is improving.

Can you please share with us with link speeds you tested? I suspect

100 Mbit/s, full duplex.

Quoted 2 lines

that this patch is only needed for some case, like for instance 100 MBit Full Duplex.

    Hm, why? :-O
Quoted 3 lines

Fixing the PHY settings makes sense even though only
a single mode needs it, but knowing which link speeds that are known to work would help a lot.

This patch should not depend on the link speed and duplex settings.

Quoted 3 lines

Cheers,

/ magnus

WBR, Sergei

#5 lore raw
In reply to Magnus Damm
Quoted 16 lines · Magnus Damm
Quoted 11 lines · Sergei Shtylyov

Currently on the Lager board NFS timeouts/delays are seen when booting. That turned out to happen because the SoC's ETH_LINK signal turns on and off after each packet. It is connected to Micrel KSZ8041 PHY's LED0 signal. Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds to non-default 01 setting of the PHY control register 1 bits 14-15. The 'sh_eth' driver resets the PHY when opening the network device, so we have to set the mentioned bits back to 01 from the default 00 value which causes bouncing of ETH_LINK. That can be achieved using the PHY platform fixup mechanism if we also modify the driver to use it..

Hi Sergei,

Quoted 8 lines

Thanks for your efforts on this. Nice to see that Ethernet for Lager board support is improving.

Can you please share with us with link speeds you tested? I suspect that this patch is only needed for some case, like for instance 100 MBit Full Duplex. Fixing the PHY settings makes sense even though only a single mode needs it, but knowing which link speeds that are known to work would help a lot.

Magnus,

I currently have this queued up as a fix for v3.12. Let me know if you would like me to drop it for now.