Skip to contentSkip to conversation

hw/arm: add Beckhoff CX7200 board

PATCH Superseded Corvin Köhne 3 participants 24 messages Nov 11, 2025 – Nov 24, 2025

Subsystems (2)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v4 cover hw/arm: add Beckhoff CX7200 board

From: Corvin Köhne <[email protected]>

Hi,

Beckhoff has build a board, called CX7200, based on the Xilinx Zynq A9 platform. This commit series adds the Beckhoff CX7200 as new board variant to QEMU.

The emulation is able to successfully boot an CX7200 image. The image includes some self tests executed on every boot. Only the cache self test fails due to QEMU emulating the cache as always being coherent. The self tests include f.e.:

* Network
* Flash
* CCAT DMA + EEPROM [1]
* TwinCAT (Beckhoff's automation control software [2])

[1] https://github.com/beckhoff/ccat
[2] https://www.beckhoff.com/en-us/products/automation/

YannickV (15):
hw/timer: Make frequency configurable
hw/timer: Make PERIPHCLK divider configurable hw/dma/zynq-devcfg: Handle bitstream loading via DMA to 0xffffffff hw/arm/zynq-devcfg: Prevent unintended unlock during initialization hw/dma/zynq: Ensure PCFG_DONE bit remains set to indicate PL is in
user mode
hw/dma/zynq-devcfg: Simulate dummy PL reset hw/dma/zynq-devcfg: Indicate power-up status of PL hw/dma/zynq-devcfg: Fix register memory
hw/misc: Add dummy ZYNQ DDR controller hw/misc/zynq_slcr: Add logic for DCI configuration hw/misc: Add Beckhoff CCAT device
hw/block/m25p80: Add HAS_SR_TB flag for is25lp016d hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200 tests/functional: Add a Beckhoff CX7200 test docs/system/arm: Add support for Beckhoff CX7200

 docs/system/arm/beckhoff-cx7200.rst          |  57 +++
 docs/system/target-arm.rst                   |   1 +
 hw/arm/Kconfig                               |  18 +
 hw/arm/beckhoff_CX7200.c                     | 443 +++++++++++++++++++
 hw/arm/meson.build                           |   1 +
 hw/block/m25p80.c                            |   3 +-
 hw/dma/xlnx-zynq-devcfg.c                    |  29 +-
 hw/misc/Kconfig                              |   6 +
 hw/misc/beckhoff_ccat.c                      | 338 ++++++++++++++
 hw/misc/meson.build                          |   2 +
 hw/misc/xlnx-zynq-ddrc.c                     | 413 +++++++++++++++++
 hw/misc/zynq_slcr.c                          |  31 ++
 hw/timer/a9gtimer.c                          |  26 +-
 hw/timer/arm_mptimer.c                       |  32 +-
 include/hw/misc/xlnx-zynq-ddrc.h             | 148 +++++++
 include/hw/timer/a9gtimer.h                  |   2 +
 include/hw/timer/arm_mptimer.h               |   4 +
 tests/functional/test_arm_beckhoff_cx7200.py |  19 +
 18 files changed, 1561 insertions(+), 12 deletions(-)
 create mode 100644 docs/system/arm/beckhoff-cx7200.rst
 create mode 100644 hw/arm/beckhoff_CX7200.c
 create mode 100644 hw/misc/beckhoff_ccat.c
 create mode 100644 hw/misc/xlnx-zynq-ddrc.c
 create mode 100644 include/hw/misc/xlnx-zynq-ddrc.h
 create mode 100644 tests/functional/test_arm_beckhoff_cx7200.py
Signature · 1 line
2.47.3
#1 lore raw

PATCH v4 1/15 hw/timer: Make frequency configurable

From: YannickV <[email protected]>

The a9 global timer and arm mp timers rely on the PERIPHCLK as their clock source. The current implementation does not take that into account. That causes problems for applications assuming other frequencies than 1 GHz.

We can now configure frequencies for the a9 global timer and arm mp timer. By allowing these values to be set according to the application's needs, we ensure that the timers behave consistently with the expected system configuration. The SoC configures the device correctly.

Information can be found in the Zynq 7000 SoC Technical Reference Manual under Timers.
https://docs.amd.com/r/en-US/ug585-zynq-7000-SoC-TRM

---
 hw/timer/a9gtimer.c            |  9 ++++++---
 hw/timer/arm_mptimer.c         | 15 +++++++++++----
 include/hw/timer/a9gtimer.h    |  1 +
 include/hw/timer/arm_mptimer.h |  2 ++
 4 files changed, 20 insertions(+), 7 deletions(-)
hw/timer/a9gtimer.c +6 -3
index 9835c35483..090d14c683 100644
@@ -63,9 +63,9 @@ static inline int a9_gtimer_get_current_cpu(A9GTimerState *s)
 static inline uint64_t a9_gtimer_get_conv(A9GTimerState *s)
 {
     uint64_t prescale = extract32(s->control, R_CONTROL_PRESCALER_SHIFT,
-                                  R_CONTROL_PRESCALER_LEN);
-
-    return (prescale + 1) * 10;
+                                  R_CONTROL_PRESCALER_LEN) + 1;
+    uint64_t scaled_prescaler = prescale * 10;
+    return muldiv64(scaled_prescaler, NANOSECONDS_PER_SECOND, s->freq_hz);
 }
 
 static A9GTimerUpdate a9_gtimer_get_update(A9GTimerState *s)
@@ -374,6 +374,9 @@ static const VMStateDescription vmstate_a9_gtimer = {
 };
 
 static const Property a9_gtimer_properties[] = {
+    /* Default clock-frequency is 1GHz (NANOSECONDS_PER_SECOND) */
+    DEFINE_PROP_UINT64("clock-frequency", A9GTimerState, freq_hz,
+                       NANOSECONDS_PER_SECOND),
     DEFINE_PROP_UINT32("num-cpu", A9GTimerState, num_cpu, 0),
 };
 
hw/timer/arm_mptimer.c +11 -4
index 803dad1e8a..cae07090f9 100644
@@ -59,9 +59,11 @@ static inline void timerblock_update_irq(TimerBlock *tb)
 }
 
 /* Return conversion factor from mpcore timer ticks to qemu timer ticks.  */
-static inline uint32_t timerblock_scale(uint32_t control)
+static inline uint32_t timerblock_scale(TimerBlock *tb, uint32_t control)
 {
-    return (((control >> 8) & 0xff) + 1) * 10;
+    uint64_t prescale = (((control >> 8) & 0xff) + 1);
+    uint64_t scaled_prescaler = prescale * 10;
+    return muldiv64(scaled_prescaler, NANOSECONDS_PER_SECOND, tb->freq_hz);
 }
 
 /* Must be called within a ptimer transaction block */
