From patchwork Tue Mar 14 00:34:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 69207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1485336wrd; Mon, 13 Mar 2023 17:38:03 -0700 (PDT) X-Google-Smtp-Source: AK7set/Boh3s148q1uiomd4plhWIcN2N7vabXjIjTGg27uSFe9Rv5sY7tMtPbEa2tDrcrFo7+1vW X-Received: by 2002:a05:6102:3f09:b0:411:b165:704d with SMTP id k9-20020a0561023f0900b00411b165704dmr14786729vsv.34.1678754283287; Mon, 13 Mar 2023 17:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678754283; cv=none; d=google.com; s=arc-20160816; b=wyr6YoFdNV0Mm61bP8XItVJrLJXgK/HeV0bI1/j9JVehvO9+2zSGpt/k8ucpfuSwb4 JlxAGed91nUd51Xc6PT1RV20bD27IBzwaKxTEle+zHTYgSsx5+2fRGPvqJmTw1ftbjCR SQm2O7aNH6+sxWFpTLodakP7R07Vsnyp70BuLdU6qS1YGQGVbf7B6qQg1qPc0NR95qSM sLQs1WCN7/yrLxL+xjtGS4seJtF0Ijw4/iCCztiV+R/O0yFlorSucCtPgqbSnMY9bOBE VVPM8UVuqI58o6eCP2IoqBdPcWzpQOAB0xBux+o564hXrIPBlBefBX1cz7pqdcI4o0si XL4Q== 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=AFpSdl91p+yHkJBKisXVGqbEGN/oM0+lPdNuX2ACPOw=; b=qNdnXuLB4PR+m7svhB9Jkb36hbqaF6WHLEsRU7gwxPKo576cHVYZrUnBIcN5rjc19F DG680NckW2OQzTmDn7gSZ553+PTTYvohcW/28Sm3ZRF2e4O2pUHjJ+HSyPDhjeu1gB5q x8/tvt6AaoxoZhe84avSk65rPEytI4TILZZdLZkcJ38pQmS6FLHtLLgwUpUdmv2HPThW GggIxfjvM7cL1Kd8qMbRbVHaZ8V6JUndGBV1/mPmvv0r5XTNHtUoOd8Z34cMq125RTnQ bq4cdN9eRokZOrsaT1/8p8eM13WWivVuo+z9tAMQpCXiFWy5NyVl6oiw2aGWt2rao8c1 wFEg== 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 dc2-20020a056102558200b00421ebc4e850si474457vsb.504.2023.03.13.17.37.48; Mon, 13 Mar 2023 17:38:03 -0700 (PDT) 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 S230105AbjCNAgN (ORCPT + 99 others); Mon, 13 Mar 2023 20:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjCNAgJ (ORCPT ); Mon, 13 Mar 2023 20:36:09 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1770F81CF9; Mon, 13 Mar 2023 17:36:06 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pbse4-0005Ly-1O; Tue, 14 Mar 2023 01:36:04 +0100 Date: Tue, 14 Mar 2023 00:34:26 +0000 From: Daniel Golle To: devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , 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 , Vladimir Oltean Cc: =?iso-8859-1?q?Bj=F8rn?= Mork , Frank Wunderlich , Alexander Couzens Subject: [PATCH 1/2] 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?1760301451191997593?= X-GMAIL-MSGID: =?utf-8?q?1760301451191997593?= Reset the internal PCS state machine when changing interface mode. This prevents confusing the state machine when changing interface modes, e.g. from SGMII to 2500Base-X or vice-versa. Fixes: 7e538372694b ("net: ethernet: mediatek: Re-add support SGMII") 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 b65de174c3d9..084a6badef6d 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -542,6 +542,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 bb00de1003ac..612f65bb0345 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 (interface == PHY_INTERFACE_MODE_2500BASEX) rgc3 = RG_PHY_SPEED_3_125G; else