From patchwork Wed Apr 6 14:34:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803562 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 7B805C433F5 for ; Wed, 6 Apr 2022 14:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YcGD9tmCYn8JtRCnTYG3g4D/pQzal5DT9IHYgOyS698=; b=ka+AiznNGtfhsb p9em1xLno1YItfEEk6jmfSdw+jTyRZrMvWPS9L6+cmtPYmflrousJqiZ/+dKNa8iDq57rXV61DE0w BRBUCF1QiBMSXkmM1hMgz5auf7wcuK8a9welF6NiAxeKv575qeV9HW29cU3/lA/PyVTg/5tZ2Pxod AfQNF0BZFKEG5LVxGYauEmYlz4dGRn+BX5AgGWlR/Oa7PxRg+mmI/s6MV5DPweYKeuiPlDPCatOmX nIc/0bEpEkxMK19/RUeVXvyOKZbUvh1bYCWzGuB4ZUcNA/8hJHgEFMNthYzAdzv11T056m2Qo3Hne LH78ZBrSEZg5T8EscT6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6ka-006Xit-Uk; Wed, 06 Apr 2022 14:35:13 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6kW-006XgK-3B; Wed, 06 Apr 2022 14:35:09 +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:References: In-Reply-To:Reply-To: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=DUAo+mqYnAUG+mILjNagVGzTyTx2txWqKx2hHt8JQgQ=; b=DcrJHcfWXhL/+trcV52rNWOE0C /NWlUwoJQUt/2aeM3SmW2Da1KIlyDKHOdwmtupE9Hxioj+aVJFiS1/R+mH2NSTmA0nmyNfbm55yrO ZC8hhYUccRia7O0Xx0wVuo76lJbCwqa96zot/DYdaNB3A1HJGKaTSRelmdvciftbbj/ky7lPVR7fP JjL/kMn5dwKh/bekfVUg3zX6C4f+LfEj/yRiyOuHlEAUDMpk4WO3ED0SYLyzBojRMjKIG+0LO8RsA 9rKmCNXOPTJ4gZQpbN0brtqh3TQN9x0UHB9kY7crAkQ5w4OtswbhvYoFU9oOpY7Uhiyi7r/oGiGyN /MMXtPHA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60662 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6kO-0002tt-Fs; Wed, 06 Apr 2022 15:35:00 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6kN-004ijV-JN; Wed, 06 Apr 2022 15:34:59 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 01/12] net: mtk_eth_soc: remove unused mac->mode MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:34:59 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073508_161969_4C3FA509 X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org mac->mode is only ever written to in one location, and is thus superflous. Remove it. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 - drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index f02d07ec5ccb..e491d43f049a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2968,7 +2968,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) /* mac config is not set */ mac->interface = PHY_INTERFACE_MODE_NA; - mac->mode = MLO_AN_PHY; mac->speed = SPEED_UNKNOWN; mac->phylink_config.dev = ð->netdev[id]->dev; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index c9d42be314b5..2b690f8a5391 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -989,7 +989,6 @@ struct mtk_eth { struct mtk_mac { int id; phy_interface_t interface; - unsigned int mode; int speed; struct device_node *of_node; struct phylink *phylink; From patchwork Wed Apr 6 14:35:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803563 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 F3751C433F5 for ; Wed, 6 Apr 2022 14:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=THxZRBcpTwByzb0tS4C+djg5sL9dGgHK6JYCCQmV1Kg=; b=eD16mtAv1gMp+M 8vHEInlVCkvbXkdDsj3MBO9XTQr0m5zT3mrnnYJaXRc4N7ibLfHyDMbXsCI4i0IOnyz3we4kbAjIC AHKCkVH8poBYNwGx0DIreInEXNphSL3gCsOlBiN08BtQoWG6PqaErPLM0ONVxxWWPGekBRs4jmTsw rl8FSOXfJP4i+kEkCWUjlZt7uwqCOtDsYHiA9VbAKmrbNcW3bKfMykuI3oSVeYXg/glRGEnThs3+8 WQu+UscWSBxa3UCziMEVnvOCDbUnXBcub6XDA3orprcbtCB5iwOqs5feuIwEHGvyJIuW1G/HkBXkr p0V5ESizSGiRMIP6btnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6l5-006XyK-0P; Wed, 06 Apr 2022 14:35:43 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6kb-006Xjr-3k; Wed, 06 Apr 2022 14:35:14 +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:References: In-Reply-To:Reply-To: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=4lhcZU1UliNq09YYX/sPSI7uRvQe7Xolf5tmFxI5yGQ=; b=lyuERrSwwLXMMotNdfbfP154yg EcXdzfCtzc1xiePoX1FuqwOxU4h6KSKdoWL1OkOg3gVfoTzcYpxsPNmAmohz1w+CYC6MAjVv64ygV VUR8GrpUSYZllGQqPNRR5Bh99ki8qpFSJM1BDey2V8SRc023kOZpNIpOZHm0quBkBP57xZk1TwjA6 1F6Ektr9q1pGuF8ZQbg6fujooOh3D3mZePT6b+oPvUPJt68vc/5cUQlKtH0XWVbGBZLELPJRLpCd0 vK4ZcNR0lqPKrz/QBrKP0y6eOedG8RPwdW0wJN+viBUJ1C0asiWqWQQxnE4c/fdgnrR2798g/4Z/6 IuUbZKRg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60664 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6kT-0002u9-JT; Wed, 06 Apr 2022 15:35:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6kS-004ijd-N4; Wed, 06 Apr 2022 15:35:04 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 02/12] net: mtk_eth_soc: remove unused sgmii flags MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:04 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073513_298304_F32AE9D8 X-CRM114-Status: GOOD ( 10.49 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The "flags" member of struct mtk_sgmii appears to be unused, as are the MTK_SGMII_PHYSPEED_* and MTK_HAS_FLAGS() macros. Remove them. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 2b690f8a5391..8a10761adda0 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -859,23 +859,15 @@ struct mtk_soc_data { /* currently no SoC has more than 2 macs */ #define MTK_MAX_DEVS 2 -#define MTK_SGMII_PHYSPEED_AN BIT(31) -#define MTK_SGMII_PHYSPEED_MASK GENMASK(2, 0) -#define MTK_SGMII_PHYSPEED_1000 BIT(0) -#define MTK_SGMII_PHYSPEED_2500 BIT(1) -#define MTK_HAS_FLAGS(flags, _x) (((flags) & (_x)) == (_x)) - /* struct mtk_sgmii - This is the structure holding sgmii regmap and its * characteristics * @regmap: The register map pointing at the range used to setup * SGMII modes - * @flags: The enum refers to which mode the sgmii wants to run on * @ana_rgc3: The offset refers to register ANA_RGC3 related to regmap */ struct mtk_sgmii { struct regmap *regmap[MTK_MAX_DEVS]; - u32 flags[MTK_MAX_DEVS]; u32 ana_rgc3; }; From patchwork Wed Apr 6 14:35:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803564 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 35E9CC433F5 for ; Wed, 6 Apr 2022 14:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g2d0o6qsYGJkQhxcpKUJDi2tUqCW6kZWpyW6anTqHWQ=; b=WI5YFRioKOBGS4 A2JFbWp/3qXB7dPfp8Ch2xYMxu83OS2iKP+lcvRP7NJJvs/thsirYIcyIsAYajlS4Ejuz9aU84vi9 Gu9mDrTqvhe7cBE95mcFD8RU+rZvxArAHUlqJI/lzFAiLG7vvO5kPuL9I9s72FEXgoe8p7jtS+NZ3 2kdhi/Gp4H006z1WoGJxNdnHJhjOqryZELXVoqo3kX+XyHzMq6eWEfNfuy0k1caP01dJzrBkfZB7P +ervJizbXACErrKAVeyUGYr0JE0272C3LskpKv/17UB4tDtY0nlsALOsnm7oSXQNwN8TM8ZXl6vO+ n7StRgZXvrmVKip4P9eA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6lX-006YAd-Hu; Wed, 06 Apr 2022 14:36:12 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6kg-006XmV-7k; Wed, 06 Apr 2022 14:35:21 +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:References: In-Reply-To:Reply-To: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=/IAm1zyPctcxoxML0sDPVKwxvBMfVjy+g9VTkY82hNA=; b=oR5EtfpyxI9NbMR5HQ93DbqWh/ HmOo3JuMp8fTwIxeooksI4Y4LaA0SFpCiR3L2YrOx0sZ1ix7AyAmO0nmMRkX34pE/OYalicl3XHW1 IlAg+v8NRmeaC6oEXogY9Tgtp0+P/OGH0PeHbhkY3YhJKq9zSm3jIV5iLSbSP/R6d5vtZalu/4FiP RfoewGRgp9RTKDCtVuPzU28snOacIjWUzgSSQDkgKwWhnMMrjSskFiyhVHMP4KvbD5l11HroPzqlF w4Ap4Wt7G4ujPzwSdZAn2YT7ZuVh7Aei1PZ1mNNotYP/hJow5JT445nOONAlA4XzvqiHh3PNoGE6N eFJxPcRA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60666 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6kY-0002uQ-MT; Wed, 06 Apr 2022 15:35:10 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6kX-004ijj-Qk; Wed, 06 Apr 2022 15:35:09 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 03/12] net: mtk_eth_soc: add mask and update PCS speed definitions MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:09 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073518_390975_C940979C X-CRM114-Status: GOOD ( 10.21 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PCS speed setting is a two bit field, but it is defined as two separate bits. Add a bitfield mask for the speed definitions, an use the FIELD_PREP() macro to define each PCS speed. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 8a10761adda0..f31ef594008a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -17,6 +17,7 @@ #include #include #include +#include #include "mtk_ppe.h" #define MTK_QDMA_PAGE_SIZE 2048 @@ -485,9 +486,10 @@ #define SGMSYS_SGMII_MODE 0x20 #define SGMII_IF_MODE_BIT0 BIT(0) #define SGMII_SPEED_DUPLEX_AN BIT(1) -#define SGMII_SPEED_10 0x0 -#define SGMII_SPEED_100 BIT(2) -#define SGMII_SPEED_1000 BIT(3) +#define SGMII_SPEED_MASK GENMASK(3, 2) +#define SGMII_SPEED_10 FIELD_PREP(SGMII_SPEED_MASK, 0) +#define SGMII_SPEED_100 FIELD_PREP(SGMII_SPEED_MASK, 1) +#define SGMII_SPEED_1000 FIELD_PREP(SGMII_SPEED_MASK, 2) #define SGMII_DUPLEX_FULL BIT(4) #define SGMII_IF_MODE_BIT5 BIT(5) #define SGMII_REMOTE_FAULT_DIS BIT(8) From patchwork Wed Apr 6 14:35:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803572 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 558A3C433EF for ; Wed, 6 Apr 2022 14:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1nSIzqkvlli7bdYfJp/qBXawVE/kF7ZF8r1P9VRiArQ=; b=ccQ/2LNmiJtJnd lrMRpBwflfrUTsuYnatH6t2dvxie1F8KpNQzysQV4++5a6e8ggNag+68OWJwgWqPKJEVEvUVQS4U9 pcYHNOm4O60jev7Aq//PZZshz3Q7226QFCSaBpXt8WjpgQs28z3DUnjdIaNEfo4LxXTagy2QftBAM 3VAOYQ55SSUqVDbTZbgr70noAzin0J6kfcNTn8e6T+Aj2MjtHRB0V3uMphT5viJeUVlzpxiEftk7c yqRvYrcwRm7raW97PeyZxQUBmF/sz8qo6tS25hmgOZl2ufLI479fOzGefQxDimiRiy5Ij+7iigN8R JKWwD/QKRTq+B9xRXckQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6mD-006YWw-OF; Wed, 06 Apr 2022 14:36:53 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6kl-006Xpk-33; Wed, 06 Apr 2022 14:35:24 +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:References: In-Reply-To:Reply-To: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=Oqe5W/YFbOBMN4vY9PN0fb0OS5WRh0LTSsST1Vzy05w=; b=rnQshrRRf5/+IvGg4KNdegvTU0 7U/+Nmb9Mry4lPWQgxO5tSu6RkzKmsEQJHJNlhrhEcEpmcOrfQeEX11XLDli5bTn2T8pPhuqPYlFm XfF/1cQMfEdD6zMdMpBi8SmdpPrXmjK1WGzvveTpckXdmDhdbvU3255pHLpsKg0IKIIylK5I4JEja WZ9SrAvFsdBb0gDC4wwNu4avpbYLov7A3YP99X2dQ5yhKGXqU2KpbFHHtAofww65TUYq8b4BdjUvk QXOUC4UQSXNPScF1WFDT3bpefYX1pmllHCcj5dNhUZGeuQnKnPOq+mATA7UK6zjy1BnaxO145dsEm yINT155w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60668 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6kd-0002uh-QW; Wed, 06 Apr 2022 15:35:15 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6kc-004ijq-U0; Wed, 06 Apr 2022 15:35:14 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 04/12] net: mtk_eth_soc: correct 802.3z speed setting MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:14 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073523_198048_80F8AC7D X-CRM114-Status: GOOD ( 11.87 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Phylink does not guarantee that state->speed will be set correctly in the mac_config() call, so it's a bug that the driver makes use of it. Moreover, it is making use of it in a function that is only ever called for 1000BASE-X and 2500BASE-X which operate at a fixed speed which happens to be the same setting irrespective of the interface mode. We can simply remove the switch statement and just set the SGMII interface speed. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_sgmii.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index 32d83421226a..16e66c0cb557 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -33,6 +33,7 @@ int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *r, u32 ana_rgc3) return 0; } +/* For SGMII interface mode */ int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id) { unsigned int val; @@ -59,6 +60,9 @@ int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id) return 0; } +/* For 1000BASE-X and 2500BASE-X interface modes, which operate at a + * fixed speed. + */ int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, const struct phylink_link_state *state) { @@ -81,19 +85,7 @@ int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, /* SGMII force mode setting */ regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val); val &= ~SGMII_IF_MODE_MASK; - - switch (state->speed) { - case SPEED_10: - val |= SGMII_SPEED_10; - break; - case SPEED_100: - val |= SGMII_SPEED_100; - break; - case SPEED_2500: - case SPEED_1000: - val |= SGMII_SPEED_1000; - break; - } + val |= SGMII_SPEED_1000; if (state->duplex == DUPLEX_FULL) val |= SGMII_DUPLEX_FULL; From patchwork Wed Apr 6 14:35:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803573 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 6408FC433F5 for ; Wed, 6 Apr 2022 14:38: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/+V8KbVkhvkDXziLDcNkSmC65jW/DZNS3BvKYM5Rbcw=; b=lkbWUfltTR2ZSs Pk9PN6UM4rjO+hvbsn311hMK6IdIksz79Z+pC3CvgXD0qzD9+ihgXlYHrB2+TFHXMbazItgwcULgZ zMi5qaBokjlZNU8V64gOlkpGQji0+IBgdgRon05lfhhpRCPf1+/TgeSF3VDwAUOjYsOaappDCa+tB /3AO6iTrvB/cD6G27r7BJyE1WVMVgVZJmfNJFs5DlSxzpzSP+QCkwLGlh7obAnrvc10M71IgN3/mb kHkrCdPHoyWsTKq+DH50+jvZtysy66D/lXG0ePMxpFwP8NPwCHTZaOTdlQ5VB/m+638ssZgmGUhEP 7JJpdqKT5Jvfpmw7U1Kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6mg-006Ymn-GC; Wed, 06 Apr 2022 14:37:22 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6kp-006Xrv-G2; Wed, 06 Apr 2022 14:35:29 +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:References: In-Reply-To:Reply-To: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=BDbYnTS0oTHfNb+Yu5s/Nzh1/TaiMZpWAo7vfLU9G5A=; b=ul37fOcGJxV3Zg/+WyhP/4e7Z2 k8foi0+QqiT2WPKNxNYfBQZzWNsShObr32XbAxnY9Na7lGKKLzoJ/8H5mEc6q+UgtE7bwiw3ul1dS QDBzD2GI2y047fEFVZ5VKbmUSShAce8tmYitbYDBbGFygIVQZbKlTK7UKZdKx/lMn+8HdT4HA9eG7 o3yGqxgnaQpOOv2R7pCo5Dr3ujNEZWBfQ7OsQgxk8jA4qZcnsxgyYpD4M6MKclCQQjbYINA3iILm7 csu0MZhMam9lFWDCjTWiasSnZgWysSWJfNkHlAHiXZagLT0fqD7FatyDdUzI6qbn0IjRljs2DeZuH bEHc9HnQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60672 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6ki-0002ux-UY; Wed, 06 Apr 2022 15:35:20 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6ki-004ijw-1O; Wed, 06 Apr 2022 15:35:20 +0100 In-Reply-To: References: From: Russell King To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 05/12] net: mtk_eth_soc: correct 802.3z duplex setting MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:20 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073527_608153_D4C74964 X-CRM114-Status: GOOD ( 15.29 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Phylink does not guarantee that state->duplex will be set correctly in the mac_config() call, so it's a bug that the driver makes use of it. Move the 802.3z PCS duplex configuration to mac_link_up(). Signed-off-by: Russell King --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 16 +++++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + drivers/net/ethernet/mediatek/mtk_sgmii.c | 22 +++++++++++++++------ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index e491d43f049a..6fedfa8fceb1 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -482,8 +482,18 @@ static void mtk_mac_link_up(struct phylink_config *config, { struct mtk_mac *mac = container_of(config, struct mtk_mac, phylink_config); - u32 mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); + u32 mcr; + + if (phy_interface_mode_is_8023z(interface)) { + struct mtk_eth *eth = mac->hw; + + /* Decide how GMAC and SGMIISYS be mapped */ + int sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? + 0 : mac->id; + mtk_sgmii_link_up(eth->sgmii, sid, speed, duplex); + } + 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); @@ -2972,9 +2982,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->phylink_config.dev = ð->netdev[id]->dev; mac->phylink_config.type = PHYLINK_NETDEV; - /* This driver makes use of state->speed/state->duplex in - * mac_config - */ + /* This driver makes use of state->speed in mac_config */ mac->phylink_config.legacy_pre_march2020 = true; mac->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index f31ef594008a..1912f84922c8 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1007,6 +1007,7 @@ int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *np, int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id); int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, const struct phylink_link_state *state); +void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex); void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id); int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id); diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index 16e66c0cb557..a5ec61e13b85 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -82,14 +82,10 @@ int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, val &= ~SGMII_AN_ENABLE; regmap_write(ss->regmap[id], SGMSYS_PCS_CONTROL_1, val); - /* SGMII force mode setting */ + /* Set the speed etc but leave the duplex unchanged */ regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val); - val &= ~SGMII_IF_MODE_MASK; + val &= SGMII_DUPLEX_FULL | ~SGMII_IF_MODE_MASK; val |= SGMII_SPEED_1000; - - if (state->duplex == DUPLEX_FULL) - val |= SGMII_DUPLEX_FULL; - regmap_write(ss->regmap[id], SGMSYS_SGMII_MODE, val); /* Release PHYA power down state */ @@ -100,6 +96,20 @@ int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, return 0; } +/* For 1000BASE-X and 2500BASE-X interface modes */ +void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex) +{ + unsigned int val; + + /* SGMII force duplex setting */ + regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val); + val &= ~SGMII_DUPLEX_FULL; + if (duplex == DUPLEX_FULL) + val |= SGMII_DUPLEX_FULL; + + regmap_write(ss->regmap[id], SGMSYS_SGMII_MODE, val); +} + void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id) { struct mtk_sgmii *ss = eth->sgmii; From patchwork Wed Apr 6 14:35:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803574 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 185ECC433F5 for ; Wed, 6 Apr 2022 14:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7aLxhKpt2YYmrXjm8hhNqT1gSfArPeR9lSgRWnHN0yE=; b=lhza3kG4tQoLo8 Fun13/BkLi+RMWjpMlyQe10jEA3jQCyfxJRjtsqzaGyoszkZLsWRep+ha4g4R41OTJH93y7UBuDYQ yyOaIjBQn0PC/9rlfdki2LxqLjl0hVCNXH66z0EFCPp0Th2EqSlk1yY4w3R9BXBfHuSehqjD3MdXT uZ0Cg0382g6gmclf4n7y9FZ9XsB0OUx3zSrT994sUmoOIacjhn53Xejm9yI+vRKk2+wLWccmygFs0 DEd+DssSQ+Gtc1c5CpGEjtIccqRsSYwt13WMKP1ATVsoFI9bGiaf1kUPvWZQOy8B0pu88kUyLV8rt Nj13fi9/4bKWVmFhjvRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6nL-006Z99-S8; Wed, 06 Apr 2022 14:38:04 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6ku-006Xtp-Ea; Wed, 06 Apr 2022 14:35:34 +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:References: In-Reply-To:Reply-To: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=R926PzfjUYoA24VgpIYq2VzMgn3qO9GangkHxkFJif4=; b=WWvosuPOfDyD1qa4W377AX+7jI iDSQVSCozvzI4DiQEAqljJiE67qpAaXy7SkbzVlvZnD29lBlyrZpxejElg1Cx53QUs5b2E/JL0ngu gvckF1YQvm91sxAqWvfOSGpSE4mfAO2r3pGMQmgshBncMD357owCpQfqwCmL+vDnGyoovJyzTXIM3 Q8eByHid7F9Jb7xib0RB8qoqxeCcg0RAXRDmg8ORYISNnL0nbh54Yi8FcA8zkATYpv6ZZevSawrrM HkauzIUWejBM1/r2dRNFpVkYHnGJPzX5PiwSBzxuIxjmehc7QUPWg7bS2TY3YCS+irrVzqUPhbWxG RRp0Kk9A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60674 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6ko-0002vK-1t; Wed, 06 Apr 2022 15:35:25 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6kn-004ik2-51; Wed, 06 Apr 2022 15:35:25 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 06/12] net: mtk_eth_soc: stop passing phylink state to sgmii setup MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:25 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073532_571693_AE1C3A2D X-CRM114-Status: GOOD ( 12.28 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that mtk_sgmii_setup_mode_force() only uses the interface mode from the phylink state, pass just the interface mode into this function. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- drivers/net/ethernet/mediatek/mtk_sgmii.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6fedfa8fceb1..7f29256b4b3c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -387,7 +387,7 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, /* Setup SGMIISYS with the determined property */ if (state->interface != PHY_INTERFACE_MODE_SGMII) err = mtk_sgmii_setup_mode_force(eth->sgmii, sid, - state); + state->interface); else if (phylink_autoneg_inband(mode)) err = mtk_sgmii_setup_mode_an(eth->sgmii, sid); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 1912f84922c8..93f150bb09dd 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1006,7 +1006,7 @@ int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *np, u32 ana_rgc3); int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id); int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, - const struct phylink_link_state *state); + phy_interface_t interface); void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex); void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id); diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index a5ec61e13b85..b656c8b3ca35 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -64,7 +64,7 @@ int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id) * fixed speed. */ int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, - const struct phylink_link_state *state) + phy_interface_t interface) { unsigned int val; @@ -73,7 +73,7 @@ int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, regmap_read(ss->regmap[id], ss->ana_rgc3, &val); val &= ~RG_PHY_SPEED_MASK; - if (state->interface == PHY_INTERFACE_MODE_2500BASEX) + if (interface == PHY_INTERFACE_MODE_2500BASEX) val |= RG_PHY_SPEED_3_125G; regmap_write(ss->regmap[id], ss->ana_rgc3, val); From patchwork Wed Apr 6 14:35:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803575 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 18CC5C433EF for ; Wed, 6 Apr 2022 14:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QMo1wZLq5Ul9uICp79+IEyQdbKvH8bOGxqOVqxyWP7A=; b=aBVUvLsb+vqQpa 284z4IEdtq1OxWWq61N1qCbcQAn/InDW75ikeFAa4cZmvxGZ1AFtRhV4MekqFqvaZAIMGkJtPmqA9 XQbEZVzkO3cggB4AGNVUFNrRUJbFDoWSDeVnSmCGtjerQmbar4dilE/bEGwYeVWyshF/h60DG60q3 FtvWJucb9c3A+VFWct9zXGtAMry5q2wVTVwda4cIM5UBIi7i3DRTLR0TkKNQnpSjziAm83CO8HGtR GdIWAH07BLE81rlVxQBjJmKviUi/UFTalJ5SlxEBMtXHBAKzUmhUO25Ev69eYGP/NK1bAGMuIwTLG ZGMvIQn5rXyBKGugVTnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6o0-006ZQg-JS; Wed, 06 Apr 2022 14:38:45 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6kz-006XwI-La; Wed, 06 Apr 2022 14:35:39 +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:References: In-Reply-To:Reply-To: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=C+mT+I7C+rLOYe6LNKXzFxNP6ULNetQoJpOopRm5OHY=; b=UGYzJtZnwvhZFBrjhlySSsm0je XuHys9yELk2KWm3ynxiYjR8MrDurnKPPskcq6ZXS/MwN/SCsyT1L4qd+ISX/dV5xX4z3+XTfM1dWx t90RrSeNZuNwCYVAjK/8Zel1sQhjmKxg3K1WenxL/z992dsYaNm3SkkxZZzXFth4hTvGw0xQ5lMis pei/ePQzXLT4RCy6UmhE+qFA8ARmI2agTW1ZeOUhw/cZLvbwbpS9bpeOHDKMv4ZknCiTggIiFf9hF RaPCIMhDPE9gEJmi1m/pKO//Z2NUWAyaV66OB4gMx4LUPlDtUviwFIckIBlE/mAajKnD5LHzDo0ip 1kY0g1Rw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60676 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6kt-0002vc-7Q; Wed, 06 Apr 2022 15:35:30 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6ks-004ik8-8j; Wed, 06 Apr 2022 15:35:30 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 07/12] net: mtk_eth_soc: provide mtk_sgmii_config() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:30 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073537_787162_466ED608 X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Provide mtk_sgmii_config() to wrap up the decisions about which SGMII configuration will be called. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 +------ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 5 ++--- drivers/net/ethernet/mediatek/mtk_sgmii.c | 20 +++++++++++++++++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 7f29256b4b3c..a16f02ed921a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -385,12 +385,7 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, 0 : mac->id; /* Setup SGMIISYS with the determined property */ - if (state->interface != PHY_INTERFACE_MODE_SGMII) - err = mtk_sgmii_setup_mode_force(eth->sgmii, sid, - state->interface); - else if (phylink_autoneg_inband(mode)) - err = mtk_sgmii_setup_mode_an(eth->sgmii, sid); - + err = mtk_sgmii_config(eth->sgmii, sid, mode, state->interface); if (err) goto init_err; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 93f150bb09dd..4be779109cff 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1004,9 +1004,8 @@ u32 mtk_r32(struct mtk_eth *eth, unsigned reg); int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *np, u32 ana_rgc3); -int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id); -int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, - phy_interface_t interface); +int mtk_sgmii_config(struct mtk_sgmii *ss, int id, unsigned int mode, + phy_interface_t interface); void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex); void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id); diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index b656c8b3ca35..57925910cf80 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -34,7 +34,7 @@ int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *r, u32 ana_rgc3) } /* For SGMII interface mode */ -int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id) +static int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id) { unsigned int val; @@ -63,8 +63,8 @@ int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id) /* For 1000BASE-X and 2500BASE-X interface modes, which operate at a * fixed speed. */ -int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, - phy_interface_t interface) +static int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, + phy_interface_t interface) { unsigned int val; @@ -96,6 +96,20 @@ int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, return 0; } +int mtk_sgmii_config(struct mtk_sgmii *ss, int id, unsigned int mode, + phy_interface_t interface) +{ + int err = 0; + + /* Setup SGMIISYS with the determined property */ + if (interface != PHY_INTERFACE_MODE_SGMII) + err = mtk_sgmii_setup_mode_force(ss, id, interface); + else if (phylink_autoneg_inband(mode)) + err = mtk_sgmii_setup_mode_an(ss, id); + + return err; +} + /* For 1000BASE-X and 2500BASE-X interface modes */ void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex) { From patchwork Wed Apr 6 14:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803576 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 B9068C433F5 for ; Wed, 6 Apr 2022 14:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7u2ogWaSOeR4MWd5DX6O3IEXWBTgOmGCBtMqLo+yiAI=; b=mKelTYZ1fiM9Rb +g1MyYb2HanDQvh1dUDA2dAATZPNPBDhBVffDAhZzF1V5i6Dw7qPJhlcIZLB0sLTx9D1Xk+PKqvdJ Fr3rOV2+mh86eq1DqAp/dyD4h+vC+wznSPfzDKeJVi3n8UwMbQ02Ra8XoNgLLv3lVULEybO18pu98 O52IA6pflDl4qM8ZLIIHQraW2YD0FNaJESo5b0p8/jVN/tGLIL0YPaRoZTSpk1PZeg6fsE51/o9M4 MwNAuDysAplp15OSAMudZv5z3tsOD8LN9yzBbinyTS4dHrdKhWhYQhRTqU09SYprFJjvWMdhPFRW9 r3q0BCEQ13rTpTTpPYiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6oi-006Zm2-TL; Wed, 06 Apr 2022 14:39:29 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6l6-006Xz2-Om; Wed, 06 Apr 2022 14:35:46 +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:References: In-Reply-To:Reply-To: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=XVocJGw0syYpnJfzHYQoJ7e5WCFSCvmwf3JsfDKxORE=; b=HStDEVrJMxvoW1fCf4q7HpZHJ4 sXul8yTcVhcd1yZRJhycRpQp4tIZb4ClisuuCF11mGe+tfAIRr9pLuUBD6OndEfFtud/lCV9kBPmP VRMzssRr0O6oIdbIBGcYMryvH+bzWI5VK8/T94wF2UYpcCcFwilQ6wHEs+d+yjGXRLcULL1ChCwH4 9W2M5NqeQ7Em0uEUf0kdUrqGeM6RHSXEhw5SAzVcbrZ77PzGe4Gra1TeMS03BDMN3GLHI1VNQUOR/ XPPzr0wBFNQle1qPk7jqYDcqHPr8NwdoMmfnt/5Zy3fY9Thxu9z74ipFRrfkMm2iKn4Ka3kQmoDF/ DdMFpa5g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60678 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6ky-0002vs-8g; Wed, 06 Apr 2022 15:35:35 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6kx-004ikJ-CY; Wed, 06 Apr 2022 15:35:35 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 08/12] net: mtk_eth_soc: add fixme comment for state->speed use MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:35 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073544_863545_E174C700 X-CRM114-Status: GOOD ( 14.13 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a fixme comment for the last remaining incorrect usage of state->speed in the mac_config() method, which is strangely in a code path which is only run when the PHY interface mode changes. This means if we are in RGMII mode, changes in state->speed will not cause the INTF_MODE, TRGMII_RCK_CTRL and TRGMII_TCK_CTRL registers to be set according to the speed, nor will the TRGPLL clock be set to the correct value. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index a16f02ed921a..b605a823dcd4 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -324,6 +324,14 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, state->interface)) goto err_phy; } else { + /* FIXME: this is incorrect. Not only does it + * use state->speed (which is not guaranteed + * to be correct) but it also makes use of it + * in a code path that will only be reachable + * when the PHY interface mode changes, not + * when the speed changes. Consequently, RGMII + * is probably broken. + */ mtk_gmac0_rgmii_adjust(mac->hw, state->interface, state->speed); From patchwork Wed Apr 6 14:35:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803577 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 3C917C433FE for ; Wed, 6 Apr 2022 14:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XZUowIYGt8c+d6+OiFOMfQwAZUvocV5+Cy09mpRSWls=; b=U54yZqTzf/ZWAY 0cTdp8TWiLXhh7MWYN8NYaJCkjg+kW3w/QRAquuMhF+Rd+KffRD8ibBKjOU4n/JVCsr+Rj3FjOhqr GK0k1YpyZbcwVSnuY1EPcI4kghQnN9cvr1SxhfZ/dYAm2DbpZTyjiyZdhVWQCpEab8w0BE0DGHqdQ +TGjqGZikhBkQwD1fn80/oyHsPf3AKHp3XF/M/y1f9bZiEH5vOtNf2fIpjcBCGQw8dJhw8eXj9OC4 lTpuiaYhqVyDdjccWGzw39aCghc/dPBh033fBahNTm0n8rQUXnKUPIXnAEPYrZrtAVso79p2k7QpT u5jv4gJADNbrPdmqgh/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6pN-006a78-4t; Wed, 06 Apr 2022 14:40:09 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6lA-006Y1V-Bj; Wed, 06 Apr 2022 14:35:49 +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:References: In-Reply-To:Reply-To: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=JQSlel8AieXouTtT5+5HawG7kkWOIrXmlkWdkVJz4w0=; b=uUiglIY6z87IBgcefc/BK5ruqQ 9wyur/5p18lnAAIt9AeBQsRpfQEG3IZSGXN7BRFRvgiLl0WtmvY49NAE81pNG9VnhPNA4IV3uh2+H /1sMbn2V8m4apuLzT6jvB9DNtglmuK7LUEM4gJkBTbY6t0egxbd6qRwP9zXL9fKWiCHSxAmsuXfmv 3VFY/8tq0h4yRoHmmjG6HwpJ+xSTK4paoIOwJX6Tt7u3A2bMmz5b9Cdwd9enwJELY9Q4bd3m3SsEe 5F1iT6jyqNXn2vBMAOs0XlyS8mVOeEMIn0+9Vv3iJ18u47YveiR39g3h9iFzm89Li8s3IYxXWRZgs 00nCWdtw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60680 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6l3-0002w4-Bu; Wed, 06 Apr 2022 15:35:41 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6l2-004ikQ-G0; Wed, 06 Apr 2022 15:35:40 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 09/12] net: mtk_eth_soc: move MAC_MCR setting to mac_finish() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:40 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073548_471310_43B70E90 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the setting of the MTK_MAC_MCR register from the end of mac_config into the phylink mac_finish() method, to keep it as the very last write that is done during configuration. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 33 ++++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index b605a823dcd4..2ede1ccc538b 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -266,8 +266,8 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, struct mtk_mac *mac = container_of(config, struct mtk_mac, phylink_config); struct mtk_eth *eth = mac->hw; - u32 mcr_cur, mcr_new, sid, i; int val, ge_mode, err = 0; + u32 sid, i; /* MT76x8 has no hardware settings between for the MAC */ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) && @@ -405,16 +405,6 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, return; } - /* Setup gmac */ - mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); - mcr_new = mcr_cur; - mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE | - MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK; - - /* Only update control register when needed! */ - if (mcr_new != mcr_cur) - mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id)); - return; err_phy: @@ -427,6 +417,26 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, mac->id, phy_modes(state->interface), err); } +static int mtk_mac_finish(struct phylink_config *config, unsigned int mode, + phy_interface_t interface) +{ + struct mtk_mac *mac = container_of(config, struct mtk_mac, + phylink_config); + u32 mcr_cur, mcr_new; + + /* Setup gmac */ + mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); + mcr_new = mcr_cur; + mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE | + MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK; + + /* Only update control register when needed! */ + if (mcr_new != mcr_cur) + mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id)); + + return 0; +} + static void mtk_mac_pcs_get_state(struct phylink_config *config, struct phylink_link_state *state) { @@ -531,6 +541,7 @@ static const struct phylink_mac_ops mtk_phylink_ops = { .mac_pcs_get_state = mtk_mac_pcs_get_state, .mac_an_restart = mtk_mac_an_restart, .mac_config = mtk_mac_config, + .mac_finish = mtk_mac_finish, .mac_link_down = mtk_mac_link_down, .mac_link_up = mtk_mac_link_up, }; From patchwork Wed Apr 6 14:35:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803578 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 DCD90C433F5 for ; Wed, 6 Apr 2022 14:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aKtOFIJv5dljnfZw7khvfabM1kg84KYMeMAvv1X9ka0=; b=FRwumvS796ZXFj QwOOUXgTPNGgOyh7fxbRLgzpixFDkmXyFiyzlRKbaMkAkxLkFxQvYe4H5iLuKmVFhgEN9fUQw2gMC IxGxb5gHL58nvqnckfzKabdfW1x788ish9OGmJ5mcJpx6hXY2149Vdx/NXXsEFobLx6Q6BTF9zoT8 L/gwLiEVzSM91qxaCml757aV6KVBoFyxhVWUKPaAM+uE2/Nhp9SsAc+8GrbcmyTltXbSLrf6E9DC5 MbctOpQh4PJnm2yK/sQ7Y97FlF2dAUEf1xN8NCcDLGDrtsqImb5/jh9A1o+i1LMQ1nkzicFcQEntb uuZVXzvDkkYNbUIKVPbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6q1-006aPr-Us; Wed, 06 Apr 2022 14:40:51 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6lE-006Y3c-QR; Wed, 06 Apr 2022 14:35:54 +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:References: In-Reply-To:Reply-To: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=mJ/2y9TIn3Crwly17sB8UaPx0ccqqplirtTuhQuWO04=; b=CKe9js/NrB3cJqZ/HEiE98KS4v WlzXBjWszeWnpmsBsaFBbtqkBpefUK60kjI9/ih2ny9iM/4tFALSLCzObo7gsbgduak1lEZ4yhPUu awQj0cR3Qy/SubeyI1c3L8joOTXdxAWGvvx1XRbkj+RZksK3bjyrmNH4XOOaSkSGoXW8OYFblG+Mg aMi48ubTul3xD6g+igAxRaJw9epJ1HO7FxsJ5XopRBeiFu5dcuAxHrTVQoZunFqDDhYmjWJYIWkJr J09WeC07GagZQ3vu0zTePOgl2wkgT4f57ACS+A0fPAvFmz2i1A+nMwL05F/4GhuWwjWvTIqPO8cG1 WDYID/xA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60682 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6l8-0002wS-FJ; Wed, 06 Apr 2022 15:35:46 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6l7-004ikW-JI; Wed, 06 Apr 2022 15:35:45 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 10/12] net: mtk_eth_soc: move restoration of SYSCFG0 to mac_finish() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:45 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073552_915234_63D0A9E7 X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The SGMIISYS configuration is performed while ETHSYS_SYSCFG0 is in a disabled state. In order to preserve this when we switch to phylink_pcs we need to move the restoration of this register to the mac_finish() callback. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 11 +++++++++-- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 2ede1ccc538b..0db2341f399f 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -397,8 +397,8 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, if (err) goto init_err; - regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0, - SYSCFG0_SGMII_MASK, val); + /* Save the syscfg0 value for mac_finish */ + mac->syscfg0 = val; } else if (phylink_autoneg_inband(mode)) { dev_err(eth->dev, "In-band mode not supported in non SGMII mode!\n"); @@ -422,8 +422,15 @@ static int mtk_mac_finish(struct phylink_config *config, unsigned int mode, { struct mtk_mac *mac = container_of(config, struct mtk_mac, phylink_config); + struct mtk_eth *eth = mac->hw; u32 mcr_cur, mcr_new; + /* Enable SGMII */ + if (interface == PHY_INTERFACE_MODE_SGMII || + phy_interface_mode_is_8023z(interface)) + regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0, + SYSCFG0_SGMII_MASK, mac->syscfg0); + /* Setup gmac */ mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); mcr_new = mcr_cur; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 4be779109cff..96f90e9fb9dd 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -991,6 +991,7 @@ struct mtk_mac { struct mtk_hw_stats *hw_stats; __be32 hwlro_ip[MTK_MAX_LRO_IP_CNT]; int hwlro_ip_cnt; + unsigned int syscfg0; }; /* the struct describing the SoC. these are declared in the soc_xyz.c files */ From patchwork Wed Apr 6 14:35:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803579 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 741D0C433F5 for ; Wed, 6 Apr 2022 14:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gv+pVP1nSh/lkVp0HlTxGi8yWed0rIzpU8aL6JrGOX8=; b=X0e9w0IeF5qjF9 gIYhs3GOBdDDEL6biBjXpQvjuCu/0mW1yJLjlEQmLKqocFc4ydKE84Q3OkvoRgcicKK4kqt/fcrAG lviuORhxTTdn1/2Hl8KLjYfhPL/wK64SvP5f/cgLrkq8F3oZPk7azYR1Rn6XIDZmoBPV5o2xnDxhI yTWZG4RQDsiWdnd+rAzl1T3hxDpsgaLiIvQKipdRV7JUvPybHxMJ6CaVH+KdT51clPKdXS13Aa2oF 7RuqoE0Lvqkr2EH49TWabiVlb3anYuHcIdscjnpSq/Xdm1e7yQPI0r+Aq5xGttyAYIj4nv2+K41Mu LV7S2ZtLJv9BExBhjnEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6qd-006ahd-Je; Wed, 06 Apr 2022 14:41:28 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6lK-006Y6C-KM; Wed, 06 Apr 2022 14:36:00 +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:References: In-Reply-To:Reply-To: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=3aELTLXSVHVJO4R6HumLWNbOhT+VYNeqFlfo7ug2NNg=; b=Nw/djBvZd/UIIuDaJ2NxqzZhXg ivTE/MOprwJfNGixXWgxLJNHlmKytO/RN351RT7RikuOB5DmeE5ugmJEmof6IeaaoXVu3arEP+bS5 Gw/zMi64uxCrJ9Fj8/g7hzG4FIheoVP3/3Z1fdkJF3oUfLx+Ks6TzBSylyjVIOVWw1JoS0PClYtmb VBH8WIPawyDLU7QJCn5xze6BkskhF7YT22cB3fYACmuJiZY9pyuRIg84F5nT38NNQQLGxrZKFUru4 nJXv/VqCVNBpXfawYj0ueVd+t7f255kBjboTrVkQF7cj5JVGv26vOTM1yIY+HOuXeotquYOV/nlp3 NyRfQExA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60684 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6lD-0002wi-Ke; Wed, 06 Apr 2022 15:35:51 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6lC-004ikc-NR; Wed, 06 Apr 2022 15:35:50 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 11/12] net: mtk_eth_soc: convert code structure to suit split PCS support MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:50 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073558_876537_69A86A4A X-CRM114-Status: GOOD ( 20.56 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Provide a mtk_pcs structure which encapsulates everything that the PCS functions need (the regmap and ana_rgc3 offset), and use this in the PCS functions. Provide shim functions to convert from the existing "mtk_sgmii_*" interface to the converted PCS functions. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 15 ++- drivers/net/ethernet/mediatek/mtk_sgmii.c | 121 +++++++++++--------- 2 files changed, 78 insertions(+), 58 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 96f90e9fb9dd..7de860c9d2e3 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -861,16 +861,23 @@ struct mtk_soc_data { /* currently no SoC has more than 2 macs */ #define MTK_MAX_DEVS 2 -/* struct mtk_sgmii - This is the structure holding sgmii regmap and its - * characteristics +/* struct mtk_pcs - This structure holds each sgmii regmap and associated + * data * @regmap: The register map pointing at the range used to setup * SGMII modes * @ana_rgc3: The offset refers to register ANA_RGC3 related to regmap */ +struct mtk_pcs { + struct regmap *regmap; + u32 ana_rgc3; +}; +/* struct mtk_sgmii - This is the structure holding sgmii regmap and its + * characteristics + * @pcs Array of individual PCS structures + */ struct mtk_sgmii { - struct regmap *regmap[MTK_MAX_DEVS]; - u32 ana_rgc3; + struct mtk_pcs pcs[MTK_MAX_DEVS]; }; /* struct mtk_eth - This is the main datasructure for holding the state diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index 57925910cf80..aac71eb4ac7c 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -9,89 +9,71 @@ #include #include +#include #include #include "mtk_eth_soc.h" -int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *r, u32 ana_rgc3) -{ - struct device_node *np; - int i; - - ss->ana_rgc3 = ana_rgc3; - - for (i = 0; i < MTK_MAX_DEVS; i++) { - np = of_parse_phandle(r, "mediatek,sgmiisys", i); - if (!np) - break; - - ss->regmap[i] = syscon_node_to_regmap(np); - if (IS_ERR(ss->regmap[i])) - return PTR_ERR(ss->regmap[i]); - } - - return 0; -} - /* For SGMII interface mode */ -static int mtk_sgmii_setup_mode_an(struct mtk_sgmii *ss, int id) +static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs) { unsigned int val; - if (!ss->regmap[id]) + if (!mpcs->regmap) return -EINVAL; /* Setup the link timer and QPHY power up inside SGMIISYS */ - regmap_write(ss->regmap[id], SGMSYS_PCS_LINK_TIMER, + regmap_write(mpcs->regmap, SGMSYS_PCS_LINK_TIMER, SGMII_LINK_TIMER_DEFAULT); - regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val); + regmap_read(mpcs->regmap, SGMSYS_SGMII_MODE, &val); val |= SGMII_REMOTE_FAULT_DIS; - regmap_write(ss->regmap[id], SGMSYS_SGMII_MODE, val); + regmap_write(mpcs->regmap, SGMSYS_SGMII_MODE, val); - regmap_read(ss->regmap[id], SGMSYS_PCS_CONTROL_1, &val); + regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &val); val |= SGMII_AN_RESTART; - regmap_write(ss->regmap[id], SGMSYS_PCS_CONTROL_1, val); + regmap_write(mpcs->regmap, SGMSYS_PCS_CONTROL_1, val); - regmap_read(ss->regmap[id], SGMSYS_QPHY_PWR_STATE_CTRL, &val); + regmap_read(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, &val); val &= ~SGMII_PHYA_PWD; - regmap_write(ss->regmap[id], SGMSYS_QPHY_PWR_STATE_CTRL, val); + regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, val); return 0; + } /* For 1000BASE-X and 2500BASE-X interface modes, which operate at a * fixed speed. */ -static int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, - phy_interface_t interface) +static int mtk_pcs_setup_mode_force(struct mtk_pcs *mpcs, + phy_interface_t interface) { unsigned int val; - if (!ss->regmap[id]) + if (!mpcs->regmap) return -EINVAL; - regmap_read(ss->regmap[id], ss->ana_rgc3, &val); + 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(ss->regmap[id], ss->ana_rgc3, val); + regmap_write(mpcs->regmap, mpcs->ana_rgc3, val); /* Disable SGMII AN */ - regmap_read(ss->regmap[id], SGMSYS_PCS_CONTROL_1, &val); + regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &val); val &= ~SGMII_AN_ENABLE; - regmap_write(ss->regmap[id], SGMSYS_PCS_CONTROL_1, val); + regmap_write(mpcs->regmap, SGMSYS_PCS_CONTROL_1, val); /* Set the speed etc but leave the duplex unchanged */ - regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val); + regmap_read(mpcs->regmap, SGMSYS_SGMII_MODE, &val); val &= SGMII_DUPLEX_FULL | ~SGMII_IF_MODE_MASK; val |= SGMII_SPEED_1000; - regmap_write(ss->regmap[id], SGMSYS_SGMII_MODE, val); + regmap_write(mpcs->regmap, SGMSYS_SGMII_MODE, val); /* Release PHYA power down state */ - regmap_read(ss->regmap[id], SGMSYS_QPHY_PWR_STATE_CTRL, &val); + regmap_read(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, &val); val &= ~SGMII_PHYA_PWD; - regmap_write(ss->regmap[id], SGMSYS_QPHY_PWR_STATE_CTRL, val); + regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, val); return 0; } @@ -99,44 +81,75 @@ static int mtk_sgmii_setup_mode_force(struct mtk_sgmii *ss, int id, int mtk_sgmii_config(struct mtk_sgmii *ss, int id, unsigned int mode, phy_interface_t interface) { + struct mtk_pcs *mpcs = &ss->pcs[id]; int err = 0; /* Setup SGMIISYS with the determined property */ if (interface != PHY_INTERFACE_MODE_SGMII) - err = mtk_sgmii_setup_mode_force(ss, id, interface); + err = mtk_pcs_setup_mode_force(mpcs, interface); else if (phylink_autoneg_inband(mode)) - err = mtk_sgmii_setup_mode_an(ss, id); + err = mtk_pcs_setup_mode_an(mpcs); return err; } -/* For 1000BASE-X and 2500BASE-X interface modes */ -void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex) +static void mtk_pcs_restart_an(struct mtk_pcs *mpcs) +{ + unsigned int val; + + if (!mpcs->regmap) + return; + + regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &val); + val |= SGMII_AN_RESTART; + regmap_write(mpcs->regmap, SGMSYS_PCS_CONTROL_1, val); +} + +static void mtk_pcs_link_up(struct mtk_pcs *mpcs, int speed, int duplex) { unsigned int val; /* SGMII force duplex setting */ - regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val); + regmap_read(mpcs->regmap, SGMSYS_SGMII_MODE, &val); val &= ~SGMII_DUPLEX_FULL; if (duplex == DUPLEX_FULL) val |= SGMII_DUPLEX_FULL; - regmap_write(ss->regmap[id], SGMSYS_SGMII_MODE, val); + regmap_write(mpcs->regmap, SGMSYS_SGMII_MODE, val); +} + +/* For 1000BASE-X and 2500BASE-X interface modes */ +void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex) +{ + mtk_pcs_link_up(&ss->pcs[id], speed, duplex); +} + +int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *r, u32 ana_rgc3) +{ + struct device_node *np; + int i; + + for (i = 0; i < MTK_MAX_DEVS; i++) { + np = of_parse_phandle(r, "mediatek,sgmiisys", i); + if (!np) + break; + + ss->pcs[i].ana_rgc3 = ana_rgc3; + ss->pcs[i].regmap = syscon_node_to_regmap(np); + if (IS_ERR(ss->pcs[i].regmap)) + return PTR_ERR(ss->pcs[i].regmap); + } + + return 0; } void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id) { - struct mtk_sgmii *ss = eth->sgmii; - unsigned int val, sid; + unsigned int sid; /* Decide how GMAC and SGMIISYS be mapped */ sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? 0 : mac_id; - if (!ss->regmap[sid]) - return; - - regmap_read(ss->regmap[sid], SGMSYS_PCS_CONTROL_1, &val); - val |= SGMII_AN_RESTART; - regmap_write(ss->regmap[sid], SGMSYS_PCS_CONTROL_1, val); + mtk_pcs_restart_an(ð->sgmii->pcs[sid]); } From patchwork Wed Apr 6 14:35:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12803589 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 B7CD7C433EF for ; Wed, 6 Apr 2022 14:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NXkLfP7vulbEx8X72yNEnDpj9zi5udcPqSEwOyuTCe4=; b=V7VH6kHeEv06df sFQ7SpY4/I9vTPeFmt90sq8flmwy6nt9XKPEN78pTW2QtaHS3iI6WXZ7mzqeb0bCzjwbdVW6KsFZS QDEi7sV6R+TzsU6w0WcvF/SxcjoisUuPeNBjKAuUzB2LJcbvv9NvgIkOQ34WBDfTeKOnC4TyuegOj tFUc+HBg1YFubODxM10foqhoVLXIO7MSnLE2RyXNo8vhkxjRUDtRPbcjqfl+1RvMNeevO9VxlvJhc Lxq0z/EQQ7UdlugmWKO+CjIsbwadgMHzGK3JqBqzpxjvBrtSp2IZtF5aFlaB6QhI+Ye0O+/nhI++x gSWKL0cvoXoZg/LlU2CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6r9-006axT-0S; Wed, 06 Apr 2022 14:41:59 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc6lQ-006Y8Q-1Z; Wed, 06 Apr 2022 14:36:06 +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:References: In-Reply-To:Reply-To: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=InOuFeKOhi5b+0cenuAkGRX26M4ti/ZbX6nZ1bpPm4Y=; b=oJTnZq9X1Mejotk2iNTQt4VvWB vy1nFNPQAlQFE2MTgCJj/+YQpEs+U/UXUa1oSaI6M0EwSuvRTL7Oglz6HSlc+I+SlcEszevllejBR aBqcst3wgeXWeovia2fAOklYIyT7z6fu2OvmSXNmc+OCFF4JzA/o3TJI/UFj+L7HxhP9Z8MM/oIHr wx014y3XAxM2bIMZcGPe6D+ra1nQaMQsW0PFvHlaI9sviXrlzpsRmVNbZr3WZLW/E8MZU4kc6ap3f ttC1c9eDqyQuBIFqD2NNQhfXdV17ubjZm43qs84h0YUUq9LneKbnuz8hCbnu4gknHMRG7/BlBBKH8 819wQ+OQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60686 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nc6lI-0002wy-Om; Wed, 06 Apr 2022 15:35:56 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nc6lH-004iki-Rb; Wed, 06 Apr 2022 15:35:55 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Marek =?iso-8859-1?q?Beh=FAn?= Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 12/12] net: mtk_eth_soc: partially convert to phylink_pcs MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 06 Apr 2022 15:35:55 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_073604_285113_44D2EEDE X-CRM114-Status: GOOD ( 19.71 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Partially convert mtk_eth_soc to phylink_pcs, moving the configuration, link up and AN restart over. However, it seems mac_pcs_get_state() doesn't actually get the state from the PCS, so we can't convert that over without a better understanding of the hardware. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 49 ++++++++---------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 7 ++- drivers/net/ethernet/mediatek/mtk_sgmii.c | 55 +++++++++++---------- 3 files changed, 53 insertions(+), 58 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 0db2341f399f..874fec43fb35 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -260,6 +260,25 @@ static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, mtk_w32(eth, val, TRGMII_TCK_CTRL); } +static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config, + phy_interface_t interface) +{ + struct mtk_mac *mac = container_of(config, struct mtk_mac, + phylink_config); + struct mtk_eth *eth = mac->hw; + unsigned int sid; + + if (interface == PHY_INTERFACE_MODE_SGMII || + phy_interface_mode_is_8023z(interface)) { + sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? + 0 : mac->id; + + return mtk_sgmii_select_pcs(eth->sgmii, sid); + } + + return NULL; +} + static void mtk_mac_config(struct phylink_config *config, unsigned int mode, const struct phylink_link_state *state) { @@ -267,7 +286,7 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, phylink_config); struct mtk_eth *eth = mac->hw; int val, ge_mode, err = 0; - u32 sid, i; + u32 i; /* MT76x8 has no hardware settings between for the MAC */ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) && @@ -388,15 +407,6 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, SYSCFG0_SGMII_MASK, ~(u32)SYSCFG0_SGMII_MASK); - /* Decide how GMAC and SGMIISYS be mapped */ - sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? - 0 : mac->id; - - /* Setup SGMIISYS with the determined property */ - err = mtk_sgmii_config(eth->sgmii, sid, mode, state->interface); - if (err) - goto init_err; - /* Save the syscfg0 value for mac_finish */ mac->syscfg0 = val; } else if (phylink_autoneg_inband(mode)) { @@ -476,14 +486,6 @@ static void mtk_mac_pcs_get_state(struct phylink_config *config, state->pause |= MLO_PAUSE_TX; } -static void mtk_mac_an_restart(struct phylink_config *config) -{ - struct mtk_mac *mac = container_of(config, struct mtk_mac, - phylink_config); - - mtk_sgmii_restart_an(mac->hw, mac->id); -} - static void mtk_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface) { @@ -504,15 +506,6 @@ static void mtk_mac_link_up(struct phylink_config *config, phylink_config); u32 mcr; - if (phy_interface_mode_is_8023z(interface)) { - struct mtk_eth *eth = mac->hw; - - /* Decide how GMAC and SGMIISYS be mapped */ - int sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? - 0 : mac->id; - mtk_sgmii_link_up(eth->sgmii, sid, speed, duplex); - } - 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 | @@ -545,8 +538,8 @@ static void mtk_mac_link_up(struct phylink_config *config, static const struct phylink_mac_ops mtk_phylink_ops = { .validate = phylink_generic_validate, + .mac_select_pcs = mtk_mac_select_pcs, .mac_pcs_get_state = mtk_mac_pcs_get_state, - .mac_an_restart = mtk_mac_an_restart, .mac_config = mtk_mac_config, .mac_finish = mtk_mac_finish, .mac_link_down = mtk_mac_link_down, diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 7de860c9d2e3..209ab2a1433c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -866,10 +866,12 @@ struct mtk_soc_data { * @regmap: The register map pointing at the range used to setup * SGMII modes * @ana_rgc3: The offset refers to register ANA_RGC3 related to regmap + * @pcs: Phylink PCS structure */ struct mtk_pcs { struct regmap *regmap; u32 ana_rgc3; + struct phylink_pcs pcs; }; /* struct mtk_sgmii - This is the structure holding sgmii regmap and its @@ -1010,12 +1012,9 @@ void mtk_stats_update_mac(struct mtk_mac *mac); void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg); u32 mtk_r32(struct mtk_eth *eth, unsigned reg); +struct phylink_pcs *mtk_sgmii_select_pcs(struct mtk_sgmii *ss, int id); int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *np, u32 ana_rgc3); -int mtk_sgmii_config(struct mtk_sgmii *ss, int id, unsigned int mode, - phy_interface_t interface); -void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex); -void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id); int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id); int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id); diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index aac71eb4ac7c..647745284318 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -14,14 +14,16 @@ #include "mtk_eth_soc.h" +static struct mtk_pcs *pcs_to_mtk_pcs(struct phylink_pcs *pcs) +{ + return container_of(pcs, struct mtk_pcs, pcs); +} + /* For SGMII interface mode */ static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs) { unsigned int val; - if (!mpcs->regmap) - return -EINVAL; - /* Setup the link timer and QPHY power up inside SGMIISYS */ regmap_write(mpcs->regmap, SGMSYS_PCS_LINK_TIMER, SGMII_LINK_TIMER_DEFAULT); @@ -50,9 +52,6 @@ static int mtk_pcs_setup_mode_force(struct mtk_pcs *mpcs, { unsigned int val; - if (!mpcs->regmap) - return -EINVAL; - regmap_read(mpcs->regmap, mpcs->ana_rgc3, &val); val &= ~RG_PHY_SPEED_MASK; if (interface == PHY_INTERFACE_MODE_2500BASEX) @@ -78,10 +77,12 @@ static int mtk_pcs_setup_mode_force(struct mtk_pcs *mpcs, return 0; } -int mtk_sgmii_config(struct mtk_sgmii *ss, int id, unsigned int mode, - phy_interface_t interface) +static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) { - struct mtk_pcs *mpcs = &ss->pcs[id]; + struct mtk_pcs *mpcs = pcs_to_mtk_pcs(pcs); int err = 0; /* Setup SGMIISYS with the determined property */ @@ -93,22 +94,25 @@ int mtk_sgmii_config(struct mtk_sgmii *ss, int id, unsigned int mode, return err; } -static void mtk_pcs_restart_an(struct mtk_pcs *mpcs) +static void mtk_pcs_restart_an(struct phylink_pcs *pcs) { + struct mtk_pcs *mpcs = pcs_to_mtk_pcs(pcs); unsigned int val; - if (!mpcs->regmap) - return; - regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &val); val |= SGMII_AN_RESTART; regmap_write(mpcs->regmap, SGMSYS_PCS_CONTROL_1, val); } -static void mtk_pcs_link_up(struct mtk_pcs *mpcs, int speed, int duplex) +static void mtk_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, int speed, int duplex) { + struct mtk_pcs *mpcs = pcs_to_mtk_pcs(pcs); unsigned int val; + if (!phy_interface_mode_is_8023z(interface)) + return; + /* SGMII force duplex setting */ regmap_read(mpcs->regmap, SGMSYS_SGMII_MODE, &val); val &= ~SGMII_DUPLEX_FULL; @@ -118,11 +122,11 @@ static void mtk_pcs_link_up(struct mtk_pcs *mpcs, int speed, int duplex) regmap_write(mpcs->regmap, SGMSYS_SGMII_MODE, val); } -/* For 1000BASE-X and 2500BASE-X interface modes */ -void mtk_sgmii_link_up(struct mtk_sgmii *ss, int id, int speed, int duplex) -{ - mtk_pcs_link_up(&ss->pcs[id], speed, duplex); -} +static const struct phylink_pcs_ops mtk_pcs_ops = { + .pcs_config = mtk_pcs_config, + .pcs_an_restart = mtk_pcs_restart_an, + .pcs_link_up = mtk_pcs_link_up, +}; int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *r, u32 ana_rgc3) { @@ -138,18 +142,17 @@ int mtk_sgmii_init(struct mtk_sgmii *ss, struct device_node *r, u32 ana_rgc3) ss->pcs[i].regmap = syscon_node_to_regmap(np); if (IS_ERR(ss->pcs[i].regmap)) return PTR_ERR(ss->pcs[i].regmap); + + ss->pcs[i].pcs.ops = &mtk_pcs_ops; } return 0; } -void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id) +struct phylink_pcs *mtk_sgmii_select_pcs(struct mtk_sgmii *ss, int id) { - unsigned int sid; - - /* Decide how GMAC and SGMIISYS be mapped */ - sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? - 0 : mac_id; + if (!ss->pcs[id].regmap) + return NULL; - mtk_pcs_restart_an(ð->sgmii->pcs[sid]); + return &ss->pcs[id].pcs; }