From patchwork Fri Feb 10 23:38:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 55646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1235526wrn; Fri, 10 Feb 2023 15:41:56 -0800 (PST) X-Google-Smtp-Source: AK7set+GrIvJcJbG9Di9SvQG7mGf0HP+HhqsgJ9yCzMKywAQj6HgpVvzhw0MTb+HUDPUkuU8c/rf X-Received: by 2002:a50:d4c6:0:b0:4aa:a571:bf38 with SMTP id e6-20020a50d4c6000000b004aaa571bf38mr17419012edj.24.1676072516568; Fri, 10 Feb 2023 15:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676072516; cv=none; d=google.com; s=arc-20160816; b=0WAaobjTC6QpmVCoFw2Yam4CHARW3YI0KWyrhWgRosJ77cjwahz8cbU4c/Jw7Mmv/P 2bfTjde348DsZOwyC3+VZwPVmyttjcwFfC3pDO+uhLp4IPSGFlS5EVAg2wVe7ocfN6I6 synrE960v+a/knMlHWHZZtlPMuHQyIlL2pIJFGyYGUWVWGopqMYQ2t/PNDpnW3RVMyDX KfXjavd8oLxP/I5Y0pcEQ+xY4VYE9kZIkUYbW0cF8lCQROM6QEW1ZG3ELxLAs7hO6mbj hg17+aWGfuYcu2T6pdQx3kq+NfWklXnDqlkS1a/97KFbt7bW8Hc30WBViQhh7DHEZoMa P+dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JwcrMfNgF63gIrZ/GkmsQ7CjfsIvdJXRwyJlJfugE+g=; b=r2JTYlNNSeiwDJz4bW5c1zl+daGgrBM3QBuyyfStZEik/y8BBLE0mWyhiuGR4dEEnc MVQoFW4mZmMy19ZCaYf+8Gy3BFNo6jcc9ngU30Ekzv3d6eD5eSiCmEQHFkPEh3K4OkmF isJN/J+V6xgB9beByDokWm9nm+M79S1AhQt+9f/Yua9MeshteLQ1GoAuOXdfsFmQETFm loZJFBZoAOOvqjo+ewCt823ABvqIJvDxU9BKkIdYZaDsd42ffu86iwnZxtyOaXG+RvKK 76QRkNbo4aRq3BoU3aY1nsd+qlRc0lEm6hi1bQFR/8Lvx/Sr7kaTjlt5b3Xme2KW/09E 2iTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020aa7d44d000000b004aadaee6ddbsi6261363edr.525.2023.02.10.15.41.30; Fri, 10 Feb 2023 15:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbjBJXk3 (ORCPT + 99 others); Fri, 10 Feb 2023 18:40:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjBJXk2 (ORCPT ); Fri, 10 Feb 2023 18:40:28 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D774840E5; Fri, 10 Feb 2023 15:40:00 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pQczh-0004Ci-2O; Sat, 11 Feb 2023 00:39:53 +0100 Date: Fri, 10 Feb 2023 23:38:13 +0000 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Russell King , Heiner Kallweit , Lorenzo Bianconi , Mark Lee , John Crispin , Felix Fietkau , AngeloGioacchino Del Regno , Matthias Brugger , DENG Qingfang , Landen Chao , Sean Wang , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Vladimir Oltean , Florian Fainelli , Andrew Lunn Cc: Jianhui Zhao , =?iso-8859-1?q?Bj=F8rn?= Mork Subject: [PATCH v4 06/12] net: ethernet: mtk_eth_soc: reset PCS state Message-ID: <9983a2ee3f1e42b9515852e4faa590225ffcd521.1676071508.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757489414657385700?= X-GMAIL-MSGID: =?utf-8?q?1757489414657385700?= Reset PCS state when changing interface mode. Reviewed-by: Russell King (Oracle) Tested-by: Bjørn Mork Signed-off-by: Daniel Golle --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++++ drivers/net/ethernet/mediatek/mtk_sgmii.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 7014c02ba2d4..142def8629c8 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -548,6 +548,10 @@ #define SGMII_SEND_AN_ERROR_EN BIT(11) #define SGMII_IF_MODE_MASK GENMASK(5, 1) +/* Register to reset SGMII design */ +#define SGMII_RESERVED_0 0x34 +#define SGMII_SW_RESET BIT(0) + /* Register to set SGMII speed, ANA RG_ Control Signals III*/ #define SGMSYS_ANA_RG_CS3 0x2028 #define RG_PHY_SPEED_MASK (BIT(2) | BIT(3)) diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c index d7ffaaeaf9ab..d7e7352041a4 100644 --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c @@ -88,6 +88,10 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode, regmap_update_bits(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD, SGMII_PHYA_PWD); + /* Reset SGMII PCS state */ + regmap_update_bits(mpcs->regmap, SGMII_RESERVED_0, + SGMII_SW_RESET, SGMII_SW_RESET); + if (mpcs->flags & MTK_SGMII_FLAG_PN_SWAP) regmap_update_bits(mpcs->regmap, SGMSYS_QPHY_WRAP_CTRL, SGMII_PN_SWAP_MASK,