From patchwork Sat Nov 14 20:01:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 11905823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 059EF14C0 for ; Sat, 14 Nov 2020 20:02:15 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C310B2231B for ; Sat, 14 Nov 2020 20:02:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZoT3zUX5"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="hmVK45Xu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C310B2231B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yayz8h+gOJXHQ3HxKdulg4RbLtm8LrTY9gK/AWWyHr8=; b=ZoT3zUX5RBgBHB+ooFTxFgoXo Ei+iVQEfKd67h4/fDi/+P9CzFjJDl0fIE4zNqznEEFTzqKtGf6l/tNc7MjPZ/xCHhSZ1JrHRo3Y6D Qo36WQthJDk/dGL5dhQM4gmBPskb7LzK7eZ3DvRbjBsQTueDwCxeS11+f9ExAxUbezwh1dAu5mULG lCWqeWgVjeJXXqh2qROo+pkMrSwizBMQaYDCit4oAEnmgEXc1BgO09C8bZbaWs0yGvHOx253LtQrn iboz1FFi3h+ieyf7L+Q3FeI0NEHIMfEJlJqBSIeDPZqwh08+2Qb5W9pbHLsVoZ6HlWA2w4NbLJHp/ /vmqDn2JQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ke1kI-0004AG-T2; Sat, 14 Nov 2020 20:02:02 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ke1k6-00047Z-SB; Sat, 14 Nov 2020 20:01:51 +0000 Received: by mail-wr1-x444.google.com with SMTP id l1so14076842wrb.9; Sat, 14 Nov 2020 12:01:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6AIoFNZ/yLqMb8IJ3uIxUoE5cACLn4dM8V8GVRWjKYI=; b=hmVK45Xu0/R8zNP4CFJ4Ftzi4wcJj3/cd20qg6nP3qEDEfzLJ96R+PlXYsOSrbKum2 MFB3zkRU0cGvamQmMVKvo3ZGAFVS2mFDuW64XyW045tkuJDf+tvT23YZRpJ4tBAAqX2o hkKaM6ReHL9LH7FTtrA6Q6hFsqVVIblYbfAli5u09DLHQPcAdHoF0Q9CGeGFGWvQ0zoU dPq9uUwHmW/TgLcQXNjiCR20+7jrB7Ao621r7DMuI1d1taNrq0fgaGXmX/LcHhkwpmEd oUUKuninLoelAHlr9GGhuNKhJh26iv8PjsxXTXgbvopw78tN69q+Hn4STTpIc5SIqbG5 s7Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6AIoFNZ/yLqMb8IJ3uIxUoE5cACLn4dM8V8GVRWjKYI=; b=KeAVmByZPl31TmjlYVlO3y8oWOtAtVljNCDQaPW535LDNS434ckaQBzoI4IvL++uFM nzvCn4xPF/8I0hG9WzDeBIlLNGkfjVXpWf3IrNq6E+kWU0lgVy9N3nED5JUjhfRYs619 e36ChyP4g3W+JthaGuKGrQSlsbhkG+/lGAd6r9UpvVhcj6MHsHucSR/IfEJegAV5jBbe mICDSq0RjcU3TO1aCiRc7IUrgt2uwoTlVHy3K1eMB+TeCaUaK7dBuqCv3qnmfRs+extl 64kmYnDSDjJ5xI7Tlg1Ez/aPPcAtm2SQcjSIdyWgkMuj9UiClM4UOv70sOqWbrBDMS1i yG/w== X-Gm-Message-State: AOAM530Hwqz4OX5EQlhDGPP6NS1FVUgYfcw3oPUHuBZ+zak1kPUUXZ3D KNmrTMEOhwmJirMYvQPKmWI= X-Google-Smtp-Source: ABdhPJydEBL73jFweyqT4tskHwRL1D3qKsJIU1phA9V/TJ+4GuwNhYYV/yNr2BFvAUO19LdSLTdetA== X-Received: by 2002:adf:fc41:: with SMTP id e1mr10914610wrs.406.1605384110061; Sat, 14 Nov 2020 12:01:50 -0800 (PST) Received: from localhost.localdomain (p4fc3ea77.dip0.t-ipconnect.de. [79.195.234.119]) by smtp.googlemail.com with ESMTPSA id g138sm14342953wme.39.2020.11.14.12.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Nov 2020 12:01:49 -0800 (PST) From: Martin Blumenstingl To: davem@davemloft.net, kuba@kernel.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, robh+dt@kernel.org Subject: [PATCH RFC v1 2/4] net: stmmac: dwmac-meson8b: use picoseconds for the RGMII RX delay Date: Sat, 14 Nov 2020 21:01:02 +0100 Message-Id: <20201114200104.4148283-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201114200104.4148283-1-martin.blumenstingl@googlemail.com> References: <20201114200104.4148283-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201114_150150_941483_A7840436 X-CRM114-Status: GOOD ( 14.55 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:444 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [martin.blumenstingl[at]googlemail.com] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, jianxin.pan@amlogic.com, narmstrong@baylibre.com, Martin Blumenstingl , khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org Amlogic Meson G12A, G12B and SM1 SoCs have a more advanced RGMII RX delay register which allows picoseconds precision. Parse the new "amlogic,rgmii-rx-delay-ps" property or fall back to the old "amlogic,rx-delay-ns". Signed-off-by: Martin Blumenstingl --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index dc0b8b6d180d..465eaf000da1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -83,7 +83,7 @@ struct meson8b_dwmac { phy_interface_t phy_mode; struct clk *rgmii_tx_clk; u32 tx_delay_ns; - u32 rx_delay_ns; + u32 rx_delay_ps; struct clk *timing_adj_clk; }; @@ -276,7 +276,7 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) tx_dly_config = FIELD_PREP(PRG_ETH0_TXDLY_MASK, dwmac->tx_delay_ns >> 1); - if (dwmac->rx_delay_ns == 2) + if (dwmac->rx_delay_ps == 2000) rx_dly_config = PRG_ETH0_ADJ_ENABLE | PRG_ETH0_ADJ_SETUP; else rx_dly_config = 0; @@ -406,14 +406,20 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) &dwmac->tx_delay_ns)) dwmac->tx_delay_ns = 2; - /* use 0ns as fallback since this is what most boards actually use */ - if (of_property_read_u32(pdev->dev.of_node, "amlogic,rx-delay-ns", - &dwmac->rx_delay_ns)) - dwmac->rx_delay_ns = 0; + /* RX delay defaults to 0ps since this is what many boards use */ + if (of_property_read_u32(pdev->dev.of_node, + "amlogic,rgmii-rx-delay-ps", + &dwmac->rx_delay_ps)) { + if (!of_property_read_u32(pdev->dev.of_node, + "amlogic,rx-delay-ns", + &dwmac->rx_delay_ps)) + /* convert ns to ps */ + dwmac->rx_delay_ps *= 1000; + } - if (dwmac->rx_delay_ns != 0 && dwmac->rx_delay_ns != 2) { + if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) { dev_err(&pdev->dev, - "The only allowed RX delays values are: 0ns, 2ns"); + "The only allowed RX delays values are: 0ps, 2000ps"); ret = -EINVAL; goto err_remove_config_dt; }