From nobody Sun Oct 5 21:59:21 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 AF9D3285C83; Tue, 29 Jul 2025 09:38:10 +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=1753781892; cv=none; b=dqfNRYiUX9Xy0nC6EUCQyI0j2pRCGWfQE89PuptL58P6Dmr6/dV6TbqzI+/y+7MH9M2Wu6vwvvPPbKiEm2Q/fz1yHvG/1dniokfQNdEt0C6QpaL1mZQ38PeMYDU2+YMR+n1t4ysFuM3lx91kN7LSTvr4OyGhfxCyefnQByilZzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753781892; c=relaxed/simple; bh=KckubxbZ+pvtLSm9LYRkKrPsFoinp6cu370w3zIGmtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbDvLvUoQ0NMZQYfkP7J3e9SXYa6Muc//ia0HuoVIJ6aoo9+eIBnA1L3JER7R1M92d6+vQEEcIZIzjkKrBVVTaS9lDTBp6sJKbmfNkJQcASJWGyzjGRjbInC6RYbAtUT8vkjDJrVrLlmuHGQHz4DVIn1T35WOyYpBe6Re3CaeU4= 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=YXLWxqz/; 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="YXLWxqz/" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 0EF442047B; Tue, 29 Jul 2025 11:38:09 +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 msMHQLLUizam; Tue, 29 Jul 2025 11:38:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1753781888; bh=KckubxbZ+pvtLSm9LYRkKrPsFoinp6cu370w3zIGmtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YXLWxqz/tf0VbrkuyE6TpM6Wc6BNMKRNLm//4y/sVJGdvwV4giddqf94ptF4lG07a yVCMtn86CcTdR06cI3HgX1u5w4uNHWW8SErTcEymAhRkb18KLGD8/HB2Pt4yVCB/aW 40hWtan3L5szusC0X8X1TFYzgtFT9vnee6UvE7vzMqqi02sGMh4dN+ye0OyP3YlZb+ 3jhBFgFHXq7lbtRhveJY2Qrnms/odgyc57B4FjrbfPNd8yBKUQ9wrtPJSIll5P3AA4 l9ykh3o7FozLnzmFNRitHCmCjdq0xW9USV3ssvre2Ri8nE7c7Qa+699SdYUJUuDKL9 bA0uNDHwjwTDA== 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 1/3] dt-bindings: net: thead,th1520-gmac: Describe APB interface clock Date: Tue, 29 Jul 2025 09:37:32 +0000 Message-ID: <20250729093734.40132-2-ziyao@disroot.org> In-Reply-To: <20250729093734.40132-1-ziyao@disroot.org> References: <20250729093734.40132-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. Though the clock is essential for operation, it's not marked as required for now to avoid introducing new dt-binding warnings to existing dts. Fixes: f920ce04c399 ("dt-bindings: net: Add T-HEAD dwmac support") Signed-off-by: Yao Zi Tested-by: Drew Fustini --- .../devicetree/bindings/net/thead,th1520-gmac.yaml | 8 ++++++-- 1 file changed, 6 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..fea9fbc1d006 100644 --- a/Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml +++ b/Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml @@ -59,14 +59,18 @@ properties: - const: apb =20 clocks: + minItems: 2 items: - description: GMAC main clock - description: Peripheral registers interface clock + - description: APB glue registers interface clock =20 clock-names: + minItems: 2 items: - const: stmmaceth - const: pclk + - const: apb =20 interrupts: items: @@ -88,8 +92,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 21:59:21 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 D6843233140; Tue, 29 Jul 2025 09:38:17 +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=1753781899; cv=none; b=jE6rhO6hm74I9toxSKhxXiMXHPMtuzf1OG6JjHHrnrxYjR1pjCtNzREhqhBwHN9oeHPrSuXo+EfF57szzSkPMgvgQ0jFfcBpwPgpGn4nBjY7MjSxxovHzwdWgi2EU44FIYw8+q4tPhjpbbaXA08t0cTQ6qT3PFypTaZ7/qgBxmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753781899; c=relaxed/simple; bh=dbCvNaqSs+EE66nSXH0s8xd+C/Lm0/TvIxSmIJpIbVk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NIoXxWOmFvaXvCEG9xi2EnzoAL46tprQWVqvdhReH4DPi4M9UT7yP9GxqW/dIkAZvHMfSVDcu9YA/wwaBg7H6ewE5FMaCywZApiiGbhbeLg3MP/4aAZ1rCG8TbCdLTsaeAcNLzlHGYiq0WtZDKlafRM7vWLHSlI5IJfkDDXePOY= 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=Ok1BP9fT; 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="Ok1BP9fT" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 344BE206BD; Tue, 29 Jul 2025 11:38:16 +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 C6Wu41bWfsYT; Tue, 29 Jul 2025 11:38:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1753781895; bh=dbCvNaqSs+EE66nSXH0s8xd+C/Lm0/TvIxSmIJpIbVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ok1BP9fTsD9JNInYx6Trjr+Cazv/2Waple+MjsYgwP3J2cheZRtcdWsAEVUU4rD4o ZHmsgJNA4rxK7qK/Fqk1coz34H5/kC+CtfFrLG77xCxAvHGtBabX4GqshUNtqjGU2g +kFWuVnExZDqa2E2E2HB+TZcP9qUeiyOue3nZwhQZzyU8ox9QnkUSUXW0nVLAQnOYd JrPFnw8mYGj5SuBQnZD8RNp50KKWP1PMn395U8PGUctd2TF3lumIeSxaEmGaNo8DXH 4vH/+QsXs8cCUUDzgLd6eHWoKegXy6AOXpNyCQhxNmsGAOIoFVVbY4WWTpvksC7jJh 8+luIuwzUdeIg== 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 2/3] net: stmmac: thead: Get and enable APB clock on initialization Date: Tue, 29 Jul 2025 09:37:33 +0000 Message-ID: <20250729093734.40132-3-ziyao@disroot.org> In-Reply-To: <20250729093734.40132-1-ziyao@disroot.org> References: <20250729093734.40132-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 21:59:21 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 1E04C264F8A; Tue, 29 Jul 2025 09:41:46 +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=1753782108; cv=none; b=qwkQbnzajtRQvepOkZx2OKXIkWGm4ZZXkWFyIpEAOWyk8V0wpIMuwxp5bSCvxT8bjas//jaMB+ptm1nhUfubnQxrSqLqcvDHnW9Bymz4PWMERoEdkuj8FHf/IB9MQCPrDUO2rQal5UAJaf+UGP3tGTkmbCAY5e517DGBIKqabxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753782108; c=relaxed/simple; bh=/DRfirf/6tX1d3cecrOUoT/ylGXL16bxkleWN8hcOpM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XnuSnWmi0d0PSbB+WSg/lWgExF8UpsAgDUhe1CWp5RRowomfnlVleaRp1law4YVLGt2WAh6FGhQMBwqYnAVkMvYxWM8g3T55drwd2wn/rsvI2Zvf3fkE7k/swEBuWgkAaNenNnPzWMEz7POJTcPaTRsOZDP6JIcU4R3UkNiPXCY= 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=W/GF8vNk; 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="W/GF8vNk" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 70F4925A96; Tue, 29 Jul 2025 11:41:45 +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 riiRElZg150v; Tue, 29 Jul 2025 11:41:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1753782104; bh=/DRfirf/6tX1d3cecrOUoT/ylGXL16bxkleWN8hcOpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W/GF8vNkmIErBK6sNeP1dkzNGNz1GXJ8rYaze11Iva9WDsfxpW0VE+1kVfhtV/od9 bFK4e1+SVowr9gbTsPvOWatMDY2TASbql5gRmaEOj3B3gzLGgMpWgkBxqvu0Uo+Afn H1PWUWpt3RL//shv3FdAq5J62l4yw4VdJpaPAfBr8VjMu5Y05lxnH+vIFvyRskCgQz C83oz2ZSB4O6rFJ4lpz4iweHwdjP20efmRXcTj2+XaDBHKqN+UoN/Ti9N/a2B4om3C M9eAZMyVlvDouPSsMeZZuTRSiL1Z+Yz1wUNZmPe5CYaiB3Nett3VHYdN+ahzJm/fps gw/td2DGWSM5A== 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 3/3] riscv: dts: thead: Add APB clocks for TH1520 GMACs Date: Tue, 29 Jul 2025 09:37:34 +0000 Message-ID: <20250729093734.40132-4-ziyao@disroot.org> In-Reply-To: <20250729093734.40132-1-ziyao@disroot.org> References: <20250729093734.40132-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