From patchwork Sun Jun 21 14:36:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 11617659 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 15F7913A0 for ; Mon, 22 Jun 2020 13:09:49 +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 C876D2073E for ; Mon, 22 Jun 2020 13:09:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="w6Qd1FGc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="knaxMkyX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="XOBSC2jE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C876D2073E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk 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-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=6erjXH/46w2wM+3xGgHDKwzby7582WAk8qWoGerQbo4=; b=w6Qd1FGcKpA0aoiaEEabu+PRRW 7v0jNBAT7iH/xbw+CRd45NCC4rxnDGHpjhexLq6s8gQIqGgBKzsHpKuUQBGVqfQ0AvWaF8iVWHfBg iG62JDWPnFToWDzy66x9syX0wcENMy5OHbcPTPH82uLRkzRgWLQIwDKrfQ8xGDENMz591dM2OkagB Ybbwqi23nXkhlFAUj+9mrzCHIc4b76n+K/hRU0Z37dBTlghoNN9RkNmyUXRI0pHFThkdPjNBxqKOg qPFM2lE0CeJ2qQPF4+1dLABAe9Ys559ZcGnGKJGUISC02ffZELKqbfc9S/DBOCN7GOdZDgKSDDTBt jb/+M8Nw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnMCn-0002I7-GU; Mon, 22 Jun 2020 13:09:45 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnLuh-0003cT-2h; Mon, 22 Jun 2020 12:51:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:In-Reply-To:References; bh=OO7MBhIF3uuv6rDmcjDqhIxU6W1sKcos8zRQgNu+lwk=; b=knaxMkyXlT9ASzhXCs8vep7u/N f6d7mIWeb9BYsRatuWIf9de/0JNozE+HmCKUwjUNzP2YRIqjQpwIWj09lxsDaR5fas5Wg5JYjVV53 j8vNAHprQsw4DaDrZLQzaWy96iVQlo7nLlAw4qawzEMg22EZw/E5FvPacIpoX1xAA3PbyUPYW6Hqt I7hk3D9PjhCcaEX8qWENgge9kn2GcAwpdkTDGhUirQlYwD8uc7jYf+rXNT0+SoUMOt7cC3l1Vqp2L mIr/2ScZBEIrMl8SiKAgRPePN9V3g5BLPndj3GaW0tuFoAVS1ieIo3E8UtERs1NHuxxhPNAqBAOQH lpNtjRZw==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jn18y-0004Er-RB; Sun, 21 Jun 2020 14:40:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OO7MBhIF3uuv6rDmcjDqhIxU6W1sKcos8zRQgNu+lwk=; b=XOBSC2jE7GiAhalZ9nE2EHMMO4 p/PvP8D5gdxWYsgv9UWjPMDUV34FLnQoCxUdj4mnyRn9U4LKpMZAsPFQFNYX+zZaA7AMOMciik5XO A+XUaUf0lJ5b5TJbuyoGv6+xB99xJfAHoCsMHFJSLLAyVXePwyLCpjloZXMnbh/w43qPRtwOc2pjj B7xcIdVSYSlaigVmgGQk72vInFwP8GJbDB+hKnH2uex/+RSM2BQLwu9kHinzjir7D1N4qwMGyAFEE xrKtyYGwiLxY0eXKBN3lxDTmwKrj/XC18SnjSLC+GTsAVIkcaOstvV0U0/6bNjs5aQ2hIW+V2IuIq KRdkMxAA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:41032 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jn15L-0007yS-EI; Sun, 21 Jun 2020 15:36:39 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jn15L-0006zk-5F; Sun, 21 Jun 2020 15:36:39 +0100 From: Russell King To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Subject: [PATCH net-next] net: mtk_eth_soc: use resolved link config in mac_link_up() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sun, 21 Jun 2020 15:36:39 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200621_154025_066265_A811B340 X-CRM114-Status: GOOD ( 10.80 ) X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: Felix Fietkau , netdev@vger.kernel.org, Sean Wang , "David S. Miller" , linux-mediatek@lists.infradead.org, John Crispin , Matthias Brugger , Jakub Kicinski , Mark Lee , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Convert the mtk_eth_soc driver to use the finalised link parameters in mac_link_up() rather than the parameters in mac_config(). Signed-off-by: Russell King --- This is my untested stab at converting mtk_eth_soc.c to use the state passed in via mac_link_up() rather than mac_config(). Please test and report back. Thanks. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 45 ++++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index f6a1f8666f95..20db302d31ce 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -344,29 +344,9 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, /* Setup gmac */ mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); mcr_new = mcr_cur; - mcr_new &= ~(MAC_MCR_SPEED_100 | MAC_MCR_SPEED_1000 | - MAC_MCR_FORCE_DPX | MAC_MCR_FORCE_TX_FC | - MAC_MCR_FORCE_RX_FC); mcr_new |= MAC_MCR_MAX_RX_1536 | MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE | MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK; - switch (state->speed) { - case SPEED_2500: - case SPEED_1000: - mcr_new |= MAC_MCR_SPEED_1000; - break; - case SPEED_100: - mcr_new |= MAC_MCR_SPEED_100; - break; - } - if (state->duplex == DUPLEX_FULL) { - mcr_new |= MAC_MCR_FORCE_DPX; - if (state->pause & MLO_PAUSE_TX) - mcr_new |= MAC_MCR_FORCE_TX_FC; - if (state->pause & MLO_PAUSE_RX) - mcr_new |= MAC_MCR_FORCE_RX_FC; - } - /* Only update control register when needed! */ if (mcr_new != mcr_cur) mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id)); @@ -443,6 +423,31 @@ static void mtk_mac_link_up(struct phylink_config *config, phylink_config); u32 mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); + mcr &= ~(MAC_MCR_SPEED_100 | MAC_MCR_SPEED_1000 | + MAC_MCR_FORCE_DPX | MAC_MCR_FORCE_TX_FC | + MAC_MCR_FORCE_RX_FC); + + /* Configure speed */ + switch (speed) { + case SPEED_2500: + case SPEED_1000: + mcr |= MAC_MCR_SPEED_1000; + break; + case SPEED_100: + mcr |= MAC_MCR_SPEED_100; + break; + } + + /* Configure duplex */ + if (duplex == DUPLEX_FULL) + mcr |= MAC_MCR_FORCE_DPX; + + /* Configure pause modes - phylink will avoid these for half duplex */ + if (tx_pause) + mcr |= MAC_MCR_FORCE_TX_FC; + if (rx_pause) + mcr |= MAC_MCR_FORCE_RX_FC; + mcr |= MAC_MCR_TX_EN | MAC_MCR_RX_EN; mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); }