CV-Bowen opened a new pull request, #21861:
URL: https://github.com/apache/nuttx/pull/21861
## Summary
NuttX has VirtIO frontends for block, net, rng, serial, gpu, input and
sound, but none for the OASIS I2C, SPI and GPIO devices, so a NuttX
guest cannot use an I2C/SPI bus or GPIO lines provided by the host or
by a peer core.
- drivers/virtio: add the VirtIO I2C frontend driver
- Device id 34. Each device becomes a `struct i2c_master_s`,
returned by `virtio_i2c_get_master(index)`; implements the
`status` op from #21816.
- drivers/virtio: add the VirtIO SPI frontend driver
- Device id 45. Each device becomes a `struct spi_dev_s`, returned by
`virtio_spi_get_master(index)`; uses the int `exchange` from
#21817 to report transfer errors. Wire format in
`include/nuttx/virtio/virtio-spi.h`.
- drivers/virtio/virtio-spi: register /dev/spiN at probe
- drivers/virtio/virtio-i2c: register /dev/i2cN at probe
- With `CONFIG_SPI_DRIVER` / `CONFIG_I2C_DRIVER` the probe registers
the character device, as the other VirtIO frontends do, so no board
code is needed.
- drivers/virtio: add the VirtIO GPIO frontend driver
- Device id 41. Each device becomes an ioexpander, returned by
`virtio_gpio_get_ioe(index)`. With `IOEXPANDER_INT_ENABLE` it
negotiates `VIRTIO_GPIO_F_IRQ` and delivers line interrupts from the
event queue. Wire format in `include/nuttx/virtio/virtio-gpio.h`.
## Impact
- New Kconfig: `DRIVERS_VIRTIO_I2C` (selects `I2C`),
`DRIVERS_VIRTIO_SPI` (depends on `SPI && SPI_EXCHANGE`),
`DRIVERS_VIRTIO_GPIO` (depends on `IOEXPANDER`), all default n.
- New headers: `include/nuttx/i2c/i2c_virtio.h`,
`include/nuttx/spi/spi_virtio.h`,
`include/nuttx/ioexpander/gpio_virtio.h`,
`include/nuttx/virtio/virtio-spi.h`,
`include/nuttx/virtio/virtio-gpio.h`.
- Documentation: VirtIO sections in the I2C and SPI driver pages.
- No change unless the new options are enabled.
## Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
Build: each commit builds with 0 warnings on qemu-armv8a:netnsh with
`CONFIG_DRIVERS_VIRTIO_I2C`, `CONFIG_I2C_DRIVER`,
`CONFIG_DRIVERS_VIRTIO_SPI`, `CONFIG_SPI_EXCHANGE`,
`CONFIG_SPI_DRIVER`, `CONFIG_DRIVERS_VIRTIO_GPIO`,
`CONFIG_IOEXPANDER_DUMMY` (which selects `IOEXPANDER_INT_ENABLE`, so
the GPIO interrupt path is built) and `CONFIG_DEV_GPIO`.
Runtime: not run in this PR. QEMU only offers these devices as
vhost-user devices, which need an external backend daemon. A follow-up
PR adds the I2C, SPI and GPIO entries to the rptun ivshmem resource
table so that two NuttX instances (qemu-armv8a:rpserver/rpproxy) can
run these frontends against the in-tree vhost backends
(`drivers/vhost/vhost-i2c.c`, and vhost-spi / vhost-gpio in their own
PRs); the runtime test will be in that PR.
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 15/15). No regression in virtio: qemu-armv8a:netnsh boot and pass the
fixed virtio cases (rng, blk on mmio and pci, net, 9p; 24/24). qemu-armv8a was
built with LIBC_ENVPATH and BINFMT_CHECKEXEC disabled, which current master
needs for nxinit to start nsh there; unrelated to this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]