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: 13858592 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 49C951C687; Fri, 1 Nov 2024 01:44:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730425447; cv=none; b=EB5XQwOp3OCfh+U3sSC7GuixmJRV5GkBhsQxfnlhMmp1XvvLgDxoHnGRx7X4+mB2+kCl95n4JqmidnYueOTEO70C50KB3ahcAvcELjgFyDV4PWsdu4sd25LfubN0kaJeU8Ppd0ki6eHGLvEPcTyuiGYTavS6mNzxPWJ4KeLFc6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730425447; c=relaxed/simple; bh=20bJSjv4jt+C0TC2PG5qcin1ziynK583FwI1gLhIQtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BUhVO+fn3hgKjy0oczftLdXnKUv0TtvLlSFdl/YaMS6M+OfWY+ntOQuuyA/v7/YkZyvmZiYfB+MMBns7IC56YnUx5l1dUmliflouEoitBZZT2wLbTvjWpXWVmwF33Bjl4R8OVJeQEeIyrnA6qJgopJncefnPLuIbLdisrysCTrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BUmssTYE; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BUmssTYE" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20cf6eea3c0so13322625ad.0; 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=vger.kernel.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=BUmssTYEf32YezHOelby6Ssjw1rIvdGKsEgZ12/ELaYlkbWti5dGcVUcoRjCAJgJUp 5KqMnCLi3yUlLxc5SnVwNnzyxf0yNRyV0SBdUt/O8oJwURZtYe7z/r1hSr3QIEL5Ozf2 nNx2MdwjrT6nO7OhfMFxyqgWhsW2HSFses7TUcp+u3ckE/NyIIMQIlMAZPx2AeTDMBur pszyHvIg8Zqln55DYam5cV9AE4pYvy4J/vkDeIVIBUcUytSTmtSyfrPFyFEkk4+CBOZB THPprR9zr1+oWbPOyhoyCfqecH9l+Mj1bLPG8/DC9FHXXvyGSPIQwBd0D4fgiftUpaRg 7Irg== 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=jXEXrS88xjlEz/qqimXGwB+aqw1wFq7lm7mwdAt9UCspR2Dmsl6PRBJ5LE+Jcd9Ax/ c3K79zIzfukJeOO2DFaSz9KC6DpVtNVRm7M2jh/ZFFplPc7/KZIroHVAKM57exysEBye qEFvYioytn+ca/CbiQcy+0GrEbiSfZiBY+NIKJa2wwlesWS5PXX3s8VrKi8BqrCJzNjZ cTxRQ+3ODqmVkl6vmhjL8jstwWCgB3OZ7dDlytHNdDgj9A6NQiPCjVUvYLimjeGQQAsK nPtOjyuCXouUpgZi8mB68oO02MszPw1n0VWVPB2hG0MR98yAdWaqbylLFYynJZCwdxJf j4XA== X-Forwarded-Encrypted: i=1; AJvYcCUIG7HPxTjMz+9pK4qw+MQ9UBH/0Bz8VOT08+sbVbl7DbVsufJSRIIWyUQ2rxzbt1fJbkACPf7m3LM9@vger.kernel.org, AJvYcCV3j1qbfJzB4d6tbHAtQEPCGabTuCTNi373ybTv0gwZotq2PrwtunC71NWLqTYCeaih5AY1ARocyG6sPbJe@vger.kernel.org, AJvYcCXkzIuHP3NX2mn+DPCMWvXzIJPFTLhEsEZ67FweqhIw1Ww169CSZBFkgrzKGuPWHLp0GlleXCG7@vger.kernel.org X-Gm-Message-State: AOJu0YyFp230jkcNd05wLh5xBQZzKHPKwV/QowWpMHsEwurLHQQPwJpV jWvaPghY/bMcRmeVozN5WPiVZzvHajJewmOEygPmHgmf3F7HdrvJ 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- .../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: 13858593 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 0D2F681741; Fri, 1 Nov 2024 01:44:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730425450; cv=none; b=pk6M7a9s1DLTRjOtV++szYFWtVvN2I7HKWeUx7vzSbhS9Jz1p2F7h3OUlLzvwlhaPNrDkRwl0z8TUlQm1UscLDrhhJht0MGG/haTMdnbZJwpJxKakXOfo6WDxkoqk5PBDO1yuwsljfyCrlI7c69uXdH23T8Kph4Yjt0klpzhtx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730425450; c=relaxed/simple; bh=Rm+galXTiV6N8MuVFMQgKwOoQ3w9H03hvs4ZTzCWpac=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ahKLXXuiJo4aWoJVympg3wmhGHLoGY9hnMdKvgxiQbQc316KgaJ+/NV2EaBPql9CvF1RRP4KzBzLyuo8WDD6ntyQ5TVYXGvg/6pwmqnUAkCbDzItOBJVxMfecD4FkBGRoWQVFz7ct5XRZH87GnL3bKfnPOvMbekv4GkLKcwQeK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HdHIHbRw; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HdHIHbRw" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-72061bfec2dso1258877b3a.2; 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=vger.kernel.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=HdHIHbRwDawdNfR7aGmjjc9wTTrmBgr4Cds0CaBt4anDk96MNsE8L+S0gmmwrpzJgj xdcrpHZGpuSel9FVT/O0+A/o/uYrvcQIPcuCbflXjMcIWTcHp0z4vF1hjZXFuJc4+fg5 0HqzewOZ4hurHpEsiyNrbOzZNeTx/G64Hi8WB3KroNS6qowIpjWfKjsDz6y094UdZIs6 0MUKWd4RaR/21wsQAsS4F5v8OEjZ1TinAE4WVXxFSvHDedSxxXrr1t8EYGWrNqbt0rSR SsrImpjVyje1jEpo79La64DtttqiB1AicAfKcBg8Jm0M4JyScrZNl1NL3ycgYFkAEJU0 dGJw== 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=iSpmQgUyIUTW+XGdZEOB6cS4xvmqcmqPEnZ5gjhgt+rKcboRzxGfian8QL2jWvl/Uo sEuJKjzcc1Dt00LuEtxTR5f5DNEAYKPSEhi2hu0MRQveaaPllU5xqnnqfx3pfVKF2kV7 re5zvcBcXgMdiu5kmCatm0EMDoiqMaDZ41Qn8rT65REglVZoYJpnEZnm8q+8/gWEBUWm UhFUll8oHk0Gd4aHQnVhUm7jaJ8Q3DLyCZf50nWlYpw8hbor8mhuxWbsjDQ4eZr8cKws DB4vqkU3ZHgM/2VtX157CXvQ+pQb+alRqvaXDJP2WVCr8IHHX5GZcQUnHswZDccBulWc HibQ== X-Forwarded-Encrypted: i=1; AJvYcCUK2HQGieD/JmU25riC4JLa4gVMAzh260+7z/6YJym/3WEqMnhP3h+vqw9fIDiYkvHG+FQI54BrOrnCkfjc@vger.kernel.org, AJvYcCUlydTVhxcAg0Oc01DbSJN57B7HrhyQ9ZeAEe5kzWIRbuWJ0vp0AAppkQ+n9qdjxcc4Xc2L8mEOmAX/@vger.kernel.org, AJvYcCVEgSkLEBzKOuMCRJ7097eGBz67do2Y7GJNjiQyIHC+jMQehgknawIVQ77Z2cXSeS2qNYsxIGlB@vger.kernel.org X-Gm-Message-State: AOJu0YyR9jM2CTimtukQJ44Zxl22OhPutB8GXQVxVk8Ov5k7j78ae9dm P23t9vt94I+ZTDo7QcH7kTwIXcKrsfZk7tFKImu0TSuLmnfF8O30 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13858594 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 ECF968615A; Fri, 1 Nov 2024 01:44:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730425451; cv=none; b=ZyK+wP+xPIpgR0LDrhnX/OdBywhCKLiLx1/LKw/T/1KULEczaZxgNCqti+/MdeeZ+XhFqBlrTGKzoxH0yMqhwI5ST44MkkmLCXf6oM4w9GT4PtIbyyACkoombeAJv39uHbRTMF0qi3nRQBt0Cbl7m8nHxokZoqJ8vYOPk6dPY08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730425451; c=relaxed/simple; bh=EyXf5SHMkWNNdAkgndgdeF4CpDJYSuEG3jVFZ4mal8w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jOxhnAtPR1wbwn3YxGZAZ/YMvP2yLp+Gm0Xb0dwHVLJPFrOmjWACxmRelr3ATfBju/+aG77kjc7Juvj/E2h9FbvxEqD6RHu0nrKX0qST/A6dTVC6WZedpX+XoSfgkMYoENgcqzzBWEqNFqK0hRDn99YNhE8c0xjOJ/xcKq0yr+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eQtDw36Y; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eQtDw36Y" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7db238d07b3so1203392a12.2; 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=vger.kernel.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=eQtDw36YRcygyYm4CHxmO0odnyjWatdOLfIWysfRKAo/lwkZORJjhd1Hi0Lohe2tMg gIych4TEcpSbCN+HS4+03MCDswuUTCvQxUUEOEI0geQSGY4AGWUpb9mbD0n5a9x+j9zw 1sPsciKq/IPx4RnJzddk4fyLmAfGgdJhmpZlSmiL2cJuOp5FTSsVRwfj2LbBFX/HIBCL IofqmtXHyAHU2Sx+QBDsyBOdTl7phLH5K/c7C6ZX+wDu7PToA7dIa9j+qCYq9UEUXHHU Z24zyhEaVD1LP5vzCybb8Asen7gL9LQYxl0Sc6Aqc/CEqdK3UrncdLoRpNaEcBDCMlV/ 3nwA== 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=ZCTOIOBStS2H7JXwN9SmBegh0hQho1T/xx18GwsyZXJbIsZY5NUsLyxmBvLrinpOOw P+8cIxT4oVD0WITIuPt5riM6/klJafnIDOtvD0fnWcdF4V4aLGzi1jsvOaG8AirTqjF0 /fI0B0VvkLgtzUGk0x3wrjWK5C7WgAyDXYhf0pEhCRmFUZnL97HhXy/s0fUaO/lMzUym /aRoVzgqZi7pcJ/wM1SL/bBJkD4DnSQRjSKcr544yzJ8Ke4GnLz584B9dstBmlZn0/MZ HawwtkKePgBmk/j3QW6My8bg/AJi06p5ppjngPjK0Kh4KonScHYd8kDsmYrjD7sM0a9a PWCg== X-Forwarded-Encrypted: i=1; AJvYcCUhrj6Ys0RAMXFXxB6CRKB+4t5eQh4FHgm42ZRLe/dNlXI/Cq7IBPoEa7K4kZ9IWsvEOowEOLkIy44O66jT@vger.kernel.org, AJvYcCUlK6/2RsYe8YTzJ+z4D+97GVy7tzBN75Bnprv1NNWC5UftSG2sHSJ6AGTFQT1fOOZDaaeFXXM9@vger.kernel.org, AJvYcCVHX/rtPFDmPGgEmIURTQ/GqLc2fftp0+vGb12RNi8TgzwwPJDyoYIj4fZucKfIlN6wYaCGuDS+2NUA@vger.kernel.org X-Gm-Message-State: AOJu0YyXsUKEqRM13PqLx1za8mxrDHSuEM0ax5JVvDWsppejl07o3J/X 5mpyb/J0vCwuNP9GPJt9G5grEzpIVL5Jl/uOlT/rA0iJLWUrsHhH 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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");