Using I2C or SPI device via Linux Userspace I/O driver?

Is Linux Userspace I/O driver can support to use for a I2C or SPI device?

For example in case of use in an SoC like an i.MX or Zynq, is it possible to use UIO for I2C or SPI? Can be probed an I2C or SPI sensor/IC as dev/uioX device which is able to mmap() and also use some GPIO based interrupt?

In the device tree, is it possibble to use for example to make an UIO device on I2C bus on address 0x40?

&i2c1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c1>;
    clock-frequency = <100000>;
    status = "okay";

    acc_sensor_0: acc_sensor@0x40 {
        reg = <0x40 0x100>;
        compatible = "generic-uio";
        linux,uio-name = "my_acc_sensor_0";


  • Is Linux Userspace I/O driver can support to use for a I2C or SPI device?

    I2C and SPI are busses, and have a master controller and slave devices.
    It's the master controller that is connected to, and therefore directly controlled (i.e. written to and read from) by the CPU. Any I/O with a slave device on the bus must be performed through the master controller. One abnormal exception is an interrupt; a slave device could generate an interrupt to the CPU, which is then handled by the slave device's driver.

    Your question is ambiguous; to what exactly are you referring by "I2C or SPI device"?

    If you meant a slave device, then you seem to be unaware that such a slave device is not accessed directly by the CPU. A slave device would have registers that are only accessed through the bus. Those registers would not be assigned any address in the SoC physical address space. Hence memory mapping of slave device registers by the CPU is impossible. An I2C or SPI slave device would not be a suitable candidate for Linux Userspace I/O driver.

    An I2C slave device can be controlled from userspace using i2c-dev.
    Study Documentation/i2c/dev-interface.rst.

    An SPI slave device can be controlled from userspace using spidev.
    Study Documentation/spi/spidev.rst.

    An I2C or SPI master controller would not make a good candidate for a Linux Userspace I/O driver. An SPI master controller never has a userspace interface (e.g. a device node in the /dev/ directory) even when it has a kernel driver.

    Study Introduction to I2C and SPI both in-kernel and in user space.