From patchwork Tue Dec 5 13:26:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 844737 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yrjFs4lTkz9tB7 for ; Wed, 6 Dec 2017 00:26:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753044AbdLEN0p (ORCPT ); Tue, 5 Dec 2017 08:26:45 -0500 Received: from relay08.alfahosting-server.de ([109.237.142.245]:15667 "EHLO relay08.alfahosting-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752923AbdLEN0l (ORCPT ); Tue, 5 Dec 2017 08:26:41 -0500 Received: by relay01.alfahosting-server.de (Postfix, from userid 1001) id 5214232C3569; Tue, 5 Dec 2017 14:26:40 +0100 (CET) X-Spam-DCC: : X-Spam-Level: X-Spam-Status: No, score=-1000.0 required=7.0 tests=BAYES_50, D_SENT_WITH_SASL autolearn=disabled version=3.2.5 Received: from alfa3028.alfahosting-server.de (alfa3028.alfahosting-server.de [109.237.138.38]) by relay01.alfahosting-server.de (Postfix) with ESMTPS id 5E61532C356C; Tue, 5 Dec 2017 14:26:34 +0100 (CET) Received: from localhost.localdomain (unknown [91.230.2.244]) (Authenticated sender: yes) by alfa3028.alfahosting-server.de (Postfix) with ESMTPA id C78743BE0001; Tue, 5 Dec 2017 14:26:33 +0100 (CET) From: Richard Leitner To: robh+dt@kernel.org, mark.rutland@arm.com, fugang.duan@nxp.com, andrew@lunn.ch, f.fainelli@gmail.com, frowand.list@gmail.com Cc: davem@davemloft.net, geert+renesas@glider.be, sergei.shtylyov@cogentembedded.com, baruch@tkos.co.il, david.wu@rock-chips.com, lukma@denx.de, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, richard.leitner@skidata.com Subject: [PATCH net-next v3 4/4] net: fec: add phy_reset_after_clk_enable() support Date: Tue, 5 Dec 2017 14:26:00 +0100 Message-Id: <20171205132600.13796-5-dev@g0hl1n.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171205132600.13796-1-dev@g0hl1n.net> References: <20171205132600.13796-1-dev@g0hl1n.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Richard Leitner Some PHYs (for example the SMSC LAN8710/LAN8720) doesn't allow turning the refclk on and off again during operation (according to their datasheet). Nonetheless exactly this behaviour was introduced for power saving reasons by commit e8fcfcd5684a ("net: fec: optimize the clock management to save power"). Therefore add support for the phy_reset_after_clk_enable function from phylib to mitigate this issue. Generally speaking this issue is only relevant if the ref clk for the PHY is generated by the SoC and therefore the PHY is configured to "REF_CLK In Mode". In our specific case (PCB) this problem does occur at about every 10th to 50th POR of an LAN8710 connected to an i.MX6SOLO SoC. The typical symptom of this problem is a "swinging" ethernet link. Similar issues were reported by users of the NXP forum: https://community.nxp.com/thread/389902 https://community.nxp.com/message/309354 With this patch applied the issue didn't occur for at least a few hundret PORs of our board. Fixes: e8fcfcd5684a ("net: fec: optimize the clock management to save power") Signed-off-by: Richard Leitner --- drivers/net/ethernet/freescale/fec_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 610573855213..8c3d0fb7db20 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1862,6 +1862,8 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ret = clk_prepare_enable(fep->clk_ref); if (ret) goto failed_clk_ref; + + phy_reset_after_clk_enable(ndev->phydev); } else { clk_disable_unprepare(fep->clk_ahb); clk_disable_unprepare(fep->clk_enet_out); @@ -2860,6 +2862,11 @@ fec_enet_open(struct net_device *ndev) if (ret) goto err_enet_mii_probe; + /* reset phy if needed here, due to the fact this is the first time we + * have the net_device to phy_driver link + */ + phy_reset_after_clk_enable(ndev->phydev); + if (fep->quirks & FEC_QUIRK_ERR006687) imx6q_cpuidle_fec_irqs_used();