[PATCH v4 0/2] spmi: core: Add generic DebugFS interface for bus inspection

From: vamshi gajjela

Date: Fri Oct 30 2026 - 00:59:57 EST


From: Vamshi Gajjela <vamshigajjela@xxxxxxxxxx>

This series introduces a generic, controller-agnostic DebugFS interface in the
SPMI core under /sys/kernel/debug/spmi/spmi-<nr>/ to inspect registered
controllers and perform SPMI transactions during board bringup and debugging.

Patch 1/2 renames drivers/spmi/spmi.c to spmi-core.c so that the core driver
and optional debugfs support can be linked into the spmi.ko composite module.

Patch 2/2 adds the DebugFS interface (name and xfer) along with its ABI
documentation under Documentation/ABI/testing/debugfs-spmi.

Changes in v4:
- Rebased onto spmi-next (8f70c729e68c).
- Split the rename of drivers/spmi/spmi.c -> spmi-core.c into a separate
preparatory patch.
- Removed the 'detect' debugfs entry as MIPI SPMI does not mandate a universal
register address across all slave devices, and probing 0x0000 fails on
controllers with channel/register access policies such as Qualcomm PMIC Arb.
- Dropped redundant Runtime PM calls from spmi-debugfs.c since SPMI controller
drivers manage their own runtime PM inside their transaction callbacks.
- Gated raw write ('w') and command ('c') operations behind
#undef SPMI_ALLOW_WRITE_DEBUGFS (matching regmap-debugfs.c) so that the
interface is read-only by default unless explicitly enabled in source.
- Updated Date and KernelVersion in Documentation/ABI/testing/debugfs-spmi.
- Link to v3: https://lore.kernel.org/r/20261019202107.888262-1-vamshigajjela@xxxxxxxxxx

Changes in v3:
- Move internal SPMI core command helpers (spmi_cmd(), spmi_read_cmd(),
spmi_write_cmd()) and DebugFS prototypes out of the public
include/linux/spmi.h header into a local drivers/spmi/spmi-internal.h
header.

Changes in v2:
- Rename spmi.c to spmi-core.c and link spmi-debugfs.o into the composite
spmi.o module so CONFIG_SPMI=m builds cleanly with CONFIG_DEBUG_FS=y.
- Route DebugFS bus operations through spmi_read_cmd(), spmi_write_cmd(),
and spmi_cmd() instead of calling controller callbacks directly,
preserving SPMI tracepoints and core validation.
- Allocate a per-open-file struct spmi_xfer_ctx in open() instead of
sharing a controller-wide buffer, avoiding races across concurrent file
descriptors, and store struct dentry *debugfs directly on
struct spmi_controller.
- Reset *ppos = 0 on register read commands so repeated transactions on
the same open file descriptor work without manual seeking.
- Restrict SPMI_CMD_ZERO_WRITE at address 0x00 to 7-bit payloads
(data[0] <= 0x7f) per the MIPI SPMI specification, falling back to
SPMI_CMD_WRITE for 8-bit values.
- Parse register addresses with kstrtou16() so values above 0xffff are
rejected instead of silently truncated.
- Update Documentation/ABI/testing/debugfs-spmi to document per-fd xfer
buffers and 7-bit Zero Write opcode selection.

Vamshi Gajjela (2):
spmi: core: Rename spmi.c to spmi-core.c
spmi: core: Add generic DebugFS interface for bus inspection

Documentation/ABI/testing/debugfs-spmi | 68 +++++
MAINTAINERS | 1 +
drivers/spmi/Makefile | 2 +
drivers/spmi/{spmi.c => spmi-core.c} | 20 +-
drivers/spmi/spmi-debugfs.c | 341 +++++++++++++++++++++++++
drivers/spmi/spmi-internal.h | 28 ++
include/linux/spmi.h | 6 +
7 files changed, 460 insertions(+), 6 deletions(-)
create mode 100644 Documentation/ABI/testing/debugfs-spmi
rename drivers/spmi/{spmi.c => spmi-core.c} (97%)
create mode 100644 drivers/spmi/spmi-debugfs.c
create mode 100644 drivers/spmi/spmi-internal.h

--
2.56.0.317.g454f8302e1-goog