🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25894

Re: [PATCH net-next v5 7/9] mfd: soce: Add SWIP core driver

#25894
From: Lee Jones
Date: Wed, 02 Dec 2026 17:20
152 lines
13173 bytes
On Fri, 20 Nov 2026, Vasilij Strassheim wrote:

> Add an MFD parent driver for SoC-e SWIP FPGA IP cores.
> 
> Validate the core version before populating the addressed switch, MDIO,
> and MDIO mux child devices from Device Tree.
> 
> Signed-off-by: Vasilij Strassheim <v.strassheim@linutronix.de>
> ---
>  drivers/mfd/Kconfig          |  9 ++++++
>  drivers/mfd/Makefile         |  2 ++
>  drivers/mfd/soce-swip-core.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 87 insertions(+)
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 87ed55c155f0..ff3378e928fd 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -1291,6 +1291,15 @@ config MFD_QCOM_RPM
>  	  Say M here if you want to include support for the Qualcomm RPM as a
>  	  module. This will build a module called "qcom_rpm".
>  
> +config MFD_SOCE_SWIP
> +	tristate
> +	depends on OF
> +	help
> +	  Support for memory-mapped SoC-e Ethernet switch IP cores implemented
> +	  in FPGAs. These devices integrate an Ethernet
> +	  switch, an MDIO controller, and an MDIO bus selector.
> +	  This is selected if Ethernet switch functionality is configured.
> +
>  config MFD_SPACEMIT_P1
>  	tristate "SpacemiT P1 PMIC"
>  	depends on ARCH_SPACEMIT || COMPILE_TEST
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index f8101d2a9ce9..9f4d2ccc3a24 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -302,6 +302,8 @@ obj-$(CONFIG_MFD_QNAP_MCU)	+= qnap-mcu.o
>  obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu_i2c.o rsmu_core.o
>  obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu_spi.o rsmu_core.o
>  
> +obj-$(CONFIG_MFD_SOCE_SWIP)	+= soce-swip-core.o
> +
>  obj-$(CONFIG_MFD_UPBOARD_FPGA)	+= upboard-fpga.o
>  
>  obj-$(CONFIG_MFD_LOONGSON_SE)	+= loongson-se.o
> diff --git a/drivers/mfd/soce-swip-core.c b/drivers/mfd/soce-swip-core.c
> new file mode 100644
> index 000000000000..2f7d966eeab2
> --- /dev/null
> +++ b/drivers/mfd/soce-swip-core.c
> @@ -0,0 +1,76 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/bitfield.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/platform_device.h>
> +
> +#define SWIP_CORE_VERSION_OFFSET		0x0000
> +#define SWIP_CORE_VERSION_VERSION_MASK		GENMASK(31, 24)
> +#define SWIP_CORE_VERSION_SUBVERSION_MASK	GENMASK(23, 16)
> +#define SWIP_CORE_VERSION_REVISION_MASK		GENMASK(15, 0)
> +#define SWIP_MIN_CORE_VERSION			0x24
> +#define SWIP_MIN_CORE_SUBVERSION		0x01
> +
> +static int swip_check_version(struct device *dev, void __iomem *base)
> +{
> +	u8 subversion;
> +	u16 revision;
> +	u8 version;
> +	u32 regval;
> +
> +	regval = readl(base + SWIP_CORE_VERSION_OFFSET);
> +	version = FIELD_GET(SWIP_CORE_VERSION_VERSION_MASK, regval);
> +	subversion = FIELD_GET(SWIP_CORE_VERSION_SUBVERSION_MASK, regval);
> +	revision = FIELD_GET(SWIP_CORE_VERSION_REVISION_MASK, regval);
> +	if (version < SWIP_MIN_CORE_VERSION ||
> +	    (version == SWIP_MIN_CORE_VERSION &&
> +	     subversion < SWIP_MIN_CORE_SUBVERSION))
> +		return dev_err_probe(dev, -ENODEV,
> +				     "unsupported core version %02x.%02x.%04x\n",
> +				     version, subversion, revision);
> +
> +	dev_info(dev, "SoC-e IP core version %02x.%02x.%04x detected\n",
> +		 version, subversion, revision);

Please remove this noise.  Only log errors and warnings.

> +
> +	return 0;
> +}
> +
> +static int swip_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *res;
> +	void __iomem *base;
> +	int ret;
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res || resource_size(res) < sizeof(u32))
> +		return -EINVAL;
> +	base = devm_ioremap(dev, res->start, sizeof(u32));

