Skip to contentSkip to conversation

hw/misc: emulated Nexthop FPGA I2C (Xilinx AXI-IIC) device

RFC PATCH Superseded Nodoka Shibasaki 1 participant 5 messages Jul 15 – Jul 28 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover hw/misc: emulated Nexthop FPGA I2C (Xilinx AXI-IIC) device

Hi all,

This RFC adds a QEMU device model, "xiic-fpga-i2c", for a Nexthop-style PCIe FPGA that exposes Xilinx AXI-IIC (i2c-xiic) controllers. The goal is to let the SONiC platform bring-up path (the multifpgapci + i2c-xiic kernel drivers, plus the userspace platform code that walks the I2C tree) be exercised under QEMU without access to real switch hardware.

The device presents a PCIe function with a BAR0 register window that decodes the AXI-IIC register map, gives each channel its own QEMU I2C bus (so standard slave models such as at24c-eeprom / tmp105 / tmp421 can be attached from the command line), drives real transfers through the i2c core in dynamic (DTR) mode, and delivers completion via MSI with a legacy INTx fallback.

Open questions I would appreciate guidance on:

1. Is an emulation of a vendor-specific FPGA appropriate for hw/misc, or would you prefer it live elsewhere / be structured differently? It is modelled as a TEST_DEVICES-gated device alongside EDU and pci-testdev, since its purpose is CI/bring-up rather than modelling a shipping board.

2. The AXI-IIC register decode here is deliberately partial: it implements the subset the Linux i2c-xiic driver actually touches in dynamic mode. I can flesh out the static/manual mode if that is preferred for a general-purpose model.

3. A documentation file under docs/specs/ can be added if this is something you would consider merging; I left it out of the RFC to keep the first posting focused on the device itself.

This series is based on current master (191489ba75). No documentation or qtest is included yet (happy to add both if there is interest).

Thanks,
Nodoka

Nodoka Shibasaki (1):
hw/misc: add xiic-fpga-i2c, an emulated Nexthop PCIe FPGA I2C
controller

 MAINTAINERS             |   5 +
 hw/misc/Kconfig         |   6 +
 hw/misc/meson.build     |   1 +
 hw/misc/xiic_fpga_i2c.c | 651 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 663 insertions(+)
 create mode 100644 hw/misc/xiic_fpga_i2c.c
Signature · 1 line
2.50.1
#1 lore raw

RFC PATCH 1/1 hw/misc: add xiic-fpga-i2c, an emulated Nexthop PCIe FPGA I2C controller

Add a QEMU model of a Nexthop-style PCIe FPGA that exposes Xilinx AXI-IIC (i2c-xiic) controllers, so that SONiC's multifpgapci / i2c-xiic hardware path can be exercised without real switch hardware.

The device presents a PCIe function with a BAR0 register window that decodes the Xilinx AXI-IIC register map. Each channel exposes its own QEMU I2C bus, so slave models can be attached from the command line, for example:

  -device xiic-fpga-i2c,id=fpga,num-channels=2 \
  -device at24c-eeprom,bus=xiic-fpga-i2c.0,address=0x50

Dynamic-mode DTR transfers drive the I2C core via the standard i2c_start_send()/i2c_start_recv()/i2c_send()/i2c_recv() helpers, a NACK is reported through IISR.TX_ERROR, and transfer completion is delivered via MSI (one vector per channel) with a legacy INTx fallback.

The device is gated behind a new CONFIG_XIIC_FPGA_I2C Kconfig symbol (default y if TEST_DEVICES), following the convention used by other hw/misc devices such as EDU and pci-testdev.

---
 MAINTAINERS             |   5 +
 hw/misc/Kconfig         |   6 +
 hw/misc/meson.build     |   1 +
 hw/misc/xiic_fpga_i2c.c | 651 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 663 insertions(+)
 create mode 100644 hw/misc/xiic_fpga_i2c.c
MAINTAINERS +5 -0
index ecb8cfdc41..8bbc7202fa 100644
@@ -2157,6 +2157,11 @@ S: Maintained
 F: hw/misc/edu.c
 F: docs/specs/edu.rst
 
+xiic-fpga-i2c
+M: Nodoka Shibasaki <[email protected]>
+S: Maintained
+F: hw/misc/xiic_fpga_i2c.c
+
 IDE
 M: John Snow <[email protected]>
 L: [email protected]
hw/misc/Kconfig +6 -0
index 1543ee6653..3aa26a6550 100644
@@ -25,6 +25,12 @@ config PCI_TESTDEV
     default y if TEST_DEVICES
     depends on PCI
 
