[U-Boot] [PATCH v3 0/4] net: phy: Force master mode for RTL8211C on some boards

This patch is required to get reliable 1000BASE-T operation on some boards using the RTL8211C(L) PHY.
Following discussions on v2 of this patch, I have removed the incorrect check for the RTL8211C(L). Affected boards now have to define CONFIG_RTL8211X_PHY_FORCE_MASTER to benefit from the fix.
Note that this patch requires Karsten Merkers '[PATCH] net: phy: Realtek RTL8211B/C PHY ID fix' as well as Hans de Goede's recent u-boot-sunxi pull request, specifically 1eae8f66ff749409eb96e2f3f3387c56232d0b8a and fc8991c61c393ce6a9d3dfc97cb56dbbd9e8cbba.
Michael
Changes in v3: - Remove incorrect detection of RTL8211CL and use #ifdef instead (thanks to Karsten Merker) - Introduced constants for register bits
Changes in v2: - Removed accidental inclusion of Karsten's patch in my first submission of this series. - Fix a typo in the code: 6 -> &
Michael Haas (4): net: phy: Optionally force master mode for RTL PHY net: phy: Force master mode for A20-Olimex-SOM-EVB net: phy: Force master mode A20-OLinuXino-Lime2 net: phy: Add RTL8211X_PHY_FORCE_MASTER to Kconfig
configs/A20-OLinuXino-Lime2_defconfig | 1 + configs/A20-Olimex-SOM-EVB_defconfig | 1 + drivers/net/Kconfig | 17 +++++++++++++++++ drivers/net/phy/realtek.c | 13 ++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-)

This patch introduces CONFIG_RTL8211X_PHY_FORCE_MASTER. If this define is set, RTL8211x PHYs will have their 1000BASE-T master/slave autonegotiation disabled and forced to master mode.
This is helpful for PHYs like the RTL8211C which produce unstable links in slave mode. Such problems have been found on the A20-Olimex-SOM-EVB and A20-OLinuXino-Lime2.
There is no proper way to identify affected PHYs as the RTL8211C shares its UID with the RTL8211B. Thus, this fixes requires the introduction of an #ifdef.
CC: fradav@gmail.com CC: merker@debian.org CC: hdegoede@redhat.com CC: ijc@hellion.org.uk CC: joe.hershberger@ni.com Signed-off-by: Michael Haas haas@computerlinguist.org ---
Changes in v3: - Remove incorrect detection of RTL8211CL and use #ifdef instead (thanks to Karsten Merker) - Introduced constants for register bits
Changes in v2: - Removed accidental inclusion of Karsten's patch in my first submission of this series. - Fix a typo in the code: 6 -> &
drivers/net/phy/realtek.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 259a87f..359ec50 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -12,6 +12,10 @@
#define PHY_AUTONEGOTIATE_TIMEOUT 5000
+/* RTL8211x 1000BASE-T Control Register */ +#define MIIM_RTL8211x_CTRL1000T_MSCE (1 << 12); +#define MIIM_RTL8211X_CTRL1000T_MASTER (1 << 11); + /* RTL8211x PHY Status Register */ #define MIIM_RTL8211x_PHY_STATUS 0x11 #define MIIM_RTL8211x_PHYSTAT_SPEED 0xc000 @@ -53,7 +57,14 @@ static int rtl8211x_config(struct phy_device *phydev) */ phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER, MIIM_RTL8211x_PHY_INTR_DIS); - +#ifdef CONFIG_RTL8211X_PHY_FORCE_MASTER + unsigned int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000); + /* force manual master/slave configuration */ + reg |= MIIM_RTL8211x_CTRL1000T_MSCE; + /* force master mode */ + reg |= MIIM_RTL8211X_CTRL1000T_MASTER; + phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg); +#endif /* read interrupt status just to clear it */ phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);

