From patchwork Thu Feb 9 23:31: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: 55130 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp636545wrn; Thu, 9 Feb 2023 15:35:18 -0800 (PST) X-Google-Smtp-Source: AK7set8BjuO0vPyhvbS6ZGwqsDqD7Qqc0stxM9KevCKrkfuen9gm98y/CfrnBIQdzKe6ParJN7Hy X-Received: by 2002:a17:902:e844:b0:196:8dce:82eb with SMTP id t4-20020a170902e84400b001968dce82ebmr14536806plg.66.1675985718651; Thu, 09 Feb 2023 15:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675985718; cv=none; d=google.com; s=arc-20160816; b=kCOEeDknp3Xk1NGVtbOuYsjTxnhXjvAdPA8Uu6d94OaGveq5XFQH8gsLL6pcWaXMou dSkpuTBqsppTMTAlXYpKEYk5O8LJzwHEOYpAgQcC5FXLaUwsCtZL40HoW+rRFJ/piEn4 s4vhaxY+5UJjV/ZUUj268eYmtV5u+aLo0UrAD3u32fQ8qF4CqMh9oRIKhXQk74XYkRDd Vn6+BPKItgxnleofMgPz6b75C2DSDuacnDfo2KwDCtdHqIkJJe2B1A/32/gglTRHtTP4 57Ut7a70pH/LD3lJCfwMoUlrjRP93qoV3dEz71jG6r1Rj5t6lkwbKQs10y30i08OYF6i y4Gw== 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=UJb+YsDMMWMrwFnVoAupA5tny2and+LmluzWoZT+5Is=; b=WUYfy4JkTI2w1EqcwHf2f+7dE2r5m0n2o3OVRMzyok+NUMCsSFZgCH4gwPqPrV3OwY kvHboxOHSWVr3jaWVgatbZCVuaFoIzxpH/6ME3vrhF7OOvK700uE8VukiGCJR7azkomi WBPq9WJ2NdnleA/23cOt3IXK/kBWDeAMruYmx6HOhF5dC+ZHRM3leuKxpqAYe+4/tcax FVV37zSTVd5OQnmSdq30DKbKbnhwYmAMwQdOKLYOF0Ramib0ooiJRGNSAM9BUhFuBLAm AUP9jYCrlDa4498VkWoqB1T9eFLuStLgpzF1+HuoqU23I/i68GAj7B3RUquRegAOq7NE 1D2g== 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 b12-20020a170902d50c00b001964a32a321si3330107plg.522.2023.02.09.15.35.05; Thu, 09 Feb 2023 15:35:18 -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 S230523AbjBIXdA (ORCPT + 99 others); Thu, 9 Feb 2023 18:33:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230516AbjBIXcy (ORCPT ); Thu, 9 Feb 2023 18:32:54 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D34131E31; Thu, 9 Feb 2023 15:32:52 -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 1pQGPK-0002GU-23; Fri, 10 Feb 2023 00:32:50 +0100 Date: Thu, 9 Feb 2023 23:31: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 v3 06/12] net: ethernet: mtk_eth_soc: reset PCS state Message-ID: <9de6402e09536d1c1a95d28615c1ed2aba223dbd.1675984550.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?1757398400945338928?= X-GMAIL-MSGID: =?utf-8?q?1757398400945338928?= Reset PCS state when changing interface mode. 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,