+config XIIC_FPGA_I2C
+    bool
+    default y if TEST_DEVICES
+    depends on PCI
+    select I2C
+
 config IOMMU_TESTDEV
     bool
     default y if TEST_DEVICES
hw/misc/meson.build +1 -0
index 23265f6035..69d816cad9 100644
@@ -4,6 +4,7 @@ system_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('vmcoreinfo.c'))
 system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugexit.c'))
 system_ss.add(when: 'CONFIG_ISA_TESTDEV', if_true: files('pc-testdev.c'))
 system_ss.add(when: 'CONFIG_PCI_TESTDEV', if_true: files('pci-testdev.c'))
+system_ss.add(when: 'CONFIG_XIIC_FPGA_I2C', if_true: files('xiic_fpga_i2c.c'))
 system_ss.add(when: 'CONFIG_IOMMU_TESTDEV', if_true: files('iommu-testdev.c'))
 system_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
 system_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
hw/misc/xiic_fpga_i2c.c new file +651 -0

651 lines not on this page · raw message

Signature · 1 line
2.50.1
#2 lore raw

v2 cover hw/i2c, hw/misc: emulated Xilinx AXI-IIC controller + PCIe FPGA carrier

In reply to Nodoka Shibasaki

Hi all,

This is a follow-up to the single-patch RFC I sent last week ("[RFC PATCH 1/1] hw/misc: add xiic-fpga-i2c, an emulated PCIe FPGA I2C controller"). Based on the split suggested there between a standardized controller and its carrier, this v2 breaks the device in two:

1/2 - hw/i2c: a generic model of the AMD/Xilinx AXI IIC controller
(LogiCORE IP, PG090) as a SysBus device, independent of any particular carrier.
2/2 - hw/misc: a PCIe function, gated behind TEST_DEVICES, that
embeds N of the above controllers behind one BAR0 window and aggregates their interrupts onto a single MSI vector (with a legacy INTx fallback). This models a specific FPGA carrier rather than a standardized board, hence hw/misc + TEST_DEVICES rather than hw/i2c proper.

Together they let the Linux i2c-xiic driver, and any I2C slave behind it, be exercised under QEMU without real hardware.

Changes since v1:
- Split the single device into a generic hw/i2c controller model and a separate hw/misc PCIe carrier that instantiates it.
- Added a register-level spec for the controller

    (docs/specs/xlnx-axi-iic.rst).

- Added a qtest (tests/qtest/xiic-fpga-i2c-test.c) that drives a transfer through BAR0 to a tmp105 slave and checks register, transfer and NACK behavior.
- Reworded comments/commit messages to describe the hardware in generic terms rather than referencing a specific downstream project.

Open questions (carried over / updated from v1):

1. Is hw/misc + TEST_DEVICES the right home for the carrier, given the controller itself is now a standalone hw/i2c device? I split it this way since the carrier's register aggregation is specific to one FPGA design rather than a standardized board.

2. The AXI-IIC register decode is deliberately partial: it implements the subset the Linux i2c-xiic driver actually touches in dynamic mode. I can flesh out static/manual mode if that is preferred for a general-purpose model.

This series is based on current master. Happy to add more qtest coverage or documentation if there's interest in merging either half.

Thanks

Nodoka Shibasaki (2):
hw/i2c: add xlnx-axi-iic, a Xilinx AXI IIC controller hw/misc: add xiic-fpga-i2c, a PCIe FPGA embedding xlnx-axi-iic cores

 MAINTAINERS                                |  12 +
 configs/devices/x86_64-softmmu/default.mak |   5 +
 docs/specs/index.rst                       |   1 +
 docs/specs/xlnx-axi-iic.rst                |  62 +++++
 hw/i2c/Kconfig                             |   4 +
 hw/i2c/meson.build                         |   1 +
 hw/i2c/xlnx-axi-iic.c                      | 284 +++++++++++++++++++++
 hw/misc/Kconfig                            |   6 +
 hw/misc/meson.build                        |   1 +
 hw/misc/xiic_fpga_i2c.c                    | 261 +++++++++++++++++++
 include/hw/i2c/xlnx-axi-iic.h              |  69 +++++
 tests/qtest/meson.build                    |   2 +
 tests/qtest/xiic-fpga-i2c-test.c           | 159 ++++++++++++
 13 files changed, 867 insertions(+)
 create mode 100644 docs/specs/xlnx-axi-iic.rst
 create mode 100644 hw/i2c/xlnx-axi-iic.c
 create mode 100644 hw/misc/xiic_fpga_i2c.c
 create mode 100644 include/hw/i2c/xlnx-axi-iic.h
 create mode 100644 tests/qtest/xiic-fpga-i2c-test.c
