From nobody Sun Oct 5 16:15:46 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 4F1B72222D7; Fri, 1 Aug 2025 09:13:16 +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=1754039599; cv=none; b=Gd2tIerowH0EhTod3OSwAcgIY8LpaDcdl6fZ68qva+K3MRj+wyPYgzCY9L72fxHG4hP9RHhIz9J5DugMMpFrQVH9USRtfI0tHc8qPbd3cNOxPRNae046OebTiesyEw+ErEJWI+1oX6ZAKQ2lKHSx0C23/kGg60fsGWEWeaMMvqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754039599; c=relaxed/simple; bh=0a/cTE0bx1ATJ5XeKNodUXK3aNY1rEiyvhz5v3jv5T8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CqTEfX+n2+Z1pzCnp6TLlmZa/jV8XRv0ncJtaE0ZOy8mKnluxMC2FbCBkS4HYZiCwxTcOGxWiWtCBvh/5AuFP7RED7q+rX8Ozxq4IXc0im9fZgFKFzfrX0MJResbVROc/NqapXAh6rT2LYaHUDp0hVcTE1xdFMvkF9qYHCR8K3Y= 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=eFJntMlv; 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="eFJntMlv" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6377A2072F; Fri, 1 Aug 2025 11:13:14 +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 hIxTaEIjrnft; Fri, 1 Aug 2025 11:13:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1754039593; bh=0a/cTE0bx1ATJ5XeKNodUXK3aNY1rEiyvhz5v3jv5T8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eFJntMlvqkYUyfSsujXcVIBs5oApoYhdSGJGyQIYLP71GO2TqgTlWq8dEJtoB/vhD RftaFO0h68vB5P0f1aixtY4w+J6skwOr73EtHBvnOl0HSZly+axLy+TOvq3gaLWiSF aMKQXMEkygd8H4h+L5j+j6sISNNuDCaHMMZJ0TcN11pZHWiTyDvk2J5TyGdNtiNVgf G3j+CTaIBZq0F62HYmX+5K/dMYcIlVK34qIp1o69P757ZSHuwX+Aw1WqcgzbNwEw10 vcgk45l+5Te7bEj7vQ6/noZXUurs6g4EIxOjVUk6SfhCvcJ7grfc4dXqmGKa7L2Uov uHUeGpH2E5UYg== 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 v2 1/3] dt-bindings: net: thead,th1520-gmac: Describe APB interface clock Date: Fri, 1 Aug 2025 09:12:38 +0000 Message-ID: <20250801091240.46114-2-ziyao@disroot.org> In-Reply-To: <20250801091240.46114-1-ziyao@disroot.org> References: <20250801091240.46114-1-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 Tested-by: Drew Fustini Acked-by: Krzysztof Kozlowski Reviewed-by: Drew Fustini Tested-by: should be dropped if there or is another series or when --- .../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 Sun Oct 5 16:15:46 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 36DB514F70; Fri, 1 Aug 2025 09:13: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=1754039606; cv=none; b=kK2tMC6Xzuv4KYONRLyZ9sZapJC5TJJ9JOmT9WhCb3OLWvBl7/YLeD1Zsi8MmVstRuLXMhznXBhomtV4s+QFgUjk5XTFYu3lulNnEgN/zjUv8GGIGIGhRt1ESnpeIhtZFKavmmCCanNOAKAz3VCDUnBaVd4TuGkgczxxuwdNl9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754039606; c=relaxed/simple; bh=mREQxr9hxnCZLcPI7LJv8koSLrqI56N3FH8DH5s+/KY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l6nfWnhY1gdYmKVcxzGiqfAcDXLFd5N8q2MkAzv4O6NnX0+ieXssqXcEsk32EQx39+xi1t4181kC5q/KF8+pfervaDVL3URZE17f2r5InoIWIdac4Cnzacjsph9V3BKlTG4b56UvWAFr/SopmsFz7sLsnXFwLcBm+OA6iTol0A8= 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=E+xqim97; 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="E+xqim97" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C3D172072F; Fri, 1 Aug 2025 11:13: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 k86eVxTC7xFp; Fri, 1 Aug 2025 11:13:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1754039603; bh=mREQxr9hxnCZLcPI7LJv8koSLrqI56N3FH8DH5s+/KY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E+xqim971noDZDK5NhLGGrGS2kDOzOrPVk+EC0AwF5rpjKeRr1gZlZAoEO7wJMWen //y5p8Sw/nrt2yubZGGHaSrOytF8iVPM/lZitckJY3jv9vTkpujNKYZoxLfxGTcvjl FzpcuxWK7Kfx/af8caYsgjfNk+jxlVJ0vTrWlL/h/GRLtadn98xHNX91QSt4Bt5wDJ JGYkG+hCX1xt6IJwMw1fzGZdfIsdApO0hga6DWukdX/kvyhKCiOTHEV1s86a0u4RrY RDfsC2uR/cuUhk6a0WAPWBGgE6/+zi77fdJWxVb7xaiUP8P74rYApM80U8CGmU9Bad xa7nWjw3Zyfew== 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 v2 2/3] net: stmmac: thead: Get and enable APB clock on initialization Date: Fri, 1 Aug 2025 09:12:39 +0000 Message-ID: <20250801091240.46114-3-ziyao@disroot.org> In-Reply-To: <20250801091240.46114-1-ziyao@disroot.org> References: <20250801091240.46114-1-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. Fixes: 33a1a01e3afa ("net: stmmac: Add glue layer for T-HEAD TH1520 SoC") Signed-off-by: Yao Zi Reviewed-by: Drew Fustini Tested-by: Drew Fustini --- drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c b/drivers/ne= t/ethernet/stmicro/stmmac/dwmac-thead.c index c72ee759aae5..95096244a846 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,11 @@ static int thead_dwmac_probe(struct platform_device *p= dev) return dev_err_probe(&pdev->dev, PTR_ERR(plat), "dt configuration failed\n"); =20 + apb_clk =3D devm_clk_get_optional_enabled(&pdev->dev, "apb"); + 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 Sun Oct 5 16:15:46 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 B79793C38; Fri, 1 Aug 2025 09:14:14 +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=1754039657; cv=none; b=pCKE5wCDqharB+L3/AzGaptnPphiniB7RDzrfJbsLy99NxqRlSh2Mycgp2Bx+imqWUotuqU10KsmWUMfxN7H6FCwGQZMZUmqxlyomR0m3CpGwlBvE0cXhqqtxoDRAgR55VORPuOZ+SArk3FYhiXadTiiewvXho94sniV++9Uk2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754039657; c=relaxed/simple; bh=gJCswTbeSm0cfVQDYDQlFj9ENNDHXqLsDS5p8UVfsgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=reMt4WUEXRK/9IC1qN1omPH/TkLmM1CVqcLv/JEF9tYG9IrxgVrUyvjMAJDT4sIh8v2W6kczjHHI+gkTj1V2M6QiFF82RxXSS1QjlEuMgrslXgS4bpMik9lopQnrFgJr4nXkjwlIZkAUjfVzpGk2Z3F0wWrgxNC6p4EmSX/IsoE= 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=kHneXBoV; 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="kHneXBoV" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 3516520E2E; Fri, 1 Aug 2025 11:14:13 +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 vMBKehoM4TjO; Fri, 1 Aug 2025 11:14:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1754039652; bh=gJCswTbeSm0cfVQDYDQlFj9ENNDHXqLsDS5p8UVfsgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kHneXBoV4+3z2CKrLnBMl2/wPm8HQG+g/FZ79WqnWUyBdRcVgEQJ7/1pL4HC25Tk8 sTQC63MV4YROaCJTJgkBaiF7GHg+rR5IwXNg7rBSjd8leon5qvE4ZZLdd2kZVvo+gC Miqqv49cvTIs3Dlz0gnW2wYK+typqmE/TvxoZi4w+15bTnk8zfWZq11Z/NPD3uNkUE ECGGSD3gGiDKnUlRhWMyb1PHsyQB25j4DeJr+GkP3BN55b/jfRU4hlQAWYkWoetxhN T5YxIIYPXTJ7TRcJAzculAzZmEhPPjT95yqbazpkLwEgwQF0aBa1lU2CwjPk3dPD/k o9+BYsI2k72FQ== 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 v2 3/3] riscv: dts: thead: Add APB clocks for TH1520 GMACs Date: Fri, 1 Aug 2025 09:12:40 +0000 Message-ID: <20250801091240.46114-4-ziyao@disroot.org> In-Reply-To: <20250801091240.46114-1-ziyao@disroot.org> References: <20250801091240.46114-1-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