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.st…@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