From patchwork Fri Nov 1 01:43:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13858596 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 13E6BE67492 for ; Fri, 1 Nov 2024 01:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=D83zUD3CTgh/1eqyO1pfkLK+N2dWxttwy3sSJgFuC1w=; b=M8BA/+2kGRVnifKP0a8XjCa+d3 OwnotOpKUupF4Pe9L+xQs1bMoBbqYt/g7sFsGgACYEqlJZhFPgaqmVNkVjVLH7jDk9emzq+kvBvGq xb2TFzfv46x6IaRLYQsFJ+/wsozYW9fkPivOR1+K3UdWn9vXESD3pSv+odjS8iDdJfvXjGjKuZ997 Qie5+1LhikzOJhYs7noOWwpjIHdcHmcrnoSI6HFvvq+LNm1edK+Ativ2yw3msstBd/7n48HUuBJdC wLb04z7Hl66jbpyVwU1xAiEsYgxBeoartUfe1ll3Fs7pYguS+C7UAydl/XQBnhawgzSZB7Huj1Ih+ rTzLczJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6gl4-00000005T8x-2hYF; Fri, 01 Nov 2024 01:47:26 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6ghl-00000005SLu-1xWn; Fri, 01 Nov 2024 01:44:02 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-207115e3056so14907525ad.2; Thu, 31 Oct 2024 18:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730425440; x=1731030240; 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=D83zUD3CTgh/1eqyO1pfkLK+N2dWxttwy3sSJgFuC1w=; b=lUasV2K0R0JDropPjOs/guc8T5NaO6vGRJ4EENL0KAV0OfJIds4HUUH8wfMooJPERo UksygMOQ2GU/1tOYXT/r70Y1HDiaRAd++YUA7FSVYoay1aGHvQyoPpFZZzS0GlRzY/TL my5mBtFzjo2qJdTl4A7pR6DGHzG9jptClmLPzNA6DX+3cV5B3whfSjOd3g8m1orrJjJn mpat9QavHlCrtHy2O+s3ewr4qNIXwyfmwM/ysemdI1kLVNij+uMgwGBcUSOpOoB7Hxpp r8E7nHdRBbdsxsJ9wgACuvrazBzQ/dFth2zXcpanVWJk+lSqVpWMb5eQM9oMJOwffpMt VPOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730425440; x=1731030240; 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=D83zUD3CTgh/1eqyO1pfkLK+N2dWxttwy3sSJgFuC1w=; b=Js3ywdOvpw8Ad5J4Ho1bPqj0Wm/yIjfe+xWTqZOa61SkVNPszxEmmnT7bq3Ms6uzKY osMOwdyTQbxGoSvEf29LrDmzNzcd2/RiyHlJCHhJC8fZeWd8Z87OI+HCaENMYJIaqmTC 5KUMJMDgoutDaF3mw5R+ChCjfieVf3GA9oJamQntsRXhhmbzCcvOgjPPznL1HBSY60mX V6ghEV+vvjtTUJUYq9weOYcHlgSbcA7ifCqethutJHTUNKuHJUik2ES8QzrGc5ivFXhF nnp845kR75sb9R6f6hZAnZ5W5F39TVvYGg0z2ACD7CxlltcKvLo0afzayXToFcTJZvmj o83Q== X-Forwarded-Encrypted: i=1; AJvYcCWWuuEmh92R1LHOT3QYmjPNgYbXVUSJdX37wwzA8Pp7b2Q49ybWdvFHV3jAl7aUgZBMnRGIADpMJPJsNpyCHSis@lists.infradead.org, AJvYcCX5nnMlWIRpE7FaZ/nzCbc5OJWPYENPIh14rC0r4ATmvMkSOwMcUtN33hTHD5Cw7QdsIylNtxeHuyliqbY=@lists.infradead.org X-Gm-Message-State: AOJu0YxNvjwGcS02VlWu36fVBlmetHirIIvD9vPowCYGYn213RjxmnRJ Y9njaMB1mwVpJ9+up+OsHwiTh1s0PYO0i1AuX9f29lASZGNFoIO1 X-Google-Smtp-Source: AGHT+IH8ClJCvm8SMQlEP26mhBKhiwtPhGm4vHIJFTxKdWRzsSUKpwtONxc6wRtHFIxmornn8f85jg== X-Received: by 2002:a17:902:e808:b0:20c:8f98:5dbe with SMTP id d9443c01a7336-210c6ae3d6bmr267036415ad.33.1730425440342; Thu, 31 Oct 2024 18:44:00 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ee3ccsm14453055ad.46.2024.10.31.18.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 18:44:00 -0700 (PDT) From: Inochi Amaoto To: Chen Wang , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Yixun Lan , Longbin Li , 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 Subject: [PATCH RFC net-next 1/3] dt-bindings: net: Add support for Sophgo SG2044 dwmac Date: Fri, 1 Nov 2024 09:43:25 +0800 Message-ID: <20241101014327.513732-2-inochiama@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101014327.513732-1-inochiama@gmail.com> References: <20241101014327.513732-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241031_184401_531297_538645FC X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 4e2ba1bf788c..69f6bb36970b 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -31,6 +31,7 @@ select: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 @@ -95,8 +96,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 @@ -627,6 +630,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 Fri Nov 1 01:43:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13858599 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 9821CE67492 for ; Fri, 1 Nov 2024 01:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AxfricRE7uBgf4L4U+T/hPqm/Ex2rRvslCVlqeVs1RU=; b=geRzazzi7NDuB9lGK4aYy+DLrR t9TIltWvTwUQUBCEqHZfRmcvUgL0vJLdRiOxlQRqthVni5AxhP4Vc7Dr9IjkMVs8XeCAAQ52X97e0 H0/TtnzucdgGXJwUT8u/2r8RfYge8egDmZlysEhHp9OlFOVJixn93zkauUHECOzJj/ZCQOTLBhY1D dm3UV+UQnJVZjgQ3PcSzquHqils75AKWdgh71OwUn+Gp/LKggGEaA+HlYlsPPU6fdQCtk5IxmoKxS iUHEXF3uSAM+JGUI6Cr7b/3zhEZLgX7Ya+wWPStd17LAoYKVeHMEdKbNoqEmfSJyxQvZ3C3cWBAyf ouMmqNRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6gmh-00000005TOm-29D8; Fri, 01 Nov 2024 01:49:07 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6gho-00000005SMV-3p6h; Fri, 01 Nov 2024 01:44:06 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-72097a5ca74so1280098b3a.3; Thu, 31 Oct 2024 18:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730425444; x=1731030244; 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=AxfricRE7uBgf4L4U+T/hPqm/Ex2rRvslCVlqeVs1RU=; b=l/y4dqQxm59FudQYaq0OeXxN+LSYWzAVrsg8liZmbQku9RmLjgEWLz0I35BjJNNyH0 BSDft8gUsTqgi2qynNUgK6s6L/9xfFQg38dv8BMuPMnfkBFydNvedm5B9RPr0P4nfwfy BJHTSL3O6HC02cIppdwlNYI7qhCCPbOk16FlYEFmxEcxFGcKO5Xvdpa+t111tlFtPmJl hX/8mKpLPo3KSpOpVXg+oSIaEWtgXr4+h3a98lf9/MaMIJzFhU8BlM5l5ZMscSUW7LUX vPUf310f7jCdDqXQ5OsC9gr9D6eiDjveUEnUUgNTA/ogKTLmBcJQqArpNqni6IynfVbj iVrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730425444; x=1731030244; 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=AxfricRE7uBgf4L4U+T/hPqm/Ex2rRvslCVlqeVs1RU=; b=wNOJIWDSgmqEsWMTdaGkpr6Wf3evw2Oq+ojeKgSchjgoa+Lm1e1vgVGxpr+gNvAbGE g2A6mzPhRR+dTOM+qj2AEjM2NrH2LAFNAfX8GTNm98oAix+hsZgssCs7NZ5HOAAfmyKe d2LqRM5+YKKNrN0UG7cQ320EdBEv7EbuVwSczWNAlryWCWU3+U7v/rcwoD1wzCeTofJl aQlLSsgGJSDsUEPB5JGMqJ9fIthGQ1V2XYAyO6Sp9OF9ztY7aIVE51xu+zsPvcje0fF1 fyHb5h3p2h6jBC2lGw3i6xonlDKiHAPYDUGS/cA6gBED9tq75N+FCTezZ+MqcA7ljJu/ D9bQ== X-Forwarded-Encrypted: i=1; AJvYcCUr79rv4QtbrfAGQavaHgmr2fwjnzzX/W6+Wt97LzxbJJA1+TdbU7AImEDHh2/+bqdhINbo70ne32fNJU4=@lists.infradead.org, AJvYcCXLmUKiLiUazBMx1+a+lTRCoJ4l4mxSGFn/oTKLjbubBD3YOjFVYhIT0IesDpepd69++IqHwoCqYs97YpmchDSf@lists.infradead.org X-Gm-Message-State: AOJu0Yw+sUpXSiAjr4+YzkEDH8hUGqnidPeXDWb7wuDq6j9DRdK8chjK xjua2nux18JrApX468F4NkX7qIeQ0MX23/dvUbM2rlCSlivSHZhIbhAylA== X-Google-Smtp-Source: AGHT+IHZtCCUDX7mDEeuB8aZyi3qRWI1DKZU0sOe1chkb3X/72NCuBzDYpNglTWXoR6Evrq69uLEFQ== X-Received: by 2002:a05:6a00:a93:b0:71e:f83:5c00 with SMTP id d2e1a72fcca58-720c98a19d4mr2723785b3a.2.1730425442887; Thu, 31 Oct 2024 18:44:02 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc2e95a6sm1834390b3a.145.2024.10.31.18.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 18:44:02 -0700 (PDT) From: Inochi Amaoto To: Chen Wang , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Yixun Lan , Longbin Li , 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 Subject: [PATCH RFC net-next 2/3] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string Date: Fri, 1 Nov 2024 09:43:26 +0800 Message-ID: <20241101014327.513732-3-inochiama@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101014327.513732-1-inochiama@gmail.com> References: <20241101014327.513732-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241031_184404_970628_7808C995 X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 ad868e8d195d..86ca39f89447 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 @@ -551,11 +562,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 Fri Nov 1 01:43:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13858600 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 A3BD4E67492 for ; Fri, 1 Nov 2024 01:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=q61+EZuwNAUrMd8RAaYUfGL0d1Lz2giuMYEfNJvU2Dg=; b=nLqMOeLRV9N7L9mTI9jDwCaRws BYzkmv56DamI1kqWOL7PUsRzgF4GHMDJhJg6yVp1VZbxjxUeepZ5c6Keb+3QwX1/wqtBGfz5DJlWz yNXVY2/HBbwXnyzJLVHhr/I/BoozoAhfL+84uHhIY5HHBBcJnF6ZNlj7L4uv385u9cWgMdbGPQ6sU OO1Rej90yLvZ358EXE2WkWLoOx136rbK+ghxccTSs2ScJqB9/mRxr2jXMpcH0dp+3FoLeHI2rL10v TzZuss0wvxlquiCnFGo0/1xkLXNlrO5ADm2rgfw7f3/LBNmGpz/vJOszx/PtHayqQortVtObUgxkE VlXFYxxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6goK-00000005Tgb-2dr7; Fri, 01 Nov 2024 01:50:48 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6ghq-00000005SMr-0Loz; Fri, 01 Nov 2024 01:44:07 +0000 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-7eab7622b61so1237626a12.1; Thu, 31 Oct 2024 18:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730425445; x=1731030245; 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=q61+EZuwNAUrMd8RAaYUfGL0d1Lz2giuMYEfNJvU2Dg=; b=WMBMJnDyQ/9062fWB4gOH5fh6BFQzgLqPmYQpRnw/CTH6S/zLcQwJlGUA9OIRjBajk 8Hhx/fmYjMdyv/vv8B6+n/Mgh1ns+6BU8lf7JE6PGCke8TdCYy/SwOWCoeHK8Q1E8Nn7 yqGK9T/9ilBO/pDhiNx8VvXkcqswKyGYGPVaUUwLXGkLYZugcdhRadmjHvIkhw1o3W+6 WWQfTuvGBOIEntchL54re91xNpgl1PhBOPJGppSJ9Kl6g7wQ6hegiPLODt6IxP2+Nqrk lK1axB9gImFqjInwyp+Olalvp6kUlutdy5VGP4d7DYg6Id8hC65I91Bwwc5G5UyK891l 3GPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730425445; x=1731030245; 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=q61+EZuwNAUrMd8RAaYUfGL0d1Lz2giuMYEfNJvU2Dg=; b=sCtOGFhCZ7Szm3ZF36W/dEJrd+LiMgfffo0NW8K6H8Ipg2S4eIfwuTNq1sip0/0ip3 e7tLRjC3f/N7h2wZr1L4qD5kqj6ayZ4g9ug0C/5reMR+xD3uKvpHwUCraQOsxxxvbZR/ QM2zMhbN3VBwhmId9QWR764kkv1PT8iw6BDIQ7uXPawoIM0rIokqwSVrj3GoT8+dGYxS YFwHoqUVRO8gOukqGEXCVqq9KiYxWHJc0PS5BvOqfqThEWvg+zTBDF+aWyl9PRgCyYHk 9w+uRATNpcFO5+62UCikrze2/z00sXFsxvAKvZID0KdsENnc1mD6I8bxgKJs83a5WMww h3LA== X-Forwarded-Encrypted: i=1; AJvYcCWIcPMkL7A+DzVpmqhUv3ljrURfGUgn7OPcJNygLISNWAfmy5uKJnFFEdFFT0fMHYduOe077hEL9A7AR60=@lists.infradead.org, AJvYcCWfsOLQarixlswfHQ9O+C8vQTJI+Uc7gB2V5/JMzU/2BzsmlmQ7vwkzqFTnp3lHEXFmX7v7dTOekrJFbH/qiwQn@lists.infradead.org X-Gm-Message-State: AOJu0YyIvmZUxNbcGtcoeyiqwYQAh/f5ssGPPNzV/133M51owho4JcfG Zzx5IdIKq24NqA++v2Yb8US2lb/OT36L7l+XIH+vdjV0SzQWlN1/ X-Google-Smtp-Source: AGHT+IHuQlXeDzxBjV0qHdNAUW/L4HbcBenlLkY5FwGEDvFKXThiyZ6Be/Uxw/pMTfPZF0B8P7/cyQ== X-Received: by 2002:a05:6a20:e188:b0:1d9:2994:ca27 with SMTP id adf61e73a8af0-1d9a84d17aemr28269194637.36.1730425445001; Thu, 31 Oct 2024 18:44:05 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e93da983edsm1785417a91.4.2024.10.31.18.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 18:44:04 -0700 (PDT) From: Inochi Amaoto To: Chen Wang , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Yixun Lan , Longbin Li , 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 Subject: [PATCH RFC net-next 3/3] net: stmmac: Add glue layer for Sophgo SG2044 SoC Date: Fri, 1 Nov 2024 09:43:27 +0800 Message-ID: <20241101014327.513732-4-inochiama@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101014327.513732-1-inochiama@gmail.com> References: <20241101014327.513732-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241031_184406_711864_6E64A5E3 X-CRM114-Status: GOOD ( 21.69 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 05cc07b8f48c..bc44b21c593f 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 c2f0e91f6bf8..e1287b53047b 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");