@@ -155,7 +157,7 @@ static void timerblock_write(void *opaque, hwaddr addr,
             ptimer_stop(tb->timer);
         }
         if ((control & 0xff00) != (value & 0xff00)) {
-            ptimer_set_period(tb->timer, timerblock_scale(value));
+            ptimer_set_period(tb->timer, timerblock_scale(tb, value));
         }
         if (value & 1) {
             uint64_t count = ptimer_get_count(tb->timer);
@@ -222,7 +224,8 @@ static void timerblock_reset(TimerBlock *tb)
         ptimer_transaction_begin(tb->timer);
         ptimer_stop(tb->timer);
         ptimer_set_limit(tb->timer, 0, 1);
-        ptimer_set_period(tb->timer, timerblock_scale(0));
+        ptimer_set_period(tb->timer,
+            timerblock_scale(tb, tb->control));
         ptimer_transaction_commit(tb->timer);
     }
 }
@@ -269,6 +272,7 @@ static void arm_mptimer_realize(DeviceState *dev, Error **errp)
      */
     for (i = 0; i < s->num_cpu; i++) {
         TimerBlock *tb = &s->timerblock[i];
+        tb->freq_hz = s->freq_hz;
         tb->timer = ptimer_init(timerblock_tick, tb, PTIMER_POLICY);
         sysbus_init_irq(sbd, &tb->irq);
         memory_region_init_io(&tb->iomem, OBJECT(s), &timerblock_ops, tb,
@@ -301,6 +305,9 @@ static const VMStateDescription vmstate_arm_mptimer = {
 };
 
 static const Property arm_mptimer_properties[] = {
+    /* Default clock-frequency is 1GHz (NANOSECONDS_PER_SECOND) */
+    DEFINE_PROP_UINT64("clock-frequency", ARMMPTimerState, freq_hz,
+                       NANOSECONDS_PER_SECOND),
     DEFINE_PROP_UINT32("num-cpu", ARMMPTimerState, num_cpu, 0),
 };
 
include/hw/timer/a9gtimer.h +1 -0
index 6ae9122e4b..3b63d14927 100644
@@ -76,6 +76,7 @@ struct A9GTimerState {
 
     MemoryRegion iomem;
     /* static props */
+    uint64_t freq_hz;
     uint32_t num_cpu;
 
     QEMUTimer *timer;
include/hw/timer/arm_mptimer.h +2 -0
index 65a96e2a0d..da43a3d351 100644
@@ -31,6 +31,7 @@ typedef struct {
     uint32_t control;
     uint32_t status;
     struct ptimer_state *timer;
+    uint64_t freq_hz;
     qemu_irq irq;
     MemoryRegion iomem;
 } TimerBlock;
@@ -43,6 +44,7 @@ struct ARMMPTimerState {
     SysBusDevice parent_obj;
     /*< public >*/
 
+    uint64_t freq_hz;
     uint32_t num_cpu;
     TimerBlock timerblock[ARM_MPTIMER_MAX_CPUS];
     MemoryRegion iomem;
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH v4 01/15] hw/timer: Make frequency configurable

Hi Yannick, Corvin.

Quoted 6 lines · Corvin Köhne

From: YannickV <[email protected]>

The a9 global timer and arm mp timers rely on the PERIPHCLK as their clock source. The current implementation does not take that into account. That causes problems for applications assuming other frequencies than 1 GHz.

This change makes sense, but IMHO we should model the source as a Clock object (see docs/devel/clocks.rst).

Quoted 17 lines

We can now configure frequencies for the a9 global timer and arm mp timer. By allowing these values to be set according to the application's needs, we ensure that the timers behave consistently with the expected system configuration. The SoC configures the device correctly.

Information can be found in the Zynq 7000 SoC Technical Reference Manual under Timers.
https://docs.amd.com/r/en-US/ug585-zynq-7000-SoC-TRM

---
  hw/timer/a9gtimer.c            |  9 ++++++---
  hw/timer/arm_mptimer.c         | 15 +++++++++++----
  include/hw/timer/a9gtimer.h    |  1 +
  include/hw/timer/arm_mptimer.h |  2 ++
  4 files changed, 20 insertions(+), 7 deletions(-)
#3 lore raw

Re: [PATCH v4 01/15] hw/timer: Make frequency configurable

Quoted 6 lines · Philippe Mathieu-Daudé

Hi Yannick, Corvin.

Quoted 2 lines · Corvin Köhne

From: YannickV <[email protected]>

Quoted 7 lines
Quoted 4 lines

The a9 global timer and arm mp timers rely on the PERIPHCLK as their clock source. The current implementation does not take that into account. That causes problems for applications assuming other frequencies than 1 GHz.

This change makes sense, but IMHO we should model the source as a Clock object (see docs/devel/clocks.rst).

I agree that would be the modern and cleaner way to do this, but I said in review on an earlier version of this series that I wasn't going to insist on that:

https://lore.kernel.org/qemu-devel/CAFEAcA8opzjChTA7UONEPtrUnQ-xayoMgxH5gK9Bi-_VnMXjUQ@mail.gmail.com/

thanks
-- PMM

#4 lore raw

PATCH v4 2/15 hw/timer: Make PERIPHCLK divider configurable

In reply to Corvin Köhne

From: YannickV <[email protected]>

The A9 global timer and ARM MP timer use PERIPHCLK as their clock source. The frequency of PERIPHCLK is derived by dividing the main clock (CLK) by a configurable divider (must be at least 2). Previously, the PERIPHCLK divider was not configurable, which could lead to unexspected behavior if the application exspected a different PERIPHCLK rate.

The property periphclk-divider specifies by which value the main clock is divided to generate PERIPHCLK. This allows flexible configuration of the timer clocks to match application requirements.

Information can be found in the Zynq 7000 Soc Technical Reference Manual under Timers.
https://docs.amd.com/r/en-US/ug585-zynq-7000-SoC-TRM

---
 hw/timer/a9gtimer.c            | 19 ++++++++++++++++++-
 hw/timer/arm_mptimer.c         | 19 ++++++++++++++++++-
 include/hw/timer/a9gtimer.h    |  1 +
 include/hw/timer/arm_mptimer.h |  2 ++
 4 files changed, 39 insertions(+), 2 deletions(-)
hw/timer/a9gtimer.c +18 -1
index 090d14c683..31eb9422f7 100644
@@ -27,6 +27,7 @@
 #include "hw/timer/a9gtimer.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "qemu/bitops.h"
 #include "qemu/log.h"
@@ -62,9 +63,17 @@ static inline int a9_gtimer_get_current_cpu(A9GTimerState *s)
 
 static inline uint64_t a9_gtimer_get_conv(A9GTimerState *s)
 {
+    /*
+     * Referring to the ARM-Cortex-A9 MPCore TRM
+     *
+     * The a9 global timer relies on the PERIPHCLK as its clock source.
+     * The PERIPHCLK clock period must be configured as a multiple of the
+     * main clock CLK. The conversion from the qemu clock (1GHz) to a9
+     * gtimer ticks can be calculated like this:
+     */
     uint64_t prescale = extract32(s->control, R_CONTROL_PRESCALER_SHIFT,
                                   R_CONTROL_PRESCALER_LEN) + 1;
-    uint64_t scaled_prescaler = prescale * 10;
+    uint64_t scaled_prescaler = prescale * s->periphclk_divider;
     return muldiv64(scaled_prescaler, NANOSECONDS_PER_SECOND, s->freq_hz);
 }
 
@@ -312,6 +321,12 @@ static void a9_gtimer_realize(DeviceState *dev, Error **errp)
     sysbus_init_mmio(sbd, &s->iomem);
     s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, a9_gtimer_update_no_sync, s);
 
+    if (s->periphclk_divider < 2) {
+        error_setg(errp, "Invalid periphclk-divider (%lu), must be >= 2",
+                   s->periphclk_divider);
+        return;
+    }
+
     for (i = 0; i < s->num_cpu; i++) {
         A9GTimerPerCPU *gtb = &s->per_cpu[i];
 
@@ -378,6 +393,8 @@ static const Property a9_gtimer_properties[] = {
     DEFINE_PROP_UINT64("clock-frequency", A9GTimerState, freq_hz,
                        NANOSECONDS_PER_SECOND),
     DEFINE_PROP_UINT32("num-cpu", A9GTimerState, num_cpu, 0),
+    DEFINE_PROP_UINT64("periphclk-divider", A9GTimerState,
+                       periphclk_divider, 10),
 };
 
 static void a9_gtimer_class_init(ObjectClass *klass, void *data)
hw/timer/arm_mptimer.c +18 -1
index cae07090f9..a7434cf56a 100644
@@ -27,6 +27,7 @@
 #include "hw/timer/arm_mptimer.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "hw/core/cpu.h"
 
@@ -61,8 +62,16 @@ static inline void timerblock_update_irq(TimerBlock *tb)
 /* Return conversion factor from mpcore timer ticks to qemu timer ticks.  */
 static inline uint32_t timerblock_scale(TimerBlock *tb, uint32_t control)
 {
+    /*
+     * Referring to the ARM-Cortex-A9 MPCore TRM
+     *
+     * The arm mp timer relies on the PERIPHCLK as its clock source.
+     * The PERIPHCLK clock period must be configured as a multiple of the
+     * main clock CLK. The conversion from the qemu clock (1GHz) to arm mp
+     * timer ticks can be calculated like this:
+     */
     uint64_t prescale = (((control >> 8) & 0xff) + 1);
-    uint64_t scaled_prescaler = prescale * 10;
+    uint64_t scaled_prescaler = prescale * tb->periphclk_divider;
     return muldiv64(scaled_prescaler, NANOSECONDS_PER_SECOND, tb->freq_hz);
 }
 
@@ -273,6 +282,12 @@ static void arm_mptimer_realize(DeviceState *dev, Error **errp)
     for (i = 0; i < s->num_cpu; i++) {
         TimerBlock *tb = &s->timerblock[i];
         tb->freq_hz = s->freq_hz;
+        if (s->periphclk_divider < 2) {
+            error_setg(errp, "Invalid periphclk-divider (%lu), must be >= 2",
+                       s->periphclk_divider);
+            return;
+        }
+        tb->periphclk_divider = s->periphclk_divider;
         tb->timer = ptimer_init(timerblock_tick, tb, PTIMER_POLICY);
         sysbus_init_irq(sbd, &tb->irq);
         memory_region_init_io(&tb->iomem, OBJECT(s), &timerblock_ops, tb,
@@ -309,6 +324,8 @@ static const Property arm_mptimer_properties[] = {
     DEFINE_PROP_UINT64("clock-frequency", ARMMPTimerState, freq_hz,
                        NANOSECONDS_PER_SECOND),
     DEFINE_PROP_UINT32("num-cpu", ARMMPTimerState, num_cpu, 0),
+    DEFINE_PROP_UINT64("periphclk-divider", ARMMPTimerState,
+                       periphclk_divider, 10),
 };
 
 static void arm_mptimer_class_init(ObjectClass *klass, void *data)
include/hw/timer/a9gtimer.h +1 -0
index 3b63d14927..ff9baf1c77 100644
@@ -77,6 +77,7 @@ struct A9GTimerState {
     MemoryRegion iomem;
     /* static props */
     uint64_t freq_hz;
+    uint64_t periphclk_divider;
     uint32_t num_cpu;
 
     QEMUTimer *timer;
include/hw/timer/arm_mptimer.h +2 -0
index da43a3d351..061934e4b5 100644
@@ -32,6 +32,7 @@ typedef struct {
     uint32_t status;
     struct ptimer_state *timer;
     uint64_t freq_hz;
+    uint64_t periphclk_divider;
     qemu_irq irq;
     MemoryRegion iomem;
 } TimerBlock;
@@ -45,6 +46,7 @@ struct ARMMPTimerState {
     /*< public >*/
 
     uint64_t freq_hz;
+    uint64_t periphclk_divider;
     uint32_t num_cpu;
     TimerBlock timerblock[ARM_MPTIMER_MAX_CPUS];
     MemoryRegion iomem;
Signature · 1 line
2.47.3
Reviewed-by on v4 2/15
#5 lore raw

Re: [PATCH v4 02/15] hw/timer: Make PERIPHCLK divider configurable

Quoted 19 lines · Corvin Köhne

From: YannickV <[email protected]>

The A9 global timer and ARM MP timer use PERIPHCLK as their clock source. The frequency of PERIPHCLK is derived by dividing the main clock (CLK) by a configurable divider (must be at least 2). Previously, the PERIPHCLK divider was not configurable, which could lead to unexspected behavior if the application exspected a different PERIPHCLK rate.

The property periphclk-divider specifies by which value the main clock is divided to generate PERIPHCLK. This allows flexible configuration of the timer clocks to match application requirements.

Information can be found in the Zynq 7000 Soc Technical Reference Manual under Timers.
https://docs.amd.com/r/en-US/ug585-zynq-7000-SoC-TRM

Quoted 7 lines
---
  hw/timer/a9gtimer.c            | 19 ++++++++++++++++++-
  hw/timer/arm_mptimer.c         | 19 ++++++++++++++++++-
  include/hw/timer/a9gtimer.h    |  1 +
  include/hw/timer/arm_mptimer.h |  2 ++
  4 files changed, 39 insertions(+), 2 deletions(-)
#6 lore raw

PATCH v4 3/15 hw/dma/zynq-devcfg: Handle bitstream loading via DMA to 0xffffffff

In reply to Corvin Köhne

From: YannickV <[email protected]>

A DMA transfer to destination address 0xffffffff should trigger a bitstream load via the PCAP interface. Currently, this case is not intercepted, causing loaders to enter an infinite loop when polling the status register.

This commit adds a check for 0xffffffff as the destination address. If detected, the relevant status register bits (DMA_DONE, DMA_P_DONE, and PCFG_DONE) are set to indicate a successful bitstream load. If the address is different, the DMA transfer proceeds as usual. A successful load is indicated but nothing is actually done. Guests relying on FPGA functions are still known to fail.

This feature is required for the integration of the Beckhoff CX7200 model.

---
 hw/dma/xlnx-zynq-devcfg.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/dma/xlnx-zynq-devcfg.c +8 -1
index 0fd0d23f57..b838c1c0d0 100644
@@ -247,7 +247,14 @@ static uint64_t r_lock_pre_write(RegisterInfo *reg, uint64_t val)
 static void r_dma_dst_len_post_write(RegisterInfo *reg, uint64_t val)
 {
     XlnxZynqDevcfg *s = XLNX_ZYNQ_DEVCFG(reg->opaque);
-
+    if ((s->regs[R_DMA_DST_ADDR]) == 0xffffffff) {
+        DB_PRINT("bitstream loading detected\n");
+        s->regs[R_INT_STS] |= R_INT_STS_DMA_DONE_MASK |
+                                R_INT_STS_DMA_P_DONE_MASK |
+                                R_INT_STS_PCFG_DONE_MASK;
+        xlnx_zynq_devcfg_update_ixr(s);
+        return;
+    }
     s->dma_cmd_fifo[s->dma_cmd_fifo_num] = (XlnxZynqDevcfgDMACmd) {
             .src_addr = s->regs[R_DMA_SRC_ADDR] & ~0x3UL,
             .dest_addr = s->regs[R_DMA_DST_ADDR] & ~0x3UL,
Signature · 1 line
2.47.3
#7 lore raw

PATCH v4 4/15 hw/arm/zynq-devcfg: Prevent unintended unlock during initialization

In reply to Corvin Köhne

From: YannickV <[email protected]>

During the emulation startup, all registers are reset, which triggers the r_unlock_post_write function with a value of 0. This led to an unintended memory access disable, making the devcfg unusable.

During startup, the memory space no longer gets locked.

---
 hw/dma/xlnx-zynq-devcfg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/dma/xlnx-zynq-devcfg.c +3 -1
index b838c1c0d0..f28d0015e6 100644
@@ -221,7 +221,9 @@ static void r_unlock_post_write(RegisterInfo *reg, uint64_t val)
 {
     XlnxZynqDevcfg *s = XLNX_ZYNQ_DEVCFG(reg->opaque);
     const char *device_prefix = object_get_typename(OBJECT(s));
-
+    if (device_is_in_reset(DEVICE(s))) {
+        return;
+    }
     if (val == R_UNLOCK_MAGIC) {
         DB_PRINT("successful unlock\n");
         s->regs[R_CTRL] |= R_CTRL_PCAP_PR_MASK;
Signature · 1 line
2.47.3
#8 lore raw

Re: [PATCH v4 04/15] hw/arm/zynq-devcfg: Prevent unintended unlock during initialization

Hi,

Quoted 19 lines · Corvin Köhne

From: YannickV <[email protected]>

During the emulation startup, all registers are reset, which triggers the r_unlock_post_write function with a value of 0. This led to an unintended memory access disable, making the devcfg unusable.

During startup, the memory space no longer gets locked.

---
  hw/dma/xlnx-zynq-devcfg.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
hw/dma/xlnx-zynq-devcfg.c +0 -0
index b838c1c0d0..f28d0015e6 100644

hw/dma/xlnx-zynq-devcfg.c static void r_unlock_post_write(RegisterInfo *reg, uint64_t val) · line 225

Quoted 6 lines
hw/dma/xlnx-zynq-devcfg.c +2 -1
@@ -221,7 +221,9 @@ static void r_unlock_post_write(RegisterInfo *reg, uint64_t val)
  {
      XlnxZynqDevcfg *s = XLNX_ZYNQ_DEVCFG(reg->opaque);
      const char *device_prefix = object_get_typename(OBJECT(s));
-
+    if (device_is_in_reset(DEVICE(s))) {
+        return;

Alistair, does this belong to the upper layer in register_reset()?

Quoted 4 lines
hw/dma/xlnx-zynq-devcfg.c +1 -0
+    }
      if (val == R_UNLOCK_MAGIC) {
          DB_PRINT("successful unlock\n");
          s->regs[R_CTRL] |= R_CTRL_PCAP_PR_MASK;
#9 lore raw

PATCH v4 5/15 hw/dma/zynq: Ensure PCFG_DONE bit remains set to indicate PL is in user mode

In reply to Corvin Köhne

From: YannickV <[email protected]>

All register bits are clear on write by writing 1s to those bits, however the register bits will only be cleared if the condition that sets the interrupt flag is no longer true. Since we can assume that programming is always done, the PCFG_DONE flag is always set to 1, so it will not never be cleared.

---
 hw/dma/xlnx-zynq-devcfg.c | 2 ++
 1 file changed, 2 insertions(+)
hw/dma/xlnx-zynq-devcfg.c +2 -0
index f28d0015e6..28b3cd2902 100644
@@ -188,6 +188,8 @@ static void r_ixr_post_write(RegisterInfo *reg, uint64_t val)
 {
     XlnxZynqDevcfg *s = XLNX_ZYNQ_DEVCFG(reg->opaque);
 
+    s->regs[R_INT_STS] |= R_INT_STS_PCFG_DONE_MASK;
+
     xlnx_zynq_devcfg_update_ixr(s);
 }
 
Signature · 1 line
2.47.3
#10 lore raw

PATCH v4 6/15 hw/dma/zynq-devcfg: Simulate dummy PL reset

In reply to Corvin Köhne

From: YannickV <[email protected]>

Setting PCFG_PROG_B should reset the PL. After a reset PCFG_INIT should indicate that the reset is finished successfully.

In order to add a MMIO-Device as part of the PL in the Zynq, the reset logic must succeed. The PCFG_INIT flag is now set when the PL reset is triggered by PCFG_PROG_B. Indicating the reset was successful.

---
 hw/dma/xlnx-zynq-devcfg.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/dma/xlnx-zynq-devcfg.c +9 -0
index 28b3cd2902..53bcf49140 100644
@@ -49,6 +49,7 @@
 
 REG32(CTRL, 0x00)
     FIELD(CTRL,     FORCE_RST,          31,  1) /* Not supported, wr ignored */
+    FIELD(CTRL,     PCFG_PROG_B,        30,  1)
     FIELD(CTRL,     PCAP_PR,            27,  1) /* Forced to 0 on bad unlock */
     FIELD(CTRL,     PCAP_MODE,          26,  1)
     FIELD(CTRL,     MULTIBOOT_EN,       24,  1)
@@ -116,6 +117,7 @@ REG32(STATUS, 0x14)
     FIELD(STATUS,   PSS_GTS_USR_B,      11,  1)
     FIELD(STATUS,   PSS_FST_CFG_B,      10,  1)
     FIELD(STATUS,   PSS_CFG_RESET_B,     5,  1)
+    FIELD(STATUS,   PCFG_INIT,           4,  1)
 
 REG32(DMA_SRC_ADDR, 0x18)
 REG32(DMA_DST_ADDR, 0x1C)
@@ -204,6 +206,13 @@ static uint64_t r_ctrl_pre_write(RegisterInfo *reg, uint64_t val)
             val |= lock_ctrl_map[i] & s->regs[R_CTRL];
         }
     }
+
+    if (FIELD_EX32(val, CTRL, PCFG_PROG_B)) {
+        s->regs[R_STATUS] |= R_STATUS_PCFG_INIT_MASK;
+    } else {
+        s->regs[R_STATUS] &= ~R_STATUS_PCFG_INIT_MASK;
+    }
+
     return val;
 }
 
Signature · 1 line
2.47.3
#11 lore raw

PATCH v4 7/15 hw/dma/zynq-devcfg: Indicate power-up status of PL

In reply to Corvin Köhne

From: YannickV <[email protected]>

It is assumed, that the programmable logic (PL) is always powered during emulation. Therefor the PCFG_POR_B bit in the MCTRL register is set.

---
 hw/dma/xlnx-zynq-devcfg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/dma/xlnx-zynq-devcfg.c +2 -1
index 53bcf49140..512a33b066 100644
@@ -333,7 +333,8 @@ static const RegisterAccessInfo xlnx_zynq_devcfg_regs_info[] = {
        /* Silicon 3.0 for version field, the mysterious reserved bit 23
         * and QEMU platform identifier.
         */
-       .reset = 0x2 << R_MCTRL_PS_VERSION_SHIFT | 1 << 23 | R_MCTRL_QEMU_MASK,
+       .reset = 0x2 << R_MCTRL_PS_VERSION_SHIFT | 1 << 23 |
+                R_MCTRL_PCFG_POR_B_MASK | R_MCTRL_QEMU_MASK,
        .ro = ~R_MCTRL_INT_PCAP_LPBK_MASK,
        .rsvd = 0x00f00303,
     },
Signature · 1 line
2.47.3
#12 lore raw

PATCH v4 8/15 hw/dma/zynq-devcfg: Fix register memory

In reply to Corvin Köhne

From: YannickV <[email protected]>

Registers are always 32 bit aligned. R_MAX is not the maximum register address, it is the maximum register number. The memory size can be determined by 4 * R_MAX.

Currently every register with an offset bigger than 0x40 will be ignored, because the memory size is set wrong. This effects the MCTRL register and makes it useless. This commit restores the correct behaviour.

---
 hw/dma/xlnx-zynq-devcfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/dma/xlnx-zynq-devcfg.c +1 -1
index 512a33b066..abb8c419d9 100644
@@ -393,7 +393,7 @@ static void xlnx_zynq_devcfg_init(Object *obj)
                               s->regs_info, s->regs,
                               &xlnx_zynq_devcfg_reg_ops,
                               XLNX_ZYNQ_DEVCFG_ERR_DEBUG,
-                              XLNX_ZYNQ_DEVCFG_R_MAX);
+                              XLNX_ZYNQ_DEVCFG_R_MAX * 4);
     memory_region_add_subregion(&s->iomem,
                                 A_CTRL,
                                 &reg_array->mem);
Signature · 1 line
2.47.3
Reviewed-by on v4 8/15
#13 lore raw

Re: [PATCH-for-10.2 v4 08/15] hw/dma/zynq-devcfg: Fix register memory

Quoted 11 lines · Corvin Köhne

From: YannickV <[email protected]>

Registers are always 32 bit aligned. R_MAX is not the maximum register address, it is the maximum register number. The memory size can be determined by 4 * R_MAX.

Currently every register with an offset bigger than 0x40 will be ignored, because the memory size is set wrong. This effects the MCTRL register and makes it useless. This commit restores the correct behaviour.

Quoted 2 lines
Quoted 3 lines
---
  hw/dma/xlnx-zynq-devcfg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
#14 lore raw

PATCH v4 9/15 hw/misc: Add dummy ZYNQ DDR controller

In reply to Corvin Köhne

From: YannickV <[email protected]>

A dummy DDR controller for ZYNQ has been added. While all registers are present, not all are functional. Read and write access is validated, and the user mode can be set. This provides a basic DDR controller initialization, preventing system hangs due to endless polling or similar issues.

---
 hw/misc/Kconfig                  |   3 +
 hw/misc/meson.build              |   1 +
 hw/misc/xlnx-zynq-ddrc.c         | 413 +++++++++++++++++++++++++++++++
 include/hw/misc/xlnx-zynq-ddrc.h | 148 +++++++++++
 4 files changed, 565 insertions(+)
 create mode 100644 hw/misc/xlnx-zynq-ddrc.c
 create mode 100644 include/hw/misc/xlnx-zynq-ddrc.h
hw/misc/Kconfig +3 -0
index 8f9ce2f68c..99548e146f 100644
@@ -220,4 +220,7 @@ config IOSB
 config XLNX_VERSAL_TRNG
     bool
 
+config XLNX_ZYNQ_DDRC
+    bool
+
 source macio/Kconfig
hw/misc/meson.build +1 -0
index 55f493521b..6ee7b6c71d 100644
@@ -89,6 +89,7 @@ system_ss.add(when: 'CONFIG_RASPI', if_true: files(
 ))
 system_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c'))
 system_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c'))
+system_ss.add(when: 'CONFIG_ZYNQ', if_true: files('xlnx-zynq-ddrc.c'))
 system_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c'))
 system_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c'))
 system_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files(
hw/misc/xlnx-zynq-ddrc.c new file +413 -0

413 lines not on this page · raw message

include/hw/misc/xlnx-zynq-ddrc.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
2.47.3
#15 lore raw

PATCH v4 10/15 hw/misc/zynq_slcr: Add logic for DCI configuration

In reply to Corvin Köhne

From: YannickV <[email protected]>

The registers for the digitally controlled impedance (DCI) clock are part of the system level control registers (SLCR). The DONE bit in the status register indicates a successfull DCI calibration. An description of the calibration process can be found here:
https://docs.amd.com/r/en-US/ug585-zynq-7000-SoC-TRM/DDR-IOB-Impedance-Calibration

The DCI control register and status register have been added. As soon as the ENABLE and RESET bit are set, the RESET bit has also been toggled to 0 before and the UPDATE_CONTROL is not set, the DONE bit in the status register is set. If these bits change the DONE bit is reset. Note that the option bits are not taken into consideration.

---
 hw/misc/zynq_slcr.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
hw/misc/zynq_slcr.c +31 -0
index a766bab182..d7a2994f47 100644
@@ -180,6 +180,12 @@ REG32(GPIOB_CFG_HSTL, 0xb14)
 REG32(GPIOB_DRVR_BIAS_CTRL, 0xb18)
 
 REG32(DDRIOB, 0xb40)
+REG32(DDRIOB_DCI_CTRL, 0xb70)
+    FIELD(DDRIOB_DCI_CTRL, RESET, 0, 1)
+    FIELD(DDRIOB_DCI_CTRL, ENABLE, 1, 1)
+    FIELD(DDRIOB_DCI_CTRL, UPDATE_CONTROL, 20, 1)
+REG32(DDRIOB_DCI_STATUS, 0xb74)
+    FIELD(DDRIOB_DCI_STATUS, DONE, 13, 1)
 #define DDRIOB_LENGTH 14
 
 #define ZYNQ_SLCR_MMIO_SIZE     0x1000
@@ -193,6 +199,8 @@ struct ZynqSLCRState {
 
     MemoryRegion iomem;
 
+    bool ddriob_dci_ctrl_reset_toggled;
+
     uint32_t regs[ZYNQ_SLCR_NUM_REGS];
 
     Clock *ps_clk;
@@ -331,6 +339,8 @@ static void zynq_slcr_reset_init(Object *obj, ResetType type)
 
     DB_PRINT("RESET\n");
 
+    s->ddriob_dci_ctrl_reset_toggled = false;
+
     s->regs[R_LOCKSTA] = 1;
     /* 0x100 - 0x11C */
     s->regs[R_ARM_PLL_CTRL]   = 0x0001A008;
@@ -418,6 +428,8 @@ static void zynq_slcr_reset_init(Object *obj, ResetType type)
     s->regs[R_DDRIOB + 4] = s->regs[R_DDRIOB + 5] = s->regs[R_DDRIOB + 6]
                           = 0x00000e00;
     s->regs[R_DDRIOB + 12] = 0x00000021;
+
+    s->regs[R_DDRIOB_DCI_CTRL] = 0x00000020;
 }
 
 static void zynq_slcr_reset_hold(Object *obj, ResetType type)
@@ -554,6 +566,25 @@ static void zynq_slcr_write(void *opaque, hwaddr offset,
                 (int)offset, (unsigned)val & 0xFFFF);
         }
         return;
+
+    case R_DDRIOB_DCI_CTRL:
+        if (!FIELD_EX32(val, DDRIOB_DCI_CTRL, RESET) &&
+            FIELD_EX32(s->regs[R_DDRIOB_DCI_CTRL], DDRIOB_DCI_CTRL, RESET)) {
+
+            s->ddriob_dci_ctrl_reset_toggled = true;
+            DB_PRINT("DDRIOB DCI CTRL RESET was toggled\n");
+        }
+
+        if (FIELD_EX32(val, DDRIOB_DCI_CTRL, ENABLE) &&
+            FIELD_EX32(val, DDRIOB_DCI_CTRL, RESET) &&
+            !FIELD_EX32(val, DDRIOB_DCI_CTRL, UPDATE_CONTROL) &&
+            s->ddriob_dci_ctrl_reset_toggled) {
+
+            s->regs[R_DDRIOB_DCI_STATUS] |= R_DDRIOB_DCI_STATUS_DONE_MASK;
+        } else {
+            s->regs[R_DDRIOB_DCI_STATUS] &= ~R_DDRIOB_DCI_STATUS_DONE_MASK;
+        }
+        break;
     }
 
     if (s->regs[R_LOCKSTA]) {
Signature · 1 line
2.47.3
#16 lore raw

PATCH v4 11/15 hw/misc: Add Beckhoff CCAT device

In reply to Corvin Köhne

From: YannickV <[email protected]>

This adds the Beckhoff Communication Controller (CCAT). The information block, EEPROM interface and DMA controller are currently implemented.

The EEPROM provides production information for Beckhoff Devices. An EEPORM binary must therefor be handed over. It should be aligned to a power of two. If no EEPROM binary is handed over an empty EEPROM of size 4096 is initialized.

This device is needed for the Beckhoff CX7200 board emulation.

---
 hw/misc/Kconfig         |   3 +
 hw/misc/beckhoff_ccat.c | 338 ++++++++++++++++++++++++++++++++++++++++
 hw/misc/meson.build     |   1 +
 3 files changed, 342 insertions(+)
 create mode 100644 hw/misc/beckhoff_ccat.c
hw/misc/Kconfig +3 -0
index 99548e146f..f3a2efa350 100644
@@ -223,4 +223,7 @@ config XLNX_VERSAL_TRNG
 config XLNX_ZYNQ_DDRC
     bool
 
+config BECKHOFF_CCAT
+    bool
+
 source macio/Kconfig
hw/misc/beckhoff_ccat.c new file +338 -0

338 lines not on this page · raw message

hw/misc/meson.build +1 -0
index 6ee7b6c71d..1fc1468464 100644
@@ -14,6 +14,7 @@ system_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c'))
 system_ss.add(when: 'CONFIG_INTEGRATOR_DEBUG', if_true: files('arm_integrator_debug.c'))
 system_ss.add(when: 'CONFIG_A9SCU', if_true: files('a9scu.c'))
 system_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c'))
+system_ss.add(when: 'CONFIG_BECKHOFF_CCAT', if_true: files('beckhoff_ccat.c'))
 
 system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_ras.c'))
 
Signature · 1 line
2.47.3
#17 lore raw

Re: [PATCH v4 11/15] hw/misc: Add Beckhoff CCAT device

Quoted 21 lines · Corvin Köhne

From: YannickV <[email protected]>

This adds the Beckhoff Communication Controller (CCAT). The information block, EEPROM interface and DMA controller are currently implemented.

The EEPROM provides production information for Beckhoff Devices. An EEPORM binary must therefor be handed over. It should be aligned to a power of two. If no EEPROM binary is handed over an empty EEPROM of size 4096 is initialized.

This device is needed for the Beckhoff CX7200 board emulation.

---
  hw/misc/Kconfig         |   3 +
  hw/misc/beckhoff_ccat.c | 338 ++++++++++++++++++++++++++++++++++++++++
  hw/misc/meson.build     |   1 +
  3 files changed, 342 insertions(+)

create mode 100644 hw/misc/beckhoff_ccat.c

hw/misc/beckhoff_ccat.c line 40

Quoted 10 lines
hw/misc/beckhoff_ccat.c new file +10 -0
+#define TYPE_BECKHOFF_CCAT "beckhoff-ccat"
+OBJECT_DECLARE_SIMPLE_TYPE(BeckhoffCcat, BECKHOFF_CCAT)
+
+#define MAX_NUM_SLOTS 32
+#define CCAT_FUNCTION_BLOCK_SIZE 16
+
+#define CCAT_EEPROM_OFFSET 0x100
+#define CCAT_DMA_OFFSET 0x8000
+
+#define CCAT_MEM_SIZE 0xFFFF

Likely

  #define CCAT_MEM_SIZE (64 * KiB)
Quoted 4 lines
hw/misc/beckhoff_ccat.c new file +4 -0
+#define CCAT_DMA_SIZE 0x800
+#define CCAT_EEPROM_SIZE 0x20
+
+#define EEPROM_MEMORY_SIZE 0x1000
#18 lore raw

PATCH v4 12/15 hw/block/m25p80: Add HAS_SR_TB flag for is25lp016d

In reply to Corvin Köhne

From: YannickV <[email protected]>

The is25lp016d has 4 Block Write Protect Bits. BP3 specifies whether the upper or lower range should be protected. Therefore, we add the HAS_SR_TB flag to the is25lp016d flags.

---
 hw/block/m25p80.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/block/m25p80.c +2 -1
index b84c6afb32..4c9d79ec44 100644
@@ -217,7 +217,8 @@ static const FlashPartInfo known_devices[] = {
     /* ISSI */
     { INFO("is25lq040b",  0x9d4013,      0,  64 << 10,   8, ER_4K) },
     { INFO("is25lp080d",  0x9d6014,      0,  64 << 10,  16, ER_4K) },
-    { INFO("is25lp016d",  0x9d6015,      0,  64 << 10,  32, ER_4K) },
+    { INFO("is25lp016d",  0x9d6015,      0,  64 << 10,  32,
+           ER_4K | HAS_SR_TB) },
     { INFO("is25lp032",   0x9d6016,      0,  64 << 10,  64, ER_4K) },
     { INFO("is25lp064",   0x9d6017,      0,  64 << 10, 128, ER_4K) },
     { INFO("is25lp128",   0x9d6018,      0,  64 << 10, 256, ER_4K) },
Signature · 1 line
2.47.3
#19 lore raw

PATCH v4 13/15 hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200

In reply to Corvin Köhne

From: YannickV <[email protected]>

This commit introduces a new machine, derived from xilinx-zynq-a9. While retaining the foundational architecture, unnecessary peripherals have been removed and the remaining peripherals have been adapted to match the CX7200's hardware layout and behavior.

---
 hw/arm/Kconfig           |  18 ++
 hw/arm/beckhoff_CX7200.c | 443 +++++++++++++++++++++++++++++++++++++++
 hw/arm/meson.build       |   1 +
 3 files changed, 462 insertions(+)
 create mode 100644 hw/arm/beckhoff_CX7200.c
hw/arm/Kconfig +18 -0
index 256013ca80..66af990da9 100644
@@ -310,6 +310,24 @@ config ZYNQ
     select XILINX_SPIPS
     select ZYNQ_DEVCFG
 
+config BECKHOFF_CX7200
+    bool
+    default y
+    depends on TCG && ARM
+    select A9MPCORE
+    select CADENCE # UART
+    select PFLASH_CFI02
+    select PL310 # cache controller
+    select PL330
+    select SDHCI
+    select SSI_M25P80
+    select XILINX # UART
+    select XILINX_AXI
+    select XILINX_SPI
+    select XILINX_SPIPS
+    select ZYNQ_DEVCFG
+    select BECKHOFF_CCAT
+
 config ARM_V7M
     bool
     # currently v7M must be included in a TCG build due to translate.c
hw/arm/beckhoff_CX7200.c new file +443 -0

443 lines not on this page · raw message

hw/arm/meson.build +1 -0
index 490234b3b8..b774b066dd 100644
@@ -17,6 +17,7 @@ arm_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa-ref.c'))
 arm_ss.add(when: 'CONFIG_STELLARIS', if_true: files('stellaris.c'))
 arm_ss.add(when: 'CONFIG_STM32VLDISCOVERY', if_true: files('stm32vldiscovery.c'))
 arm_ss.add(when: 'CONFIG_ZYNQ', if_true: files('xilinx_zynq.c'))
+arm_ss.add(when: 'CONFIG_BECKHOFF_CX7200', if_true: files('beckhoff_CX7200.c'))
 arm_ss.add(when: 'CONFIG_SABRELITE', if_true: files('sabrelite.c'))
 
 arm_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m.c'))
Signature · 1 line
2.47.3
#20 lore raw

Re: [PATCH v4 13/15] hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200

Hi Yannick, Corvin,

Quoted 19 lines · Corvin Köhne

From: YannickV <[email protected]>

This commit introduces a new machine, derived from xilinx-zynq-a9. While retaining the foundational architecture, unnecessary peripherals have been removed and the remaining peripherals have been adapted to match the CX7200's hardware layout and behavior.

---
  hw/arm/Kconfig           |  18 ++
  hw/arm/beckhoff_CX7200.c | 443 +++++++++++++++++++++++++++++++++++++++
  hw/arm/meson.build       |   1 +
  3 files changed, 462 insertions(+)

create mode 100644 hw/arm/beckhoff_CX7200.c

hw/arm/beckhoff_CX7200.c new file +3 -0
+static void beckhoff_cx7200_init(MachineState *machine)
+{
+    CX7200MachineState *cx7200_machine = CX7200_MACHINE(machine);

[...]

Quoted 6 lines
hw/arm/beckhoff_CX7200.c new file +6 -0
+    n = beckhoff_cx7200_init_spi_flashes(0xE0006000, pic[58 - IRQ_OFFSET],
+                                         false, 0);
+    n = beckhoff_cx7200_init_spi_flashes(0xE0007000, pic[81 - IRQ_OFFSET],
+                                         false, n);
+    n = beckhoff_cx7200_init_spi_flashes(0xE000D000, pic[51 - IRQ_OFFSET],
+                                         true, n);

[...]

Quoted 15 lines
hw/arm/beckhoff_CX7200.c new file +12 -0
+    beckhoff_cx7200_binfo.ram_size = machine->ram_size;
+    beckhoff_cx7200_binfo.board_id = 0xd32;
+    beckhoff_cx7200_binfo.loader_start = 0;
+    beckhoff_cx7200_binfo.board_setup_addr = BOARD_SETUP_ADDR;
+    beckhoff_cx7200_binfo.write_board_setup = beckhoff_cx7200_write_board_setup;
+
+    arm_load_kernel(cx7200_machine->cpu[0], machine, &beckhoff_cx7200_binfo);
+}
+
+static void beckhoff_cx7200_machine_class_init(ObjectClass *oc, void *data)
+{
 
+    mc->desc = "Beckhoff IPC based on the Xilinx Zynq Platform Baseboard";
 
 

hw/arm/beckhoff_CX7200.c line 432

Quoted 10 lines
hw/arm/beckhoff_CX7200.c new file +10 -0
+    prop = object_class_property_add_str(oc, "boot-mode", NULL,
+                                         beckhoff_cx7200_set_boot_mode);
+    object_class_property_set_description(oc, "boot-mode",
+                                          "Supported boot modes:"
+                                          " jtag qspi sd nor");
+    object_property_set_default_str(prop, "qspi");
+}
+
+static const TypeInfo beckhoff_cx7200_machine_type = {
+    .name = TYPE_CX7200_MACHINE,

A lot of code is duplicated from hw/arm/xilinx_zynq.c; this does not sounds right. Can't you have your machine inherit from TYPE_ZYNQ_MACHINE and expand it in a .instance_init() handler?

If this isn't possible, then we need to refactor hw/arm/xilinx_zynq.c:
- extract TYPE_ZYNQ_SOC from TYPE_ZYNQ_MACHINE
- have TYPE_CX7200_MACHINE use TYPE_ZYNQ_SOC

hw/arm/beckhoff_CX7200.c line 436

Quoted 4 lines
hw/arm/beckhoff_CX7200.c new file +4 -0
+    .parent = TYPE_MACHINE,
+    .class_init = beckhoff_cx7200_machine_class_init,
+    .instance_size = sizeof(CX7200MachineState),
+};

Regards,

Phil.

#21 lore raw

PATCH v4 14/15 tests/functional: Add a Beckhoff CX7200 test

In reply to Corvin Köhne

From: YannickV <[email protected]>

TODO

---
 tests/functional/test_arm_beckhoff_cx7200.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 tests/functional/test_arm_beckhoff_cx7200.py
tests/functional/test_arm_beckhoff_cx7200.py new file +19 -0
new file mode 100644
index 0000000000..a7fb88ac30
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a bare metal application on the Beckhoff CX7200
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest
+
+class CX7200Test(LinuxKernelTest):
+    def test_baremetal_elf(self):
+        self.set_machine('beckhoff-cx7200')
+        elf_path = '/home/yannickv/git/build-TCRTOS/FreeRTOS/Zynq7000/DriveZynq_Fsbl/build/CX7200/Optg/ZYNQ7000S/CX7200_Zynq_Fsbl.elf'
+        self.vm.set_console()
+        self.vm.add_args('-kernel', elf_path, '-nographic')
+        self.vm.launch()
+        self.wait_for_console_pattern('Boot mode is SD')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
\ No newline at end of file
Signature · 1 line
2.47.3
#22 lore raw

Re: [PATCH v4 14/15] tests/functional: Add a Beckhoff CX7200 test

Quoted 16 lines · Corvin Köhne

From: YannickV <[email protected]>

TODO

---
  tests/functional/test_arm_beckhoff_cx7200.py | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

create mode 100644 tests/functional/test_arm_beckhoff_cx7200.py

tests/functional/test_arm_beckhoff_cx7200.py new file +2 -0
new file mode 100644
index 0000000000..a7fb88ac30
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+#

tests/functional/test_arm_beckhoff_cx7200.py line 12

Quoted 10 lines
tests/functional/test_arm_beckhoff_cx7200.py new file +10 -0
+# Functional test that boots a bare metal application on the Beckhoff CX7200
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest
+
+class CX7200Test(LinuxKernelTest):
+    def test_baremetal_elf(self):
+        self.set_machine('beckhoff-cx7200')
+        elf_path = '/home/yannickv/git/build-TCRTOS/FreeRTOS/Zynq7000/DriveZynq_Fsbl/build/CX7200/Optg/ZYNQ7000S/CX7200_Zynq_Fsbl.elf'

Could you upload this file in some git forge repository like github?

Quoted 8 lines
tests/functional/test_arm_beckhoff_cx7200.py new file +7 -0
+        self.vm.set_console()
+        self.vm.add_args('-kernel', elf_path, '-nographic')
+        self.vm.launch()
+        self.wait_for_console_pattern('Boot mode is SD')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
\ No newline at end of file
#23 lore raw

PATCH v4 15/15 docs/system/arm: Add support for Beckhoff CX7200

In reply to Corvin Köhne

From: YannickV <[email protected]>

This commit offers some documentation on the Beckhoff CX7200 qemu emulation.

---
 docs/system/arm/beckhoff-cx7200.rst | 57 +++++++++++++++++++++++++++++
 docs/system/target-arm.rst          |  1 +
 2 files changed, 58 insertions(+)
 create mode 100644 docs/system/arm/beckhoff-cx7200.rst
docs/system/arm/beckhoff-cx7200.rst new file +57 -0
new file mode 100644
index 0000000000..f060319b0f
@@ -0,0 +1,57 @@
+Beckhoff CX7200 (``beckhoff-cx7200``)
+======================================
+The Beckhoff CX7200 is based on the same architecture as the Xilinx Zynq A9.
+The Zynq 7000 family is based on the AMD SoC architecture. These products
+integrate a feature-rich dual or single-core Arm Cortex-A9 MPCore based
+processing system (PS) and AMD programmable logic (PL) in a single device.
+The Beckhoff Communication Controller (CCAT) can be found in the PL of Zynq.
+
+More details here:
+https://docs.amd.com/r/en-US/ug585-zynq-7000-SoC-TRM/Zynq-7000-SoC-Technical-Reference-Manual
+https://www.beckhoff.com/de-de/produkte/ipc/embedded-pcs/cx7000-arm-r-cortex-r/cx7293.html
+
+The CX7200 supports following devices:
+    - A9 MPCORE
+        - cortex-a9
+        - GIC v1
+        - Generic timer
+        - wdt
+    - OCM 256KB
+    - SMC SRAM@0xe2000000 64MB
+    - Zynq SLCR
+    - SPI x2
+    - QSPI
+    - UART
+    - TTC x2
+    - Gigabit Ethernet Controller
+    - SD Controller
+    - XADC
+    - Arm PrimeCell DMA Controller
+    - DDR Memory
+    - DDR Controller
+    - Beckhoff Communication Controller (CCAT)
+        - EEPROM Interface
+        - DMA Controller
+
+Following devices are not supported:
+    - I2C
+
+Running
+"""""""
+Directly loading an ELF file to the CPU of the CX7200 to run f.e. TC/RTOS (based on FreeRTOS):
+
+.. code-block:: bash
+
+  $ qemu-system-arm -M beckhoff-cx7200 \
+        -device loader,file=CX7200_Zynq_Fsbl.elf \
+        -display none \
+        -icount shift=auto \
+
+
+For setting the EEPROM content of the CCAT provide the following on the command line:
+
+.. code-block:: bash
+
+        -drive file=eeprom.bin,format=raw,id=ccat-eeprom
+
+The size of eeprom.bin must be aligned to a power of 2 and bigger than 256 bytes.
docs/system/target-arm.rst +1 -0
index 9aaa9c414c..5f15fda630 100644
@@ -81,6 +81,7 @@ Board-specific documentation
    arm/aspeed
    arm/bananapi_m2u.rst
    arm/b-l475e-iot01a.rst
+   arm/beckhoff-cx7200
    arm/sabrelite
    arm/highbank
    arm/digic
Signature · 1 line
2.47.3