hw/arm: add Beckhoff CX7200 board
Subsystems (2)
v3 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 (14):
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 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 + 17 files changed, 1542 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
Signature · 1 line
2.47.3
PATCH v3 1/14 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v3 2/14 hw/timer: Make PERIPHCLK divider configurable
In reply to Corvin KöhneFrom: 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
@@ -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,const void *data)
hw/timer/arm_mptimer.c +18 -1
@@ -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,const void *data)
include/hw/timer/a9gtimer.h +1 -0
@@ -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
@@ -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
PATCH v3 3/14 hw/dma/zynq-devcfg: Handle bitstream loading via DMA to 0xffffffff
In reply to Corvin KöhneFrom: 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
@@ -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
PATCH v3 4/14 hw/arm/zynq-devcfg: Prevent unintended unlock during initialization
In reply to Corvin KöhneFrom: 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
@@ -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
PATCH v3 5/14 hw/dma/zynq: Ensure PCFG_DONE bit remains set to indicate PL is in user mode
In reply to Corvin KöhneFrom: 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
@@ -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
PATCH v3 6/14 hw/dma/zynq-devcfg: Simulate dummy PL reset
In reply to Corvin KöhneFrom: 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
@@ -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
PATCH v3 7/14 hw/dma/zynq-devcfg: Indicate power-up status of PL
In reply to Corvin KöhneFrom: 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
@@ -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
PATCH v3 8/14 hw/dma/zynq-devcfg: Fix register memory
In reply to Corvin KöhneFrom: 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
@@ -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 , ®_array->mem);
Signature · 1 line
2.47.3
PATCH v3 9/14 hw/misc: Add dummy ZYNQ DDR controller
In reply to Corvin KöhneFrom: 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
@@ -235,4 +235,7 @@ config IOSB config XLNX_VERSAL_TRNG bool +config XLNX_ZYNQ_DDRC + bool + source macio/Kconfig
hw/misc/meson.build +1 -0
@@ -95,6 +95,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
PATCH v3 10/14 hw/misc/zynq_slcr: Add logic for DCI configuration
In reply to Corvin KöhneFrom: 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
@@ -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
PATCH v3 11/14 hw/misc: Add Beckhoff CCAT device
In reply to Corvin KöhneFrom: 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
@@ -238,4 +238,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
@@ -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
PATCH v3 12/14 hw/block/m25p80: Add HAS_SR_TB flag for is25lp016d
In reply to Corvin KöhneFrom: 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
@@ -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
PATCH v3 13/14 hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200
In reply to Corvin KöhneFrom: 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
@@ -307,6 +307,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
@@ -2,6 +2,7 @@ arm_ss = ss.source_set() arm_common_ss = ss.source_set() arm_ss.add(when: 'CONFIG_ARM_VIRT', if_true: files('virt.c')) arm_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c')) +arm_common_ss.add(when: 'CONFIG_BECKHOFF_CX7200', if_true: files('beckhoff_CX7200.c')) arm_common_ss.add(when: 'CONFIG_DIGIC', if_true: files('digic_boards.c')) arm_common_ss.add(when: 'CONFIG_EMCRAFT_SF2', if_true: files('msf2-som.c')) arm_common_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c'))
Signature · 1 line
2.47.3
PATCH v3 14/14 docs/system/arm: Add support for Beckhoff CX7200
In reply to Corvin KöhneFrom: 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
@@ -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
@@ -82,6 +82,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
Quoted 8 lines · Corvin Köhne
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.
Did you base this on current master? beckhoff_ccat.c tries to include "exec/address-spaces.h", which hasn't existed since commit dfc56946a7005 renamed it to system/address-spaces.h back in March, so it doesn't compile...
-- PMM
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Corvin Köhne
From: Corvin Köhne <[email protected]>
Hi,
Quoted 8 lines
Quoted 3 lines
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.
Did you base this on current master?
beckhoff_ccat.ctries to include "exec/address-spaces.h", which hasn't existed since commitdfc56946a7005renamed it tosystem/address-spaces.hback in March, so it doesn't compile...
Similarly for references to exec/memory.h.
Please rebase this on current head-of-git, make sure it compiles and passes 'make check' and 'make check-functional', and then resend it.
thanks
-- PMM