Force master mode for 1000BASE-T operation on the A20-Olimex-SOM-EVB.
Karsten Merker reports that this change is necessary to get a reliable link at gigabit speeds.
Signed-off-by: Michael Haas haas@computerlinguist.org ---
Changes in v3: None Changes in v2: None
configs/A20-Olimex-SOM-EVB_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/A20-Olimex-SOM-EVB_defconfig b/configs/A20-Olimex-SOM-EVB_defconfig index 66d8f98..68de5f2 100644 --- a/configs/A20-Olimex-SOM-EVB_defconfig +++ b/configs/A20-Olimex-SOM-EVB_defconfig @@ -19,3 +19,4 @@ CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPC(3)" CONFIG_CMD_GPIO=y CONFIG_ETH_DESIGNWARE=y CONFIG_USB_EHCI_HCD=y +CONFIG_RTL8211X_PHY_FORCE_MASTER=y

On Thu, Mar 24, 2016 at 1:46 AM, Michael Haas haas@computerlinguist.org wrote:
Force master mode for 1000BASE-T operation on the A20-Olimex-SOM-EVB.
Karsten Merker reports that this change is necessary to get a reliable link at gigabit speeds.
Signed-off-by: Michael Haas haas@computerlinguist.org
Acked-by: Joe Hershberger joe.hershberger@ni.com

Force master mode on the A20-OLinuXino-Lime2. This change is required to get a reliable link at gigabit speeds.
Signed-off-by: Michael Haas haas@computerlinguist.org ---
Changes in v3: None Changes in v2: None
configs/A20-OLinuXino-Lime2_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig index 95c67d6..3bd4fa7 100644 --- a/configs/A20-OLinuXino-Lime2_defconfig +++ b/configs/A20-OLinuXino-Lime2_defconfig @@ -16,3 +16,4 @@ CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPC(3)" CONFIG_CMD_GPIO=y CONFIG_ETH_DESIGNWARE=y CONFIG_USB_EHCI_HCD=y +CONFIG_RTL8211X_PHY_FORCE_MASTER=y

On Thu, Mar 24, 2016 at 1:46 AM, Michael Haas haas@computerlinguist.org wrote:
Force master mode on the A20-OLinuXino-Lime2. This change is required to get a reliable link at gigabit speeds.
Signed-off-by: Michael Haas haas@computerlinguist.org
Acked-by: Joe Hershberger joe.hershberger@ni.com

On 24/03/16 06:46, Michael Haas wrote:
Force master mode on the A20-OLinuXino-Lime2. This change is required to get a reliable link at gigabit speeds.
Signed-off-by: Michael Haas haas@computerlinguist.org
Acked-by: Iain Paton ipaton0@gmail.com
Glad to see someone finally got to the bottom of this. On the boards I have I only see the problem intermittantly, perhaps 2% of boots so virtually impossible to know if anything fixed it.
Is something needed in the kernel as well, or is it sufficient to do it in u-boot?
Iain

On 03/26/2016 12:46 AM, Iain Paton wrote:
On 24/03/16 06:46, Michael Haas wrote:
Force master mode on the A20-OLinuXino-Lime2. This change is required to get a reliable link at gigabit speeds.
Signed-off-by: Michael Haas haas@computerlinguist.org
Acked-by: Iain Paton ipaton0@gmail.com
Glad to see someone finally got to the bottom of this. On the boards I have I only see the problem intermittantly, perhaps 2% of boots so virtually impossible to know if anything fixed it.
Is something needed in the kernel as well, or is it sufficient to do it in u-boot?
Iain
I have not verified this extensively. In my experience, fixing u-boot is enough to get a stable link in the kernel.
Michael

This change mainly serves as a way to document the define.
Signed-off-by: Michael Haas haas@computerlinguist.org ---
Changes in v3: None Changes in v2: None
drivers/net/Kconfig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 2a229b8..b102bc6 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -13,6 +13,23 @@ config PHYLIB help Enable Ethernet PHY (physical media interface) support.
+config RTL8211X_PHY_FORCE_MASTER + bool "Ethernet PHY RTL8211x: force 1000BASE-T master mode" + depends on PHYLIB + help + Force master mode for 1000BASE-T on RTl8211x PHYs. + This is helpful for unstable gigabit links, e.g. on the + RTL8211C(L). + + If two devices force master mode, they will not be able to establish + a direct link between themselves. In this case, either: + - live with an unstable link and disable this option + - reduce link speed to 100MBit/s + - use a switch + + Does not apply to RTL8211F. + If unsure, say N. + menuconfig NETDEVICES bool "Network device support" depends on NET

