|
|
Log in / Subscribe / Register

spi: add sysfs interface for userspace device instantiation

From:  Vishwaroop A <va-AT-nvidia.com>
To:  Mark Brown <broonie-AT-kernel.org>
Subject:  [PATCH v2 0/2] spi: add sysfs interface for userspace device instantiation
Date:  Sat, 25 Apr 2026 17:34:23 +0000
Message-ID:  <20260425173425.622042-1-va@nvidia.com>
Cc:  <linux-spi-AT-vger.kernel.org>, <linux-kernel-AT-vger.kernel.org>, "Thierry Reding" <thierry.reding-AT-kernel.org>, Jonathan Hunter <jonathanh-AT-nvidia.com>, Francesco Dolcini <francesco.dolcini-AT-toradex.com>, <smangipudi-AT-nvidia.com>, <va-AT-nvidia.com>
Archive-link:  Article

Development boards such as the Jetson AGX Orin expose SPI buses on
expansion headers so that users can connect and interact with SPI
peripherals from userspace via /dev/spidevB.C character devices.

Today there is no viable upstream mechanism to create these device nodes:

  - The spidev driver rejects the bare "spidev" compatible string in DT,
    since spidev is a Linux software interface, not a hardware description.
  - Vendor-specific compatible strings (e.g. "nvidia,tegra-spidev") have
    been rejected by DT maintainers for the same reason.

The I2C subsystem solved an analogous problem years ago by exposing
new_device/delete_device sysfs attributes on each i2c adapter. This
series adds the same interface to SPI host controllers.

Patch 1 adds the core implementation: new_device and delete_device sysfs
attributes under /sys/class/spi_master/spiB/, allowing userspace to
dynamically instantiate and remove SPI devices at runtime.

Patch 2 adds documentation: an RST guide describing usage, parameters,
examples, and limitations, plus a formal ABI entry.

Link: https://lore.kernel.org/linux-tegra/909f0c92-d110-4253-90...

Changes in v2:
  - Fixed race between new_device_store() and spi_unregister_controller():
    replaced spi_add_device() with direct __spi_add_device() call under
    add_lock so that device registration and userspace_clients list
    insertion are atomic with respect to controller teardown.
    (Mark Brown)

Vishwaroop A (2):
  spi: add new_device/delete_device sysfs interface
  docs: spi: add documentation for userspace device instantiation

 .../ABI/testing/sysfs-class-spi-master        |  34 ++++
 Documentation/spi/index.rst                   |   1 +
 Documentation/spi/instantiating-devices.rst   |  88 ++++++++
 drivers/spi/spi.c                             | 190 ++++++++++++++++++
 include/linux/spi/spi.h                       |  10 +
 5 files changed, 323 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-spi-master
 create mode 100644 Documentation/spi/instantiating-devices.rst

-- 
2.17.1




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds