Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2526804lqp; Mon, 25 Mar 2024 01:11:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW24IsD38Mo+b8efbiw4HkNBp2t06nBA0vpNg5dp9+1QQJGzUK+2w22fu+7nKidcQY1QHK8ZbPUEYNLRX2aOIrIUvXcUcG2zjbmEtuk3Q== X-Google-Smtp-Source: AGHT+IFuqODRgl/dnGc6FjY2wg1qwzYvxaBwSEyS2lNSbOhydbHaYf4chZ12KkNom0q/o9/aiFxn X-Received: by 2002:ac8:5755:0:b0:431:4e6d:e40e with SMTP id 21-20020ac85755000000b004314e6de40emr4653452qtx.45.1711354265642; Mon, 25 Mar 2024 01:11:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711354265; cv=pass; d=google.com; s=arc-20160816; b=b9mFGV6s5QIvvrR7UAebE1IEeOtviFHx50MroOu32VHy4yqtyn2MY4wTbbPmj5eLg8 0YUagU4ToV1PbG0t8bMFF3ffXhlsWQlkjuKki5p8d65FS/Bf1mahTzVgTLub4MnWS5lF GAG2R4/fOT58lstX1euKHXoidrcJBzz4uO4cm/YSVwG7c+E/awRp6NAiXaNzu5bzVTe0 hvbBP2ztU3rK5Urp6uLuqnDKQbZeGFoLgSaWyfLxz5X2JwR2W8bhAYisbd0GQOCAUchq qJPOLjpSwnyd78q9F88pQmhUI/Uns7HZyxFgcsMeApsD08kLM5VjOjb+NIxtcZPRWkG5 BwKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=buOpV7lIEcn2RDm5SsKNbosoxqRPBvlwvDtgnQlyqU8=; fh=CoIu91pS++sbOHO/8gCCXVRAwIeNlUftt7vhUb+IqUs=; b=IwvjVzfj5wbc/t8p0cYZtPf1+T4UWzz6+X6vYd1Edf2kBV8UTDtSJI3MerZagoR8Vo N8ZyEX8iho+ene7OJCtPKoOU6rh+Mwy9Gily5RTOq291oSwPltLGWLGvytz99Br9nEjY u7kmi2GMtnjyu9GI4ojKO3l6GrJW0Ou9qVqhovA6+i51gBVD5IgcD4t/eUM8+yeUVoiZ RZpw6HrlPftDlQEiG+ED113K+3da98GsaCzFzyoKOceexuTmuK+WsVvtIFOx33URZyUo npLOQjsli4oSY4mm7vm/PsnB8JIjpwbY71+/GRRssTYCo/W6ClK3abzyS60rcN98aDAc ej0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qUSX+/mq"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r13-20020a05622a034d00b00431500fd3fcsi2443522qtw.372.2024.03.25.01.11.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 01:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qUSX+/mq"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 602791C2F597 for ; Mon, 25 Mar 2024 08:11:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 223112669F8; Mon, 25 Mar 2024 03:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qUSX+/mq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C5231487F8; Sun, 24 Mar 2024 23:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322145; cv=none; b=Q8gs8hbHgvTpPAHNGNSJbqlzS9ecD35oxgFuZLNUT7GhVhBVEQX89W857OhCd0jPsBWpmRHO0WVcO+VfusOeHLcNYyuovN/7xqcWuQrceTkUmDAoCXxzpBEdcVG3Nyr02L1ZaWZl1IXUW0mA7n1Llf5f7WiegeJ4nPV29kOay7E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322145; c=relaxed/simple; bh=2DvJvaZyFK9vHNgI+suBjYVyGIRaLvxgXFom/JoexWE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oailKz4w+3cycjRxSh7yLrf7o2YRgmKsdMNfExFM9upmmBRYCpWxOJ9Cp4oK4UBcgkCIaqV59a1OVdKwaaIOk5C4XhHd8400QoewDxVxzC1Xq1oth+wO/iXGSlRJBghNQkwnaWw/Ti+8d5IfiKi0KX9D3qgbKhKtsm2Ps76H3to= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qUSX+/mq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88021C433F1; Sun, 24 Mar 2024 23:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322145; bh=2DvJvaZyFK9vHNgI+suBjYVyGIRaLvxgXFom/JoexWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUSX+/mqpQJWjKOBmr71gAq83CcFFFocgCw/i+PCkuo1cd7LrDv2F68aJ99fN+Czi BfcJXB1BGrklIhKWGKVmI9ajCqblEURgU8dwgvAVD1r8/fI89uL506uEIf+cwvhFIX xcjqMB/9k5ChoRHZf6gI83rGm2qMIaxurhHBY33eaAiyJ1wZxWY0S66cEjFoP/BZgT 0mLYR9s0ERlnIIcP3IYlKfCMvQkf+nWsuOugi1qkzpB0R6V2XN5FuLa8PYnTdfOX52 hK+UpyolZCMKKMcoZUmvee4LOnZSkn+t6f4DROkcoUsTPp6bDD9H3Vs+uTnryJ1iKu 4/C6QbciGfv4Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tim Pambor , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 222/451] net: phy: dp83822: Fix RGMII TX delay configuration Date: Sun, 24 Mar 2024 19:08:18 -0400 Message-ID: <20240324231207.1351418-223-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Tim Pambor [ Upstream commit c8a5c731fd1223090af57da33838c671a7fc6a78 ] The logic for enabling the TX clock shift is inverse of enabling the RX clock shift. The TX clock shift is disabled when DP83822_TX_CLK_SHIFT is set. Correct the current behavior and always write the delay configuration to ensure consistent delay settings regardless of bootloader configuration. Reference: https://www.ti.com/lit/ds/symlink/dp83822i.pdf p. 69 Fixes: 8095295292b5 ("net: phy: DP83822: Add setting the fixed internal delay") Signed-off-by: Tim Pambor Link: https://lore.kernel.org/r/20240305110608.104072-1-tp@osasysteme.de Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/phy/dp83822.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index 267e6fd3d4448..57411ee1d8374 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -380,7 +380,7 @@ static int dp83822_config_init(struct phy_device *phydev) { struct dp83822_private *dp83822 = phydev->priv; struct device *dev = &phydev->mdio.dev; - int rgmii_delay; + int rgmii_delay = 0; s32 rx_int_delay; s32 tx_int_delay; int err = 0; @@ -390,30 +390,33 @@ static int dp83822_config_init(struct phy_device *phydev) rx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, true); - if (rx_int_delay <= 0) - rgmii_delay = 0; - else - rgmii_delay = DP83822_RX_CLK_SHIFT; + /* Set DP83822_RX_CLK_SHIFT to enable rx clk internal delay */ + if (rx_int_delay > 0) + rgmii_delay |= DP83822_RX_CLK_SHIFT; tx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, false); + + /* Set DP83822_TX_CLK_SHIFT to disable tx clk internal delay */ if (tx_int_delay <= 0) - rgmii_delay &= ~DP83822_TX_CLK_SHIFT; - else rgmii_delay |= DP83822_TX_CLK_SHIFT; - if (rgmii_delay) { - err = phy_set_bits_mmd(phydev, DP83822_DEVADDR, - MII_DP83822_RCSR, rgmii_delay); - if (err) - return err; - } + err = phy_modify_mmd(phydev, DP83822_DEVADDR, MII_DP83822_RCSR, + DP83822_RX_CLK_SHIFT | DP83822_TX_CLK_SHIFT, rgmii_delay); + if (err) + return err; + + err = phy_set_bits_mmd(phydev, DP83822_DEVADDR, + MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); - phy_set_bits_mmd(phydev, DP83822_DEVADDR, - MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); + if (err) + return err; } else { - phy_clear_bits_mmd(phydev, DP83822_DEVADDR, - MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); + err = phy_clear_bits_mmd(phydev, DP83822_DEVADDR, + MII_DP83822_RCSR, DP83822_RGMII_MODE_EN); + + if (err) + return err; } if (dp83822->fx_enabled) { -- 2.43.0