From patchwork Tue Feb 7 14:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 53925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp4038338dyf; Tue, 7 Feb 2023 06:25:24 -0800 (PST) X-Google-Smtp-Source: AK7set/59MUa/2e8TpkONtDNHhVxQ5mXcpgwUSC+KczyIaHIBBMe/+yaTwGQFxIZI0fM/vkMptKH X-Received: by 2002:a17:906:3810:b0:887:dea8:b025 with SMTP id v16-20020a170906381000b00887dea8b025mr3557659ejc.65.1675779924411; Tue, 07 Feb 2023 06:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675779924; cv=none; d=google.com; s=arc-20160816; b=XmbmI1Dp2Rw/o0O5onCfKGN6B4N1QvJgS8ldnTfyRFigWG7ftMO0RlRnmngOJGFjLd Qa/FG2JCPRuBmOpQtTBi5yIIVTvB8ZbRRmrFUKOnisTE66Wb0ZgupN1eQxhgZyrGLTLr 7CF1/tHhidHCNidHFsYP7FmBnuxxuiLji/HIhMvOiuSEwVj2ebYt8ANtvC8AxIyQbXTi NZi9AFwPiTEG+cXOUPzyR7bs6A0elwBk3l9e7W1Sw0I3hUtGtYEZRbZRYEJjCmBDlep3 5KtcBPFJw2JYrWtu1HIwPv3SQ+QLtCsOITpNnVH6lsZQdrQlCKVKGBPsVRSqFXAWyFB3 9rQw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=wfxXvdyld1pR6LfZ335c/2XNJuEFetYgjZhY5OVuVVg=; b=a8ZP6YvJossODc5cRPWD6hmRWjj5n1dTe+hw29gzBRqATuPJF0YrYtEXzH8MwbGcOF RIujU6xWEsjzAAFNFG6aEpt0PGtiyWsq5OdWPhThX3bKteOvoH5+U0nUU9BMrSmbQrjG Ne+Ixxvl4D2hRuiosl7uV5B5vHHyCXklJcOhTka8Yol9jqCWOMOq5cMjQ6LhOjMSGT+u BLx3AViHXEp20TwWl3xmRX1wTyRraRuaOHSVj3aZDbZPwQ27cnupDR7n925WggOdmFL4 Iui8vP639dTcT6E/goTiVs6DyrDDkiJjtPT3NubncbFj/dWgB97oBHVehqZr09Edrrtp okmw== 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 w18-20020a170906969200b0088f88d1d352si14696948ejx.202.2023.02.07.06.25.01; Tue, 07 Feb 2023 06:25:24 -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 S232470AbjBGOW5 (ORCPT + 99 others); Tue, 7 Feb 2023 09:22:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232524AbjBGOWu (ORCPT ); Tue, 7 Feb 2023 09:22:50 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE9C23C288; Tue, 7 Feb 2023 06:22:40 -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 1pPOrn-0002A1-00; Tue, 07 Feb 2023 15:22:39 +0100 Date: Tue, 7 Feb 2023 14:21:02 +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 v2 05/11] net: ethernet: mtk_eth_soc: reset PCS state Message-ID: 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?1757182609949880254?= X-GMAIL-MSGID: =?utf-8?q?1757182609949880254?= Reset PCS state when changing interface mode. Signed-off-by: Daniel Golle Reviewed-by: Russell King (Oracle) --- 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 0071352c93ba..d8184448cd5a 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,