Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3628245pxb; Mon, 24 Jan 2022 13:54:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtZTF9UL4hk50e1NxAl+D5e9DbLgIbJ7GVKMCVKKaOMwFLyjP//Q/DVo2erkHUDP+OhsUw X-Received: by 2002:a17:902:e750:b0:14b:4bef:a2e0 with SMTP id p16-20020a170902e75000b0014b4befa2e0mr6794266plf.2.1643061240830; Mon, 24 Jan 2022 13:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061240; cv=none; d=google.com; s=arc-20160816; b=NxH0CPrlaEOArgvRW8aWBXAfH0czyXItAA5Hqxq73/STUr6DiDmxQJIf4UhuoZ9TZB JFhEMRfdzT0iRjryBq1sX2/VxN6Q8UvHQUUCrUjiiviPSG8iH0UuTayRi2lohm5quBXg NIuvoNRN73rdaO687lLofSTPq9LiMSvHWjcGtfyZppUfHcO+Zg9PFvxpa1SxzW1i+olB OZDn3eNLHobWqvgvsOCOS+Jy49agP0L//tMgogQbtChjILqpb5TMlNVJimKlXsiADDbx 8JE/n07HQtNEDNqtxakuDEgBnmnr6uxdscg79odlRproHR281/TLbxQ01SoGnj8r79AZ 8IDA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gVP4AeJAA1uEZVDiTyJ6P0dad0i8MF5r8kkb8avr14I=; b=ghRD3sO/9nyXfaDNW1TYH528qav4GbzuX83leZ30tZNOS50rXWEeV5HbjZvinwXkeX uKrSBxhavSNn80n7j32YtBMpRMNfqdTg+79lpod387c+M8ZUUmjNjsR8NHgLN5NRr2oE rF+exiBoKJq7sWdQ1Bv7QGE6mI75QMsjJUNVOhYZnss30nWTGRGS2NMOrY9DXcZSpRBC yldycS2cOeATqf3Gei+8iCvoxRDbv215DrLqtDYpUD0Pgw7Sz2goNFf77IddBUx89CPz k8J9DC+nJp3bFy3aAhOlMNOZA0qkH5ny6lVSzWBRPCOshdguNJiPv8ZiQwklRCaAWV8A qv+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wTWlIEJH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x15si1745139pla.221.2022.01.24.13.53.48; Mon, 24 Jan 2022 13:54:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wTWlIEJH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351467AbiAXVhL (ORCPT + 99 others); Mon, 24 Jan 2022 16:37:11 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:52752 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444838AbiAXVBi (ORCPT ); Mon, 24 Jan 2022 16:01:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 21ED0611C8; Mon, 24 Jan 2022 21:01:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCDA1C340E5; Mon, 24 Jan 2022 21:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058097; bh=YuuSrqYlWfqBWeMQ4MbvsTRyHLnB3n4XxO178j8t/cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wTWlIEJHUj+SvR86COfrF5+QtM6FCY8NVkyYJvtfAIPSZ5IW00TUEtKV+DxJUJGX0 X2BW5ridq/ZrGibioCzuFr4qizkkUfc0k3rkgyO4ymPRVp+9hQW9bvGpawyuCAQMeQ h2ohs/jRLrpH9pcRw1NRCXvUwgCkl9toF6aAqj0I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , "David S. Miller" , Sasha Levin Subject: [PATCH 5.16 0180/1039] net: dsa: rtl8365mb: set RGMII RX delay in steps of 0.3 ns Date: Mon, 24 Jan 2022 19:32:49 +0100 Message-Id: <20220124184131.329846146@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin Šipraga [ Upstream commit ef136837aaf6f37f2dec78551671a6883f868d69 ] A contact at Realtek has clarified what exactly the units of RGMII RX delay are. The answer is that the unit of RX delay is "about 0.3 ns". Take this into account when parsing rx-internal-delay-ps by approximating the closest step value. Delays of more than 2.1 ns are rejected. This obviously contradicts the previous assumption in the driver that a step value of 4 was "about 2 ns", but Realtek also points out that it is easy to find more than one RX delay step value which makes RGMII work. Fixes: 4af2950c50c8 ("net: dsa: realtek-smi: add rtl8365mb subdriver for RTL8365MB-VC") Cc: Arınç ÜNAL Signed-off-by: Alvin Šipraga Acked-by: Arınç ÜNAL Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/rtl8365mb.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/rtl8365mb.c b/drivers/net/dsa/rtl8365mb.c index 078ca4cd71605..48c0e3e466001 100644 --- a/drivers/net/dsa/rtl8365mb.c +++ b/drivers/net/dsa/rtl8365mb.c @@ -767,7 +767,8 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_smi *smi, int port, * 0 = no delay, 1 = 2 ns delay * RX delay: * 0 = no delay, 7 = maximum delay - * No units are specified, but there are a total of 8 steps. + * Each step is approximately 0.3 ns, so the maximum delay is about + * 2.1 ns. * * The vendor driver also states that this must be configured *before* * forcing the external interface into a particular mode, which is done @@ -778,10 +779,6 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_smi *smi, int port, * specified. We ignore the detail of the RGMII interface mode * (RGMII_{RXID, TXID, etc.}), as this is considered to be a PHY-only * property. - * - * For the RX delay, we assume that a register value of 4 corresponds to - * 2 ns. But this is just an educated guess, so ignore all other values - * to avoid too much confusion. */ if (!of_property_read_u32(dn, "tx-internal-delay-ps", &val)) { val = val / 1000; /* convert to ns */ @@ -794,13 +791,13 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_smi *smi, int port, } if (!of_property_read_u32(dn, "rx-internal-delay-ps", &val)) { - val = val / 1000; /* convert to ns */ + val = DIV_ROUND_CLOSEST(val, 300); /* convert to 0.3 ns step */ - if (val == 0 || val == 2) - rx_delay = val * 2; + if (val <= 7) + rx_delay = val; else dev_warn(smi->dev, - "EXT port RX delay must be 0 to 2 ns\n"); + "EXT port RX delay must be 0 to 2.1 ns\n"); } ret = regmap_update_bits( -- 2.34.1