From patchwork Fri Nov 25 13:12:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9447581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 03A806071C for ; Fri, 25 Nov 2016 13:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E82A627F85 for ; Fri, 25 Nov 2016 13:16:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCDFA27F8F; Fri, 25 Nov 2016 13:16:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C333028068 for ; Fri, 25 Nov 2016 13:15:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cAGLz-0001S3-EX; Fri, 25 Nov 2016 13:15:47 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cAGIv-0005t3-UT for linux-amlogic@lists.infradead.org; Fri, 25 Nov 2016 13:12:44 +0000 Received: by mail-wm0-x241.google.com with SMTP id u144so7740240wmu.0 for ; Fri, 25 Nov 2016 05:12:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5cVD3KUJhF4xGrZs26JlK9olsMPkYBMx+eKYSiKpzXc=; b=XVBN+djNpxO9+kzRFYfEntLkwHlaA/waksLld3PDJBTZZe1WR+Ph7YPVaMwg8V7AQh 7uCDMRxPIANZ0dihekOrdN7sl4oj/kntnex84X8gtiSP4fnrDAhe/lWZNO/rgRciuywt IkjQMfeOCXfjH39vEMdVw77J9RqgUiunMbMn+gQPDg+BMHZTyhEDYKEF2ZB63jp1Dg6H U7QxSdL5IFG5a4WEoWVmZ6QUJjTIVICjzYKBxMwjiJ653SCFZS5KwVkEVhrctBpf9YBC wbc3RRIiNbelEOgKTohTT9eWC/qVZdBDFzYRxTDSChg9dyUCu55HbTJE5nTlNjo5T3XN 02vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5cVD3KUJhF4xGrZs26JlK9olsMPkYBMx+eKYSiKpzXc=; b=Dh4D8PCatCkA+hlCkGVSOnuZDd1S2pIKqfVqNHZoCIa0DR71TyjGJY1zVjgPMNBTCG 7pTpjrqFzV3hnjBm/neN+5ecdABc/HXVo0idD6qU1GnMO3SrxbXs1eiK3QgSEe989OI2 UDG8cNFtq/0VvdLsbLc1TUuIEXv3dymLqM0zMa3HBWzCH2UUXCgRiYGH4hwyr6KlIpKQ 0Jp99KbolAwz/eFx+MZT0bJNhjcblZ5TbnvXKXJPXTfwyQO1VgeGAfEngIPsyspNEs1s KUvFeIWCu1YlUobTYQVsPL7je1W2l5W0mFP8VcU0Vq2pLmvI/uSXEPbK8XYOgpFYhqv7 O34A== X-Gm-Message-State: AKaTC027VT1saA9zscirXi9ObvcveCYtJPJZ+cp2IWnmpDpIlBd2LyRpywqAVA8R6v2JXw== X-Received: by 10.28.184.23 with SMTP id i23mr8167597wmf.66.1480079535891; Fri, 25 Nov 2016 05:12:15 -0800 (PST) Received: from blackbox.darklights.net ([2003:dc:d3d3:9204:9426:48db:352f:a6de]) by smtp.googlemail.com with ESMTPSA id y4sm47009872wjp.0.2016.11.25.05.12.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 05:12:15 -0800 (PST) From: Martin Blumenstingl To: f.fainelli@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, davem@davemloft.net, sean.wang@mediatek.com, netdev@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/2] net: phy: realtek: fix enabling of the TX-delay for RTL8211F Date: Fri, 25 Nov 2016 14:12:01 +0100 Message-Id: <20161125131201.19994-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161125131201.19994-1-martin.blumenstingl@googlemail.com> References: <20161125131201.19994-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161125_051238_574437_B815DFA0 X-CRM114-Status: GOOD ( 15.11 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Blumenstingl , linux-amlogic@lists.infradead.org, jbrunet@baylibre.com MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The old logic always enabled the TX-delay when the phy-mode was set to PHY_INTERFACE_MODE_RGMII. There are dedicated phy-modes which tell the PHY driver to enable the RX and/or TX delays: - PHY_INTERFACE_MODE_RGMII should disable the RX and TX delay in the PHY (if required, the MAC should add the delays in this case) - PHY_INTERFACE_MODE_RGMII_ID should enable RX and TX delay in the PHY - PHY_INTERFACE_MODE_RGMII_TXID should enable the TX delay in the PHY - PHY_INTERFACE_MODE_RGMII_RXID should enable the RX delay in the PHY (currently not supported by RTL8211F) With this patch we enable the TX delay for PHY_INTERFACE_MODE_RGMII_ID and PHY_INTERFACE_MODE_RGMII_TXID. Additionally we now explicity disable the TX-delay, which seems to be enabled automatically after a hard-reset of the PHY (by triggering it's reset pin) to get a consistent state (as defined by the phy-mode). This fixes a compatibility problem with some SoCs where the TX-delay was also added by the MAC. With the TX-delay being applied twice the TX clock was off and TX traffic was broken or very slow (<10Mbit/s) on 1000Mbit/s links. Signed-off-by: Martin Blumenstingl Reviewed-by: Florian Fainelli --- drivers/net/phy/realtek.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index aadd6e9..9cbe645 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -102,15 +102,19 @@ static int rtl8211f_config_init(struct phy_device *phydev) if (ret < 0) return ret; - if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { - /* enable TXDLY */ - phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); - reg = phy_read(phydev, 0x11); + phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); + reg = phy_read(phydev, 0x11); + + /* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */ + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || + phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) reg |= RTL8211F_TX_DELAY; - phy_write(phydev, 0x11, reg); - /* restore to default page 0 */ - phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); - } + else + reg &= ~RTL8211F_TX_DELAY; + + phy_write(phydev, 0x11, reg); + /* restore to default page 0 */ + phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); return 0; }