From patchwork Sat Aug 20 22:45:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Couzens X-Patchwork-Id: 12949847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98EC7C32796 for ; Sat, 20 Aug 2022 22:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dAZIRY5AGxEnOQppN8jQUMbg7mSLVLi2n6oyk0nmHQc=; b=upy3HZPc4SPz4hu/xXzFATQRQs FyyvTJsxzqypa6kWCe/Wlg1UWlvZr+3ILOQiz4V6WTN92xdHfW1Iil1/pO3RbgO6QU0ih+DtM48Lq /J/kqYa77s0bUHbgEyvLgzEc+DzxafmVN60XWX2iOlZif4y6pkEPEVSbznp3Qjv7r2y3ph/g2mDGA Y/dzpgTilaHlhvcf5dLG+eCr5ocGsWEYzPklw7y+3x/g9NiioPKCYc+iM1/wKO1Sa3ZaXa3dV7d/l d26AYnztPaxD2DWfxugjpJflQKlp80SgtKKVvt2a+o6BaSm6KQbErxH6Py5QFv1hySq03iNDQJ+n8 i7ylOBRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXEc-00D3eF-3b; Sat, 20 Aug 2022 22:46:30 +0000 Received: from mail.base45.de ([2001:67c:2050:320::77]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXET-00D3Ub-JT for linux-mediatek@lists.infradead.org; Sat, 20 Aug 2022 22:46:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fe80.eu; s=20190804; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=dAZIRY5AGxEnOQppN8jQUMbg7mSLVLi2n6oyk0nmHQc=; b=HKS+WKBa2OPxVQmxIefBthHbZi xhs40fnMMNPcdvxnnR2B+ofNMO8gWecn6A6tStW6DF8CqRzb+SgLtXhLLnwRJK9q3ZFOfYwbfAnai FuoVSAMYU3sXlpiI6lCnjRZcMKwGlHEv/rv29vlBlnGptMZLvD1+URGaZi5q4YKXUUJwvOMJJ6mq0 SdEV1mTVi6k9z5H+gPZ9GjasrIG2sz6z+j0bRbKJzMsPhrQ9v6fblWpdZRR5rA9GF3IRlcRK4692X yBnfdQEjV0bK8OhcKouTr55MDnmtNXmCLp1ajImbkcz9qjFgZOzr7CTI2+T5eFmsMXPUtj57q86aG 2bb7suYg==; Received: from [2a02:2454:9869:1a:9eb6:54ff:0:fa5] (helo=cerator.lan) by mail.base45.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oPXE5-00G2sh-8A; Sat, 20 Aug 2022 22:45:57 +0000 From: Alexander Couzens To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King , netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Golle , Alexander Couzens Subject: [PATCH 1/4] net: mediatek: sgmii: fix powering up the SGMII phy Date: Sun, 21 Aug 2022 00:45:35 +0200 Message-Id: <20220820224538.59489-2-lynxis@fe80.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220820224538.59489-1-lynxis@fe80.eu> References: <20220820224538.59489-1-lynxis@fe80.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220820_154622_193315_A521BFDE X-CRM114-Status: UNSURE ( 9.66 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org There are cases when the SGMII_PHYA_PWD register contains 0x9 which prevents SGMII from working. The SGMII still shows link but no traffic can flow. Writing 0x0 to the PHYA_PWD register fix the issue. 0x0 was taken from a good working state of the SGMII interface. Signed-off-by: Alexander Couzens --- drivers/net/ethernet/mediatek/mtk_sgmii.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index 736839c84130..a01bb20ea957 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -36,9 +36,7 @@ static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs) val |= SGMII_AN_RESTART; regmap_write(mpcs->regmap, SGMSYS_PCS_CONTROL_1, val); - regmap_read(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, &val); - val &= ~SGMII_PHYA_PWD; - regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, val); + regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, 0); return 0; @@ -70,9 +68,7 @@ static int mtk_pcs_setup_mode_force(struct mtk_pcs *mpcs, regmap_write(mpcs->regmap, SGMSYS_SGMII_MODE, val); /* Release PHYA power down state */ - regmap_read(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, &val); - val &= ~SGMII_PHYA_PWD; - regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, val); + regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, 0); return 0; } From patchwork Sat Aug 20 22:45:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Couzens X-Patchwork-Id: 12949846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13580C32772 for ; Sat, 20 Aug 2022 22:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Skn6knx7DWTwYsEOVvaiAtKq6ITBTeteroMRofDadYM=; b=hT9mLVT0ye/OpHhyKNaolNhuLl K8flJRO9UjlfT90jLsaFt9ELKDUdqii6s4l/F0NgDG5U7EZ4eG1+xaalJojrPlege3nG3cBu45gFi FYZg8Mq5tg7tj2QEjnmJsniypIPCC/EZLu9qjwN7wsTfaUbrYgSO2THGYSTP344R4Hq/nWrR4JyvA vxkIADAtB96PJfqUK2ByVXp8MrQyMfhfqoRLgADEiA6UDCFvHoMl2ZmhdjzqNBBekdMKmyBC9lIgg 3VguuvChq3xqa1QKHwNrbnYmSkDIz1oTgTiJVjNsWw8r7jV9bP29rbz1ONpvA2Ks6KmpaUC2LVv7T /80BTfCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXEb-00D3dT-2N; Sat, 20 Aug 2022 22:46:29 +0000 Received: from mail.base45.de ([2001:67c:2050:320::77]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXET-00D3UK-JW for linux-mediatek@lists.infradead.org; Sat, 20 Aug 2022 22:46:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fe80.eu; s=20190804; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Skn6knx7DWTwYsEOVvaiAtKq6ITBTeteroMRofDadYM=; b=spSguYHK4keCpgMbpmRvLdz+5x Pb9Fy+vc0wQ1M6KAG5JWjqBaJygPLJyyXjaRPkSvm1GsgPtxKYFNZEL75M9xbXQR8ywXw2em+jfD4 CoMLAdIPdQTUrEsLitBiCE6EA9dhjJxWR5vgSThJyaGb6pmG/+4gdl5YZuvwUtv4ZxX5NzmkbtjUC 3dHWRf014xypVG+VTMWpXyZ6HeIVMuT+mbInEu0TFsEBMHACYdQeWMem2Owv82FiMCQPHpwVJt1in iJSMVY0XOmbpKIf5CAcv/KCl7ucfuxVPfh/pwaMjKnvlH8/Pj//NXoxTgPp4Xtr1XMoa/FZnSZa16 GqML8KZw==; Received: from [2a02:2454:9869:1a:9eb6:54ff:0:fa5] (helo=cerator.lan) by mail.base45.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oPXE5-00G2sh-Mn; Sat, 20 Aug 2022 22:45:57 +0000 From: Alexander Couzens To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King , netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Golle , Alexander Couzens Subject: [PATCH 2/4] net: mediatek: sgmii: ensure the SGMII PHY is powered down on configuration Date: Sun, 21 Aug 2022 00:45:36 +0200 Message-Id: <20220820224538.59489-3-lynxis@fe80.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220820224538.59489-1-lynxis@fe80.eu> References: <20220820224538.59489-1-lynxis@fe80.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220820_154622_201060_58732AC4 X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The code expect the PHY to be in power down which is only true after reset. Allow changes of the SGMII parameters more than once. Signed-off-by: Alexander Couzens --- drivers/net/ethernet/mediatek/mtk_sgmii.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index a01bb20ea957..782812434367 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -7,6 +7,7 @@ * */ +#include #include #include #include @@ -24,6 +25,9 @@ static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs) { unsigned int val; + /* PHYA power down */ + regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); + /* Setup the link timer and QPHY power up inside SGMIISYS */ regmap_write(mpcs->regmap, SGMSYS_PCS_LINK_TIMER, SGMII_LINK_TIMER_DEFAULT); @@ -36,6 +40,10 @@ static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs) val |= SGMII_AN_RESTART; regmap_write(mpcs->regmap, SGMSYS_PCS_CONTROL_1, val); + /* Release PHYA power down state + * unknown how much the QPHY needs but it is racy without a sleep + */ + usleep_range(50, 100); regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, 0); return 0; @@ -50,6 +58,9 @@ static int mtk_pcs_setup_mode_force(struct mtk_pcs *mpcs, { unsigned int val; + /* PHYA power down */ + regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); + regmap_read(mpcs->regmap, mpcs->ana_rgc3, &val); val &= ~RG_PHY_SPEED_MASK; if (interface == PHY_INTERFACE_MODE_2500BASEX) @@ -67,7 +78,10 @@ static int mtk_pcs_setup_mode_force(struct mtk_pcs *mpcs, val |= SGMII_SPEED_1000; regmap_write(mpcs->regmap, SGMSYS_SGMII_MODE, val); - /* Release PHYA power down state */ + /* Release PHYA power down state + * unknown how much the QPHY needs but it is racy without a sleep + */ + usleep_range(50, 100); regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, 0); return 0; From patchwork Sat Aug 20 22:45:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Couzens X-Patchwork-Id: 12949845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6DBFC32789 for ; Sat, 20 Aug 2022 22:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0jImID30Vp/vYAutmCPaQyC4TRyXEdkw0IIMRl2iUHw=; b=q8lEm0MLVZcJGXkWnfzzRihul4 ltRYDugJcRSqV7RLKDlX8jNMXZkfIcJ8bRK1kaZBfJyfmp7xHljWd6NfyZB+nqzBNc3ZY9mSTB3S8 OWFsOw4yqXFqgCkiVYMfXc/4gZjKAANJwKpc76uXLbRub8qTr9mnZJtx+1T+JCVxxp7oPctcZEVUm 42NXigHDMjLUyKWVlh7tsrpib1N2bouLLGfxsvZ110OQB9sf9uRltZV9n2ihBPsUOfL/fe0fSqBVb TOJpY9UYuDHd+z7uhsjTwoqGw6jFWYMlG+eRQNQMIwjhCD2mJdYnPWff9KPw5dO03fVVxGN33zO4l aTpi1Jqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXEY-00D3bC-L4; Sat, 20 Aug 2022 22:46:26 +0000 Received: from mail.base45.de ([2001:67c:2050:320::77]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXET-00D3Ts-JU for linux-mediatek@lists.infradead.org; Sat, 20 Aug 2022 22:46:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fe80.eu; s=20190804; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0jImID30Vp/vYAutmCPaQyC4TRyXEdkw0IIMRl2iUHw=; b=D1AsLfGkGFO8vKorMpoTaWZNsl NANJ1QhSUExJ4IgqmDEx4TmgJNkg4zENBdhHel9qsdWmJMXdqszgq0lGTz7kg1wQuymdB9Z18kSYM UBqzqtQudV27B3yxvlqGCpxOoKMlm0Rg00P5QWYW1KG+h2a9XR1hL63pBL3F5Mrq0eXilQ4lOO9gy TC7WcZV0w+6g6lZ7jBejGiVBxQl3bKKmfp516Ru/PuKQ/cf5Ls+fuCb//YPSbAfp1Fbx8UT4G/ePz TDkncPoux6+6HeH0O/UnhFCucYveIQJ7qSfB/oK+oUuMgM7/0Cv+2FZ+WgHGCyG49qh8r0/hBQN0n 28+6kYcw==; Received: from [2a02:2454:9869:1a:9eb6:54ff:0:fa5] (helo=cerator.lan) by mail.base45.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oPXE6-00G2sh-4c; Sat, 20 Aug 2022 22:45:58 +0000 From: Alexander Couzens To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King , netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Golle , Alexander Couzens Subject: [PATCH 3/4] net: mediatek: sgmii: mtk_pcs_setup_mode_an: don't rely on register defaults Date: Sun, 21 Aug 2022 00:45:37 +0200 Message-Id: <20220820224538.59489-4-lynxis@fe80.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220820224538.59489-1-lynxis@fe80.eu> References: <20220820224538.59489-1-lynxis@fe80.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220820_154622_196602_8B2B2A0F X-CRM114-Status: UNSURE ( 8.34 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Ensure autonegotiation is enabled. Signed-off-by: Alexander Couzens --- drivers/net/ethernet/mediatek/mtk_sgmii.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index 782812434367..aa69baf1a42f 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -32,12 +32,13 @@ static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs) regmap_write(mpcs->regmap, SGMSYS_PCS_LINK_TIMER, SGMII_LINK_TIMER_DEFAULT); + /* disable remote fault & enable auto neg */ regmap_read(mpcs->regmap, SGMSYS_SGMII_MODE, &val); - val |= SGMII_REMOTE_FAULT_DIS; + val |= SGMII_REMOTE_FAULT_DIS | SGMII_SPEED_DUPLEX_AN; regmap_write(mpcs->regmap, SGMSYS_SGMII_MODE, val); regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &val); - val |= SGMII_AN_RESTART; + val |= SGMII_AN_RESTART | SGMII_AN_ENABLE; regmap_write(mpcs->regmap, SGMSYS_PCS_CONTROL_1, val); /* Release PHYA power down state From patchwork Sat Aug 20 22:45:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Couzens X-Patchwork-Id: 12949848 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D50F8C3F6B0 for ; Sat, 20 Aug 2022 22:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WRiYwROZ16kVAe/wuAeCca/SXcJ/4o6AYy4x1BePKz4=; b=D2c90qyEVFov5s6fK1DZ28BQoV f/Oig/ofAvSmE9rgsN/OOrEyjfEAite0f6K6TC2+MKNtBgElWQOQ4drMbM39p2nbNBSnjE3xzealB FDJCE1F9u/NtCPgqfapde9gjT2ReUKftwy3BrYJ+N7MPFnvcpqSmRWMhQOJ4v6hXCvDQLe8INypqp hXopH7qBbScHDMQAUjKkp//DaPAQddHz1XOon86c7bAzfEXMzwEgiB9gZ0NhPRnLzCYoPTrJNZfc9 D9sBJMyCSa5XUxF1Z8H1wSPmbzuXiSalLKd+xBfFBjVpezzS0WSzRuZKIoJcVOctSpmcsAf7dkR6b BTRHH4uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXEd-00D3fJ-5k; Sat, 20 Aug 2022 22:46:31 +0000 Received: from mail.base45.de ([2001:67c:2050:320::77]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPXET-00D3Ua-JW for linux-mediatek@lists.infradead.org; Sat, 20 Aug 2022 22:46:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fe80.eu; s=20190804; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WRiYwROZ16kVAe/wuAeCca/SXcJ/4o6AYy4x1BePKz4=; b=xChpAe7GlnOU0yPSil4rYT2m4g h4i18+2YpWsIX9N6Ax3WCUN6oJFUtYMyoaBLZGBicAfusNdpuoV2AwHv/9dyLWObRGkWUfMEuo20j xYotEAFzIjqGgUZM4AlcyKbrUjxxlMQ+m3mufhepAtgYJw1aO1qOcWPaNe1eRiClc4kZ3hHdHpaLn GI4N3Snpx3zoD2AQXJzK2Ln6DeTA+0vIUfh0LldXHlc3f3thnXmvncvmXyZd2mVD0w85hEm4eISm5 yyT2wMXMeRdm4Fl2AjsSMag0kVfmXIpObzlKqboHc+FJCUwZOVauZmiW0wWDwpBMWy5RZf7aHSY9E ALIAOu0Q==; Received: from [2a02:2454:9869:1a:9eb6:54ff:0:fa5] (helo=cerator.lan) by mail.base45.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oPXE6-00G2sh-JE; Sat, 20 Aug 2022 22:45:58 +0000 From: Alexander Couzens To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King , netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Golle , Alexander Couzens Subject: [PATCH 4/4] net: mediatek: sgmii: set the speed according to the phy interface in AN Date: Sun, 21 Aug 2022 00:45:38 +0200 Message-Id: <20220820224538.59489-5-lynxis@fe80.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220820224538.59489-1-lynxis@fe80.eu> References: <20220820224538.59489-1-lynxis@fe80.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220820_154622_452207_058E80AA X-CRM114-Status: GOOD ( 11.19 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The non auto-negotiating code path is setting the correct speed for the interface. Ensure auto-negotiation code path is doing it as well. Signed-off-by: Alexander Couzens --- drivers/net/ethernet/mediatek/mtk_sgmii.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index aa69baf1a42f..75de2c73a048 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -21,13 +21,20 @@ static struct mtk_pcs *pcs_to_mtk_pcs(struct phylink_pcs *pcs) } /* For SGMII interface mode */ -static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs) +static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs, phy_interface_t interface) { unsigned int val; /* PHYA power down */ regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); + /* Set SGMII phy speed */ + regmap_read(mpcs->regmap, mpcs->ana_rgc3, &val); + val &= ~RG_PHY_SPEED_MASK; + if (interface == PHY_INTERFACE_MODE_2500BASEX) + val |= RG_PHY_SPEED_3_125G; + regmap_write(mpcs->regmap, mpcs->ana_rgc3, val); + /* Setup the link timer and QPHY power up inside SGMIISYS */ regmap_write(mpcs->regmap, SGMSYS_PCS_LINK_TIMER, SGMII_LINK_TIMER_DEFAULT); @@ -100,7 +107,7 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode, if (interface != PHY_INTERFACE_MODE_SGMII) err = mtk_pcs_setup_mode_force(mpcs, interface); else if (phylink_autoneg_inband(mode)) - err = mtk_pcs_setup_mode_an(mpcs); + err = mtk_pcs_setup_mode_an(mpcs, interface); return err; }