From patchwork Thu Jul 23 19:07:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11681557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 877A313A4 for ; Thu, 23 Jul 2020 19:07:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FA85206F4 for ; Thu, 23 Jul 2020 19:07:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CA2lirHn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FA85206F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Mime-Version:References:In-Reply-To:Date:To:From:Subject:Message-ID:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qE1GAK579jhUAMJhOti+a16ajUZGkFLMzOkijEGZRTU=; b=CA2lirHnLuQbCLcKQgGfzKU+1 miRudSys51njFSuoSLxBO3KZUZmqLeAJp1HeTY9GsCUT9/esZkuPnHUIvh+C1RvTMu6zXvoOEBmXn FfwZF1ralStZ26vzB+yxYATVN/Z04qJGsCuvN5PFHsBP4ghbwJ0TpWnG2efIanGFvUogY9+8t4nDK EnJgNzJk01Nnr5o9j6LgxRMaxJbaWhUUel8UazmF2Cdfj8pO4oOZ6d3vyQhDaCkUu+JV7Gcs3ajUs ZCZY16yXVXUuJLxBxMa1QOK8wbPu38o855otVLH8b2cNQ9fdzwnpjWyiY3jcuTqJGlZFh0Tr4P0cZ 4fStNGfAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jygYo-0003fu-QH; Thu, 23 Jul 2020 19:07:19 +0000 Received: from 54-240-197-239.amazon.com ([54.240.197.239] helo=u3832b3a9db3152.ant.amazon.com) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jygYi-0003f2-VI; Thu, 23 Jul 2020 19:07:13 +0000 Message-ID: <52f10e30f62b8521fd83525a03ecff94b72d509b.camel@infradead.org> Subject: [PATCH] net: ethernet: mtk_eth_soc: Always call mtk_gmac0_rgmii_adjust() for mt7623 From: David Woodhouse To: davem@davemloft.net Date: Thu, 23 Jul 2020 20:07:10 +0100 In-Reply-To: References: X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, Frank Wunderlich , f.fainelli@gmail.com, steven.liu@mediatek.com, vivien.didelot@savoirfairelinux.com, netdev@vger.kernel.org, Sean Wang , Landen.Chao@mediatek.com, linux-kernel@vger.kernel.org, =?iso-8859-1?q?Ren=E9?= van Dorst , linux-mediatek , john@phrozen.org, Mark-MC.Lee@mediatek.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: René van Dorst Modify mtk_gmac0_rgmii_adjust() so it can always be called. mtk_gmac0_rgmii_adjust() sets-up the TRGMII clocks. Signed-off-by: René van Dorst Signed-off-By: David Woodhouse Tested-by: Frank Wunderlich --- On Mon, 2020-04-06 at 15:25 +0200, Frank Wunderlich wrote: > have tested these 2 and additional rene's 3rd Patch on my tree [1] > on BPi-R2, no problem with trgmii yet (multiple power-cycle+reboots). > I had issues with current 5.6.0 version, so imho these should go > also into 5.6.y Here's that third patch of which Frank speaks. I don't see it submitted yet, and I found I needed it on 5.4 too for the Ethernet to be functional. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index b5408c5b954a..f89f225ab144 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -171,11 +171,21 @@ static int mt7621_gmac0_rgmii_adjust(struct mtk_eth *eth, return 0; } -static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, int speed) +static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, + phy_interface_t interface, int speed) { u32 val; int ret; + if (interface == PHY_INTERFACE_MODE_TRGMII) { + mtk_w32(eth, TRGMII_MODE, INTF_MODE); + val = 500000000; + ret = clk_set_rate(eth->clks[MTK_CLK_TRGPLL], val); + if (ret) + dev_err(eth->dev, "Failed to set trgmii pll: %d\n", ret); + return; + } + val = (speed == SPEED_1000) ? INTF_MODE_RGMII_1000 : INTF_MODE_RGMII_10_100; mtk_w32(eth, val, INTF_MODE); @@ -262,10 +272,9 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, state->interface)) goto err_phy; } else { - if (state->interface != - PHY_INTERFACE_MODE_TRGMII) - mtk_gmac0_rgmii_adjust(mac->hw, - state->speed); + mtk_gmac0_rgmii_adjust(mac->hw, + state->interface, + state->speed); /* mt7623_pad_clk_setup */ for (i = 0 ; i < NUM_TRGMII_CTRL; i++)