Signature · 1 line
2.50.1
#3 lore raw

RFC PATCH v2 1/2 hw/i2c: add xlnx-axi-iic, a Xilinx AXI IIC controller

Add a model of the AMD/Xilinx AXI IIC controller (LogiCORE IP, PG090), an I2C bus controller. QEMU has no AXI IIC model today; this lets a guest driver for it, and the I2C slaves behind it, be exercised without real hardware.

The device is a SysBus device: it owns one I2C bus, decodes the AXI IIC register map, implements the controller's dynamic transfer mode, and drives a single level-triggered interrupt line while DGIER is enabled and IISR & IIER is set. It has a reset handler and migration state, and a register-level specification in docs/specs/xlnx-axi-iic.rst.

---
 MAINTAINERS                   |  10 ++
 docs/specs/index.rst          |   1 +
 docs/specs/xlnx-axi-iic.rst   |  62 ++++++++
 hw/i2c/Kconfig                |   4 +
 hw/i2c/meson.build            |   1 +
 hw/i2c/xlnx-axi-iic.c         | 284 ++++++++++++++++++++++++++++++++++
 include/hw/i2c/xlnx-axi-iic.h |  69 +++++++++
 7 files changed, 431 insertions(+)
 create mode 100644 docs/specs/xlnx-axi-iic.rst
 create mode 100644 hw/i2c/xlnx-axi-iic.c
 create mode 100644 include/hw/i2c/xlnx-axi-iic.h
MAINTAINERS +10 -0
index a28935c898..8339c9bf83 100644
@@ -2158,6 +2158,16 @@ S: Maintained
 F: hw/misc/edu.c
 F: docs/specs/edu.rst
 
+<<<<<<< Updated upstream
+=======
+xiic-fpga-i2c
+M: Nodoka Shibasaki <[email protected]>
+S: Maintained
+F: hw/i2c/xlnx-axi-iic.c
+F: include/hw/i2c/xlnx-axi-iic.h
+F: docs/specs/xlnx-axi-iic.rst
+
+>>>>>>> Stashed changes
 IDE
 M: John Snow <[email protected]>
 L: [email protected]
docs/specs/index.rst +1 -0
index b7909a108a..41b45a5be4 100644
@@ -40,3 +40,4 @@ guest hardware that is specific to QEMU.
    riscv-aia
    aspeed-intc
    iommu-testdev
+   xlnx-axi-iic
docs/specs/xlnx-axi-iic.rst new file +62 -0

62 lines not on this page · raw message

hw/i2c/Kconfig +4 -0
index 0766130b59..4faf2bda99 100644
@@ -43,6 +43,10 @@ config ALLWINNER_I2C
     bool
     select I2C
 
+config XLNX_AXI_IIC
+    bool
+    select I2C
+
 config PCA954X
     bool
     select I2C
hw/i2c/meson.build +1 -0
index 88aea35662..939f02f03b 100644
@@ -9,6 +9,7 @@ i2c_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_i2c.c'))
 i2c_ss.add(when: 'CONFIG_IMX_I2C', if_true: files('imx_i2c.c'))
 i2c_ss.add(when: 'CONFIG_MPC_I2C', if_true: files('mpc_i2c.c'))
 i2c_ss.add(when: 'CONFIG_ALLWINNER_I2C', if_true: files('allwinner-i2c.c'))
+i2c_ss.add(when: 'CONFIG_XLNX_AXI_IIC', if_true: files('xlnx-axi-iic.c'))
 i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c'))
 i2c_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_smbus.c'))
 i2c_ss.add(when: 'CONFIG_DESIGNWARE_I2C', if_true: files('designware_i2c.c'))
hw/i2c/xlnx-axi-iic.c new file +284 -0

284 lines not on this page · raw message

include/hw/i2c/xlnx-axi-iic.h new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.50.1
#4 lore raw

RFC PATCH v2 2/2 hw/misc: add xiic-fpga-i2c, a PCIe FPGA embedding xlnx-axi-iic cores

In reply to Nodoka Shibasaki

