From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793723843; b=HT9nrtnARpsNfcxnGIH/d1RWBn4szkpKa1RSZBEqT0C55e79ei9o8jR6Tw8mrpyoBmOd IcG1QlbWmRDcVyMmDH1hQ9eDMvHSVtt19rMMEEU1xy2np7K9Om1E8h7z+rP/zKOQTTKl5 KRQqoGJ9l1RVZy1S4Ng90wd+P7Res1oFQ7qgR+SaeVb8KCrLE6HScvsa4QeYCwFxGOIF3 KPqnB/ncU2G51WjBHeBKTcDao2hhjghlxgHqNjo8zv+gwfXflgyZN31clJmnvaPY7tjBi 76mkD9SbEFNWeu3f0J6ngqpSLexrpFqXWhMixthur7tGrvqtKO99X6BV6QEgleMOU/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793723843; h=DMARC-Filter:Received:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=b7yfUIavlqkZvjW0hdKuc7GNLhU6uDD+OhW8RPwrMQg=; b=t9sEHCUXpNoxE4q3E2G6bDaZuT1u/E92TqwCjATNOep9dPwOVXik6JQ08TFwHNlap6To tWjELt4/fHoHKXjV9Rb3YmE4/N0NJ63PrQL5Ssx70iGDMa/KKHgikXGvoo0M8RDTtdF5C zQQ7R/08J3IpT9ot+TEY0SVUL4R76l4HHubPaecR9NyHtO20ebKIY/LUHEibHalDitbVZ C6+1oUtk5Jp3/opMjqo1LOCZJjj3TiPDf0fYczGVGqT9ww6jeFJ03YefRCaB6BOH/UQhM pj5UEDq7leg7s0xa0QnvxcmM5XV9R6NhpLG0Rg4/bYSsqAQF5FJTJVoEBlBLKEL7utQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail header.from=linux.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.remote-ip=209.85.221.45 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB569606EE94 for ; Tue, 3 Nov 2026 16:37:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EB569606EE94 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-48e3b22e971so2257585f8f.0 for ; Tue, 03 Nov 2026 08:37:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793723841; x=1794328641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=b7yfUIavlqkZvjW0hdKuc7GNLhU6uDD+OhW8RPwrMQg=; b=E9QEIkL3F73eyOWfNnAMqgsAuaybd68WGeKdjGVD81WK8gqgCp451eTfeWiC03tiUV NvsdjBKcjNYdp2Mo0wMnIpllyc9V6wbGfQcYQm1Q0veM8m20AOecgXZ8tf/BeLELyBgo SnT+7adSuskidxiEML1OTv0wSvV8DHK0kO33UEQqJVq/wS5Htne/Uv2QdVpYaDMizhK5 6BuCDke+8TbWIgps6UEfzSRY3sAGZdcFFXgAmABDbFHbTjgviRgDvTVRwF+FCwURyOwl sd2G3mytfLIg+5DLIr5fS7PL5KqrCdAY3iVHo0ahn3Vn4D2WMXb4N5YfbBSjDTdwXGjg EpyQ== X-Forwarded-Encrypted: i=1; AKwUvByqJEWVi8jFq+FAzjJNeZxmPbobZKQT2Awbs6eo6ErpILLwji6FbXe9MSyFHJrERNCQEWNCbjBNsKgi@vger.kernel.org X-Gm-Message-State: APuU4Z+LB9VKHVMalAIvyN/AFb/Se+QrXQIJLwAfG5HsUizY9h/VkCDB Le2vgprDtL7qwnZ3KAAbP6SUmKqN4HHEltZDmHLYu1etEm71WPMOkFqq X-Gm-Gg: AYBFou3tbPvbusbjhwRDSIisAlzTOffWKPU9SUw/Sb5WHgrKwA5yaPP7mZwqDiaio1l OOaQq0Q0HojIFQrqEDsaXYOjc7BbaQp2wFI93furhPAWd5favu2midGp2O7QlZBroOzIP3yAXYM 1TaO0MbRibaV86ii5rj/CbbtVEX5wv8sNRUnzaAxR6ahUHVMniR/8465R75IgWRZpbrNeawdvgW XdnkIgyZ/K8jlr/dchUq0ukNEmf7FoCrja5qPXoiBB2wqY/xApbMpjeZwTfTf9QLpa7/EKFaj9F 6wQXfbfLhLdLUEcfOvKL5SbVtkop9LAayU7a7P4ncwC5tuaX5GpLSxhCSZ3w01CWTpovzIVoSN4 4typKu6mtvOxpUAMI/yt6HF6f75I+2CCeIVSn6M7jo3b9NXXagUQjm5ygT89CGJu4Yt/VzqCz6e PuWXwS4lwJO8zb+F8bWXgc7Afzs82MN4sDC0vKb13DEEdXR5v7lWhMajJVwNSxMp63FxxedzDzH RuLl+giN/JnKaFfJj3moEOJfxPbxB2pFQFuS7yi7FFx4jNYppE3SA0f44TxhiATT4THve/OIqrS iWOpjhX6Tmmgnwz87O1uG66NlYsDsh6+vvt4+wXwJRRECzcPVhKcqRKKNk3elu6N28an71r+CLi /VwbLkSCzpOilNZPwLhCqpKgZug== X-Received: by 2002:a05:6000:41c8:b0:48d:faa6:cedf with SMTP id ffacd0b85a97d-48e6e50645dmr30646945f8f.56.1793723841371; Tue, 03 Nov 2026 08:37:21 -0800 (PST) Received: from threads.localdomain ([90.254.187.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71a4d3e9sm29044772f8f.6.2026.11.03.08.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 08:37:20 -0800 (PST) From: Lucas Tanure To: xianwei.zhao@amlogic.com, Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Maxime Chevallier , Maxime Coquelin , Alexandre Torgue Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/7] net: stmmac: dwmac-meson8b: follow the generic RGMII delay rules on the T7 Date: Tue, 3 Nov 2026 16:37:12 +0000 Message-ID: <20261103163715.385394-5-tanure@linux.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261103163715.385394-1-tanure@linux.com> References: <20261103163715.385394-1-tanure@linux.com> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The delay code reads phy-mode as the list of delays this glue has to add, falls back to a 2ns transmit delay when no property asks for one, and takes the vendor delay properties. ethernet-controller.yaml says the opposite: the PHY adds the 2ns delays, and the MAC properties only hold small fine tuning added on top. Every board in the tree depends on the old reading, so it stays as it is. No T7 board uses this glue yet, so the T7 gets a path of its own that follows the generic rules: the receive delay line is fine tuning in 200ps steps, and the transmit side, a quarter-period phase step, offers none, so the transmit property is refused. Assisted-by: LLM Signed-off-by: Lucas Tanure --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 450f7b4b29a6..c8bd15b6780b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -80,6 +80,7 @@ struct meson8b_dwmac; struct meson8b_dwmac_data { int (*set_phy_mode)(struct meson8b_dwmac *dwmac); + int (*init_delays)(struct meson8b_dwmac *dwmac); bool has_prg_eth1_rgmii_rx_delay; bool has_pipeline_clk; }; @@ -338,6 +339,41 @@ static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac) return 0; } +/* + * The T7 follows ethernet-controller.yaml: the PHY adds the 2ns RGMII + * delays and this glue only fine tunes the RX clock on top of what + * phy-mode describes. Its TX clock has no fine tuning, the only step is + * a quarter of the clock period, so the TX property is refused, and so + * are the vendor properties of the older SoCs. + */ +static int meson_t7_init_delays(struct meson8b_dwmac *dwmac) +{ + struct device_node *np = dwmac->dev->of_node; + u32 cfg_rxclk_dly = 0; + + if (of_property_present(np, "tx-internal-delay-ps") || + of_property_present(np, "amlogic,tx-delay-ns") || + of_property_present(np, "amlogic,rx-delay-ns")) + return dev_err_probe(dwmac->dev, -EINVAL, + "only rx-internal-delay-ps is supported, the PHY adds the RGMII delays\n"); + + if (phy_interface_mode_is_rgmii(dwmac->phy_mode)) + cfg_rxclk_dly = FIELD_PREP(PRG_ETH1_CFG_RXCLK_DLY, + dwmac->rx_delay_ps / 200); + else if (dwmac->rx_delay_ps) + return dev_err_probe(dwmac->dev, -EINVAL, + "rx-internal-delay-ps needs an RGMII phy-mode\n"); + + meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_TXDLY_MASK | + PRG_ETH0_ADJ_ENABLE | PRG_ETH0_ADJ_SETUP | + PRG_ETH0_ADJ_DELAY | PRG_ETH0_ADJ_SKEW, 0); + + meson8b_dwmac_mask_bits(dwmac, PRG_ETH1, PRG_ETH1_CFG_RXCLK_DLY, + cfg_rxclk_dly); + + return 0; +} + static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) { int ret; @@ -452,7 +488,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) "missing pipeline clock\n"); } - ret = meson8b_init_rgmii_delays(dwmac); + ret = dwmac->data->init_delays(dwmac); if (ret) return ret; @@ -475,21 +511,25 @@ 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, + .init_delays = meson8b_init_rgmii_delays, .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, + .init_delays = meson8b_init_rgmii_delays, .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, + .init_delays = meson8b_init_rgmii_delays, .has_prg_eth1_rgmii_rx_delay = true, }; static const struct meson8b_dwmac_data meson_t7_dwmac_data = { .set_phy_mode = meson_axg_set_phy_mode, + .init_delays = meson_t7_init_delays, .has_prg_eth1_rgmii_rx_delay = true, .has_pipeline_clk = true, }; -- 2.56.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE2DA6083602 for ; Tue, 3 Nov 2026 16:37:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=l1kSEtw0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=lR4qwfRJoIxKy3DU2nel/t7eeFPdWsTxxmnAv2TsXkA=; b=l1kSEtw0h4MkkxpPqfulFUgRu9 cgwAA9tYFcBCYLIdjSYEe5Vh5oteXjQ313rNrvxTaYiPddpW53PfA3WzJmqmSiYjMya1cBRb7nbsU XWFldztTjEVDvna6IUZvba2o1it7Z8/1beV7GQofKFJ6vhWXbNiP5IaL3V+ALnLzXvsdm4xfyjwTw OomIAQ7Q+roPmYsjupx1Axbx9NBiUliyUBFglIoG+Edv6J/+jXDuhOZpOnK5uMQ4s9rkWH/fubWb2 CB2K1iBncWLALOvfgRUgx59TmshIqaTys24jvnB+BscWa6irPAbAubQsSeCZWcvvKwEx0+kNEFTyD Z/thQYjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOHVm-000000039aj-0sKI; Tue, 03 Nov 2026 16:37:26 +0000 Received: from mail-wr1-f54.google.com ([209.85.221.54]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOHVj-000000039Tj-0DHt for linux-amlogic@lists.infradead.org; Tue, 03 Nov 2026 16:37:24 +0000 Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-48afbd2c386so2616340f8f.3 for ; Tue, 03 Nov 2026 08:37:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793723841; x=1794328641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=b7yfUIavlqkZvjW0hdKuc7GNLhU6uDD+OhW8RPwrMQg=; b=wSqCCjcCwKUuzFvzymOH0ft4WGj4KCsY4a1x779IYSGXRliKvZ1olU61sSYoQR5i7h ukFmDfiCuBwmIKRXhFWEg507Fc3tfKYJubZVzTlWw4lApWX4nuuZNGzahMQAdZ9Yg0FS QZe0cwSCO18mPm48Sbbjzwijb5xgHx3PuUMA1cRaSZYDX1Qe8gIgAsUbnCIVxr8g4VDA QHa8jMw6lTsUnaf0lgaBmt/EvqbM8NUXc2u/f2nWhhHKJemeOpzWOhSh/IXwsd5CN0Cy eb3IneaOr8XF6xuO6QTtZ3IlnGaXHBipU5V6KynTRg+H2zYnhid7MI087yP/ktZsaT1Q ioDw== X-Forwarded-Encrypted: i=1; AKwUvBzZQ7zy/guxJaimdLwGW/tAFIKPmKYqqT1hmQEzdXN7aksJMUyn6t145RDDTfQchKYMReV1pYsqCdXdqE+z@lists.infradead.org X-Gm-Message-State: APuU4Z/7GDQLFp6CROdBgm+97iCcK4zZ38J3VCmWg2aEjbHdzieKShHR XLL5HwccDPstWkjSRw3g0tT9gmZAV9SIoo1eSDQMztMg8RhDby0qNVCp X-Gm-Gg: AYBFou1upCgeKl6o+WxbJ3GGGu5xyh8z5VXjvU+tl2utM8zSpj42moAk90GIm9LTftK Lz9Eh8id4vEZmfcQtAw/mbqZCtT6Rh51yT02frqm4wjjR020gliIfnHLKdsMSRqMHTOqrDtDYwM GobVyW/fJZtIoG/RjHfSXidFSIdvLz957+t+FOGeYF3e4VfOQb7FOCUy0K01E1agIEWog5cNPIj uFemPf+51SH4XZb4CVST8EMz2WHf6Kof1fpYL4JIkS8foH/pGLKG9KQWQWBR7pXOVT+kWfOKkU3 SRbAiNM8SfL4c6a/jSqCSFg9vJivAGskiMW5X/2deHPR7FOTIl6Zi+wElLAFstWafXiOKLqn+Vz Y+OsmJYohGc23dROWybQAokS7wk1uPbssNdO7hvn4fGUxmpctCQTdyp4108BPDc21QqyJER/5A9 PcRYt23ReYZossr7njBmKJOzw+eigobq0J1rVSL4SrxgPFKwzZ9bepqcxa8L0EmrXcbn5H+trSI w9E647UFcr6j7gSfbzxDjh81Ltaq65eqVdZsiEgyXO/YAJn+lQYpLinjOTlDzIfHnlwHaUReYyr VIBZa4/DVB/UizwewdrLHmmUMU1Sjblog6Gnmbm0lpfu+3hZtU2hF4c1qhchla1GjeXV39Wyu/N 1zFsyVXREbtsQB6HNHDf6nGc21w== X-Received: by 2002:a05:6000:41c8:b0:48d:faa6:cedf with SMTP id ffacd0b85a97d-48e6e50645dmr30646945f8f.56.1793723841371; Tue, 03 Nov 2026 08:37:21 -0800 (PST) Received: from threads.localdomain ([90.254.187.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71a4d3e9sm29044772f8f.6.2026.11.03.08.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 08:37:20 -0800 (PST) From: Lucas Tanure To: xianwei.zhao@amlogic.com, Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Maxime Chevallier , Maxime Coquelin , Alexandre Torgue Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/7] net: stmmac: dwmac-meson8b: follow the generic RGMII delay rules on the T7 Date: Tue, 3 Nov 2026 16:37:12 +0000 Message-ID: <20261103163715.385394-5-tanure@linux.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261103163715.385394-1-tanure@linux.com> References: <20261103163715.385394-1-tanure@linux.com> X-Archived-By: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261103_083723_109763_712A801D X-CRM114-Status: GOOD ( 17.16 ) X-Spam-Score: -0.8 (/) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The delay code reads phy-mode as the list of delays this glue has to add, falls back to a 2ns transmit delay when no property asks for one, and takes the vendor delay properties. ethernet-controller.yaml says the opposite: the PHY adds the 2ns delays, and the MAC properties only hold small fine tuning added on top. Every board in the tree depends on the old reading, so it stays as it is. No T7 board uses this glue yet, so the T7 gets a path of its own that follows the generic rules: the receive delay line is fine tuning in 200ps steps, and the transmit side, a quarter-period phase step, offers none, so the transmit property is refused. Assisted-by: LLM Signed-off-by: Lucas Tanure --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 450f7b4b29a6..c8bd15b6780b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -80,6 +80,7 @@ struct meson8b_dwmac; struct meson8b_dwmac_data { int (*set_phy_mode)(struct meson8b_dwmac *dwmac); + int (*init_delays)(struct meson8b_dwmac *dwmac); bool has_prg_eth1_rgmii_rx_delay; bool has_pipeline_clk; }; @@ -338,6 +339,41 @@ static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac) return 0; } +/* + * The T7 follows ethernet-controller.yaml: the PHY adds the 2ns RGMII + * delays and this glue only fine tunes the RX clock on top of what + * phy-mode describes. Its TX clock has no fine tuning, the only step is + * a quarter of the clock period, so the TX property is refused, and so + * are the vendor properties of the older SoCs. + */ +static int meson_t7_init_delays(struct meson8b_dwmac *dwmac) +{ + struct device_node *np = dwmac->dev->of_node; + u32 cfg_rxclk_dly = 0; + + if (of_property_present(np, "tx-internal-delay-ps") || + of_property_present(np, "amlogic,tx-delay-ns") || + of_property_present(np, "amlogic,rx-delay-ns")) + return dev_err_probe(dwmac->dev, -EINVAL, + "only rx-internal-delay-ps is supported, the PHY adds the RGMII delays\n"); + + if (phy_interface_mode_is_rgmii(dwmac->phy_mode)) + cfg_rxclk_dly = FIELD_PREP(PRG_ETH1_CFG_RXCLK_DLY, + dwmac->rx_delay_ps / 200); + else if (dwmac->rx_delay_ps) + return dev_err_probe(dwmac->dev, -EINVAL, + "rx-internal-delay-ps needs an RGMII phy-mode\n"); + + meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_TXDLY_MASK | + PRG_ETH0_ADJ_ENABLE | PRG_ETH0_ADJ_SETUP | + PRG_ETH0_ADJ_DELAY | PRG_ETH0_ADJ_SKEW, 0); + + meson8b_dwmac_mask_bits(dwmac, PRG_ETH1, PRG_ETH1_CFG_RXCLK_DLY, + cfg_rxclk_dly); + + return 0; +} + static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) { int ret; @@ -452,7 +488,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) "missing pipeline clock\n"); } - ret = meson8b_init_rgmii_delays(dwmac); + ret = dwmac->data->init_delays(dwmac); if (ret) return ret; @@ -475,21 +511,25 @@ 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, + .init_delays = meson8b_init_rgmii_delays, .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, + .init_delays = meson8b_init_rgmii_delays, .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, + .init_delays = meson8b_init_rgmii_delays, .has_prg_eth1_rgmii_rx_delay = true, }; static const struct meson8b_dwmac_data meson_t7_dwmac_data = { .set_phy_mode = meson_axg_set_phy_mode, + .init_delays = meson_t7_init_delays, .has_prg_eth1_rgmii_rx_delay = true, .has_pipeline_clk = true, }; -- 2.56.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic