Skip to contentSkip to conversation

Add emulation of MEN Chameleon Hardware

PATCH New Johannes Thumshirn 1 participant 5 messages Apr 18, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v4 cover Add emulation of MEN Chameleon Hardware

Add emulation of MEN Chameleon Hardware to Qemu.
This emulation is specifically designed to test the upstream Linux kernel drivers when one has no access to the hardware.

The emulation consists of the bus itself, a PCI hardware target creating the bus, MEN Micro Electronic's 8250 based UART via MCB and a watchdog timer.

Changes since v2:
- Converted DPRINTF() to tracing infrastructure again (Alistair)

Changes since v2:
- Adjusted license to GPL 2 or later (Peter)

Changes since v1:
- Converted DPRINTF() to tracing infrastructure (Alistair)
- Fixed style issues (Alistair)

Johannes Thumshirn (4):
Add MEN Chameleon Bus emulation
Add MEN Chameleon Bus via PCI carrier
serial-mcb: Add serial via MEN chameleon bus
wdt_z069: Add support for MEN 16z069 Watchdog

 MAINTAINERS              |   6 +
 hw/Kconfig               |   1 +
 hw/char/Kconfig          |   6 +
 hw/char/meson.build      |   1 +
 hw/char/serial-mcb.c     | 115 +++++++++++++++
 hw/mcb/Kconfig           |   8 ++
 hw/mcb/mcb-pci.c         | 298 +++++++++++++++++++++++++++++++++++++++
 hw/mcb/mcb.c             | 180 +++++++++++++++++++++++
 hw/mcb/meson.build       |   2 +
 hw/mcb/trace-events      |   4 +
 hw/mcb/trace.h           |   1 +
 hw/meson.build           |   1 +
 hw/watchdog/Kconfig      |   5 +
 hw/watchdog/meson.build  |   1 +
 hw/watchdog/trace-events |   6 +
 hw/watchdog/wdt_z069.c   | 207 +++++++++++++++++++++++++++
 include/hw/mcb/mcb.h     | 106 ++++++++++++++
 meson.build              |   1 +
 18 files changed, 949 insertions(+)
 create mode 100644 hw/char/serial-mcb.c
 create mode 100644 hw/mcb/Kconfig
 create mode 100644 hw/mcb/mcb-pci.c
 create mode 100644 hw/mcb/mcb.c
 create mode 100644 hw/mcb/meson.build
 create mode 100644 hw/mcb/trace-events
 create mode 100644 hw/mcb/trace.h
 create mode 100644 hw/watchdog/wdt_z069.c
 create mode 100644 include/hw/mcb/mcb.h
Signature · 1 line
2.39.2
#1 lore raw

PATCH v4 1/4 Add MEN Chameleon Bus emulation

The MEN Chameleon Bus (MCB) is an on-chip bus system exposing IP Cores of an FPGA to a outside bus system like PCIe.

---
 MAINTAINERS          |   6 ++
 hw/Kconfig           |   1 +
 hw/mcb/Kconfig       |   2 +
 hw/mcb/mcb.c         | 180 +++++++++++++++++++++++++++++++++++++++++++
 hw/mcb/meson.build   |   1 +
 hw/meson.build       |   1 +
 include/hw/mcb/mcb.h | 106 +++++++++++++++++++++++++
 7 files changed, 297 insertions(+)
 create mode 100644 hw/mcb/Kconfig
 create mode 100644 hw/mcb/mcb.c
 create mode 100644 hw/mcb/meson.build
 create mode 100644 include/hw/mcb/mcb.h
MAINTAINERS +6 -0
index 2c2068ea5c..1fa5909a97 100644
@@ -1962,6 +1962,12 @@ R: Paolo Bonzini <[email protected]>
 S: Odd Fixes
 F: hw/char/
 
+MEN Chameleon Bus
+M: Johannes Thumshirn <[email protected]>
+S: Maintained
+F: hw/mcb/
+F: include/hw/mcb/
+
 Network devices
 M: Jason Wang <[email protected]>
 S: Odd Fixes
