Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2379781lqp; Sun, 24 Mar 2024 16:49:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIl+kDeOMjXHVowYoo/P9JyoEzdj0nQ0LYxtY2hjWot32kBD9EnH6iW6FdH7SZ/CblDx+nT5gV+2qNBZXwQ9l2SOF4Y6oo4JveM01j8A== X-Google-Smtp-Source: AGHT+IGXLqHkLqejEP0eUo8GZ538s/3t+d/QKXwRpdRhdk9nEkaCxAKeXj9d4gGO898oODA2T4eA X-Received: by 2002:a05:6214:2345:b0:696:236b:f2a0 with SMTP id hu5-20020a056214234500b00696236bf2a0mr5915078qvb.28.1711324150830; Sun, 24 Mar 2024 16:49:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324150; cv=pass; d=google.com; s=arc-20160816; b=udZXC0Eg6dg3QdZEyHWoJ3WXC82ePGnekqhd1M4cwABCOeJlO8Qj/BSQx6eYhAHiRq Iu6NvFs+fE6qLTGdfcwg7Qx09ocf/chl+WNl+PPsJEG7sBulUE1VDy0UOpwpDbo0IjNC w7wkkSJdUTiMpzbbwVUFg6kUDMB/Ir5xjMRf3aDvsyNQpeyaWQIDDhlP7WMpcK92Lo2D N0SjOvV5EjQf7i17mZGAaLK1DIX9BmiOCuedqPqtHq1TL9djqgcpcXz2Kb3bndj0OATI GMXcfrrp5qbUz1GF2MrHCiyGKxPKx460PdnjvKL4+ilI1Um0VJ5KWSvmJXXymIOU3HV1 hcqQ== 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=6GiIhKDjdJ9Nxp654dRlWKooMeQPBY+tG/DgdSZapLY=; fh=CoIu91pS++sbOHO/8gCCXVRAwIeNlUftt7vhUb+IqUs=; b=Aaui+OSvt16622JUsyHYXEea7/wAnMR9+y2k6D1ciAXc7w+ORLwMMxYPU6aM4JJ5kv iGQxLfbnlgUtHfc7xvspR+2N+FSEAP3VYuVXUxvYJrCq8LEDFg9DveszB49Ms8zBp8Uu 5DKHpOCp5GpdldgvQ8tw/HdD5o1UahY7323rN+lxoie2SIY7mA0t3XGQ9Zd4/Vz8dEu2 h7jcymrWlrg5f5nZQaSIuokcxessb4iJGFFMMaCbSmMEbaJ0dIIjBIyKbtaXYYdaocfo q5g0tb9/9t2zVfH3icHjvUadmv3ugqXOGi5trACcNV36EzDYnsio+87/dEQKzs1cOuGj tlRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kY60L++Y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113225-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fo9-20020ad45f09000000b006961c193123si6772020qvb.304.2024.03.24.16.49.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:49:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kY60L++Y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113225-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 8554B1C228D7 for ; Sun, 24 Mar 2024 23:49:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B253182742; Sun, 24 Mar 2024 22:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kY60L++Y" 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 42010181D0A; Sun, 24 Mar 2024 22:40:26 +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=1711320026; cv=none; b=G5ZSIbmP/FMrndAjaXMAJPNnNwYyTN61izuCCPkQ6Hf9quv82onFHZ1RMkBiodu/alT7iJsj9XsOHcFAwbFA49YMljNLdG3JdOdVfiCt5cyEov/YGNZmHecmFFRb2RgN27noB5RcNq9j8XPBEz/9rmW49lTfbFZRoBY+xfszcW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320026; c=relaxed/simple; bh=eHTqfpRH4w1jwSBCjC/7u/xx40HMa+l75jbyu7n46y0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CiFEyfppM4P4xbvTm6muqEx8e0NiLcTXxv3j34JBg7VcrXB2NqCV0l4cOWeeFt69n1lo0MSe6OzTlx8VufhmFSSHKfsymj8+qbkj7vLoxb4uhTcm2PSfrnzarEZ8Wmac4joQ18+brPPxQjS4DYdUU+t0FGhH4pyP6a5795X/bF0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kY60L++Y; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79261C43390; Sun, 24 Mar 2024 22:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320026; bh=eHTqfpRH4w1jwSBCjC/7u/xx40HMa+l75jbyu7n46y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kY60L++YfIyJMIc32UnFOrHGfBcV2eGA7AYVNx2hygmnu2tABNDfnqRdBf1df+tXa n+JGdJWwMLWgFlNNUuNiRDEgbVk2FSuaXGREc6KTFmmUsKkQLIpOucET3f+7Jg1T5+ a4F5J3VXRSj6rQKpD2OhqQoaHTTLwbKuLELkznB/1+SdUHqSnTnGLkKp6wE7gL94Sa LynpYxOgLQfYtGEeCFpfAmFUUHZauGJr56LK2TezJz8Y8HqBwvk01pG5oQHjErKz83 pg/WZMBBI45pM9yInomqS4KrSCNdMXFflPrDI3fvmFXMDGcnfR4h3E+hOFfb8QSkcw xhF63J8jDX03g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tim Pambor , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.8 334/715] net: phy: dp83822: Fix RGMII TX delay configuration Date: Sun, 24 Mar 2024 18:28:33 -0400 Message-ID: <20240324223455.1342824-335-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 b7cb71817780c..29e1cbea6dc0c 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