Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6658296rwr; Tue, 25 Apr 2023 01:33:26 -0700 (PDT) X-Google-Smtp-Source: AKy350abP50iaHDilz2hXyM9LYHL6AjwSxFlmxjhVcpTzdjsxuvfzGu49N1qsLNOUSMp6F2dy0XS X-Received: by 2002:a17:903:1209:b0:1a6:4606:6e06 with SMTP id l9-20020a170903120900b001a646066e06mr20472674plh.17.1682411606110; Tue, 25 Apr 2023 01:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682411606; cv=none; d=google.com; s=arc-20160816; b=hvfra03ZF4TDQ2mg0qcieNXJEAoi4a2+ggfrYrFAm9Lt+c97y6gBZytohMJ9eeaLt7 MJwO08QPD5VUFKjy/HQgRL6T97cjBHvKTnYHxLO0CHdv3MAZFntzcdRs71DEgIHDveWU 424kQUCDUUU9zePAiH+8y+DRBDZDElMCOwL+028NFW9BcICVAHg85MEKvUQ8yUj16cOo z7p3E95llCUEbw6lZbLiI8tPSQ7xTNJePZW+qIA9WkEXhdPnqHYFuJou2lN6JbRT9Ljm dNlxyS/eDQ0OgOzxP9Bg1xrPAq/LQ3olLenoFwmwhEv//7B70rYf0Q0lK2PcAI7MoMlq bv2Q== 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=BDhIHtzgrt1JK0OHDfth9yreKDguDZ1mwE1kdBlBcjc=; b=p39Is4wW+OJDXLaICKk4/Thf2mP4c1Jk0LrmU75Ty4LjmCvqQmE645MnvvVcByB2bC ZyYWLMw4/h8tRAJ1mm8k3Ji7omdPAc5ehxUYF7Zj/ailFHf8ub9fLptZFH1Uet9nLmYy Hhv5SY5AcbOOu5upqwnYW4O3aR3ZvmWJXD32sS95VKoJQU+JqrBvXeBCcYfqTSZ/xDWk uAobJmHWExp/48JHVKyCUwy7R6dXU6RjCMgFICzj0s4Is4yYivzwchckVQyEGzWfh6/P q6G+QPVq1Xx3bskB40VfboE4fWKtn5/epLKFxov29rHb97/6Z5k9OG22occJDjbxlglI W1xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="Vs7/n3A1"; 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 q13-20020a170902bd8d00b001a531f29044si12342632pls.521.2023.04.25.01.33.15; Tue, 25 Apr 2023 01:33:26 -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=20221208 header.b="Vs7/n3A1"; 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 S233731AbjDYIc4 (ORCPT + 99 others); Tue, 25 Apr 2023 04:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233765AbjDYIbp (ORCPT ); Tue, 25 Apr 2023 04:31:45 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 257CF13C24; Tue, 25 Apr 2023 01:30:45 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-50506111a6eso10011019a12.1; Tue, 25 Apr 2023 01:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682411432; x=1685003432; 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=BDhIHtzgrt1JK0OHDfth9yreKDguDZ1mwE1kdBlBcjc=; b=Vs7/n3A14u40HN1zzZMUGkdqqU9uVQOs1pjNjF0fMuwj/qtPPRYsXL8b4BPsX4RZAC srr/fOeNSSA3GQpurqa6UjH0SXhSXTUUDfXwDYOF/UeakUP8z1XSZWUrwNml3PlzJ4zY gveSaBym8bK7QvSbG9pEwPvdz1obEtHS/Nh9TK73tGzL2ScCyyXbn49Ulel2kKoTUs+M tPLK6wCoGlIJR0Q19k4rvJZJ3Cb0UEgOjWzkqOLqKOtVCbY34t0v6/PNeoFJ1m2wY08+ qxOPb43iBf3jUBBmUynwG5OwA1xsMqWZd+raPGX5d1g2nBsSpzBez9f90x1cycfwA5mo xiuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682411432; x=1685003432; 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=BDhIHtzgrt1JK0OHDfth9yreKDguDZ1mwE1kdBlBcjc=; b=A6DIFy4vs+jUk+71JNNiJe83/drpYQhiDykNqNAHUGZKy7/42DujIUebwOrEb0jrO2 FZxn4CzCgLM2TfTHWcawvIXDNc81zspDwE+sspP9m+L1eDIlbYsGNoqFyXXSUf9lHLEu IxjDVTxsV5X5zs6Vkll/KC89+1RrsTXGyCqZKwYQ2PPeWSvWviFgXcb/2HqoODmvvY9u GYe8ykrcg5yYzrWzzAwXRM2f9YtQ+Ufe5GYjMkThOz160ul5zxFF8SUl7XgK/N+/KdfQ /FmA9h41Az/ECKXPsgqbdpqms6GUHkSddfpTHjrPKAToBuG3h8A5DHGu1G4E6vGQoS8C eU4A== X-Gm-Message-State: AAQBX9cu0XBKcCcHpxMxGyavwZcRZeHxyLV1ll40oLyd+qARouccKuFz B3ivPQeR0xzCLNJjbC+VUKE= X-Received: by 2002:a17:906:3086:b0:94a:8291:a1e3 with SMTP id 6-20020a170906308600b0094a8291a1e3mr11236909ejv.74.1682411432342; Tue, 25 Apr 2023 01:30:32 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id mc2-20020a170906eb4200b0094ca077c985sm6439028ejb.213.2023.04.25.01.30.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 01:30:31 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: 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?= , Richard van Schagen , Richard van Schagen , Frank Wunderlich , Bartel Eerdekens , 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: [PATCH net-next 16/24] net: dsa: mt7530: set TRGMII RD TAP if trgmii is being used Date: Tue, 25 Apr 2023 11:29:25 +0300 Message-Id: <20230425082933.84654-17-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230425082933.84654-1-arinc.unal@arinc9.com> References: <20230425082933.84654-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 ea023e32313c..0108af681d50 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -404,7 +404,7 @@ static void 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; @@ -457,6 +457,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)); } } @@ -2214,10 +2219,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