Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2070399pxb; Sat, 14 Nov 2020 12:06:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwH3F4t0vJ4RVOGxwunNPov8bfrG88pI73EnN1GXkQZDA3u4bicZruAdFI4wOx7MzmYs8Tn X-Received: by 2002:a17:906:22c7:: with SMTP id q7mr8101310eja.291.1605384360595; Sat, 14 Nov 2020 12:06:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605384360; cv=none; d=google.com; s=arc-20160816; b=WJIz2hpiM5y2RO2EJJeIxEw3x3ms9Jnb1Qko6kCd+WD9BIHx5ZcrA+OA5PIKj1aXIY Ky1yN3EFOjPROPRMlX1OzhStpsNhx8KZHFGqlYEnkjLETViXHOSufGOPQFggr2igNiuP OcCRYOCGJkDmVWch/0o8CXai/x17RQn9J2Zp4aHiBltA1CRKX14oL6TcnEmjbUjsyhbZ Hw/PrpiORbJmQE5+//QCiA07YQ7Da2Dj8zkgY4kiMaxtDcrkUNjwTz0ho3y7dgrrnqXh bnWlY7WtRvXa0xkwntgXmaucQRGEjDlDGbvU7pzL40T5L2a4Hfk5yxlo06ry5j1Nvlmm /kHw== 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=6AIoFNZ/yLqMb8IJ3uIxUoE5cACLn4dM8V8GVRWjKYI=; b=EQkrawm5DhOWkZrpTRXdBmGqFXQ/Fu9AYHJo1YztBy5VJKyRE7YUoZcBL54dogP7zB LfOyJJO+W3ghhsH4InSRdDffcj7WQQDMOAn/oJh2CAqZnpyeVT2b8yWUNEAltq5JXQqk r4FEygzhneuw9w08PNAzRFUiTlee2qdKIrV1GnSEUMxTPhjKAgD899ttUswwpG4RMH0b pGXE7tl621b7Sq7/ESncSX6uM3tgrIQfjdSkGnObkItqe5fUcMIalWlEMXED9t0DweqG Xe590CZPkDLWzRPKoYxL0tn6+1PbARcwWeGUOsBlGjUKcDsdJmA7+bNhbFWZkicfi8pG aXmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=hmVK45Xu; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si8741246ejs.645.2020.11.14.12.05.38; Sat, 14 Nov 2020 12:06: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=@googlemail.com header.s=20161025 header.b=hmVK45Xu; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726495AbgKNUB6 (ORCPT + 99 others); Sat, 14 Nov 2020 15:01:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbgKNUBv (ORCPT ); Sat, 14 Nov 2020 15:01:51 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E6D8C0613D1; Sat, 14 Nov 2020 12:01:51 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id k2so14137399wrx.2; Sat, 14 Nov 2020 12:01:51 -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=BsVqnHJICM8+ahOQt5T6Y7zvfp/qgwOhOnOd989BS7orco+ke8Nk/OzTM99SKmsTWy a9+ib3r/38jwiYdw88u1kGEiMj26PkPsxxJs429LFvvjEojZXrAeupBNP/mtC7aQAk+a U43WwCYsfDjMItKWY1zFHrmKt0olI32QvbdXrQ2KvfqHrZDxleot49S4MSURZPa2V7RE s7tbN/KvL5vm1iUQr08iEyu8ZqdBVRhX5jmX1ieTSkvU4Hh/juBiLmvCdXhBAgwzW4qE vkfzVCF9YU2v43klMHV2qEhaVePGPZDyONwif3K9eYDIk1ciPMp8ANjNPMn6maOnwnCO t79w== X-Gm-Message-State: AOAM530tHt7iwmt9O2cEnRj+uB2qyrlEITBvR8OW+WOSdMqEIvEeiJsm WJhTntWA6EFd6RfiHGBDlXs= 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 Cc: jianxin.pan@amlogic.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, khilman@baylibre.com, narmstrong@baylibre.com, jbrunet@baylibre.com, andrew@lunn.ch, Martin Blumenstingl 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; } -- 2.29.2