From: Vasilij Strassheim <v.strassheim@linutronix.de>
To: Lee Jones <lee@kernel.org>
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>
Subject: Re: [PATCH net-next v5 7/9] mfd: soce: Add SWIP core driver
Date: Fri, 04 Dec 2026 12:17:59 +0100 [thread overview]
Message-ID: <30d6ab17651e1d08b19aeee41b146a8cd1c6c201.camel@linutronix.de> (raw)
In-Reply-To: <20261202172021.GC98551@kernel.org>
On Wed, 2026-12-02 at 17:20 +0000, Lee Jones wrote:
> 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.
Ok.
>
> > +
> > + 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.
>
This revision intentionally covers only a subset of the switch IPs
features and variants to keep the implementation and review manageable.
I chose a dedicated MFD parent to support independently usable
functions, such as an I2C controller alongside the switch and MDIO.
Which functions are present and usable depends on the variant, the
bitstream and hardware licensing.
If the parent needs to read the configuration registers to determine
which children to instantiate, simple-mfd alone is not sufficient.
The writing-bindings.rst also advise against using simple-mfd for
non-trivial devices whose children depend on parent resources.
Thankfully, Bene has explained our reasoning in more detail in the
parallel discussion on the DT binding patch [1].
[1] https://lore.kernel.org/netdev/20261203142727.00b19361@mitra/
> > + 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
> >
>
Thanks,
Vasilij
next prev parent reply other threads:[~2026-12-04 11:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 14:52 [PATCH net-next v5 0/9] net: dsa: Add support for SoC-e Ethernet switch IP cores Vasilij Strassheim
2026-11-20 14:52 ` [PATCH net-next v5 1/9] dt-bindings: vendor-prefixes: Add soce Vasilij Strassheim
2026-11-20 14:52 ` [PATCH net-next v5 2/9] dt-bindings: net: Add SoC-e SWIP MDIO controller Vasilij Strassheim
[not found] ` <sashiko-outbox-227106@kernel.org>
2026-11-24 12:04 ` Vasilij Strassheim
2026-11-20 14:52 ` [PATCH net-next v5 3/9] dt-bindings: net: dsa: Add SoC-e SWIP switch function Vasilij Strassheim
2026-11-22 14:54 ` Krzysztof Kozlowski
2026-11-24 10:40 ` Vasilij Strassheim
2026-11-20 14:52 ` [PATCH net-next v5 4/9] dt-bindings: mfd: Add SoC-e SWIP parent Vasilij Strassheim
2026-11-21 10:19 ` Krzysztof Kozlowski
2026-11-23 17:59 ` Vasilij Strassheim
2026-12-01 22:48 ` Rob Herring
2026-12-02 10:26 ` Benedikt Spranger
2026-12-02 18:35 ` Rob Herring
2026-12-03 13:27 ` Benedikt Spranger
2026-11-20 14:52 ` [PATCH net-next v5 5/9] net: dsa: Add tag handling for SoC-e switches Vasilij Strassheim
2026-11-20 14:52 ` [PATCH net-next v5 6/9] net: mdio: Add SoC-e SWIP MDIO controller driver Vasilij Strassheim
2026-11-20 14:52 ` [PATCH net-next v5 7/9] mfd: soce: Add SWIP core driver Vasilij Strassheim
2026-12-02 17:20 ` Lee Jones
2026-12-04 11:17 ` Vasilij Strassheim [this message]
2026-11-20 14:52 ` [PATCH net-next v5 8/9] net: dsa: soce: Add basic support for SoC-e SWIP switch Vasilij Strassheim
2026-11-20 14:52 ` [PATCH net-next v5 9/9] net: dsa: soce: Add VLAN membership table support Vasilij Strassheim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30d6ab17651e1d08b19aeee41b146a8cd1c6c201.camel@linutronix.de \
--to=v.strassheim@linutronix.de \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=b.spranger@linutronix.de \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=martin.kaistra@linutronix.de \
--cc=mfd@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®