[PATCH v6 0/7] mfd: nct6694: Refactor transport layer and add HIF (eSPI) support
From: a0282524688
Date: Tue Jun 30 2026 - 23:53:58 EST
From: Ming Yu <a0282524688@xxxxxxxxx>
The Nuvoton NCT6694 is a peripheral expander that provides GPIO, I2C,
CAN-FD, Watchdog, HWMON, PWM, and RTC sub-devices. Currently, the
driver only supports USB as the host transport interface.
This series refactors the NCT6694 MFD core to support multiple transport
backends and adds a new Host Interface (HIF) transport driver that
communicates over eSPI using Super-I/O shared memory.
The refactoring is split into small, self-contained steps: the USB
transport is first isolated behind a dedicated data structure and file
(nct6694-usb.c), the transport-agnostic device management is extracted
into a new core module (nct6694-core.c), and the firmware command
interface is then wrapped behind regmap so that sub-device drivers no
longer reference any transport detail. The HIF (eSPI) driver is finally
added cleanly on top of this abstraction, reusing the shared core.
Changes since version 5:
- Replaced the custom read_msg/write_msg function-pointer indirection
with a regmap-based transport abstraction. The firmware addressing
(host control, module id and 16-bit offset) is packed into a single
32-bit regmap register, so sub-device drivers use the standard regmap
bulk accessors while each transport implements its own regmap_bus.
- Added nct6694_write_read_msg() for the few commands (e.g. the I2C
"deliver") that send a request and read the reply back in a single
transaction, and converted the I2C transfer path to use it.
- Dropped the per-transport access_lock; regmap already serialises bus
accesses on its own.
- Reordered the series accordingly: rename the USB I/O functions and the
driver file first, extract the transport-agnostic core, then introduce
the regmap abstraction, and finally add the HIF driver.
Changes since version 4:
- Split the monolithic refactoring and HIF support patch into a series of
smaller, logical commits to improve reviewability and adhere to the
single logical change principle.
- Decoupled USB-specific data into a dedicated 'nct6694_usb_data'
structure referenced through a void *priv pointer in the core.
- Renamed the existing driver to 'nct6694-usb.c' to strictly identify its
transport boundary, alongside Kconfig/Makefile updates.
- Extracted transport-agnostic device management (IRQ domain setup, IDA
initialization, and MFD cell registration) into a standalone
'nct6694-core.c' module.
- Added the 'nct6694-hif' eSPI transport driver on top of the new core
abstraction.
Changes since version 3:
- Remove redundant module type macro definitions from sub-device drivers
that are now provided by the shared header <linux/mfd/nct6694.h>,
fixing -Wmacro-redefined warnings.
Changes since version 2:
- Restore per-device IDA and mfd_add_hotplug_devices()/PLATFORM_DEVID_AUTO
to avoid child device ID conflicts with multiple NCT6694 chips.
- Validate irq_find_mapping() return value before dispatching IRQs.
- Check superio_enter() return value in nct6694_irq_init().
Changes since version 1:
- Reworked the Super-I/O access helpers.
Ming Yu (7):
mfd: nct6694: Move module type macros to shared header
mfd: nct6694: Refactor USB-specific data into nct6694_usb_data
mfd: nct6694: Rename USB transport functions with _usb_ prefix
mfd: nct6694: Rename driver to nct6694-usb and update Kconfig
mfd: nct6694: Extract core device management into a separate module
mfd: nct6694: Introduce regmap-based transport abstraction
mfd: nct6694: Add Host Interface (HIF) eSPI transport driver
MAINTAINERS | 2 +-
drivers/gpio/gpio-nct6694.c | 7 -
drivers/hwmon/nct6694-hwmon.c | 21 -
drivers/i2c/busses/i2c-nct6694.c | 9 +-
drivers/mfd/Kconfig | 48 +-
drivers/mfd/Makefile | 4 +-
drivers/mfd/nct6694-core.c | 136 ++++++
drivers/mfd/nct6694-hif.c | 565 +++++++++++++++++++++++
drivers/mfd/{nct6694.c => nct6694-usb.c} | 283 ++++++------
drivers/net/can/usb/nct6694_canfd.c | 6 -
drivers/rtc/rtc-nct6694.c | 7 -
drivers/watchdog/nct6694_wdt.c | 7 -
include/linux/mfd/nct6694.h | 102 +++-
13 files changed, 969 insertions(+), 228 deletions(-)
create mode 100644 drivers/mfd/nct6694-core.c
create mode 100644 drivers/mfd/nct6694-hif.c
rename drivers/mfd/{nct6694.c => nct6694-usb.c} (54%)
--
2.34.1