Add a PCIe function that embeds N xlnx-axi-iic controllers, maps each core's register window into BAR0, and adds a top-level interrupt block that aggregates the per-channel level lines into a bit-per-channel status register delivered on a single MSI vector (with a legacy INTx fallback), performing the level-to-edge translation a guest driver expects.

The aggregator's register layout models a specific FPGA carrier rather than a standardized controller, so the device is gated behind CONFIG_XIIC_FPGA_I2C (default y if TEST_DEVICES). A qtest drives a transfer through BAR0 to a tmp105 slave and checks register, transfer and NACK behavior; the test slaves it needs are enabled in the x86_64-softmmu test config.

---
 MAINTAINERS                                |   8 +-
 configs/devices/x86_64-softmmu/default.mak |   5 +
 hw/misc/Kconfig                            |   6 +
 hw/misc/meson.build                        |   1 +
 hw/misc/xiic_fpga_i2c.c                    | 261 +++++++++++++++++++++
 tests/qtest/meson.build                    |   2 +
 tests/qtest/xiic-fpga-i2c-test.c           | 159 +++++++++++++
 7 files changed, 439 insertions(+), 3 deletions(-)
 create mode 100644 hw/misc/xiic_fpga_i2c.c
 create mode 100644 tests/qtest/xiic-fpga-i2c-test.c
MAINTAINERS +5 -3
index 8339c9bf83..85f03cf4b6 100644
@@ -2158,8 +2158,6 @@ S: Maintained
 F: hw/misc/edu.c
 F: docs/specs/edu.rst
 
-<<<<<<< Updated upstream
-=======
 xiic-fpga-i2c
 M: Nodoka Shibasaki <[email protected]>
 S: Maintained
@@ -2167,7 +2165,11 @@ F: hw/i2c/xlnx-axi-iic.c
 F: include/hw/i2c/xlnx-axi-iic.h
 F: docs/specs/xlnx-axi-iic.rst
 
->>>>>>> Stashed changes
+xiic-fpga-i2c
+M: Nodoka Shibasaki <[email protected]>
+S: Maintained
+F: hw/misc/xiic_fpga_i2c.c
+
 IDE
 M: John Snow <[email protected]>
 L: [email protected]
configs/devices/x86_64-softmmu/default.mak +5 -0
index ddfc2ea626..d7a88deccc 100644
@@ -1,3 +1,8 @@
 # Default configuration for x86_64-softmmu
 
 include ../i386-softmmu/default.mak
+
+# Enable I2C slave models used by the xiic-fpga-i2c qtest.
+CONFIG_AT24C=y
+CONFIG_TMP105=y
+CONFIG_TMP421=y
hw/misc/Kconfig +6 -0
index 1543ee6653..12acca66bb 100644
@@ -25,6 +25,12 @@ config PCI_TESTDEV
     default y if TEST_DEVICES
     depends on PCI
 
+config XIIC_FPGA_I2C
+    bool
+    default y if TEST_DEVICES
+    depends on PCI && MSI_NONBROKEN
+    select XLNX_AXI_IIC
+
 config IOMMU_TESTDEV
     bool
     default y if TEST_DEVICES
hw/misc/meson.build +1 -0
index 23265f6035..69d816cad9 100644
@@ -4,6 +4,7 @@ system_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('vmcoreinfo.c'))
 system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugexit.c'))
 system_ss.add(when: 'CONFIG_ISA_TESTDEV', if_true: files('pc-testdev.c'))
 system_ss.add(when: 'CONFIG_PCI_TESTDEV', if_true: files('pci-testdev.c'))
+system_ss.add(when: 'CONFIG_XIIC_FPGA_I2C', if_true: files('xiic_fpga_i2c.c'))
 system_ss.add(when: 'CONFIG_IOMMU_TESTDEV', if_true: files('iommu-testdev.c'))
 system_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
 system_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
hw/misc/xiic_fpga_i2c.c new file +261 -0

261 lines not on this page · raw message

tests/qtest/meson.build +2 -0
index 56ff860e21..7abd2c7520 100644
@@ -74,6 +74,8 @@ qtests_i386 = \
   (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) +              \
   (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) +              \
   (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) +          \
+  (config_all_devices.has_key('CONFIG_XIIC_FPGA_I2C') and
+   config_all_devices.has_key('CONFIG_TMP105') ? ['xiic-fpga-i2c-test'] : []) +             \
   (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) +                    \
   (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) +             \
   (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) +                  \
tests/qtest/xiic-fpga-i2c-test.c new file +159 -0

159 lines not on this page · raw message

Signature · 1 line
2.50.1