From patchwork Mon Dec 23 00:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13918338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8E6FE77188 for ; Mon, 23 Dec 2024 01:01:53 +0000 (UTC) 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-Owner; bh=SgF2Hc+S7mFJWX+7yjo0AlUC5vVWN3lVossRXQ7pGuE=; b=o0MiFwT0BSltKe y6lidQLbIXD7vULD6cHdNTUsGpx6vupJ7PSRE1mQDdaPRepCxCfn6k/BzZV663RqrXO30EOel2H8x EjNVx1jEtXe59Ac7QIfIOClPIrq6I/jjWKuaiqQ4HClM8QOVvK6nhp/J6ww5oq0hXqP98ve3JxoQ3 dAdtFcRi3nnpztzybF1fjWHNATkVXktCWUcDS6uVXZSCms3SUcquTIK5UebHkveT7PFmDlKTjQwIp Pme8X/SAgh2z6foBLkbg85g7C58vDCuk5nQY5rfBm2JKhqWcNx9MnW7SeekBbeNpYkguv17QL/V87 xkctAPlOx2REBQnsaqxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tPWpR-0000000933n-2HOp; Mon, 23 Dec 2024 01:01:49 +0000 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tPWn6-000000092ab-3urd; Mon, 23 Dec 2024 00:59:26 +0000 Received: by mail-qv1-xf2f.google.com with SMTP id 6a1803df08f44-6dcd4f1aaccso56806756d6.2; Sun, 22 Dec 2024 16:59:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734915564; x=1735520364; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jRWA/tM4Nlwg4+7MH+fMHivDiS7vd/AnzDx119oQ4ZA=; b=Q1cdNzOaZNjrzPWmK+y5Fz89ka8vvDITzYHlfRz3ztRjDGHTexV01g8ziHrXix/qwK 4dmNNjROfaI9ayHfBktf924FSV7jaPOPJv/+wLvETjGfl75gEWtcE44N+VroVKSJ2sNO ifK8Y4BQTEMS1qzA17yfQXE5XMauWAApWY6EohopqCgKbaDFMMeHvaAxaUuh2FKvHX5H FegbH9L3khwuD/oG4279ST6H3xKgpf2xL03edk6jDJFzYrOhaUE3u+H4OPT1bLwRs4on aLkaSUj1qiuJaElNv4Rxor6QUmkbk3Clf+On9jeCnPLBtepjzhdylQDfLz8SbSB+2oW1 T1Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734915564; x=1735520364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jRWA/tM4Nlwg4+7MH+fMHivDiS7vd/AnzDx119oQ4ZA=; b=qMun2WbFSQnSaUzhuI2VeYaAgX7iVKysqSbV2DAsjAr5spR0kIf8sSCfnCPLt1u4kR 1aCFrNFGEpNwZSeqN00TCdpE4PyXsBKn3BV4M+zdQXrVdJWi3HvqiTqavQqFVJV7C6Vw qER/KnoWQO7eeo7k0vu+JIsjxU9F0FdJ/HLeLI5tge58bGKE1m+d/eHryAyFyzo1TwZR MXbJzX7gTvf1u0slIVtl9B5WpleaP/YPRLt5XUfq81XaS4u8c7NL9h5EPTb4pRAdD+WF mt4sw5bMLBgqzz14KVMBhnnVeS+wUISXX0l6bQuhyJE/maoBcjwG7cLHJkus1PJEmKt2 rYZw== X-Forwarded-Encrypted: i=1; AJvYcCXBsldgLxvPQQbvX20f8jVuBjNGFgcqGON+wkHRvDn4Jli976LZESh8jfrHYHAikmurVkrooa0DtmLqRhlW7AEx@lists.infradead.org, AJvYcCXE+Himjto55lWuR8P0sm01M3ZbVlC7a9rIaunsl9W292sd3cUUIb6ajajY64yjpDcUPcM1gQWrLJhztRA=@lists.infradead.org X-Gm-Message-State: AOJu0YyOR3/jESTAw+9kguQwa7CEsPu7ig7IMXTc6+2R2OsZ2cvXOq3q g5x62V72En5bLF7pO5Dc9qmHzl+wSmImtPELEIKeeCbDUaO5Baac X-Gm-Gg: ASbGncv51ANc8TEIS+3KX1Cf9QLgVc7gywwkgaifg7E1y6dX+TS/Jy7Qkh23O4/RqeS l2x7Hm1djfvPP4qEjPRy/5eDizEUl5worH/Y48Ogp/+DWjtA/Ufo3QhIyXUSgltI5HqimIpPfDY yq31DNWjEhnfPy5OesmuPTRVuQDuCuTaZ/hHMOKdswKCGdhHqHKNQwwmqeHVHXOf2ADw0XAcSWO KZgcHf86ZjY3fnJe3LduI3K7VqdP9cr X-Google-Smtp-Source: AGHT+IHN9d1bnlxRzzqRiDcadAYUGSNIOJpqNW2TaHPm8W5wc6dU1Ev4iY1D0s3G2OYKNDwOXlA05w== X-Received: by 2002:a05:6214:d89:b0:6d4:1ea3:981d with SMTP id 6a1803df08f44-6dd233a2bccmr164013606d6.43.1734915563662; Sun, 22 Dec 2024 16:59:23 -0800 (PST) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dd180ea9d0sm39145406d6.7.2024.12.22.16.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 16:59:22 -0800 (PST) From: Inochi Amaoto To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Inochi Amaoto , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li , Krzysztof Kozlowski Subject: [PATCH net-next v3 1/3] dt-bindings: net: Add support for Sophgo SG2044 dwmac Date: Mon, 23 Dec 2024 08:58:37 +0800 Message-ID: <20241223005843.483805-2-inochiama@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241223005843.483805-1-inochiama@gmail.com> References: <20241223005843.483805-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241222_165924_979512_7436509B X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC (version 5.30a) with some extra clock. Add necessary compatible string for this device. Signed-off-by: Inochi Amaoto Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/net/snps,dwmac.yaml | 4 + .../bindings/net/sophgo,sg2044-dwmac.yaml | 124 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index eb1f3ae41ab9..cd112ef6b3bf 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -32,6 +32,7 @@ select: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 @@ -97,8 +98,10 @@ properties: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 + - sophgo,sg2044-dwmac - starfive,jh7100-dwmac - starfive,jh7110-dwmac - thead,th1520-gmac @@ -630,6 +633,7 @@ allOf: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 - st,spear600-gmac diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml new file mode 100644 index 000000000000..b7e4216ea45a --- /dev/null +++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml @@ -0,0 +1,124 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/sophgo,sg2044-dwmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo SG2044 DWMAC glue layer + +maintainers: + - Inochi Amaoto + +select: + properties: + compatible: + contains: + enum: + - sophgo,sg2044-dwmac + required: + - compatible + +properties: + compatible: + items: + - const: sophgo,sg2044-dwmac + - const: snps,dwmac-5.30a + + reg: + maxItems: 1 + + clocks: + items: + - description: GMAC main clock + - description: PTP clock + - description: TX clock + + clock-names: + items: + - const: stmmaceth + - const: ptp_ref + - const: tx + + interrupts: + maxItems: 1 + + interrupt-names: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + const: stmmaceth + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - resets + - reset-names + +allOf: + - $ref: snps,dwmac.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + + ethernet@30006000 { + compatible = "sophgo,sg2044-dwmac", "snps,dwmac-5.30a"; + reg = <0x30006000 0x4000>; + clocks = <&clk 151>, <&clk 152>, <&clk 154>; + clock-names = "stmmaceth", "ptp_ref", "tx"; + interrupt-parent = <&intc>; + interrupts = <296 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + resets = <&rst 30>; + reset-names = "stmmaceth"; + snps,multicast-filter-bins = <0>; + snps,perfect-filter-entries = <1>; + snps,aal; + snps,tso; + snps,txpbl = <32>; + snps,rxpbl = <32>; + snps,mtl-rx-config = <&gmac0_mtl_rx_setup>; + snps,mtl-tx-config = <&gmac0_mtl_tx_setup>; + snps,axi-config = <&gmac0_stmmac_axi_setup>; + status = "disabled"; + + gmac0_mtl_rx_setup: rx-queues-config { + snps,rx-queues-to-use = <8>; + snps,rx-sched-wsp; + queue0 {}; + queue1 {}; + queue2 {}; + queue3 {}; + queue4 {}; + queue5 {}; + queue6 {}; + queue7 {}; + }; + + gmac0_mtl_tx_setup: tx-queues-config { + snps,tx-queues-to-use = <8>; + queue0 {}; + queue1 {}; + queue2 {}; + queue3 {}; + queue4 {}; + queue5 {}; + queue6 {}; + queue7 {}; + }; + + gmac0_stmmac_axi_setup: stmmac-axi-config { + snps,blen = <16 8 4 0 0 0 0>; + snps,wr_osr_lmt = <1>; + snps,rd_osr_lmt = <2>; + }; + }; From patchwork Mon Dec 23 00:58:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13918339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 433F5E77188 for ; Mon, 23 Dec 2024 01:03:07 +0000 (UTC) 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-Owner; bh=U9HLQ4iobUfj+5+eXszgNAUQ8YYCawA/ZCqkTvknEpQ=; b=vBU7T44YRjfzuC sJUFdiiJRcuPEuyPASLtjkuJecY0WLzBUXc3GDk2N32EvmHitn/6uTJvrxAqfizwo6/DhSDTYMi7p 5QFKfvFi+QQmIibQm4K43E7fhGAUfDq2gJ3FWeTjV1PImIjIbd+hlxFXyoigCYegifwvIRtzzT4v1 3z8bjaxc3ju0EfD1RR9e5nlVrCIysQgaTrFA2oe9Fk8sVHbmPLE1gqBTOLkmWY25A1zpJOuMbVYhG md01hFZZbQ8Q9ztjSQ7Lcjsfgaqzj4ThTmmtiBVyYnE2Wc/GWjsUSQhKI9OZ2Ec8AeU0az6SIjuKP 25aC0/7D4NzdZE4AZhIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tPWqb-000000093EZ-421P; Mon, 23 Dec 2024 01:03:01 +0000 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tPWnB-000000092b1-0Hbd; Mon, 23 Dec 2024 00:59:30 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-7b6e9db19c8so275511985a.3; Sun, 22 Dec 2024 16:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734915568; x=1735520368; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AiKcNAywK5Cmu1NkwsGA/Qh6M5B4fnjylkQgAEZo09A=; b=khKaXl31WZVWboUz8S5EBrfHGyQaeSMZvcIwv70AelTTBJv7tDPqqaRVSCzyCRv64S VrOhi1I0HsM4eI3IABBgb2pfYD6JdfNUEK/pBsI/0LV+24YajUO50PbIkfqfm9OuBIXO iyY+BvPeueGvETaFIBEiOZVOhn1CW0W7RrJIMNTnGPM8Qn4yEp48kqAJyjA4oeWLmJ0/ YW6G3/NhLW7yXaXpTtTjIKt/9Ff974L/iGuXr6UKsblb70ZHwuAp+6LXSIxMgYVdk1Nq +/HnDtQQBDkiDRllgfmWRy3beYoMdMa7dqQLRtrxMp2f+01Pq3zsytqMMqORfD8RQjW5 NP8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734915568; x=1735520368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AiKcNAywK5Cmu1NkwsGA/Qh6M5B4fnjylkQgAEZo09A=; b=CG5uRKV8iUN1OvdmqGMumnlx4JrRYog2tR1HIWnXbRdSrw4VQfvRUkM30aFHEhrwIL ekWqiw+Xi0fjScD9yIGQpKlwHhxPzp+TbbCbLfd2egmkHJadJgz/nUVtzF6+niF1/Gxi gSGGiDPhJ9Cu/6ztjKo6ql5ygJry13oe74TmWBPKPR/pRdegTGi8ukT2yO3RSXWB7RwS v3JeBTNNHhzfOXDvewZ78xHYubnzyXn//5qz0ciZXD+KJ2gEnbYQnfsphg9xGtCBqu+F TFQzVYE/TJh+cJqSGW0nCi5OCUXh1W+zrfEGNbbp6rxHMN3AF/dUu/j2uOfTURgt4zoU 9lkA== X-Forwarded-Encrypted: i=1; AJvYcCUGajCEa0CLsA3vSVORFl/SWpMiwIia30ckI6WEif8onkEqMvSiplrSi3H/overQy/Xp1BQMx1x6/DPafJyiNJS@lists.infradead.org, AJvYcCXnrVxA63tbRdspTpk4SSSKBFbt+6Ja82SdqO7lTxHknwiV17dZXyXHN1ibON9Ea+LHlVxIsuEzR8UcGEo=@lists.infradead.org X-Gm-Message-State: AOJu0YxAQQQDPNHCJgHjkLT/T04TIhWkhVuUZQfod3WthYiRK8N864Et r0ddmD4ZLiw+8GDovR39aTKT8yu6fSgiNnd49XypIMKYUIQhT6NX X-Gm-Gg: ASbGncuPSVMRMMSmlufMduNFxfSk4xCUdOqm+dTOUOy7sr3sRuLNGOTXrt1Ze826QOn LrQadXghtMudA+7N5haCWKmAtVwrGBQ8YFmbqNkU3Dx4eEBjvcfT8hLe2ALAaRsy9XKu9us83Wk DS0SpmBtVy/2Oss1LRbDIItlqGhh1+lp0jB3fkVjbCUCAn+Q0A2oVAX2lEjB8kuvibJHIqHxPbj KYPfmjE3OlC0es8LfWWLySjF+588xlW X-Google-Smtp-Source: AGHT+IHmWT1/Ptgcfo0yRcOfYVL7jRnYrWxtKz1ZxEcSoQyLNTugTUWefuWbPDDlyPnGLBEXiIHxDA== X-Received: by 2002:a05:620a:394a:b0:7b6:d710:2282 with SMTP id af79cd13be357-7b9ba80ebc6mr1941528985a.49.1734915567731; Sun, 22 Dec 2024 16:59:27 -0800 (PST) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b9ac2bd0b9sm341784485a.23.2024.12.22.16.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 16:59:27 -0800 (PST) From: Inochi Amaoto To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Inochi Amaoto , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li Subject: [PATCH net-next v3 2/3] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string Date: Mon, 23 Dec 2024 08:58:38 +0800 Message-ID: <20241223005843.483805-3-inochiama@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241223005843.483805-1-inochiama@gmail.com> References: <20241223005843.483805-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241222_165929_144169_7F986047 X-CRM114-Status: GOOD ( 10.81 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add "snps,dwmac-5.30a" compatible string for 5.30a version that can avoid to define some platform data in the glue layer. Signed-off-by: Inochi Amaoto --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 3ac32444e492..6ce3e538ce0a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -421,6 +421,17 @@ static void stmmac_remove_config_dt(struct platform_device *pdev, of_node_put(plat->mdio_node); } +/* Compatible string array for all gmac4 devices */ +static const char * const stmmac_gmac4_compats[] = { + "snps,dwmac-4.00", + "snps,dwmac-4.10a", + "snps,dwmac-4.20a", + "snps,dwmac-5.10a", + "snps,dwmac-5.20", + "snps,dwmac-5.30a", + NULL +}; + /** * stmmac_probe_config_dt - parse device-tree driver parameters * @pdev: platform_device structure @@ -552,11 +563,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->pmt = 1; } - if (of_device_is_compatible(np, "snps,dwmac-4.00") || - of_device_is_compatible(np, "snps,dwmac-4.10a") || - of_device_is_compatible(np, "snps,dwmac-4.20a") || - of_device_is_compatible(np, "snps,dwmac-5.10a") || - of_device_is_compatible(np, "snps,dwmac-5.20")) { + if (of_device_compatible_match(np, stmmac_gmac4_compats)) { plat->has_gmac4 = 1; plat->has_gmac = 0; plat->pmt = 1; From patchwork Mon Dec 23 00:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13918341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42368E77188 for ; Mon, 23 Dec 2024 01:04:21 +0000 (UTC) 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-Owner; bh=WcTZ+dGAzmO2+zMYDjDc7FQmz+W4Mq6okzRCwVXrdqQ=; b=ologpIK8P5wHQR GGBFNBWOnuBHe0Ek+zIO6iRDL5wRhm/UYSSBRaE2a+6MqBvkec5t2WEF6BGy7KgM62vO7AiFX0UB1 Ub6VOpv1jkYeZgf3Gt4kqHZ+PHPuhLUyqwbWFMZN7XKqhnQBKUpfaKNQXT9ls0wB1pU3+w4yMO7wd DFMR68Pr+Kafs3XA9fCdyDTndgMWKuUoUXIRaK+MFaGFDgstmLXxHxvgcncn8P8SpkivG9r9J9a/B PKqTgBFu03CRWBs321Qx51dBz1upRE0Kpt/L2YMHTBJpMwD2nyt5GBprozjjF+diQuHriOZ2mEb7F FLzL1rK9+IHnNb66ugcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tPWrn-000000093On-1sxU; Mon, 23 Dec 2024 01:04:15 +0000 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tPWnF-000000092bX-3mZQ; Mon, 23 Dec 2024 00:59:35 +0000 Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-467b955e288so35790251cf.1; Sun, 22 Dec 2024 16:59:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734915572; x=1735520372; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dSgmUq6fWDAYGhUiI+1p1Nvpascpw09NerCf1YnBrAA=; b=Mpcek3lblnjQiIxTt22BTNL3uebBwHOzZ0Xop5Q7es9NTsMlNIu3jLG8v1hNf6ULOL 2Sj258CGfX6FeCbj+Ui9FMBf9xzmsQxiORgaqBTEgrM65+DpOhePnToF91LC2U7RcKAB Bj3OmdQRdD4RC3uBA7+y4zbVJKYkXrTL7VD4GrhxHqneYCQLHmCwd0yBOqTxj7pEZXOe g07a8pyplpsR++kKvINqQ9k8RN/jyj4oG8+RFaxgokh2U2Ot3h5IGGIIitlzuj7h11+2 O4RmV8Br503EpKa4vKxJ4kDUPcpRSk+3kO8w9uSihCVhXv8R8NNWODrbxGY01qlEQom6 ZGqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734915572; x=1735520372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dSgmUq6fWDAYGhUiI+1p1Nvpascpw09NerCf1YnBrAA=; b=FMOK8gx0E7NLjkslZKSHsANJitA70tqPOEDywBNAvN+TxVIClhte4LeBCk/t4V/R0v h3TKZO7Kx7bL625AwgjTDeRvn8mNQCJ5DrFrM4cS2ezBvXhJ291hKXktun3zI/qpcS/0 huFGlso3PXwLXYyZWygJh34f/xkTDfL00hrMaSM8m5ISKJTRRKbHeyadYCMK0dD5B3f1 n5i5XSTcixCg94mIrkxgH29U00kRdvVgsQh6jJeJl0Cxx0wlUu0+RN3aJrnaEa6lc6TI C4HF0WZ8KT2Y98ORAWak9nRODCuizoRCorxRcu84gnbqC9A2wATmDvg77sRNS8bvj+Qb SI+A== X-Forwarded-Encrypted: i=1; AJvYcCVUgYKdunGdyN6jxk6Hlt/0zh1SsGtGqqCNmSy2GwOGxcVFQx6SWt2TW24W500ZMwwiIymIYsnQVpro887x7f8Y@lists.infradead.org, AJvYcCW6+qZXcIwxYe1XgibTgQatIdhh0NunDEycYNhmNOYUbjIWuESvYbRpW6hCo3uH9o0tZMw/Ys+8jk/J2tU=@lists.infradead.org X-Gm-Message-State: AOJu0Yxr7YAn3vJGMTGXslTx6hHFuxQ2hwN4kaKyBo1a2N9stDPKHJnI +cknEZGiBG/bZatIluJhYTc9rahN2TTywbPdyyF73FTi4E/tHxj6 X-Gm-Gg: ASbGncsjcoJL89ZWt+p74LvbZ8gzIq5lHi2lGRhkCdHVEA+YwwDOzN4dtZEoEtOHU71 M4hEZ5mKYmV+ku6L2EZbkhDMCEaib9V0oBqGiWxEJOs4EUtQU3MIt77mnIUjej5kdEqpVWh9AUR uif29afACNwIkPsW5Z/u4GYtYbCc8VERyi+tywwEWPVx16uW9793xX5FqWmUhFbAkd9C0UBySs1 MUogvkviIMumaQcQqpuDMfhgbU8toqR X-Google-Smtp-Source: AGHT+IHjz7WDJXZngk0HiOawE5i+rAuNn2t3oiKW5rDk4l39S/7Vt67KkTJKlnank9Y1jvPWV5vKBA== X-Received: by 2002:ac8:59cf:0:b0:466:9824:16ef with SMTP id d75a77b69052e-46a4a8b5f64mr181259011cf.3.1734915571686; Sun, 22 Dec 2024 16:59:31 -0800 (PST) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb33b11sm39454091cf.72.2024.12.22.16.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 16:59:30 -0800 (PST) From: Inochi Amaoto To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Inochi Amaoto , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li Subject: [PATCH net-next v3 3/3] net: stmmac: Add glue layer for Sophgo SG2044 SoC Date: Mon, 23 Dec 2024 08:58:39 +0800 Message-ID: <20241223005843.483805-4-inochiama@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241223005843.483805-1-inochiama@gmail.com> References: <20241223005843.483805-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241222_165933_945573_CA72E8B4 X-CRM114-Status: GOOD ( 21.28 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC. Signed-off-by: Inochi Amaoto --- drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 105 ++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 6658536a4e17..23085d27ace6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -169,6 +169,17 @@ config DWMAC_SOCFPGA for the stmmac device driver. This driver is used for arria5 and cyclone5 FPGA SoCs. +config DWMAC_SOPHGO + tristate "Sophgo dwmac support" + depends on OF && (ARCH_SOPHGO || COMPILE_TEST) + default m if ARCH_SOPHGO + help + Support for ethernet controllers on Sophgo RISC-V SoCs + + This selects the Sophgo SoC specific glue layer support + for the stmmac device driver. This driver is used for the + ethernet controllers on various Sophgo SoCs. + config DWMAC_STARFIVE tristate "StarFive dwmac support" depends on OF && (ARCH_STARFIVE || COMPILE_TEST) diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index 2389fd261344..36f21c86568d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o +obj-$(CONFIG_DWMAC_SOPHGO) += dwmac-sophgo.o obj-$(CONFIG_DWMAC_STARFIVE) += dwmac-starfive.o obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file mode 100644 index 000000000000..a4997cc0294a --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Sophgo DWMAC platform driver + * + * Copyright (C) 2024 Inochi Amaoto + */ + +#include +#include +#include +#include + +#include "stmmac_platform.h" + +struct sophgo_dwmac { + struct device *dev; + struct clk *clk_tx; +}; + +static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) +{ + struct sophgo_dwmac *dwmac = priv; + long rate; + int ret; + + rate = rgmii_clock(speed); + if (rate < 0) { + dev_err(dwmac->dev, "invalid speed %u\n", speed); + return; + } + + ret = clk_set_rate(dwmac->clk_tx, rate); + if (ret) + dev_err(dwmac->dev, "failed to set tx rate %lu: %pe\n", + rate, ERR_PTR(ret)); +} + +static int sophgo_sg2044_dwmac_init(struct platform_device *pdev, + struct plat_stmmacenet_data *plat_dat, + struct stmmac_resources *stmmac_res) +{ + struct sophgo_dwmac *dwmac; + + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); + if (!dwmac) + return -ENOMEM; + + dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx"); + if (IS_ERR(dwmac->clk_tx)) + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx), + "failed to get tx clock\n"); + + dwmac->dev = &pdev->dev; + plat_dat->bsp_priv = dwmac; + plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE; + plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed; + plat_dat->multicast_filter_bins = 0; + plat_dat->unicast_filter_entries = 1; + + return 0; +} + +static int sophgo_dwmac_probe(struct platform_device *pdev) +{ + struct plat_stmmacenet_data *plat_dat; + struct stmmac_resources stmmac_res; + int ret; + + ret = stmmac_get_platform_resources(pdev, &stmmac_res); + if (ret) + return dev_err_probe(&pdev->dev, ret, + "failed to get resources\n"); + + plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); + if (IS_ERR(plat_dat)) + return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat), + "dt configuration failed\n"); + + ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res); + if (ret) + return ret; + + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); +} + +static const struct of_device_id sophgo_dwmac_match[] = { + { .compatible = "sophgo,sg2044-dwmac" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, sophgo_dwmac_match); + +static struct platform_driver sophgo_dwmac_driver = { + .probe = sophgo_dwmac_probe, + .remove = stmmac_pltfr_remove, + .driver = { + .name = "sophgo-dwmac", + .pm = &stmmac_pltfr_pm_ops, + .of_match_table = sophgo_dwmac_match, + }, +}; +module_platform_driver(sophgo_dwmac_driver); + +MODULE_AUTHOR("Inochi Amaoto "); +MODULE_DESCRIPTION("Sophgo DWMAC platform driver"); +MODULE_LICENSE("GPL");