From nobody Mon Dec 15 22:40:38 2025 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D991327147A; Fri, 8 Aug 2025 09:44:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754646267; cv=none; b=jtzXsRfyGVd3UAs+hwBd/Jp5eQdolzqPhuGG2XGWj6kFyPuDls9Xb6sXSYs0y4jt1j9p4cm/mq7XSMn9WZ/anvCmXYJ2kWG6tLrZViAOVzLklbURtQQN6vEoozSkV1su+JAMxahjPi1tGb1eQHskycxeSV9l7PBdkKsgk7T06/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754646267; c=relaxed/simple; bh=bvjn31etsIDthI47vSBHLCji4m9GlQ5217Yq/HieC5o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oz+mYgBm7aGksmCQJ4Ipt4ZAR3ADyfu7rKJxc3QdnIQXoi/9XL60AwqGaB6pRanlVMavy00pi4blD+NVnpgH9w1NG72tz7mWocXvfsp1wTLeJg9zmqvzn1eyb9/7jV/5+Ng0LXxG+AUyEyam6nBkViWOt0aeWe18BoSqA6diQsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=cj+huHdm; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="cj+huHdm" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id ED81925B19; Fri, 8 Aug 2025 11:44:23 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Lu_epiSKnSqX; Fri, 8 Aug 2025 11:44:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1754646263; bh=bvjn31etsIDthI47vSBHLCji4m9GlQ5217Yq/HieC5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cj+huHdmkhARCGiOcrZcGJSUuR3pusyK9Uv8Xv/zJgYFvsJoIyX4vxFogismahLxZ 18uyN6wFHzItDLknPaabQMd4cl9ag/m/eeR48DG9Gu+WhwnrvRplJsGGAArwI9Npjb 0+VpHXImP1Qaq7dW/bsd6VsjumQjcBHhlyiZOtwx3PxGyG8I0ebAasxbH8KHZNkJLs T4pEL37ABg4guftpTvAfVJpFAGwdiph0Bs1aQ/z6BhkoCI41DfwDP6XSJsjOiC1wEl Uw8d6o3WghJ4/DzlO8FbPa24twqdlbbHjJQ1yHqsQ38eJZyZvOR4ePo525tR0JE6Op mIkpuGoHaaWzw== From: Yao Zi To: Drew Fustini , Guo Ren , Fu Wei , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Emil Renner Berthing , Jisheng Zhang Cc: linux-riscv@lists.infradead.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Yao Zi , Krzysztof Kozlowski Subject: [PATCH net v3 1/3] dt-bindings: net: thead,th1520-gmac: Describe APB interface clock Date: Fri, 8 Aug 2025 09:36:54 +0000 Message-ID: <20250808093655.48074-3-ziyao@disroot.org> In-Reply-To: <20250808093655.48074-2-ziyao@disroot.org> References: <20250808093655.48074-2-ziyao@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Besides ones for GMAC core and peripheral registers, the TH1520 GMAC requires one more clock for configuring APB glue registers. Describe it in the binding. Fixes: f920ce04c399 ("dt-bindings: net: Add T-HEAD dwmac support") Signed-off-by: Yao Zi Acked-by: Krzysztof Kozlowski Reviewed-by: Drew Fustini --- .../devicetree/bindings/net/thead,th1520-gmac.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml b= /Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml index 6d9de3303762..b3492a9aa4ef 100644 --- a/Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml +++ b/Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml @@ -62,11 +62,13 @@ properties: items: - description: GMAC main clock - description: Peripheral registers interface clock + - description: APB glue registers interface clock =20 clock-names: items: - const: stmmaceth - const: pclk + - const: apb =20 interrupts: items: @@ -88,8 +90,8 @@ examples: compatible =3D "thead,th1520-gmac", "snps,dwmac-3.70a"; reg =3D <0xe7070000 0x2000>, <0xec003000 0x1000>; reg-names =3D "dwmac", "apb"; - clocks =3D <&clk 1>, <&clk 2>; - clock-names =3D "stmmaceth", "pclk"; + clocks =3D <&clk 1>, <&clk 2>, <&clk 3>; + clock-names =3D "stmmaceth", "pclk", "apb"; interrupts =3D <66>; interrupt-names =3D "macirq"; phy-mode =3D "rgmii-id"; --=20 2.50.1 From nobody Mon Dec 15 22:40:38 2025 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EE85273D74; Fri, 8 Aug 2025 09:44:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754646276; cv=none; b=rvgv2FCPHqNkztWSzbxN2ykmgZmtWLipWhy+4Ql9YgcsIxdsA+ejJmKAOkMS3FrlNhlgEUs1kqDhLD4Y33XvkCIG6VJ1kzuHTIVfM9yuT1GoPfkJu8abL2AzJhvBIqxi8kxrYx07aNyLXGsw5FfhAVJlkFdEzatUDgWn0Agskz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754646276; c=relaxed/simple; bh=ajJkn2rR1tM7L+hlXIfE6Ac5tEpM02G6+RdV1+gRsGo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XfO8529FYWPK+VtQH3O6/joCwSCViISTlBzSq6d++t0tuYJaCecyEYpCyObA0h9BdM0X8bV+ErTquxb7owmW+BKKs2sNHmeURefOwyAyTGhs8rabdu7he33+mE9tIC6852wawVM4H6Fu6v00Mq2Sn1VfxqVMKkCLtPZESFNPlGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=JybmdVyl; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="JybmdVyl" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C5AD22093B; Fri, 8 Aug 2025 11:44:32 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id pSeEIdqlRFtF; Fri, 8 Aug 2025 11:44:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1754646272; bh=ajJkn2rR1tM7L+hlXIfE6Ac5tEpM02G6+RdV1+gRsGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JybmdVylgPRleVDjovbA2Dctq0OezgzR/rAOTF3LYY4tUfpDcdZz7e/VNyoQI0YdV ftwpNXkUC2/xOcLhGTCi/9Otu3cS4fLdd7QXBF+L5kgeQHaxpKOUrxdZRjNoFHxm0n KJfeYKEloOAkMrFkB+s2kTf8QoMCxEZm7IJLd037ypam2RZLHPvvNmaCBZcyBVgUW8 1SgAZVXuUdR4RiNkPtAFH8Isw9EEt5uaxt3rNJypLtxBjnrTnWJojOQqtCv5+/2OMs XfNq+/YMrpzwhz+P0fKIO2MIIzkM4yjLfPsVThzUR+ZH0RqGO2xztKv4YubZCpLAKS 1MWau214tA2dw== From: Yao Zi To: Drew Fustini , Guo Ren , Fu Wei , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Emil Renner Berthing , Jisheng Zhang Cc: linux-riscv@lists.infradead.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Yao Zi Subject: [PATCH net v3 2/3] net: stmmac: thead: Get and enable APB clock on initialization Date: Fri, 8 Aug 2025 09:36:55 +0000 Message-ID: <20250808093655.48074-4-ziyao@disroot.org> In-Reply-To: <20250808093655.48074-2-ziyao@disroot.org> References: <20250808093655.48074-2-ziyao@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It's necessary to adjust the MAC TX clock when the linkspeed changes, but it's noted such adjustment always fails on TH1520 SoC, and reading back from APB glue registers that control clock generation results in garbage, causing broken link. With some testing, it's found a clock must be ungated for access to APB glue registers. Without any consumer, the clock is automatically disabled during late kernel startup. Let's get and enable it if it's described in devicetree. For backward compatibility with older devicetrees, probing won't fail if the APB clock isn't found. In this case, we emit a warning since the link will break if the speed changes. Fixes: 33a1a01e3afa ("net: stmmac: Add glue layer for T-HEAD TH1520 SoC") Signed-off-by: Yao Zi Tested-by: Drew Fustini Reviewed-by: Drew Fustini --- drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c b/drivers/ne= t/ethernet/stmicro/stmmac/dwmac-thead.c index c72ee759aae5..f2946bea0bc2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c @@ -211,6 +211,7 @@ static int thead_dwmac_probe(struct platform_device *pd= ev) struct stmmac_resources stmmac_res; struct plat_stmmacenet_data *plat; struct thead_dwmac *dwmac; + struct clk *apb_clk; void __iomem *apb; int ret; =20 @@ -224,6 +225,19 @@ static int thead_dwmac_probe(struct platform_device *p= dev) return dev_err_probe(&pdev->dev, PTR_ERR(plat), "dt configuration failed\n"); =20 + /* + * The APB clock is essential for accessing glue registers. However, + * old devicetrees don't describe it correctly. We continue to probe + * and emit a warning if it isn't present. + */ + apb_clk =3D devm_clk_get_enabled(&pdev->dev, "apb"); + if (PTR_ERR(apb_clk) =3D=3D -ENOENT) + dev_warn(&pdev->dev, + "cannot get apb clock, link may break after speed changes\n"); + else if (IS_ERR(apb_clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(apb_clk), + "failed to get apb clock\n"); + dwmac =3D devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); if (!dwmac) return -ENOMEM; --=20 2.50.1 From nobody Mon Dec 15 22:40:38 2025 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E2D325EF87; Fri, 8 Aug 2025 09:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754646331; cv=none; b=HsCXsKfH7g0Ed8hjkYGmHHIApaQGZ/56bflU4KpxbsQSE2rZCofhSvyRCoR2tn3X+jjij+Y3H2WhNdzMFF2Jpz++jnFoULK0Ug6cD3ygjk8MoHQQ9oWJ77YOqOIU/X0PfA5w9NpjzHdC8ML4/3IIh6kpOj3vsOARlfd/ZL5GgmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754646331; c=relaxed/simple; bh=gJCswTbeSm0cfVQDYDQlFj9ENNDHXqLsDS5p8UVfsgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TwEPulhNjeuuWvnvzZe+Owk4DRJHTejgHyzuVXevmLit0zwnQbDBQLoPkDC0rqytTkplxlpptiUa4V3AZkopQOzlbVKLL2nfa+znP0oBFGBQjgqNOxwT+R9b7sfF9T8BEjyhTPrKBDwZ7eym8TqhR/SWjFZnW6WWJReCuF8i/Gw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=JuWdI/22; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="JuWdI/22" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id A633123CB7; Fri, 8 Aug 2025 11:45:28 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id aQEZZtQOrJMo; Fri, 8 Aug 2025 11:45:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1754646328; bh=gJCswTbeSm0cfVQDYDQlFj9ENNDHXqLsDS5p8UVfsgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JuWdI/22rnTfj2+JDLe2ZFyQkwJTP7HMjmbYqFkH//AlUH3gEJbC7WqnExmM4Essq UxFUpesshFjjPOcR5Mq6H1pkI3xd/GbzIrdN4sDqaZDMwuOq85mMIdKH+FE/Tptx9y 8zW68LQa3IynfDKWmRaT0BHQ2QIvMocS22ZqActTwLrUY1AJmaLsAp4/HWUBWM/p8y xO27gMxq/Dj7JDyb4W+Sd5L4Ku1xsdvep3P87J0rKgxGqDBdOeueMhJaeil7Oje/I3 X0IjEMhbCU/yX3cSoOf9DekyJnke9GH9qBhZkK7bn1E92EGrVt4PuTrIfKOU2dnA1y eGYyHIeZPGm0w== From: Yao Zi To: Drew Fustini , Guo Ren , Fu Wei , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Emil Renner Berthing , Jisheng Zhang Cc: linux-riscv@lists.infradead.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Yao Zi Subject: [PATCH net v3 3/3] riscv: dts: thead: Add APB clocks for TH1520 GMACs Date: Fri, 8 Aug 2025 09:36:56 +0000 Message-ID: <20250808093655.48074-5-ziyao@disroot.org> In-Reply-To: <20250808093655.48074-2-ziyao@disroot.org> References: <20250808093655.48074-2-ziyao@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Describe perisys-apb4-hclk as the APB clock for TH1520 SoC, which is essential for accessing GMAC glue registers. Fixes: 7e756671a664 ("riscv: dts: thead: Add TH1520 ethernet nodes") Signed-off-by: Yao Zi Reviewed-by: Drew Fustini Tested-by: Drew Fustini --- arch/riscv/boot/dts/thead/th1520.dtsi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/th= ead/th1520.dtsi index 42724bf7e90e..03f1d7319049 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -297,8 +297,9 @@ gmac1: ethernet@ffe7060000 { reg-names =3D "dwmac", "apb"; interrupts =3D <67 IRQ_TYPE_LEVEL_HIGH>; interrupt-names =3D "macirq"; - clocks =3D <&clk CLK_GMAC_AXI>, <&clk CLK_GMAC1>; - clock-names =3D "stmmaceth", "pclk"; + clocks =3D <&clk CLK_GMAC_AXI>, <&clk CLK_GMAC1>, + <&clk CLK_PERISYS_APB4_HCLK>; + clock-names =3D "stmmaceth", "pclk", "apb"; snps,pbl =3D <32>; snps,fixed-burst; snps,multicast-filter-bins =3D <64>; @@ -319,8 +320,9 @@ gmac0: ethernet@ffe7070000 { reg-names =3D "dwmac", "apb"; interrupts =3D <66 IRQ_TYPE_LEVEL_HIGH>; interrupt-names =3D "macirq"; - clocks =3D <&clk CLK_GMAC_AXI>, <&clk CLK_GMAC0>; - clock-names =3D "stmmaceth", "pclk"; + clocks =3D <&clk CLK_GMAC_AXI>, <&clk CLK_GMAC0>, + <&clk CLK_PERISYS_APB4_HCLK>; + clock-names =3D "stmmaceth", "pclk", "apb"; snps,pbl =3D <32>; snps,fixed-burst; snps,multicast-filter-bins =3D <64>; --=20 2.50.1