From: Mason Huo <mason.huo@starfivetech.com>
To: Lee Jones <lee@kernel.org>, Corey Minyard <corey@minyard.net>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: mfd@lists.linux.dev, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org,
openipmi-developer@lists.sourceforge.net,
Mason Huo <mason.huo@starfivetech.com>
Subject: [PATCH v2 2/3] mfd: Add StarFive JHB100 SuperIO driver
Date: Fri, 4 Dec 2026 14:06:22 +0800 [thread overview]
Message-ID: <20261204060623.2994008-3-mason.huo@starfivetech.com> (raw)
In-Reply-To: <20261204060623.2994008-1-mason.huo@starfivetech.com>
Add a driver for the SuperIO (SIO) blocks of the StarFive JHB100 BMC SoC.
It registers the functions of a block as MFD cells, for now the four
IPMI KCS channels.
Every instance of a function occupies a 0x100 byte register window of
the block. Each cell gets its window as a memory resource, which its
driver maps. The cells carry no interrupt resources, the driver of a
function looks up its interrupts in the SIO node by name. The functions
are described by a table, so adding the remaining ones only takes their
cells and an entry each.
The instances of a function in all SIO blocks are numbered
consecutively, so the platform device id of a KCS cell is its channel
number. The index of an SIO block follows from its address.
Signed-off-by: Mason Huo <mason.huo@starfivetech.com>
---
MAINTAINERS | 6 ++
drivers/mfd/Kconfig | 13 +++
drivers/mfd/Makefile | 1 +
drivers/mfd/starfive-jhb100-sio.c | 167 ++++++++++++++++++++++++++++++
4 files changed, 187 insertions(+)
create mode 100644 drivers/mfd/starfive-jhb100-sio.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 67ed5e45b61d..53ee9b601dcb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26834,6 +26834,12 @@ M: Changhuang Liang <changhuang.liang@starfivetech.com>
S: Maintained
F: drivers/soc/starfive/socinfo/jhb100-socinfo.c
+STARFIVE JHB100 SUPERIO DRIVER
+M: Mason Huo <mason.huo@starfivetech.com>
+S: Supported
+F: Documentation/devicetree/bindings/mfd/starfive,jhb100-sio.yaml
+F: drivers/mfd/starfive-jhb100-sio.c
+
STATIC BRANCH/CALL
M: Peter Zijlstra <peterz@infradead.org>
M: Josh Poimboeuf <jpoimboe@kernel.org>
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 0a2778052519..3ffa1c2ed81e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1633,6 +1633,19 @@ config STMPE_SPI
This is used to enable SPI interface of STMPE
endmenu
+config MFD_STARFIVE_JHB100_SIO
+ tristate "StarFive JHB100 SuperIO"
+ depends on ARCH_STARFIVE || COMPILE_TEST
+ select MFD_CORE
+ help
+ Support for the SuperIO (SIO) blocks of the StarFive JHB100 BMC SoC.
+ The host accesses them over the eSPI bus. This driver registers the
+ functions of each block, e.g. the IPMI KCS channels, which are
+ handled by their own drivers.
+
+ This support is also available as a module. If so, the module
+ will be called starfive-jhb100-sio.
+
config MFD_SUN6I_PRCM
bool "Allwinner A31/A23/A33 PRCM controller"
depends on ARCH_SUNXI || COMPILE_TEST
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 72d3944b0ad8..d4a680fe0e51 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -267,6 +267,7 @@ obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o
obj-$(CONFIG_MFD_ALTERA_SYSMGR) += altera-sysmgr.o
obj-$(CONFIG_MFD_STPMIC1) += stpmic1.o
obj-$(CONFIG_MFD_SUN4I_GPADC) += sun4i-gpadc.o
+obj-$(CONFIG_MFD_STARFIVE_JHB100_SIO) += starfive-jhb100-sio.o
obj-$(CONFIG_MFD_STM32_LPTIMER) += stm32-lptimer.o
obj-$(CONFIG_MFD_STM32_TIMERS) += stm32-timers.o
diff --git a/drivers/mfd/starfive-jhb100-sio.c b/drivers/mfd/starfive-jhb100-sio.c
new file mode 100644
index 000000000000..7efc9135705a
--- /dev/null
+++ b/drivers/mfd/starfive-jhb100-sio.c
@@ -0,0 +1,167 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * StarFive JHB100 SuperIO (SIO) driver
+ *
+ * Copyright (C) 2026 StarFive Technology Co., Ltd.
+ */
+
+#include <linux/array_size.h>
+#include <linux/err.h>
+#include <linux/ioport.h>
+#include <linux/mfd/core.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+#define JHB100_SIO_SIZE 0x1000
+
+/* Every instance of a function occupies a register window of this size */
+#define JHB100_SIO_FUNC_SIZE 0x100
+
+/*
+ * The cells only carry the register window of their instance. The interrupts
+ * are those of the SIO node, the driver of a function looks them up there by
+ * name: its own one, followed by the id of the cell if the block has more than
+ * one instance of the function, and "espi", the eSPI bus reset interrupt, which
+ * all functions of the block share.
+ */
+static const struct resource jhb100_sio_kcs0_resources[] = {
+ DEFINE_RES_MEM(0x200, JHB100_SIO_FUNC_SIZE),
+};
+
+static const struct resource jhb100_sio_kcs1_resources[] = {
+ DEFINE_RES_MEM(0x300, JHB100_SIO_FUNC_SIZE),
+};
+
+static const struct resource jhb100_sio_kcs2_resources[] = {
+ DEFINE_RES_MEM(0x400, JHB100_SIO_FUNC_SIZE),
+};
+
+static const struct resource jhb100_sio_kcs3_resources[] = {
+ DEFINE_RES_MEM(0x500, JHB100_SIO_FUNC_SIZE),
+};
+
+static const struct mfd_cell jhb100_sio_kcs_cells[] = {
+ MFD_CELL_BASIC("starfive-kcs-bmc", jhb100_sio_kcs0_resources, NULL, 0, 0),
+ MFD_CELL_BASIC("starfive-kcs-bmc", jhb100_sio_kcs1_resources, NULL, 0, 1),
+ MFD_CELL_BASIC("starfive-kcs-bmc", jhb100_sio_kcs2_resources, NULL, 0, 2),
+ MFD_CELL_BASIC("starfive-kcs-bmc", jhb100_sio_kcs3_resources, NULL, 0, 3),
+};
+
+/**
+ * struct jhb100_sio_func - a function of the SIO block
+ * @cells: MFD cells of the instances of the function in an SIO block
+ * @num_cells: number of entries in @cells
+ *
+ * The instances of a function in all SIO blocks are numbered consecutively,
+ * so the platform device id of a cell is the system wide instance number,
+ * e.g. the KCS channel number.
+ */
+struct jhb100_sio_func {
+ const struct mfd_cell *cells;
+ unsigned int num_cells;
+};
+
+/* Only the KCS channels are supported so far */
+static const struct jhb100_sio_func jhb100_sio_funcs[] = {
+ { jhb100_sio_kcs_cells, ARRAY_SIZE(jhb100_sio_kcs_cells) },
+};
+
+/**
+ * struct jhb100_sio_soc_data - SoC specific description of the SIO blocks
+ * @bases: base addresses of the SIO blocks of the SoC
+ * @num_bases: number of entries in @bases
+ */
+struct jhb100_sio_soc_data {
+ const resource_size_t *bases;
+ unsigned int num_bases;
+};
+
+/*
+ * The index of an SIO block is not described in the devicetree, it follows
+ * from the address of the block.
+ */
+static int jhb100_sio_get_index(struct device *dev, resource_size_t start,
+ unsigned int *index)
+{
+ const struct jhb100_sio_soc_data *data;
+ unsigned int i;
+
+ data = device_get_match_data(dev);
+ if (!data)
+ return -ENODEV;
+
+ for (i = 0; i < data->num_bases; i++) {
+ if (data->bases[i] == start) {
+ *index = i;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+
+static int jhb100_sio_probe(struct platform_device *pdev)
+{
+ const struct jhb100_sio_func *func;
+ struct device *dev = &pdev->dev;
+ unsigned int index, i;
+ struct resource *mem;
+ int rc;
+
+ /*
+ * The registers are not mapped here, the driver of each function maps
+ * the register window of its instance.
+ */
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!mem || resource_size(mem) < JHB100_SIO_SIZE)
+ return dev_err_probe(dev, -EINVAL, "Invalid register window\n");
+
+ rc = jhb100_sio_get_index(dev, mem->start, &index);
+ if (rc)
+ return dev_err_probe(dev, rc, "Unknown SIO block %pR\n", mem);
+
+ for (i = 0; i < ARRAY_SIZE(jhb100_sio_funcs); i++) {
+ func = &jhb100_sio_funcs[i];
+
+ rc = devm_mfd_add_devices(dev, index * func->num_cells,
+ func->cells, func->num_cells, mem, 0,
+ NULL);
+ if (rc)
+ return dev_err_probe(dev, rc, "Failed to add %s devices\n",
+ func->cells->name);
+ }
+
+ return 0;
+}
+
+static const resource_size_t jhb100_sio_bases[] = {
+ 0x10582000,
+ 0x10d82000,
+};
+
+static const struct jhb100_sio_soc_data jhb100_sio_soc_data = {
+ .bases = jhb100_sio_bases,
+ .num_bases = ARRAY_SIZE(jhb100_sio_bases),
+};
+
+static const struct of_device_id jhb100_sio_match[] = {
+ { .compatible = "starfive,jhb100-sio", .data = &jhb100_sio_soc_data },
+ { }
+};
+MODULE_DEVICE_TABLE(of, jhb100_sio_match);
+
+static struct platform_driver jhb100_sio_driver = {
+ .driver = {
+ .name = "starfive-jhb100-sio",
+ .of_match_table = jhb100_sio_match,
+ .suppress_bind_attrs = true,
+ },
+ .probe = jhb100_sio_probe,
+};
+module_platform_driver(jhb100_sio_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mason Huo <mason.huo@starfivetech.com>");
+MODULE_DESCRIPTION("StarFive JHB100 SuperIO driver");
--
2.50.1
next prev parent reply other threads:[~2026-12-04 6:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:06 [PATCH v2 0/3] Add StarFive JHB100 SuperIO and KCS BMC drivers Mason Huo
2026-12-04 6:06 ` [PATCH v2 1/3] dt-bindings: mfd: Add StarFive JHB100 SuperIO Mason Huo
2026-12-04 6:06 ` Mason Huo [this message]
2026-12-04 6:06 ` [PATCH v2 3/3] ipmi: Add StarFive KCS BMC driver Mason Huo
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=20261204060623.2994008-3-mason.huo@starfivetech.com \
--to=mason.huo@starfivetech.com \
--cc=conor+dt@kernel.org \
--cc=corey@minyard.net \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=openipmi-developer@lists.sourceforge.net \
--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