From patchwork Fri Mar 25 07:02:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Haas X-Patchwork-Id: 601924 X-Patchwork-Delegate: hdegoede@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qWZ4z26G0z9sDG for ; Fri, 25 Mar 2016 18:02:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7CE55A75C9; Fri, 25 Mar 2016 08:02:44 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YabP-Qxruru5; Fri, 25 Mar 2016 08:02:44 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8711FA75CF; Fri, 25 Mar 2016 08:02:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF13CA75C0 for ; Fri, 25 Mar 2016 08:02:32 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Pf7kDKCbu899 for ; Fri, 25 Mar 2016 08:02:32 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.mailbox.org (mx1.mailbox.org [80.241.60.212]) by theia.denx.de (Postfix) with ESMTPS id 0AE73A752D for ; Fri, 25 Mar 2016 08:02:25 +0100 (CET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id BD72C4344C; Fri, 25 Mar 2016 08:02:19 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id 54ctAL6htyX0; Fri, 25 Mar 2016 08:02:16 +0100 (CET) From: Michael Haas To: u-boot@lists.denx.de Date: Fri, 25 Mar 2016 08:02:10 +0100 Message-Id: <1458889332-7154-2-git-send-email-haas@computerlinguist.org> In-Reply-To: <1458889332-7154-1-git-send-email-haas@computerlinguist.org> References: <1458889332-7154-1-git-send-email-haas@computerlinguist.org> Cc: joe.hershberger@ni.com, ijc@hellion.org.uk, merker@debian.org Subject: [U-Boot] [PATCH v4 1/3] net: phy: Optionally force master mode for RTL PHY X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch introduces CONFIG_RTL8211X_PHY_FORCE_MASTER. If this define is set, RTL8211x PHYs (except for the RTL8211F) 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 in software as the RTL8211C shares its UID with the RTL8211B. Thus, this fix 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 Tested-by: Karsten Merker --- Changes in v4: - Squashed previously separate commit introducing KCONFIG variable into commit containing main code change (Hans de Goede's suggestion) - Changed KCONFIG description according to Karsten Merker's suggestions plus some clarification of my own - Changed commit message according to Karsten Merker's suggestions 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/Kconfig | 21 +++++++++++++++++++++ drivers/net/phy/realtek.c | 13 ++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 2a229b8..8a95fbd 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -13,6 +13,27 @@ 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 (except for RTL8211F). + This can work around link stability and data + corruption issues on gigabit links which can occur in slave mode on + certain PHYs, e.g. on the RTL8211C(L). + + Please note that two directly connected devices (i.e. via + crossover cable) will not be able to establish a link between each other + if they both force master mode. Multiple devices forcing + master mode when connected by a network switch do not pose a + problem as the switch configures its affected ports into slave + mode. + This option only affects gigabit links. If you must establish a direct + connection between two devices which both force master mode, try forcing + the link speed to 100MBit/s. + + If unsure, say N. + menuconfig NETDEVICES bool "Network device support" depends on NET 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);