hw/Kconfig +1 -0
index ba62ff6417..f5ef84b10b 100644
@@ -18,6 +18,7 @@ source intc/Kconfig
 source ipack/Kconfig
 source ipmi/Kconfig
 source isa/Kconfig
+source mcb/Kconfig
 source mem/Kconfig
 source misc/Kconfig
 source net/Kconfig
hw/mcb/Kconfig new file +2 -0
new file mode 100644
index 0000000000..36a7a583a8
@@ -0,0 +1,2 @@
+config MCB
+    bool
hw/mcb/mcb.c new file +180 -0

180 lines not on this page · raw message

hw/mcb/meson.build new file +1 -0
new file mode 100644
index 0000000000..a385edc07c
@@ -0,0 +1 @@
+softmmu_ss.add(when: 'CONFIG_MCB', if_true: files('mcb.c'))
hw/meson.build +1 -0
index c7ac7d3d75..3d1462ad8b 100644
@@ -18,6 +18,7 @@ subdir('intc')
 subdir('ipack')
 subdir('ipmi')
 subdir('isa')
+subdir('mcb')
 subdir('mem')
 subdir('misc')
 subdir('net')
include/hw/mcb/mcb.h new file +106 -0

106 lines not on this page · raw message

Signature · 1 line
2.39.2
#4 lore raw

PATCH v4 4/4 wdt_z069: Add support for MEN 16z069 Watchdog

In reply to Johannes Thumshirn

Add 16z069 Watchdog over MEN Chameleon BUS emulation.

---
 hw/watchdog/Kconfig      |   5 +
 hw/watchdog/meson.build  |   1 +
 hw/watchdog/trace-events |   6 ++
 hw/watchdog/wdt_z069.c   | 207 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 219 insertions(+)
 create mode 100644 hw/watchdog/wdt_z069.c
hw/watchdog/Kconfig +5 -0
index 66e1d029e3..a3f1196f66 100644
@@ -20,3 +20,8 @@ config WDT_IMX2
 
 config WDT_SBSA
     bool
+
+config WDT_Z069
+    bool
+    default y if MCB
+    depends on MCB
hw/watchdog/meson.build +1 -0
index 8974b5cf4c..7bc353774e 100644
@@ -6,4 +6,5 @@ softmmu_ss.add(when: 'CONFIG_WDT_DIAG288', if_true: files('wdt_diag288.c'))
 softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('wdt_aspeed.c'))
 softmmu_ss.add(when: 'CONFIG_WDT_IMX2', if_true: files('wdt_imx2.c'))
 softmmu_ss.add(when: 'CONFIG_WDT_SBSA', if_true: files('sbsa_gwdt.c'))
+softmmu_ss.add(when: 'CONFIG_WDT_Z069', if_true: files('wdt_z069.c'))
 specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_watchdog.c'))
hw/watchdog/trace-events +6 -0
index 54371ae075..854fa3f0c8 100644
@@ -17,6 +17,12 @@ spapr_watchdog_query(uint64_t caps) "caps=0x%" PRIx64
 spapr_watchdog_query_lpm(uint64_t caps) "caps=0x%" PRIx64
 spapr_watchdog_expired(uint64_t num, unsigned action) "num=%" PRIu64 " action=%u"
 
+# wdt_z069.c
+men_z069_wdt_enable(unsigned int timeout) "next timeout will fire in +%dms"
+men_z069_wdt_write_wtr(uint16_t tout, uint16_t t, unsigned int timeout) "new timeout: %u (0x%x) %u"
+men_z069_wdt_write_wvr(uint16_t wvr, unsigned int timeout) "watchdog triggered (wvr=0x%x), next timeout will fire in +%dms"
+men_z069_wdt_read(unsigned long addr, int size, uint64_t ret) "addr=0x%lx, size=%d, ret=0x%" PRIx64
+
 # watchdog.c
 watchdog_perform_action(unsigned int action) "action=%u"
 watchdog_set_action(unsigned int action) "action=%u"
hw/watchdog/wdt_z069.c new file +207 -0

207 lines not on this page · raw message

