Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp526404qtg; Wed, 5 Apr 2023 13:42:56 -0700 (PDT) X-Google-Smtp-Source: AKy350aKC0OTTHK2pTfVAINrhwV2TbkvrynPMxYxMTnx9WrbtTWw0NHUCVM5naecy2SV2Obn4YRa X-Received: by 2002:a17:906:144d:b0:93f:fbe:ed17 with SMTP id q13-20020a170906144d00b0093f0fbeed17mr4030001ejc.62.1680727376140; Wed, 05 Apr 2023 13:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680727376; cv=none; d=google.com; s=arc-20160816; b=iAhWMww5wwWnFltLEp7/j9wzmxhzDr/fW21WJJPAYDXNIkT8Q9gUVYR2MxbsYutToc vsih7HKdMKDkerf89PifJf3cLa6GifpJWmoHIMeU8eu0uLWX2GCELsu9tkj/gdvCCE4R HGBMZjv6R2jqNdQovnNeqS88BPafuZQdECqs2FkafP37Ep7pPgfKLI4d+BiG4bPb6yM4 STCPkR6SPeFunxNDb2xxkvHRGTWGz9EUqG/wTcG9V2Xom/egoPoXjiWzz4X36gueF9HT nXrFDLsBFQtlDbwd0A34beuWK08tegzecW3JLFXse0r9DLlIHPxJfV8Le8eNpGDB/F4U Gfgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a9BgVJEEYWS/nr7ufBquG0YTtl1dQzZWs/MVrntK8ZE=; b=ToEdZMNy6cunGKvDKoRD1/3UO8twevHt1MjtR55MaGprCFrurRg7D4TxnBROU3xVnc kyR+EnXrMivqIan14Hk7O+sa9uRMpL1cK4/NaVDrsEdxqMH5uenU1IEAauVl8r5WJ3yn S5GVJEI0pnfM6Huwmy4N1wzz3jQ7d+NSALYs59FvIduOdJMAD1TW42WZe8CMQu3EuJw8 Upc6Fa0pSPQkcVNALUzMgAjeiXqdDpq4kG69IONqkD+unDypL4Ehq502iUB6e9vQUR1p o3ULdWLAcPPihrg3GuP77pmsZkL583emVB+c5PHlDYxbiWPAIh3Jr2bkobTRJES2juAB KFkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PkCe8EUw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb23-20020a170906add700b009268b9aa263si10927121ejb.306.2023.04.05.13.42.31; Wed, 05 Apr 2023 13:42:56 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PkCe8EUw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234629AbjDEUkv (ORCPT + 99 others); Wed, 5 Apr 2023 16:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234377AbjDEUkP (ORCPT ); Wed, 5 Apr 2023 16:40:15 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 183E765B2; Wed, 5 Apr 2023 13:39:32 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id l15-20020a05600c4f0f00b003ef6d684102so19156961wmq.3; Wed, 05 Apr 2023 13:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680727170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a9BgVJEEYWS/nr7ufBquG0YTtl1dQzZWs/MVrntK8ZE=; b=PkCe8EUwo59MuxO0b6KKI0EmM0HxoC38GvoQCL9HKBu3Pi5g9oGx43peL0MKckQs05 9GTz+/qxJf8/I4YzJWNBHoxaqLYtCgzAi+4f3uduLglyaLnYD8bvZYKoMHf5SSvgNBrV 7ASNECmnIIspbW3qf7+L4jOm3cisQ42pq0C2zRANZt9PBwUTXmU4HV2ZE31zBqtBO7T0 Rnw7v6ZpKZdutrO2fHfH9Hi2hZ5dEftWF2d+Z73dcyXWJ3QsHayuBm8tzTjHTGb+ph/E JzpsdA2CZPlKGb0u5yldIRaZ8s5eu93/BO+XocnBJwc3GTWOQJ/rJXA1295X0tm5hTSs XDtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680727170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a9BgVJEEYWS/nr7ufBquG0YTtl1dQzZWs/MVrntK8ZE=; b=oINRtDsAlSuUp0EMLSBrfeSObCH5W+TDEx/tom3Qus78lCiS807/KudDhinohB1WG3 KsUtLT0pBvs1WRK8NBv5J2WaV41FC6tgiIpD574OlhVBdxB+rN+VV3n4yKqf53Hfv7BU OoKVxiaoblr69i+ewVVSDufIBAvH/vNOPrmA/6klmqBe5XmYliYpUHxkhoegedYtQbp5 Dc/3xmILoIXVkqmqfSmuo5LKzu0sFAnauMiGjtpIwFNw5z6ie4Q/1g9PvSj1n/+Dihs3 /itZqZRYLmYALo5MMtNlzL04qZXQATISpnU0M/ymgpcXpVhD8FBSYJnsWqAxHttzxDfY U1BQ== X-Gm-Message-State: AAQBX9eGJE6J6m+yA1baDDtTIRVlXAAbf9X2L+JHGyQFYNeTuXgIbc1L +BltphkL5Ypf+OW994W6kdI= X-Received: by 2002:a1c:7211:0:b0:3ef:7584:9896 with SMTP id n17-20020a1c7211000000b003ef75849896mr5529893wmc.26.1680727170331; Wed, 05 Apr 2023 13:39:30 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id p19-20020a05600c469300b003eda46d6792sm3259867wmo.32.2023.04.05.13.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 13:39:29 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= , Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Cc: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Ilya Lipnitskiy , Richard van Schagen , Richard van Schagen , Frank Wunderlich , erkin.bozoglu@xeront.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [RFC PATCH net-next 11/12] net: dsa: mt7530: set TRGMII RD TAP if trgmii is being used Date: Wed, 5 Apr 2023 23:38:58 +0300 Message-Id: <20230405203859.391267-12-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230405203859.391267-1-arinc.unal@arinc9.com> References: <20230405203859.391267-1-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 From: Arınç ÜNAL This code sets the Read Data (RD) TAP value to 16 for all TRGMII control registers. The for loop iterates over all the TRGMII control registers, and mt7530_rmw() function is used to perform a read-modify-write operation on each register's RD_TAP field to set its value to 16. This operation is used to tune the timing of the read data signal in TRGMII to match the TX signal of the link partner. Run this if trgmii is being used. Since this code doesn't lower the driving, there's no apparent benefit to run this if trgmii is not being used. Add a comment to explain the code. Thanks to 趙皎宏 (Landen Chao) for pointing out what the code does. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index fe496d865478..384e601b2ecd 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -404,7 +404,7 @@ static int mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; - u32 ncpo1, ssc_delta, xtal, val; + u32 ncpo1, ssc_delta, i, xtal, val; val = mt7530_read(priv, MT7530_MHWTRAP); val &= ~MHWTRAP_P6_DIS; @@ -464,6 +464,11 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) /* Enable the MT7530 TRGMII clocks */ core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN); + + /* Set the Read Data TAP value of the MT7530 TRGMII */ + for (i = 0; i < NUM_TRGMII_CTRL; i++) + mt7530_rmw(priv, MT7530_TRGMII_RD(i), + RD_TAP_MASK, RD_TAP(16)); } return 0; @@ -2227,10 +2232,6 @@ mt7530_setup(struct dsa_switch *ds) mt7530_write(priv, MT7530_TRGMII_TD_ODT(i), TD_DM_DRVP(8) | TD_DM_DRVN(8)); - for (i = 0; i < NUM_TRGMII_CTRL; i++) - mt7530_rmw(priv, MT7530_TRGMII_RD(i), - RD_TAP_MASK, RD_TAP(16)); - /* Enable PHY access and operate in manual mode */ val = mt7530_read(priv, MT7530_MHWTRAP); val &= ~MHWTRAP_PHY_ACCESS; -- 2.37.2