From patchwork Wed Dec 23 23:29:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 11988989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E93C9C433E6 for ; Wed, 23 Dec 2020 23:30:58 +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 85A17224B0 for ; Wed, 23 Dec 2020 23:30:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85A17224B0 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+linux-amlogic=archiver.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=u+7tEXRjVhzkaQtJ3VtsIjMSSeRUE1dmwKhZMccSdys=; b=MoLF03/kjDb1doBC2zeXfIyB1 kEMbM3wqCqFGctmr8h74qE8eBMeRjDikML5WWVNq/Czi/HrCJ/FGqv3bM9kfhKlG+MqOdZWDeBMCl jNNAh5aNncXh5JyRLpY52KTgxnq7z27u8/HfTpFB+mdVeYU5Ak2j1cFblQH2TjU6rZweDc7Kg6cEV L1uqUXDo7wLlxwW8Pk+081d0iOYMg3cn6rHb7bqXL++7ZIp2f5jEUQOCyYnNEMRrU8lZ4sX1x8sff ZFMWVPzRT97hYfobFD771iPTqHL7GcCZys1otICIS/M+DC5PF5AUWDbH+qk74AVrvl68YcKU0JGFN vM9a9hGjQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDaf-0002hI-BF; Wed, 23 Dec 2020 23:30:45 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDac-0002fY-Mu; Wed, 23 Dec 2020 23:30:44 +0000 Received: by mail-wr1-x430.google.com with SMTP id r3so716609wrt.2; Wed, 23 Dec 2020 15:30:39 -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=hQPHIvsAjymwrj88eayvDfWVEI3FeVG9migi2sLEfas=; b=rd7j9CDFeZd22ADwPLkZVVMl3AS7J/1IrJGa6JJ1zOW2YUp/XJZEQo1iCxPfE5L+sn +uakY57HlN/ymRkT/2xWJvEmW7e3T2Aah+R3TEcVastQzJM9f4yUbOlrNDWF6u/t4z0Z 60ke+dD6pN22DJ+mfaYKd8wZy+h1VAJTW2xoTQ2hftyMHWj/dga3nxt48KDBBx+aZ5TX m+qX4cLSjshjPR4ZTuqFbmxWgFYzNXGVTXfUtFXNiu8SrZj/RVZO9GqAFSUa2nwMgBCh PpMCEO4pp28IURbB0ZvygGm+3S/DpGWAg2ct6SSjgQWjiQGc8EpfgAA3bhpzBpOSKJEB 0q0g== 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=hQPHIvsAjymwrj88eayvDfWVEI3FeVG9migi2sLEfas=; b=dKGn0QYBYYVXOek5rD1vR1yg7qtUgx4pm7nN50e8T0eRu+VGS4MzU/eB2cLezRiNkB wFPb6fEOMQM5P9mhZ8R64uZ9qbZa8iDXERpU3pv4qFkKGd+tSKl3UMVFlIBcq6ZCPy0w wJ3gyId7mtS/Ta3tsoHwUegRmBWYnadk+CFiBXJ6UHABx2oTQNJdkqEVELbUC16tIthc kpsOX9uhtZ2sYUg0Jyk13ieT74Uo9k/5MwCpyafnhk5sbKENRajYXlRP6jwz24f0fWvw fJ00K3fHAu8hp9mapj3WdqA1q4FQIr1RSs4p3Dq2tGRDdBzmeYxr5uaCgNXa6lY3DEzh FaLw== X-Gm-Message-State: AOAM531Lg4XxQxyf7N4J0Zfh/P9kgLMHnMe7r6rDkxOEgJNIoBYqgjv1 Bn7ZfiG2QBj0NgUcVBvl7Fov1EU9nSE= X-Google-Smtp-Source: ABdhPJzAZbpyPuBWW2KBcu9dJa/qHhI0eE1CLPKrGsAQYhn1R/e7UieMPCs4eQ6SiOV0e6Noluus/Q== X-Received: by 2002:adf:eec6:: with SMTP id a6mr31354990wrp.239.1608766238726; Wed, 23 Dec 2020 15:30:38 -0800 (PST) Received: from localhost.localdomain (p200300f1371a0900428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:371a:900:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id l16sm37926657wrx.5.2020.12.23.15.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 15:30:38 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 1/5] dt-bindings: net: dwmac-meson: use picoseconds for the RGMII RX delay Date: Thu, 24 Dec 2020 00:29:01 +0100 Message-Id: <20201223232905.2958651-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223232905.2958651-1-martin.blumenstingl@googlemail.com> References: <20201223232905.2958651-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-20201223_183042_819301_3B538091 X-CRM114-Status: GOOD ( 12.48 ) 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, f.fainelli@gmail.com, jianxin.pan@amlogic.com, narmstrong@baylibre.com, Martin Blumenstingl , khilman@baylibre.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, kuba@kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Amlogic Meson G12A, G12B and SM1 SoCs have a more advanced RGMII RX delay register which allows picoseconds precision. Deprecate the old "amlogic,rx-delay-ns" in favour of the generic "rx-internal-delay-ps" property. For older SoCs the only known supported values were 0ns and 2ns. The new SoCs have support for RGMII RX delays between 0ps and 3000ps in 200ps steps. Don't carry over the description for the "rx-internal-delay-ps" property and inherit that from ethernet-controller.yaml instead. Signed-off-by: Martin Blumenstingl Reviewed-by: Florian Fainelli --- .../bindings/net/amlogic,meson-dwmac.yaml | 55 +++++++++++++++++-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml b/Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml index 6b057b117aa0..a406e38e1848 100644 --- a/Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +++ b/Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml @@ -74,17 +74,60 @@ allOf: Any configuration is ignored when the phy-mode is set to "rmii". amlogic,rx-delay-ns: + deprecated: true enum: - 0 - 2 default: 0 description: - The internal RGMII RX clock delay (provided by this IP block) in - nanoseconds. When phy-mode is set to "rgmii" then the RX delay - should be explicitly configured. When the phy-mode is set to - either "rgmii-id" or "rgmii-rxid" the RX clock delay is already - provided by the PHY. Any configuration is ignored when the - phy-mode is set to "rmii". + The internal RGMII RX clock delay in nanoseconds. Deprecated, use + rx-internal-delay-ps instead. + + rx-internal-delay-ps: + default: 0 + + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8b-dwmac + - amlogic,meson8m2-dwmac + - amlogic,meson-gxbb-dwmac + - amlogic,meson-axg-dwmac + then: + properties: + rx-internal-delay-ps: + enum: + - 0 + - 2000 + + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson-g12a-dwmac + then: + properties: + rx-internal-delay-ps: + enum: + - 0 + - 200 + - 400 + - 600 + - 800 + - 1000 + - 1200 + - 1400 + - 1600 + - 1800 + - 2000 + - 2200 + - 2400 + - 2600 + - 2800 + - 3000 properties: compatible: From patchwork Wed Dec 23 23:29: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: 11988991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CD5BC433DB for ; Wed, 23 Dec 2020 23:30:59 +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 AAB1A224B1 for ; Wed, 23 Dec 2020 23:30:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAB1A224B1 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+linux-amlogic=archiver.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=mq9geMm9LKfm1qZyEifAgG1riMo3+T+/zXHbW0Txb0c=; b=IMkI2UMVXil3TE6Q9/xTI3jBA a/mdjguzjjUntPMJILTy0AoAPa254xsS4Krk56KxUNj6ng1uP3HuiUNYxYmgoZoBErBSH/jkKlxLM Upy5L/uUG8dG9+qXnnQxe3GV8/sTODPP53tIY73guIqxA5yt+3XMb9m/XDBf7h4uDwGI6ENpSNPAM xEYZiJrYMYzAHLHJt6ORx8NPtGubzhJqcNifjO8Wt9A74v/bBVKFeNZ+H9W0KSQ8CoplIDV7I0Cnn kYkwTGR785rsdCyGuVkPDqFJdWiJKrlIakQKQqgzNLl5tWCrFKpT6doUNH1UqGMW9eMSnLQIeH5Kw 5Xwh9VeFA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDal-0002if-Qv; Wed, 23 Dec 2020 23:30:51 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDac-0002fa-VG; Wed, 23 Dec 2020 23:30:45 +0000 Received: by mail-wm1-x334.google.com with SMTP id n16so2190119wmc.0; Wed, 23 Dec 2020 15:30:40 -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=/IDOsxj1FkZFtUZQ+5yS2bWitABPuLIIASx9mGd33kI=; b=VuJreDFTBk+1siGVQ+QRRhstiDMGPyx1JVqRSg0H3GSmQsrV9VVhi41vxE8YzrGwDT CKyuVPRVdBireX++b4ixYWp6/9NpnExbP4PeXoz5WCBA94ymcUZ9AeIxrgGDwyyJ1Sm6 hPrTKx+BubGOz8LCXhq2Exl0/76wi0E57oA4UtxnVpdqltQUi68njhqLkKO26zKeHKkA Q5bifJzR9uzX/IruDbyBTbo26rg+wkRP9VnzDtYjyZpC/8hkbBKFbVaBt4Cg9B+Ajzsj cL7dYuIn/BBiXCUipudEkc9c9iWcngVBVAt0U2AEBSyj5Cg394BuXpxZ7AgHciaMCdoe EhSg== 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=/IDOsxj1FkZFtUZQ+5yS2bWitABPuLIIASx9mGd33kI=; b=EEXc+if1uj6ggNq8qL3mJYRtinVZ9vJsdY+nbbjySWTJy72A6j1NQAq7QaGgkWh1MU I5SQ0IAv9gqtd2dbJx18Q+9ZjOzAEuYEQJtJLxsGIJKMPlHud8brVpPMmGyTvJclYH53 /mWWaiC9T/uH5TN/3rjH14sJnPzD7VuclGRLeGvgItFxY7hQnMT+gBhV+J0LgkpKqAbT r88TIlQ4CHpR2YB+lOQgIInf0KSZHKEs55VzpvdDTEk7BU/oNTvBAk7kYmpCb0PGsC7R zjwIAyd1p9oj6halCzI3QxhhhRS+49f7zDAVyryylyXcMWWur+otGc3erUJH5f2XXn9m D8Iw== X-Gm-Message-State: AOAM532qJb7A8Mq3fRyPFrggxcnw48uKnwLol/val3MbLp4+ixVkjhsh 2Zb9neF+T27t+kf1aLgYUwAf8WOcDRo= X-Google-Smtp-Source: ABdhPJxfDnawgge8i9/tFQIhr6IWYLXwiiT4tq6T8h5vUGsTJI+w9PHPHpL4xlT+G3MUACp0RmJbhw== X-Received: by 2002:a1c:df57:: with SMTP id w84mr1717943wmg.37.1608766239904; Wed, 23 Dec 2020 15:30:39 -0800 (PST) Received: from localhost.localdomain (p200300f1371a0900428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:371a:900:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id l16sm37926657wrx.5.2020.12.23.15.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 15:30:39 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 2/5] net: stmmac: dwmac-meson8b: fix enabling the timing-adjustment clock Date: Thu, 24 Dec 2020 00:29:02 +0100 Message-Id: <20201223232905.2958651-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223232905.2958651-1-martin.blumenstingl@googlemail.com> References: <20201223232905.2958651-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-20201223_183043_036106_0C068B16 X-CRM114-Status: GOOD ( 15.96 ) 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, f.fainelli@gmail.com, jianxin.pan@amlogic.com, narmstrong@baylibre.com, Martin Blumenstingl , khilman@baylibre.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, kuba@kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org The timing-adjustment clock only has to be enabled when a) there is a 2ns RX delay configured using device-tree and b) the phy-mode indicates that the RX delay should be enabled. Only enable the RX delay if both are true, instead of (by accident) also enabling it when there's the 2ns RX delay configured but the phy-mode incicates that the RX delay is not used. Fixes: 9308c47640d515 ("net: stmmac: dwmac-meson8b: add support for the RX delay configuration") Reported-by: Andrew Lunn Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Martin Blumenstingl --- drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index f184b00f5116..5f500141567d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -301,7 +301,7 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) return -EINVAL; } - if (rx_dly_config & PRG_ETH0_ADJ_ENABLE) { + if (delay_config & PRG_ETH0_ADJ_ENABLE) { if (!dwmac->timing_adj_clk) { dev_err(dwmac->dev, "The timing-adjustment clock is mandatory for the RX delay re-timing\n"); From patchwork Wed Dec 23 23:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 11988995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72483C433DB for ; Wed, 23 Dec 2020 23:31:04 +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 2D99D224B0 for ; Wed, 23 Dec 2020 23:31:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D99D224B0 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+linux-amlogic=archiver.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=er/0qSUtG2gt9qtyxsXexkhGY5ihYClcRFP7PQy0PI4=; b=kp8sZ30CEFwh0FyBSUiXo6Sa8 gLgqle2EwoBMX6m05fZUlhjG7WI4YL3WM8mH4qLdY/4/PuLnR/iVTqIssucj5WoT9B0T/X0qsFc8T rV890IiaeOXtqrWYEjPwpwolX99Qkg57A+bWNE79plTdyBe5Yk2Mp2SRIldqV4uG0GNYenYCiHnNG WUzQeM4j/W+l5bwuR9mKXWcM9SlayHrQ8tCEWkLf568Roum/XdLqvHBsDdfhZhMYlUMe4ztM4LJDe u2CBVuRJE0sijd/6pl4AjvaYxRVm/pCOa3Itp1Nmb9HLVj4B11TRQlSlzJFqh5k+FIVmYF+oG88BO fLBh85LyA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDas-0002kD-JP; Wed, 23 Dec 2020 23:30:58 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDad-0002fd-Bd; Wed, 23 Dec 2020 23:30:46 +0000 Received: by mail-wm1-x336.google.com with SMTP id r4so259941wmh.5; Wed, 23 Dec 2020 15:30:42 -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=M0ndzokyweROc+1+J72pYZnLkVJUHj/9rLRl9lmhXAM=; b=aVjgPZg44fBmUtM/n1tXl5BjwycXTr85OlZeWOeTYBjSrDuPfOjDaMiBSlW22IkGL2 RRJuNLufji3FLz6vpOSzmbFiVepP3ZndqPgPRDtwKrJ8nurJXhEOJ2KNQ10VNA0f89x7 5t6xcdFK9sf0vI/FTYoYAI81SkwMX6adJT2MzW/wmDqf1E7uEGtM6MazTJOq5s4p8KHq FfKptQRd4vClm39VPV2i0XvsxFOKJjuYardGH+TXp77QGoVOpPAnHkFpD6vrWiVxFciM cde/TAuQKxfWpJzdlWuZYSbEMPr/OThJVuPS65g586zg5Tx7+5AU3agH2vDUpG/3RZAE uAig== 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=M0ndzokyweROc+1+J72pYZnLkVJUHj/9rLRl9lmhXAM=; b=f3c3dQU5wqAzn/mPQHYAI3+foeRPik33NFxF+mnILMvJPAui5JteggrEnxiVGPUIB0 uWxSPfgh8aLrnePeIyrwoJK4auadoLfsTo8bQazgCVHM9GV+kGnOnL52ZFdnOQasqRf8 rDb8UgwX4hMVi2uoRsms303P7iy+OXm+B4p2BwVTTEv2ldPd8FoPpz0RviQdFOOFMj4Z +QlHVzgZk5//iMt8eP1oDwgJGL2jVkZoxLp2aJP5gu/BB8WDDARUOZJWXaA8gGBLeEes gJYiCvv/tht1dl9dBpkDpF1HTbCPXa8NMEN/7CkkqlvUmI1x29iHBhnVsM6J28F+XUp6 vSUQ== X-Gm-Message-State: AOAM5302WAMcuXDLDPm2ZB3WAHuDAaXduOgeRRoqUlGooThBdcp2L0BG neZZ6ezI3nHDCUTguH/NetEAdd52JDo= X-Google-Smtp-Source: ABdhPJw80ydPE2q0jtj/nk7tg5lGhT3vPnadHtbZP5NDS3hsaBkJ0NAJ7DCwCWGiXCIAlpNHXDOWSQ== X-Received: by 2002:a7b:c8da:: with SMTP id f26mr1760579wml.155.1608766240943; Wed, 23 Dec 2020 15:30:40 -0800 (PST) Received: from localhost.localdomain (p200300f1371a0900428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:371a:900:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id l16sm37926657wrx.5.2020.12.23.15.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 15:30:40 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 3/5] net: stmmac: dwmac-meson8b: use picoseconds for the RGMII RX delay Date: Thu, 24 Dec 2020 00:29:03 +0100 Message-Id: <20201223232905.2958651-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223232905.2958651-1-martin.blumenstingl@googlemail.com> References: <20201223232905.2958651-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-20201223_183043_438221_FF503C8F X-CRM114-Status: GOOD ( 15.07 ) 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, f.fainelli@gmail.com, jianxin.pan@amlogic.com, narmstrong@baylibre.com, Martin Blumenstingl , khilman@baylibre.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, kuba@kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.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 "rx-internal-delay-ps" property or fall back to the value from the old "amlogic,rx-delay-ns" property. No upstream DTB uses the old "amlogic,rx-delay-ns" property (yet). Only include minimalistic logic to fall back to the old property, without any special validation (for example if the old and new property are given at the same time). Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Martin Blumenstingl --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 5f500141567d..d2be3a7bd8fd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -82,7 +82,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,19 @@ 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, "rx-internal-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; } From patchwork Wed Dec 23 23:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 11988993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64849C433E0 for ; Wed, 23 Dec 2020 23:31:02 +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 1B453224B0 for ; Wed, 23 Dec 2020 23:31:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B453224B0 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+linux-amlogic=archiver.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=O7VxmExdFBWUG01n7WN9CdEP3Iltu8jEMPAluGCCq2k=; b=HfWPSiCKtJnJke5hvzaeXzbBF fDecIykEHkosZcpaH6+CjetwbNNdp4iVq/dCYgxZsmZ86N8OjwewfBUKZzmoIqYBoqerDgFrK0+vg 04ewh8ERoBXG3bP0rnKR31bpOQP3QaDVlzSKNUWM78cMbb79/AxkZygQeqF5k07JLiPc8vQLeGSbM Q/FSCx9gXUnYT0Us+J4QF683kjt2bv8g/9nazkMvCZqdHqvPBLr1ipviMxY5/J3W3Z+1+BhUwMGW7 AeDDO6nb2JNcUc5WF+AK7mzl+L6FPd1YAfzi0iSx/kri6pHgannnug7UclOssEj6gmT+B+TQhfq2D kkz7dBTSA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDaq-0002je-Jb; Wed, 23 Dec 2020 23:30:56 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDae-0002fg-Dc; Wed, 23 Dec 2020 23:30:45 +0000 Received: by mail-wr1-x42e.google.com with SMTP id r7so701168wrc.5; Wed, 23 Dec 2020 15:30:43 -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=f2WQaMRGYRvLKx65rkROdWii2KWvF+WGltfYLQ57NGQ=; b=QSv1e9WF7GSxZt9mnrrAvF7gQn3O0JKgqiTyPv/zAOaudfr8twgASyQjxnm0ZEOlPL 7X+j5zelIV+zAMHombxgdIx0cz+h4y3A9EeYMbtycKHaFkfQEWd99CR6IqIcE+mxB4vI OzZ2pI9oYClu6SH+Q8Dfnzd1i8ChTqh5LatufaWDJOtXM5D6ZKuPaUW4v8X7GpvViIvh qPQtSLmTwT47sVlp9UT3Q6cT6Z9CdHPfY+mxFHzlMNWtW764oS0Sy0veHZb22TsUcV3F NjwjFYMUJO5j1cqZvE0JEemd5nnTNcOSBpoNKy5l4/hW7ixfwUCOAojUdMvA8Au05S5f Rb5g== 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=f2WQaMRGYRvLKx65rkROdWii2KWvF+WGltfYLQ57NGQ=; b=jiceAJr7Xtfs/huKm6D/Zwon1RwcXpsO575ZtauVb+qMnkCL42uRfKt+pz5GRwisuz 0KqGxRq4rtyuSwFEehNTCKDddJvePSFc+cIY7eumi7LjzYpau271EVyVnWwU/rYnRjgS cn6+PNAV3Zj8dFJj0wpI/2J28+//2o+bEmdJfgGmy+CThRGHn/vTZ+XBvZO/iMpJ/Rm8 kvrRZLsS2hsxPshpqzRVXNkQNufXIJlm2IVYruMxU7aNej7b8ndm7yK6+zNHYZodWp3V 9sxGJixUtDvioac8dVguRAr/RJ6SyzI66+Vy9C1CBEC8UoZrxd0KHfOZPPvWPttWW+H0 2pVA== X-Gm-Message-State: AOAM531h2yTz1s4I8SbWvnI8Cg6IX+gYwc/DGThwvlQ/duy+0z3cYfuT VrB9yG5A1vkcJjPLDTSNDfmthqRO8Lw= X-Google-Smtp-Source: ABdhPJyXg+0G0zvWfJSELdbAeiB/10K8VeSYCmqu14DVPFBA1rwpwToeCJYVfALVDCMCXE16BXIQSA== X-Received: by 2002:adf:82c5:: with SMTP id 63mr31797641wrc.38.1608766241992; Wed, 23 Dec 2020 15:30:41 -0800 (PST) Received: from localhost.localdomain (p200300f1371a0900428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:371a:900:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id l16sm37926657wrx.5.2020.12.23.15.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 15:30:41 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 4/5] net: stmmac: dwmac-meson8b: move RGMII delays into a separate function Date: Thu, 24 Dec 2020 00:29:04 +0100 Message-Id: <20201223232905.2958651-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223232905.2958651-1-martin.blumenstingl@googlemail.com> References: <20201223232905.2958651-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-20201223_183044_518392_E350F8BA X-CRM114-Status: GOOD ( 15.30 ) 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, f.fainelli@gmail.com, jianxin.pan@amlogic.com, narmstrong@baylibre.com, Martin Blumenstingl , khilman@baylibre.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, kuba@kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Newer SoCs starting with the Amlogic Meson G12A have more a precise RGMII RX delay configuration register. This means more complexity in the code. Extract the existing RGMII delay configuration code into a separate function to make it easier to read/understand even when adding more logic in the future. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Martin Blumenstingl --- drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index d2be3a7bd8fd..4937432ac70d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -268,7 +268,7 @@ static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, return 0; } -static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) +static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac) { u32 tx_dly_config, rx_dly_config, delay_config; int ret; @@ -323,6 +323,13 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) PRG_ETH0_ADJ_DELAY | PRG_ETH0_ADJ_SKEW, delay_config); + return 0; +} + +static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) +{ + int ret; + if (phy_interface_mode_is_rgmii(dwmac->phy_mode)) { /* only relevant for RMII mode -> disable in RGMII mode */ meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, @@ -430,6 +437,10 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) goto err_remove_config_dt; } + ret = meson8b_init_rgmii_delays(dwmac); + if (ret) + goto err_remove_config_dt; + ret = meson8b_init_rgmii_tx_clk(dwmac); if (ret) goto err_remove_config_dt; From patchwork Wed Dec 23 23:29:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 11988997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84081C433E6 for ; Wed, 23 Dec 2020 23:31:04 +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 359FC224B1 for ; Wed, 23 Dec 2020 23:31:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 359FC224B1 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+linux-amlogic=archiver.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=rw6QtFoN4nSppVDYIegotf9lr1j+9Ds5TjTCnvuCNgw=; b=yWJxpgqX4OYFpuSUXX7QLHdPI /+gLhxfejr4fbts2rPm/p0gntG5c/jgmdBLqR6O9HM3/WCF3tA2E93EVyVWqahR5SOEUGkTeP3xdE Tus8oL+4nVwZj3UxWntkZ68eGfaCw2DU+PMFjm1Sp1Ia0ZbefCDM42JY9UqV07pVmY94VgoECrEST sU414aMwl7ifIcdOTS2zAPvR5LMPTHzAhgh30jz9FyJMsqVlM0vW4Z84gqWJvq4zL1W9rE8uO5cBU Vq11W7X5n+KYTPceiFvVgjQOhWnawZKuNRPOdTxlm3rGAjve49uTTAmNn2EZ8KMLrGsl5Y+RWdPiC aOUfqa9ng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDat-0002kf-MN; Wed, 23 Dec 2020 23:30:59 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ksDae-0002gZ-G6; Wed, 23 Dec 2020 23:30:46 +0000 Received: by mail-wr1-x435.google.com with SMTP id 91so685244wrj.7; Wed, 23 Dec 2020 15:30:44 -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=xDe0p+fCHjgP8/3HdTwCfTdFrh+VCfBpvFU7FupxqxM=; b=a5m/JD67n1sNEG2yCgdvaAqsVhI24bs4L0yvW0M8S/t3WevCKohih9wiop8NQpIS0O 5MaRETZRwCb6ENQtw5rsIbozTQesm4BiQ1sWLzm3co7YWM7gg88Zf3wj/vtGCVxhI4aA 6u+AP7AZ5QFQyosIjijRm8qWYAsxwNuA3OpXK7dFZxIrhpvh54B3oDv1Vd3CK35zdp4/ wIrqnT2U+ySQKdVz0PbAAWimPNlWCENelG3fPVCVdayZIdmwp1HN2ake1+3QqQj4F7cX 1jCRFBwMvtD31Sw6NEE5562GFAtpYqXnGJVrH3BA2wpKfv69RHE1QeQWBJWo+EWQFxpA N3UA== 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=xDe0p+fCHjgP8/3HdTwCfTdFrh+VCfBpvFU7FupxqxM=; b=PLyazKwjzIzfzxMn3PnBjgEqyL+oIHZwNZmIR80wCM1HNRPusa/973JUjXOYTzFcS/ kCLVOhAKc7LCR4LVftrVnDCxyyIMrxTfo7+DpzFyjCZA6Kyq05dzu4kmEw+ifvY2Sjwc 9XjNrUHzayuUUxF5gmlcwDalAY4Qv3Wc7wwz5hURIugWz7LJIP0ch1J/yG5IBPg5gdwD gbI3h6kYXgS2cFy6NBXgEqBqW8C5CSKIE2qH+xPz4eeFS0jzP39pZZvV/gE64jRo29rQ yg0NgG9aX8QTYb6jCCX1ZwR8rNXfY1fONSNlHAjeQzMT0e5JRIW5XlqJcRqfdPE7m3yG 247w== X-Gm-Message-State: AOAM533Uq4iII8vA5JOk/6hCT1dSGXYnd7jBs5hqw6qZ4oK8kCaSG9JH CqVg6+YxFy1fLwq1wCrZXtNm3w5WHXA= X-Google-Smtp-Source: ABdhPJw5Ez/gToiq52vpj3Abpb+v5FIko90pZbplhBepbNdPFGa/+E4ZV0SpTwefYDAkozF55ECLcw== X-Received: by 2002:a5d:504d:: with SMTP id h13mr31960136wrt.246.1608766243040; Wed, 23 Dec 2020 15:30:43 -0800 (PST) Received: from localhost.localdomain (p200300f1371a0900428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:371a:900:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id l16sm37926657wrx.5.2020.12.23.15.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 15:30:42 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 5/5] net: stmmac: dwmac-meson8b: add support for the RGMII RX delay on G12A Date: Thu, 24 Dec 2020 00:29:05 +0100 Message-Id: <20201223232905.2958651-6-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223232905.2958651-1-martin.blumenstingl@googlemail.com> References: <20201223232905.2958651-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-20201223_183044_624059_3EAAC56E X-CRM114-Status: GOOD ( 19.94 ) 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, f.fainelli@gmail.com, jianxin.pan@amlogic.com, narmstrong@baylibre.com, Martin Blumenstingl , khilman@baylibre.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, kuba@kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Amlogic Meson G12A (and newer: G12B, SM1) SoCs have a more advanced RX delay logic. Instead of fine-tuning the delay in the nanoseconds range it now allows tuning in 200 picosecond steps. This support comes with new bits in the PRG_ETH1[19:16] register. Add support for validating the RGMII RX delay as well as configuring the register accordingly on these platforms. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Martin Blumenstingl --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 4937432ac70d..55152d7ba99a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -68,10 +68,21 @@ */ #define PRG_ETH0_ADJ_SKEW GENMASK(24, 20) +#define PRG_ETH1 0x4 + +/* Defined for adding a delay to the input RX_CLK for better timing. + * Each step is 200ps. These bits are used with external RGMII PHYs + * because RGMII RX only has the small window. cfg_rxclk_dly can + * adjust the window between RX_CLK and RX_DATA and improve the stability + * of "rx data valid". + */ +#define PRG_ETH1_CFG_RXCLK_DLY GENMASK(19, 16) + struct meson8b_dwmac; struct meson8b_dwmac_data { int (*set_phy_mode)(struct meson8b_dwmac *dwmac); + bool has_prg_eth1_rgmii_rx_delay; }; struct meson8b_dwmac { @@ -270,30 +281,35 @@ static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac) { - u32 tx_dly_config, rx_dly_config, delay_config; + u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config; int ret; + rx_adj_config = 0; + cfg_rxclk_dly = 0; tx_dly_config = FIELD_PREP(PRG_ETH0_TXDLY_MASK, dwmac->tx_delay_ns >> 1); - if (dwmac->rx_delay_ps == 2000) - rx_dly_config = PRG_ETH0_ADJ_ENABLE | PRG_ETH0_ADJ_SETUP; - else - rx_dly_config = 0; + if (dwmac->data->has_prg_eth1_rgmii_rx_delay) + cfg_rxclk_dly = FIELD_PREP(PRG_ETH1_CFG_RXCLK_DLY, + dwmac->rx_delay_ps / 200); + else if (dwmac->rx_delay_ps == 2000) + rx_adj_config = PRG_ETH0_ADJ_ENABLE | PRG_ETH0_ADJ_SETUP; switch (dwmac->phy_mode) { case PHY_INTERFACE_MODE_RGMII: - delay_config = tx_dly_config | rx_dly_config; + delay_config = tx_dly_config | rx_adj_config; break; case PHY_INTERFACE_MODE_RGMII_RXID: delay_config = tx_dly_config; + cfg_rxclk_dly = 0; break; case PHY_INTERFACE_MODE_RGMII_TXID: - delay_config = rx_dly_config; + delay_config = rx_adj_config; break; case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RMII: delay_config = 0; + cfg_rxclk_dly = 0; break; default: dev_err(dwmac->dev, "unsupported phy-mode %s\n", @@ -323,6 +339,9 @@ static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac) PRG_ETH0_ADJ_DELAY | PRG_ETH0_ADJ_SKEW, delay_config); + meson8b_dwmac_mask_bits(dwmac, PRG_ETH1, PRG_ETH1_CFG_RXCLK_DLY, + cfg_rxclk_dly); + return 0; } @@ -423,11 +442,20 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) dwmac->rx_delay_ps *= 1000; } - if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) { - dev_err(&pdev->dev, - "The only allowed RX delays values are: 0ps, 2000ps"); - ret = -EINVAL; - goto err_remove_config_dt; + if (dwmac->data->has_prg_eth1_rgmii_rx_delay) { + if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) { + dev_err(dwmac->dev, + "The only allowed RGMII RX delays values are: 0ps, 2000ps"); + ret = -EINVAL; + goto err_remove_config_dt; + } + } else { + if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) { + dev_err(dwmac->dev, + "The RGMII RX delay range is 0..3000ps in 200ps steps"); + ret = -EINVAL; + goto err_remove_config_dt; + } } dwmac->timing_adj_clk = devm_clk_get_optional(dwmac->dev, @@ -469,10 +497,17 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) static const struct meson8b_dwmac_data meson8b_dwmac_data = { .set_phy_mode = meson8b_set_phy_mode, + .has_prg_eth1_rgmii_rx_delay = false, }; static const struct meson8b_dwmac_data meson_axg_dwmac_data = { .set_phy_mode = meson_axg_set_phy_mode, + .has_prg_eth1_rgmii_rx_delay = false, +}; + +static const struct meson8b_dwmac_data meson_g12a_dwmac_data = { + .set_phy_mode = meson_axg_set_phy_mode, + .has_prg_eth1_rgmii_rx_delay = true, }; static const struct of_device_id meson8b_dwmac_match[] = { @@ -494,7 +529,7 @@ static const struct of_device_id meson8b_dwmac_match[] = { }, { .compatible = "amlogic,meson-g12a-dwmac", - .data = &meson_axg_dwmac_data, + .data = &meson_g12a_dwmac_data, }, { } };