Signature · 1 line
2.39.2
#3 lore raw

PATCH v4 3/4 serial-mcb: Add serial via MEN chameleon bus

In reply to Johannes Thumshirn

Add MEN z125 UART over MEN Chameleon Bus emulation.

---
 hw/char/Kconfig      |   6 +++
 hw/char/meson.build  |   1 +
 hw/char/serial-mcb.c | 115 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+)
 create mode 100644 hw/char/serial-mcb.c
hw/char/Kconfig +6 -0
index 6b6cf2fc1d..9e8ebf1d3d 100644
@@ -71,3 +71,9 @@ config GOLDFISH_TTY
 
 config SHAKTI_UART
     bool
+
+config SERIAL_MCB
+    bool
+    default y if MCB
+    depends on MCB
+    select SERIAL
hw/char/meson.build +1 -0
index e02c60dd54..d5893a142d 100644
@@ -20,6 +20,7 @@ softmmu_ss.add(when: 'CONFIG_SHAKTI_UART', if_true: files('shakti_uart.c'))
 softmmu_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: files('virtio-console.c'))
 softmmu_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen_console.c'))
 softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_uartlite.c'))
+softmmu_ss.add(when: 'CONFIG_SERIAL_MCB', if_true: files('serial-mcb.c'))
 
 softmmu_ss.add(when: 'CONFIG_AVR_USART', if_true: files('avr_usart.c'))
 softmmu_ss.add(when: 'CONFIG_COLDFIRE', if_true: files('mcf_uart.c'))
hw/char/serial-mcb.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.39.2
#2 lore raw

PATCH v4 2/4 Add MEN Chameleon Bus via PCI carrier

In reply to Johannes Thumshirn

Add PCI based MEN Chameleon Bus carrier emulation.

---
 hw/mcb/Kconfig      |   6 +
 hw/mcb/mcb-pci.c    | 298 ++++++++++++++++++++++++++++++++++++++++++++
 hw/mcb/meson.build  |   1 +
 hw/mcb/trace-events |   4 +
 hw/mcb/trace.h      |   1 +
 meson.build         |   1 +
 6 files changed, 311 insertions(+)
 create mode 100644 hw/mcb/mcb-pci.c
 create mode 100644 hw/mcb/trace-events
 create mode 100644 hw/mcb/trace.h
hw/mcb/Kconfig +6 -0
index 36a7a583a8..7deb96c2fe 100644
@@ -1,2 +1,8 @@
 config MCB
     bool
+
+config MCB_PCI
+    bool
+    default y if PCI_DEVICES
+    depends on PCI
+    select MCB
hw/mcb/mcb-pci.c new file +298 -0

298 lines not on this page · raw message

hw/mcb/meson.build +1 -0
index a385edc07c..4e1a0f0cdb 100644
@@ -1 +1,2 @@
 softmmu_ss.add(when: 'CONFIG_MCB', if_true: files('mcb.c'))
+softmmu_ss.add(when: 'CONFIG_MCB_PCI', if_true: files('mcb-pci.c'))
hw/mcb/trace-events new file +4 -0
new file mode 100644
index 0000000000..e4f71315ab
@@ -0,0 +1,4 @@
+# mcb-pci.c
+mpci_chamtbl_read(unsigned long addr, unsigned int size) "read from address 0x%lx size %d"
+mpci_chamtbl_write(unsigned long addr, uint64_t val) "invalid write to 0x%lx: 0x%" PRIx64
+mpci_set_irq(int intno, int level) "set IRQ #%d (level=%d)"
hw/mcb/trace.h new file +1 -0
new file mode 100644
index 0000000000..35653b3381
@@ -0,0 +1 @@
+#include "trace/trace-hw_mcb.h"
meson.build +1 -0
index c44d05a13f..26fe8e4115 100644
@@ -2990,6 +2990,7 @@ if have_system
     'hw/input',
     'hw/intc',
     'hw/isa',
+    'hw/mcb',
     'hw/mem',
     'hw/mips',
     'hw/misc',
Signature · 1 line
2.39.2