This driver doesn't actually do anything.

Have you investigated 'simple-mfd'?

Doesn't of_default_bus_match_table already do what you need?

Alternatively, since the DSA switch is the primary function of this IP
block the switch node can simply be the top-level device and either call
devm_of_platform_populate() itself, or have the MDIO and mux sub-blocks
sit alongside it under a 'simple-mfd' parent.

> +	if (!base)
> +		return -ENOMEM;
> +	ret = swip_check_version(dev, base);
> +	if (ret)
> +		return ret;
> +
> +	return devm_of_platform_populate(dev);
> +}
> +
> +static const struct of_device_id swip_of_match[] = {
> +	{ .compatible = "soce,swip" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, swip_of_match);
> +
> +static struct platform_driver swip_driver = {
> +	.probe = swip_probe,
> +	.driver = {
> +		.name = "soce-swip",
> +		.of_match_table = swip_of_match,
> +	},
> +};
> +module_platform_driver(swip_driver);
> +
> +MODULE_DESCRIPTION("SoC-e multifunction switch IP device driver");
> +MODULE_LICENSE("GPL");
> 
> -- 
> 2.39.5
> 

-- 
Lee Jones
Technical Details
Message-ID: <20261202172021.GC98551@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375950-linux-kernel-netdev=dewy.ru
References: <20261120-devel-vstrassheim-soce-dsa-ml-v5-0-5de9225715e6@linutronix.de> <20261120-devel-vstrassheim-soce-dsa-ml-v5-7-5de9225715e6@linutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375950-linux-kernel-netdev=dewy.ru
From: lee@kernel.org (Lee Jones)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 7/9] mfd: soce: Add SWIP core driver
Date: Wed, 2 Dec 2026 17:20:21 +0000
Organization: Usenet Network
Message-ID: <20261202172021.GC98551@kernel.org>
References: <20261120-devel-vstrassheim-soce-dsa-ml-v5-0-5de9225715e6@linutronix.de>
 <20261120-devel-vstrassheim-soce-dsa-ml-v5-7-5de9225715e6@linutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2018717"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+jFPQEgsxZG1OV7Obb4NYpGMyxM= sha256:sM/f3GWewAP8Jg+Ge+7T5l0Sg7ghMAiSiRVuw8HABXQ=
	sha1:fR01G/3zgLsoFisWsZKcWn4MaY4= sha256:j3lIpfqm84Gyzo2ucuOx+IC+BfwDIIDmUpWiiLgDQh4=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 86B221176CA; Wed,  2 Dec 2026 20:20:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Pfqi8EXKF1WF;
	Wed,  2 Dec 2026 20:20:44 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375950-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 1B25D1176AC; Wed,  2 Dec 2026 20:20:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 2B5C927C70; Wed,  2 Dec 2026 17:20:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796232034;
	b=L+HdYLFDa30QP0wKzwHz5qqH7uziWgp9ZyPrELcz9UBEahVd5B7+BDR2QCJFUBqnlpRv
	 yoS2wi/aAg8eSEvw6p2boeEANCfneIIwtK1hMHpzXEmrhNJAJ95ga1MGruoemafHa2How
	 XeuTsG3EEetr/liiTf5Nsw0osS2eTML5FQ8wm1keUs2BERIW3LpuUas+kBBWyXdDRltjO
	 al4dO670GdNtpkcBJtAZQY0pM6aKNG6q2NYSNrCmxqniC2VGEqQEvEp3XWZrHqbZSrSxe
	 ma7RB39xTtPkZzVZJAQVv4FX2HRwHqpEbUxnBwH+CpaPG9g/QcxADrsY/cbNBSXbiJQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796232034;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=p8bx+AiwDblYvU85aKe1zBxuoKV3ozDq+HQkQM2ydag=;
	b=JfBnjCVZcUEX4gxxoW5d1Ayk7KormebMb4SWZxt+RZu1WhK63UogCywtn21m3UScrS9m
	 gc50//cyz/5fCzetmLdi11jSoWrhcDw1l6bBkgwHBbNxZtbkUnAVrAyGVCbpVREw3TBQi
	 76O11LeKRpceDvD4dWTqY7Qbo2f6GXmBx08G0DKXqWFaNCFiVJcz28xKrf4gdm7twPdDw
	 aKjUpo/79tLH2LTCPnBpNv8VslFkVWQSsFqCvO0h7c0+99LEwV710p6jp9FA0OCnZVx3+
	 JZDNyZW2HTVel2QHpRmDEi2AseDRnkjAWU2yk+HsvIDFq2bhafR3jV4EJkBxvkoxzbQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="gD/p4t66";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 044D9606A32D;
	Wed,  2 Dec 2026 17:20:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gD/p4t66
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796232028;
	b=5ag4n/6FjkUikQmfHQq1FvTULr3M6Ya5fiJi3hcFWAMyvPmJD06yhdU3kxzm/HOiXn52
	 DhWW6O0+3Z5VgKOqJ0e46Ag8lpgbEdQSne/zRNMj5DyWRNIX+xFtidavya3mQ+A/cw2CT
	 rw+/undp8IJzwLCVuaQ006UdTA4dTLO/C5fVuuAIVpMqsLNGYpU3QVpZ4nNz6cVCT2RWj
	 EQPt4llMce3tVTLg/EhfPj7/3FcCmQ9kgLBCxjSE7GHmjgBzS4Tply1FWw5ZAofsLP/1B
	 eWv67nTVAopEBH74hJM3/xkcaj+cMfYhwUNZjA1DJ2HJvpLKBT3VjPcpjF8pTZV41CA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796232028;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=p8bx+AiwDblYvU85aKe1zBxuoKV3ozDq+HQkQM2ydag=;
	b=iWNSW+wHn2dKnTatbeGVttAfs38V76LVdqvE6BoXQDQvT4pYfE6VzP/LxiC2vyPp9qt3
	 JZSsDMSIvV0fpCbAIcJzKoJ1za0lJ7zUrATM1noEWT2YbkrvcZMk2VQTvMyPrbxkTg4h3
	 wz97PFJuoZ4oz/xrJVd7igI6awMiqp5xfXHU2R+g9A49BPGxCcnTUXE4KwfZJb34ltbmV
	 qnxxO9lxuyrpXs4VIKmV/72qjlksNIPgsZ+xa6cO1u0bV0yJFa+Qab88DeZW2hHrej9pb
	 3GkFiVtSjgLBlHvP/RE/1f3nU9tJg5jMU/Hy6BDvAGbft9YZZM6sYsa1vjXv0341nqQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="gD/p4t66";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21049606A322;
	Wed,  2 Dec 2026 17:20:27 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1617A1F000C1;
	Wed,  2 Dec 2026 17:20:23 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796232027;
	bh=p8bx+AiwDblYvU85aKe1zBxuoKV3ozDq+HQkQM2ydag=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=gD/p4t66xI+k5Pc8VuCw9miTBJLZ4yv0CYGvnrsdu+AS1Qxf2+to5mVVM6h25HSu6
	 gSV+rC+p9qOtwzLi/TNeaYn8j2++20+mLIwaa/qtnA6WCdjng63p9cPNJU4dVdhn9d
	 V5EVyV5GwP+Jw3ouXPizRiRNJ49/EcUsjl06mG+5+LBJ3EdKxedhfXgI3Oj08wkmHO
	 vaJrBIRkA19dsHsTCw+LgUK8apuqDz2q6p8rnu6JIdnQeDKBRrs19WjfR7CqZAdNlF
	 JcOG7vQMtzKrCB5R5p5f1hwAtJzOK6buy0wzcQKNwaNercJmIzy4QQpQ6PF30hoeqO
	 mIlVk/p19SxbQ==
X-Cc: Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Eric Dumazet <edumazet@kernel.org>, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	mfd@lists.linux.dev, Martin Kaistra <martin.kaistra@linutronix.de>,
	Benedikt Spranger <b.spranger@linutronix.de>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261120-devel-vstrassheim-soce-dsa-ml-v5-7-5de9225715e6@linutronix.de>