From patchwork Mon Feb 13 21:35:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 56569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2590047wrn; Mon, 13 Feb 2023 13:40:26 -0800 (PST) X-Google-Smtp-Source: AK7set8ulEvSpupI1Gkb7ccHXtr2SLgai8+JiVzVmzSDkbDd1a0lrGhoup6yO6G8SB4qczR68edQ X-Received: by 2002:a17:906:17d9:b0:8aa:f2f2:7541 with SMTP id u25-20020a17090617d900b008aaf2f27541mr330345eje.77.1676324426244; Mon, 13 Feb 2023 13:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676324426; cv=none; d=google.com; s=arc-20160816; b=pTJqGUUslDDoq+/eaboEc45SKCb9D2cHqvG1vDhlQV7IikuRGqPOT3/iyw2f1zdSPG DXftbouuBvba94IX96H9LWL6ogO9r/HiSJyYxGB4/fkCuhQwRwGXsvge6Ag7qFU60AzV SBpikQlcZ/+oKCYqLrXJtXeYy3tVpitkkXSaxbWuP2+Q3PxcOJwTgtgt5RaNEsKPojih 4WyI0IpGKj2CgJmPO2MNCvgSlmcFVY4C9vKAowR/poUnyx02KLWiR/mxky+v26NzajkM FkQtu39jaFYbftqb82fqp1fNkMBG1FaakQXTc13ffT0fk7/Na2Pfj1c0WggMEXmJHS7/ KJfg== 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=imUqDsDsTnN6TzyPkJl2MweVqJaemfJmn6DHV6HpG4507VWdhpMPyPi3yfPkCrAcsc rXS+6yWst8Bw91GXFnh6JszZu159Sz6IRYGC0K4Vz8OONi8EB/lu9sj6i9VVsajfu1UG afIOk7nGm9AD+7Qr7QtykDfj1KskXejOuUcoVbcNm9tMgtuqQsk26Nqq4KrdcU5XGmwH RPWMGYSyaSxN4kBa5V+n8R/+tx8VehVq3HIwUJg6WYOvGTnDTeLTaCQZ/uoy1BXT0kv4 7RKXzULBrgUSgaJEFKJUMKrHFty+h/lEN7QE3r0oAepqCxtQ88l7DZ/YhVfcpu8SFKyH uaeA== 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 b5-20020aa7c905000000b004ab15fb03fcsi14420720edt.421.2023.02.13.13.40.03; Mon, 13 Feb 2023 13:40:26 -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 S230164AbjBMVha (ORCPT + 99 others); Mon, 13 Feb 2023 16:37:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjBMVh2 (ORCPT ); Mon, 13 Feb 2023 16:37:28 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EDC02196A; Mon, 13 Feb 2023 13:37:06 -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 1pRgVU-0006hg-1Q; Mon, 13 Feb 2023 22:37:04 +0100 Date: Mon, 13 Feb 2023 21:35:29 +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 v6 06/12] net: ethernet: mtk_eth_soc: reset PCS state Message-ID: <8e05777b11bfcbefb6aa7642fcc80a33177a3fe1.1676323692.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?1757753561055217542?= X-GMAIL-MSGID: =?utf-8?q?1757753561055217542?= 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,