From patchwork Tue Nov 15 14:29:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9429911 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 800F360469 for ; Tue, 15 Nov 2016 14:31:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F18F28BAD for ; Tue, 15 Nov 2016 14:31:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63D3028BB6; Tue, 15 Nov 2016 14:31:56 +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_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 DFF0228BAD for ; Tue, 15 Nov 2016 14:31: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 1c6ekf-0007fh-NY; Tue, 15 Nov 2016 14:30:21 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6ekE-0006UZ-C6 for linux-arm-kernel@lists.infradead.org; Tue, 15 Nov 2016 14:29:57 +0000 Received: by mail-wm0-x22d.google.com with SMTP id f82so2416818wmf.1 for ; Tue, 15 Nov 2016 06:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I3QF932m87od+RPqQjVJfv/wpVtp37hNDKLXADoxYlA=; b=FF631eaIzTLlVRDILWRgFD38OwU12acCAuDMeY5A3YeuRzhKNWcQeKaPxUkRvktYuC J4Tf9Of1Wmy2fS5jbtOxBh6eEXlJArjbo76wmMZTOVc5JBN5iKAYnFoDv5rxKOKfmimc Ky1qna8a1xvcjRt5PXhhKaZnxYWA4i22QwC8eysY3JzYj2Z82eSGDKtjdRo8nIrQRR59 4DRJs2t/K0aSrDcukL44OJjhujMUfDutoLXvwZVosYQ4Aw+jpVwlTZ6HBwi+7lPUHvh+ ogfrg6nCSj/dvMiRJElTwZYmwgHCE9CvCVV7LsIrxReI6u7l6j2U2WTbKKD3DLNH7xgb wjew== 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=I3QF932m87od+RPqQjVJfv/wpVtp37hNDKLXADoxYlA=; b=WSixiQKk0YdVIU8UpusBYb3ORWr1Th8EzpT+Ks48807roFGb2fwmDPykB/vb41OmQR RSHdmXfmGzyPoNajEOd96X1v9KsOwDvmmoGmh8VmILZghadYK6xiOnNKCYxTPhPkMphI 0C4hM/BAOTB96Y/dSkaHqmji/+oOpekRiHA7OOV4DE3Vff5BaYS/MVL5PHOesEn2+K8i mZ8g1wizoXSHl61Ynh1A7fiPNeKFuOLKX7mhlT/oZhQZ1CPlbJKigMQ3boBbMm5TGiFZ GHhvGlHVGVvwZdw85t3ZddJjtXMlBSE1cpMAnWKsDz0c6hT9L3OJwDdzVhBqD1mrAA/n j3xA== X-Gm-Message-State: ABUngvcdwDCJ31/a+gm9j8NkMCTnqECMlMqJNrgVPL+npAzUL9EpIFR6M+TRi8dUDy5JTUbe X-Received: by 10.28.19.67 with SMTP id 64mr3999645wmt.111.1479220172139; Tue, 15 Nov 2016 06:29:32 -0800 (PST) Received: from boomer.baylibre.com ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id kp5sm7619219wjb.8.2016.11.15.06.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2016 06:29:31 -0800 (PST) From: Jerome Brunet To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Florian Fainelli Subject: [PATCH net 1/3] net: phy: realtek: add eee advertisement disable options Date: Tue, 15 Nov 2016 15:29:12 +0100 Message-Id: <1479220154-25851-2-git-send-email-jbrunet@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479220154-25851-1-git-send-email-jbrunet@baylibre.com> References: <1479220154-25851-1-git-send-email-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161115_062954_763653_EA4EACCD X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre TORGUE , Neil Armstrong , Martin Blumenstingl , Kevin Hilman , linux-kernel@vger.kernel.org, Andre Roth , linux-amlogic@lists.infradead.org, Carlo Caione , Giuseppe Cavallaro , linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On some platforms, energy efficient ethernet with rtl8211 devices is causing issue, like throughput drop or broken link. This was reported on the OdroidC2 (DWMAC + RTL8211F). While the issue root cause is not fully understood yet, disabling EEE advertisement prevent auto negotiation from enabling EEE. This patch provides options to disable 1000T and 100TX EEE advertisement individually for the realtek phys supporting this feature. Reported-by: Martin Blumenstingl Cc: Giuseppe Cavallaro Cc: Alexandre TORGUE Signed-off-by: Jerome Brunet Signed-off-by: Neil Armstrong Tested-by: Andre Roth --- drivers/net/phy/realtek.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index aadd6e9f54ad..77235fd5faaf 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -15,6 +15,12 @@ */ #include #include +#include + +struct rtl8211x_phy_priv { + bool eee_1000t_disable; + bool eee_100tx_disable; +}; #define RTL821x_PHYSR 0x11 #define RTL821x_PHYSR_DUPLEX 0x2000 @@ -93,12 +99,44 @@ static int rtl8211f_config_intr(struct phy_device *phydev) return err; } +static void rtl8211x_clear_eee_adv(struct phy_device *phydev) +{ + struct rtl8211x_phy_priv *priv = phydev->priv; + u16 val; + + if (priv->eee_1000t_disable || priv->eee_100tx_disable) { + val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, + MDIO_MMD_AN); + + if (priv->eee_1000t_disable) + val &= ~MDIO_AN_EEE_ADV_1000T; + if (priv->eee_100tx_disable) + val &= ~MDIO_AN_EEE_ADV_100TX; + + phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, + MDIO_MMD_AN, val); + } +} + +static int rtl8211x_config_init(struct phy_device *phydev) +{ + int ret; + + ret = genphy_config_init(phydev); + if (ret < 0) + return ret; + + rtl8211x_clear_eee_adv(phydev); + + return 0; +} + static int rtl8211f_config_init(struct phy_device *phydev) { int ret; u16 reg; - ret = genphy_config_init(phydev); + ret = rtl8211x_config_init(phydev); if (ret < 0) return ret; @@ -115,6 +153,26 @@ static int rtl8211f_config_init(struct phy_device *phydev) return 0; } +static int rtl8211x_phy_probe(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + struct device_node *of_node = dev->of_node; + struct rtl8211x_phy_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->eee_1000t_disable = + of_property_read_bool(of_node, "realtek,disable-eee-1000t"); + priv->eee_100tx_disable = + of_property_read_bool(of_node, "realtek,disable-eee-100tx"); + + phydev->priv = priv; + + return 0; +} + static struct phy_driver realtek_drvs[] = { { .phy_id = 0x00008201, @@ -140,7 +198,9 @@ static struct phy_driver realtek_drvs[] = { .phy_id_mask = 0x001fffff, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &rtl8211x_phy_probe, .config_aneg = genphy_config_aneg, + .config_init = &rtl8211x_config_init, .read_status = genphy_read_status, .ack_interrupt = rtl821x_ack_interrupt, .config_intr = rtl8211e_config_intr, @@ -152,7 +212,9 @@ static struct phy_driver realtek_drvs[] = { .phy_id_mask = 0x001fffff, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &rtl8211x_phy_probe, .config_aneg = &genphy_config_aneg, + .config_init = &rtl8211x_config_init, .read_status = &genphy_read_status, .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211e_config_intr, @@ -164,6 +226,7 @@ static struct phy_driver realtek_drvs[] = { .phy_id_mask = 0x001fffff, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &rtl8211x_phy_probe, .config_aneg = &genphy_config_aneg, .config_init = &rtl8211f_config_init, .read_status = &genphy_read_status,