Hi Michael,
On 24-03-16 07:46, Michael Haas wrote:
This patch is required to get reliable 1000BASE-T operation on some boards using the RTL8211C(L) PHY.
Following discussions on v2 of this patch, I have removed the incorrect check for the RTL8211C(L). Affected boards now have to define CONFIG_RTL8211X_PHY_FORCE_MASTER to benefit from the fix.
Note that this patch requires Karsten Merkers '[PATCH] net: phy: Realtek RTL8211B/C PHY ID fix' as well as Hans de Goede's recent u-boot-sunxi pull request, specifically 1eae8f66ff749409eb96e2f3f3387c56232d0b8a and fc8991c61c393ce6a9d3dfc97cb56dbbd9e8cbba.
Thanks for this patch series. I believe you should squash patch 4 into patch 1, as that is where it belongs IMHO.
Also note that patch 2/3 will not do anything unless patch 4 is also applied setting CONFIG_FOO in a defconfig does not do anything unless CONFIG_FOO is defined in Kconfig.
Regards,
Hans
Michael
Changes in v3:
- Remove incorrect detection of RTL8211CL and use #ifdef instead (thanks to Karsten Merker)
- Introduced constants for register bits
Changes in v2:
- Removed accidental inclusion of Karsten's patch in my first submission of this series.
- Fix a typo in the code: 6 -> &
Michael Haas (4): net: phy: Optionally force master mode for RTL PHY net: phy: Force master mode for A20-Olimex-SOM-EVB net: phy: Force master mode A20-OLinuXino-Lime2 net: phy: Add RTL8211X_PHY_FORCE_MASTER to Kconfig
configs/A20-OLinuXino-Lime2_defconfig | 1 + configs/A20-Olimex-SOM-EVB_defconfig | 1 + drivers/net/Kconfig | 17 +++++++++++++++++ drivers/net/phy/realtek.c | 13 ++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-)

Hi,
On Thu, Mar 24, 2016 at 2:46 PM, Michael Haas haas@computerlinguist.org wrote:
This patch is required to get reliable 1000BASE-T operation on some boards using the RTL8211C(L) PHY.
Following discussions on v2 of this patch, I have removed the incorrect check for the RTL8211C(L). Affected boards now have to define CONFIG_RTL8211X_PHY_FORCE_MASTER to benefit from the fix.
Note that this patch requires Karsten Merkers '[PATCH] net: phy: Realtek RTL8211B/C PHY ID fix' as well as Hans de Goede's recent u-boot-sunxi pull request, specifically 1eae8f66ff749409eb96e2f3f3387c56232d0b8a and fc8991c61c393ce6a9d3dfc97cb56dbbd9e8cbba.
Michael
Changes in v3:
- Remove incorrect detection of RTL8211CL and use #ifdef instead (thanks to Karsten Merker)
- Introduced constants for register bits
Changes in v2:
- Removed accidental inclusion of Karsten's patch in my first submission of this series.
- Fix a typo in the code: 6 -> &
Michael Haas (4): net: phy: Optionally force master mode for RTL PHY
net: phy: Force master mode for A20-Olimex-SOM-EVB net: phy: Force master mode A20-OLinuXino-Lime2
These 2 should probably read:
sunxi: A20-Olxxxxxxxxx: Force master mode for RTL8211CL
ChenYu
net: phy: Add RTL8211X_PHY_FORCE_MASTER to Kconfig
configs/A20-OLinuXino-Lime2_defconfig | 1 + configs/A20-Olimex-SOM-EVB_defconfig | 1 + drivers/net/Kconfig | 17 +++++++++++++++++ drivers/net/phy/realtek.c | 13 ++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-)
-- 2.7.2
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
participants (5)
-
Chen-Yu Tsai
-
Hans de Goede
-
Iain Paton
-
Joe Hershberger
-
Michael Haas