hw/arm: add Beckhoff CX7200 board
Subsystems (2)
v5 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/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/xilinx_zynq: Split xilinx_zynq into header and implementation
files
hw/arm/xilinx_zynq: Add flash-type property
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 | 7 + hw/arm/beckhoff_CX7200.c | 104 +++++++ hw/arm/meson.build | 1 + hw/arm/xilinx_zynq.c | 54 ++-- hw/block/m25p80.c | 3 +- hw/dma/xlnx-zynq-devcfg.c | 27 +- hw/misc/Kconfig | 6 + hw/misc/beckhoff_ccat.c | 339 +++++++++++++++++++++++ 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/arm/xilinx_zynq.h | 37 +++ include/hw/misc/xlnx-zynq-ddrc.h | 148 ++++++++++ include/hw/timer/a9gtimer.h | 2 + include/hw/timer/arm_mptimer.h | 4 + 19 files changed, 1263 insertions(+), 31 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/arm/xilinx_zynq.h create mode 100644 include/hw/misc/xlnx-zynq-ddrc.h
Signature · 1 line
2.47.3
PATCH v5 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
@@ -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
Re: [PATCH v5 01/15] hw/timer: Make frequency configurable
Quoted 14 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.
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.
Quoted 6 lines
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-TRMSigned-off-by YannickV <[email protected]>---
thanks
-- PMM
PATCH v5 2/15 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 v5 3/15 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 v5 4/15 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 v5 5/15 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 v5 6/15 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 v5 7/15 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 v5 8/15 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/arm/xilinx_zynq.c | 16 +- hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/xlnx-zynq-ddrc.c | 413 +++++++++++++++++++++++++++++++ include/hw/misc/xlnx-zynq-ddrc.h | 148 +++++++++++ 5 files changed, 578 insertions(+), 3 deletions(-) create mode 100644 hw/misc/xlnx-zynq-ddrc.c create mode 100644 include/hw/misc/xlnx-zynq-ddrc.h
hw/arm/xilinx_zynq.c +13 -3
@@ -201,6 +201,17 @@ static void zynq_set_boot_mode(Object *obj, const char *str, m->boot_mode = mode; } +static void ddr_ctrl_init (uint32_t base) +{ +DeviceState *dev; +SysBusDevice *busdev; + + dev =qdev_new ("zynq.ddr-ctlr" ); + busdev =SYS_BUS_DEVICE (dev); +sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_mmio_map (busdev,0 , base); +} +static void zynq_init (MachineState *machine) {ZynqMachineState *zynq_machine =ZYNQ_MACHINE (machine);
@@ -312,6 +323,8 @@ static void zynq_init(MachineState *machine)sysbus_create_varargs ("cadence_ttc" ,0xF8002000 , pic[69 -GIC_INTERNAL ], pic[70 -GIC_INTERNAL ], pic[71 -GIC_INTERNAL ],NULL ); +ddr_ctrl_init (0xF8006000 ); +gem_init (0xE000B000 , pic[54 -GIC_INTERNAL ]);gem_init (0xE000C000 , pic[77 -GIC_INTERNAL ]);
@@ -393,9 +406,6 @@ static void zynq_init(MachineState *machine)/* System Watchdog Timer Registers */ create_unimplemented_device ("zynq.swdt" ,0xF8005000 ,4 * KiB); -/* DDR memory controller */ -create_unimplemented_device ("zynq.ddrc" ,0xF8006000 ,4 * KiB); -/* AXI_HP Interface (AFI) */ create_unimplemented_device ("zynq.axi_hp0" ,0xF8008000 ,0x28 );create_unimplemented_device ("zynq.axi_hp1" ,0xF8009000 ,0x28 );
hw/misc/Kconfig +3 -0
@@ -240,4 +240,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
Re: [PATCH v5 08/15] hw/misc: Add dummy ZYNQ DDR controller
Quoted 9 lines · 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.
Signed-off-by YannickV <[email protected]>
I have a few minor review comments below, but this otherwise looks good to me.
hw/misc/Kconfig config IOSB · line 246
Quoted 12 lines
hw/misc/Kconfig +3
-0@@ -240,4 +240,7 @@ config IOSB config XLNX_VERSAL_TRNG bool +config XLNX_ZYNQ_DDRC + bool + source macio/Kconfig
You also need to have the "config ZYNQ" section in hw/arm/Kconfig have a line "select XLNX_ZYNQ_DDRC", to tell kconfig that the Zynq SoC needs this device.
hw/misc/meson.build system_ss.add(when: 'CONFIG_RASPI', if_true: files( · line 98
Quoted 9 lines
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'))
This should be "when: 'CONFIG_XLNX_ZYNQ_DDRC'", so we build the source file exactly when some board or SoC says it needs the device. (This mistake is what is hiding the effects of missing the "select XLNX_ZYNQ_DDRC".)
hw/misc/meson.build system_ss.add(when: 'CONFIG_RASPI', if_true: files(
Quoted 9 lines
hw/misc/meson.build +5
-0system_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( +static const MemoryRegionOps ddrctrl_ops = { + .read = register_read_memory, + .write = register_write_memory, + .endianness = DEVICE_LITTLE_ENDIAN, +};
It's better to explicitly set the access size controls
.valid.min_access_size .valid.max_access_size
.impl.min_access_size
.impl.max_access_size
explicitly, even if they happen to match the defaults. This tells the reader you've thought about what the device actually permits and what your implementation code can deal with.
(The default is "accept anything, never generate external abort" and "assume the read and write functions handle all widths". This is usually not what actual devices do or what the code people write is intended to accept. Devices on Arm systems are often "only 32-bit accesses are permitted".)
hw/misc/meson.build
Quoted 3 lines
hw/misc/meson.build +3
-0+#define TYPE_DDRCTRL "zynq.ddr-ctlr" +#define DDRCTRL(obj) \ + OBJECT_CHECK(DDRCTRLState, (obj), TYPE_DDRCTRL)
Current QEMU style prefers using one of the helper macros to generate the cast macros etc. For this kind of "simple leaf class" OBJECT_DECLARE_SIMPLE_TYPE is probably what you want. See for some more info:
https://www.qemu.org/docs/master/devel/qom.html#standard-type-declaration-and-definition-macros
There is also OBJECT_DEFINE_SIMPLE_TYPE which provides the boilerplate TypeInfo and type registration in the .c file for you, but that one is more "optional if you prefer it".
thanks
-- PMM
PATCH v5 9/15 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 v5 10/15 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 | 339 ++++++++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + 3 files changed, 343 insertions(+) create mode 100644 hw/misc/beckhoff_ccat.c
hw/misc/Kconfig +3 -0
@@ -243,4 +243,7 @@ config XLNX_VERSAL_TRNG config XLNX_ZYNQ_DDRC bool +config BECKHOFF_CCAT + bool + source macio/Kconfig
hw/misc/beckhoff_ccat.c new file +339 -0
339 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 v5 11/15 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
Re: [PATCH v5 11/15] hw/block/m25p80: Add HAS_SR_TB flag for is25lp016d
Quoted 17 lines · 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_TBflag to the is25lp016d flags.Signed-off-by YannickV <[email protected]>--- hw/block/m25p80.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/block/m25p80.c +0
-0
hw/block/m25p80.c static const FlashPartInfo known_devices[] = {
Quoted 10 lines
hw/block/m25p80.c +2
-2@@ -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) }, --
thanks
-- PMM
PATCH v5 12/15 hw/arm/xilinx_zynq: Split xilinx_zynq into header and implementation files
In reply to Corvin KöhneFrom: YannickV <[email protected]>
Create xilinx_zynq.h header file to expose ZynqMachineState and related definitions for machine inheritance. This enables creation of derived machines based on the Zynq platform.
--- hw/arm/xilinx_zynq.c | 13 +------------ include/hw/arm/xilinx_zynq.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 include/hw/arm/xilinx_zynq.h
hw/arm/xilinx_zynq.c +1 -12
@@ -41,9 +41,7 @@#include "exec/tswap.h" #include "target/arm/cpu-qom.h" #include "qapi/visitor.h" - -#define TYPE_ZYNQ_MACHINE MACHINE_TYPE_NAME("xilinx-zynq-a9") -OBJECT_DECLARE_SIMPLE_TYPE (ZynqMachineState,ZYNQ_MACHINE ) +#include "hw/arm/xilinx_zynq.h" /* board base frequency: 33.333333 MHz */ #define PS_CLK_FREQUENCY (100 * 1000 * 1000 / 3)
@@ -87,15 +85,6 @@ static const int dma_irqs[8] = {0xe3401000 +ARMV7_IMM16 (extract32 ((val),16 ,16 )),/* movt r1 ... */ \0xe5801000 + (addr ) -#define ZYNQ_MAX_CPUS 2 - -struct ZynqMachineState { -MachineState parent; -Clock *ps_clk; -ARMCPU *cpu[ZYNQ_MAX_CPUS ]; -uint8_t boot_mode; -}; - static void zynq_write_board_setup(ARMCPU *cpu,const struct arm_boot_info *info) {
include/hw/arm/xilinx_zynq.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Xilinx Zynq Baseboard System emulation. +* +* Copyright (c) 2010 Xilinx. +* Copyright (c) 2012 Peter A.G. Crosthwaite ([email protected]) +* Copyright (c) 2012 Petalogix Pty Ltd. +* Written by Haibing Ma +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef QEMU_ARM_ZYNQ_H +#define QEMU_ARM_ZYNQ_H + +#include "target/arm/cpu-qom.h" +#include "hw/qdev-clock.h" + +#define TYPE_ZYNQ_MACHINE MACHINE_TYPE_NAME("xilinx-zynq-a9") +OBJECT_DECLARE_SIMPLE_TYPE(ZynqMachineState, ZYNQ_MACHINE) + +#define ZYNQ_MAX_CPUS 2 + +struct ZynqMachineState { +MachineState parent; +Clock *ps_clk; +ARMCPU *cpu[ZYNQ_MAX_CPUS ]; +uint8_t boot_mode; +}; + +#endif /* QEMU_ARM_ZYNQ_H */
Signature · 1 line
2.47.3
Re: [PATCH v5 12/15] hw/arm/xilinx_zynq: Split xilinx_zynq into header and implementation files
Quoted 22 lines · Corvin Köhne
From: YannickV <[email protected]>
Create
xilinx_zynq.hheader file to expose ZynqMachineState and related definitions for machine inheritance. This enables creation of derived machines based on the Zynq platform.Signed-off-by YannickV <[email protected]>include/hw/arm/xilinx_zynq.h new file +6
-0@@ -0,0 +1,36 @@ +/* +* Xilinx Zynq Baseboard System emulation. +* +* Copyright (c) 2010 Xilinx. +* Copyright (c) 2012 Peter A.G. Crosthwaite ([email protected]) +* Copyright (c) 2012 Petalogix Pty Ltd.
include/hw/arm/xilinx_zynq.h line 16
Quoted 10 lines
include/hw/arm/xilinx_zynq.h new file +10
-0+* Written by Haibing Ma +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/
Checkpatch probably complains about the missing SPDX line.
Otherwise
thanks
-- PMM
PATCH v5 13/15 hw/arm/xilinx_zynq: Add flash-type property
In reply to Corvin KöhneFrom: YannickV <[email protected]>
Read flash-type value as machine property and set the flash type accordingly.
--- hw/arm/xilinx_zynq.c | 25 ++++++++++++++++++++----- include/hw/arm/xilinx_zynq.h | 1 + 2 files changed, 21 insertions(+), 5 deletions(-)
hw/arm/xilinx_zynq.c +20 -5
@@ -120,7 +120,8 @@ static void gem_init(uint32_t base, qemu_irq irq) }static inline int zynq_init_spi_flashes (uint32_t base_addr,qemu_irq irq, -bool is_qspi,int unit0) +bool is_qspi,int unit0, +const char *flash_type) {int unit = unit0;DeviceState *dev;
@@ -152,7 +153,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,for (j =0 ; j < num_ss; ++j) {DriveInfo *dinfo =drive_get (IF_MTD ,0 , unit++); - flash_dev =qdev_new ("n25q128" ); + flash_dev =qdev_new (flash_type);if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", blk_by_legacy_dinfo(dinfo),
@@ -190,6 +191,14 @@ static void zynq_set_boot_mode(Object *obj, const char *str, m->boot_mode = mode; } +static void zynq_set_flash_type (Object *obj,const char *str, +Error **errp) +{ +ZynqMachineState *m =ZYNQ_MACHINE (obj); +g_free (m->flash_type); + m->flash_type =g_strdup (str); +} +static void ddr_ctrl_init (uint32_t base) {DeviceState *dev;
@@ -283,9 +292,12 @@ static void zynq_init(MachineState *machine) pic[n] =qdev_get_gpio_in (dev, n); } - n =zynq_init_spi_flashes (0xE0006000 , pic[58 -GIC_INTERNAL ], false,0 ); - n =zynq_init_spi_flashes (0xE0007000 , pic[81 -GIC_INTERNAL ], false, n); - n =zynq_init_spi_flashes (0xE000D000 , pic[51 -GIC_INTERNAL ], true, n); + n =zynq_init_spi_flashes (0xE0006000 , pic[58 -GIC_INTERNAL ], false,0 , + zynq_machine->flash_type); + n =zynq_init_spi_flashes (0xE0007000 , pic[81 -GIC_INTERNAL ], false, n, + zynq_machine->flash_type); + n =zynq_init_spi_flashes (0xE000D000 , pic[51 -GIC_INTERNAL ], true, n, + zynq_machine->flash_type);sysbus_create_simple (TYPE_CHIPIDEA ,0xE0002000 , pic[53 -GIC_INTERNAL ]);sysbus_create_simple (TYPE_CHIPIDEA ,0xE0003000 , pic[76 -GIC_INTERNAL ]);
@@ -473,6 +485,9 @@ static void zynq_machine_class_init(ObjectClass *oc, const void *data)"Supported boot modes:" " jtag qspi sd nor");object_property_set_default_str (prop,"qspi" ); + + prop =object_class_property_add_str (oc,"flash-type" ,NULL , zynq_set_flash_type); +object_property_set_default_str (prop,"n25q128" ); }static const TypeInfo zynq_machine_type = {
include/hw/arm/xilinx_zynq.h +1 -0
@@ -31,6 +31,7 @@ struct ZynqMachineState {Clock *ps_clk;ARMCPU *cpu[ZYNQ_MAX_CPUS ];uint8_t boot_mode; + char *flash_type; };#endif /* QEMU_ARM_ZYNQ_H */
Signature · 1 line
2.47.3
Re: [PATCH v5 13/15] hw/arm/xilinx_zynq: Add flash-type property
Quoted 7 lines · Corvin Köhne
From: YannickV <[email protected]>
Read flash-type value as machine property and set the flash type accordingly.
Signed-off-by YannickV <[email protected]>
Machine properties are user-facing : this one seems to let the user specify any random device name with no error checking which it will then try to instantiate. I think it would be better to have the base class code know via some other mechanism what kind of flash device it should create.
One approach would be to have suitable information in the machine class struct, which is filled in by the class init function. You can see this in hw/arm/raspi.c, for instance, where we set a board_rev field that then the code creating the board can look at.
thanks
-- PMM
PATCH v5 14/15 hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200
In reply to Corvin KöhneFrom: YannickV <[email protected]>
Introduce a new machine type 'beckhoff-cx7200' that inherits from the xilinx-zynq-a9 machine. The CX7200 is an industrial PC based on the Xilinx Zynq-7000 SoC.
The machine preserves all standard Zynq features (boot-mode selection, SPI, UART, Ethernet, etc.) while adding CX7200-specific hardware components.
--- hw/arm/Kconfig | 7 +++ hw/arm/beckhoff_CX7200.c | 104 +++++++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 1 + 3 files changed, 112 insertions(+) create mode 100644 hw/arm/beckhoff_CX7200.c
hw/arm/Kconfig +7 -0
@@ -307,6 +307,13 @@ config ZYNQ select XILINX_SPIPS select ZYNQ_DEVCFG +config BECKHOFF_CX7200 + bool + default y + depends on TCG && ARM + select ZYNQ + 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 +104 -0
104 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_common_ss.add(when: 'CONFIG_ARM_VIRT', if_true: files('virt.c')) arm_common_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
Re: [PATCH v5 14/15] hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200
Quoted 13 lines · Corvin Köhne
From: YannickV <[email protected]>
Introduce a new machine type 'beckhoff-cx7200' that inherits from the xilinx-zynq-a9 machine. The CX7200 is an industrial PC based on the Xilinx Zynq-7000 SoC.
The machine preserves all standard Zynq features (boot-mode selection, SPI, UART, Ethernet, etc.) while adding CX7200-specific hardware components.hw/arm/beckhoff_CX7200.c new file +3
-0+/* Find A9MPCore and set timer frequencies directly */ + a9mpcore_dev =DEVICE (object_resolve_path_type ("" ,TYPE_A9MPCORE_PRIV , +NULL ));
hw/arm/beckhoff_CX7200.c line 72
Quoted 10 lines
hw/arm/beckhoff_CX7200.c new file +10
-0+if (a9mpcore_dev) { + a9mp_priv_state =A9MPCORE_PRIV (a9mpcore_dev); + +/* Direct struct access - devices are already realized */ + a9mp_priv_state->gtimer.freq_hz =CX7200_PS7_CPU_CLK_FREQUENCY ; + a9mp_priv_state->gtimer.periphclk_divider =CX7200_PERIPHCLK_DIVIDER ; + a9mp_priv_state->mptimer.freq_hz =CX7200_PS7_CPU_CLK_FREQUENCY ; + a9mp_priv_state->mptimer.periphclk_divider =CX7200_PERIPHCLK_DIVIDER ; + a9mp_priv_state->wdt.freq_hz =CX7200_PS7_CPU_CLK_FREQUENCY ; + a9mp_priv_state->wdt.periphclk_divider =CX7200_PERIPHCLK_DIVIDER ;
You shouldn't be reaching inside the device's private state struct fields like this -- please find another way to configure it with the correct frequency info.
-- PMM
PATCH v5 15/15 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
Re: [PATCH v5 15/15] docs/system/arm: Add support for Beckhoff CX7200
Quoted 57 lines · Corvin Köhne
From: YannickV <[email protected]>
This commit offers some documentation on the Beckhoff CX7200 qemu emulation.
Signed-off-by YannickV <[email protected]>--- 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.rstdocs/system/arm/beckhoff-cx7200.rst new file +39
-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
docs/system/arm/beckhoff-cx7200.rst line 49
Quoted 10 lines
docs/system/arm/beckhoff-cx7200.rst new file +10
-0+""""""" +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 \ +
Is icount actually required for running? Or does it just affect the fidelity of performance counters?
Quoted 13 lines
docs/system/arm/beckhoff-cx7200.rst new file +8
-0+ +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 +0
-0
docs/system/target-arm.rst Board-specific documentation · line 88
Quoted 7 lines
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
Otherwise:
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH v5 15/15] docs/system/arm: Add support for Beckhoff CX7200
In reply to Corvin KöhneQuoted 20 lines · Corvin Köhne
From: YannickV <[email protected]>
This commit offers some documentation on the Beckhoff CX7200 qemu emulation.
Signed-off-by YannickV <[email protected]>--- 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.rstdocs/system/arm/beckhoff-cx7200.rst new file +1
-0@@ -0,0 +1,57 @@ +Beckhoff CX7200 (``beckhoff-cx7200``)
docs/system/arm/beckhoff-cx7200.rst line 11
Quoted 10 lines
docs/system/arm/beckhoff-cx7200.rst new file +10
-0+====================================== +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
This doesn't render very nicely in the HTML documentation, because it comes out as two bare URLs with no line break between them. Can you write this as something which uses the rST syntax for links, please, e.g:
You can find more detail about this board on the manufacturer's product page <https://....>__.
The SoC is documented in theZynq 7000 Technical Reference manual <https://...>__.
Also, is there an English language version of the product page? Since QEMU's documentation is in English that would be the better link if it exists. Otherwise we should warn the reader by adding "(in German)" when we point them at it.
docs/system/arm/beckhoff-cx7200.rst line 13
Quoted 2 lines
docs/system/arm/beckhoff-cx7200.rst new file +2
-0+ +The CX7200 supports following devices:
"the following"
docs/system/arm/beckhoff-cx7200.rst line 20
Quoted 7 lines
docs/system/arm/beckhoff-cx7200.rst new file +7
-0+ - A9 MPCORE + - cortex-a9 + - GIC v1 + - Generic timer + - wdt + - OCM 256KB + - SMC SRAM@0xe2000000 64MB
The "SRAM@0xe2000000" renders as an email address hyperlink, which probably isn't what you intended. I don't think the address of the RAM is particularly important to the reader of the docs, so we could just omit it.
For docs changes, I recommend making sure your build is building the docs by passing --enable-docs to configure. Then you can look at the HTML that is generated in your build directory under docs/manual/ to check that it hasn't come out with any unintentional markup issues
Quoted 6 lines
docs/system/arm/beckhoff-cx7200.rst new file +6
-0+ - Zynq SLCR + - SPI x2 + - QSPI + - UART + - TTC x2 + - Gigabit Ethernet Controller
docs/system/arm/beckhoff-cx7200.rst line 36
Quoted 10 lines
docs/system/arm/beckhoff-cx7200.rst new file +10
-0+ - SD Controller + - XADC + - Arm PrimeCell DMA Controller + - DDR Memory + - DDR Controller + - Beckhoff Communication Controller (CCAT) + - EEPROM Interface + - DMA Controller + +Following devices are not supported:
"The following"
docs/system/arm/beckhoff-cx7200.rst line 37
Quoted 1 line
docs/system/arm/beckhoff-cx7200.rst new file +1
-0+ - I2C
thanks
-- PMM
Re: [PATCH v5 15/15] docs/system/arm: Add support for Beckhoff CX7200
Quoted 8 lines · Peter Maydell
Quoted 6 lines · Corvin Köhne
From: YannickV <[email protected]>
This commit offers some documentation on the Beckhoff CX7200 qemu emulation.
Quoted 6 lines
Quoted 4 lines
Signed-off-by YannickV <[email protected]>--- docs/system/arm/beckhoff-cx7200.rst | 57 +++++++++++++++++++++++++++++ docs/system/target-arm.rst | 1 +This doesn't render very nicely in the HTML documentation,
I noticed also that the nested bulleted lists in this file come out a bit odd, and so I checked the existing xlnx-zynq docs, which also have that issue. I just sent this patch to docs/system/arm/xlnx-zynq.rst which fixes various minor rendering issues:
https://patchew.org/QEMU/[email protected]/[email protected]/
You might find it useful to refer to in updating your patch here.
-- PMM
Quoted 50 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.
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 to0xffffffffhw/arm/zynq-devcfg: Prevent unintended unlock during initialization hw/dma/zynq: EnsurePCFG_DONEbit 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/misc: Add dummy ZYNQ DDR controller
hw/misc/zynq_slcr: Add logic for DCI configuration hw/misc: Add Beckhoff CCAT device
hw/block/m25p80: AddHAS_SR_TBflag for is25lp016d hw/arm/xilinx_zynq: Splitxilinx_zynqinto header and implementation
files
hw/arm/xilinx_zynq: Add flash-type property
hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200 docs/system/arm: Add support for Beckhoff CX7200docs/system/arm/beckhoff-cx7200.rst | 57 ++++ docs/system/target-arm.rst | 1 + hw/arm/Kconfig | 7 + hw/arm/beckhoff_CX7200.c | 104 +++++++ hw/arm/meson.build | 1 + hw/arm/xilinx_zynq.c | 54 ++-- hw/block/m25p80.c | 3 +- hw/dma/xlnx-zynq-devcfg.c | 27 +- hw/misc/Kconfig | 6 + hw/misc/beckhoff_ccat.c | 339 +++++++++++++++++++++++ hw/misc/meson.build | 2 +
Quoted 8 lines
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/arm/xilinx_zynq.h | 37 +++ include/hw/misc/xlnx-zynq-ddrc.h | 148 ++++++++++ include/hw/timer/a9gtimer.h | 2 + include/hw/timer/arm_mptimer.h | 4 +
Hi!
Looking at the list of changed files, I think this series misses an update to MAINTAINERS to add the new board there. Could you please add such a patch?
Also, are there any binaries for this board publically available somewhere on the internet? If so, please also add a functional test for this board to tests/functional/ - thanks!
Thomas
Quoted 12 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.
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.:
Quoted 7 lines
* 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/
Is it possible to host a binary build somewhere so there can be a functional test?
Quoted 46 lines
YannickV (15):
hw/timer: Make frequency configurable
hw/timer: Make PERIPHCLK divider configurable hw/dma/zynq-devcfg: Handle bitstream loading via DMA to0xffffffffhw/arm/zynq-devcfg: Prevent unintended unlock during initialization hw/dma/zynq: EnsurePCFG_DONEbit 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/misc: Add dummy ZYNQ DDR controller
hw/misc/zynq_slcr: Add logic for DCI configuration hw/misc: Add Beckhoff CCAT device
hw/block/m25p80: AddHAS_SR_TBflag for is25lp016d hw/arm/xilinx_zynq: Splitxilinx_zynqinto header and implementation
files
hw/arm/xilinx_zynq: Add flash-type property
hw/arm: Add new machine based on xilinx-zynq-a9 for Beckhoff CX7200 docs/system/arm: Add support for Beckhoff CX7200docs/system/arm/beckhoff-cx7200.rst | 57 ++++ docs/system/target-arm.rst | 1 + hw/arm/Kconfig | 7 + hw/arm/beckhoff_CX7200.c | 104 +++++++ hw/arm/meson.build | 1 + hw/arm/xilinx_zynq.c | 54 ++-- hw/block/m25p80.c | 3 +- hw/dma/xlnx-zynq-devcfg.c | 27 +- hw/misc/Kconfig | 6 + hw/misc/beckhoff_ccat.c | 339 +++++++++++++++++++++++ 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/arm/xilinx_zynq.h | 37 +++ include/hw/misc/xlnx-zynq-ddrc.h | 148 ++++++++++ include/hw/timer/a9gtimer.h | 2 + include/hw/timer/arm_mptimer.h | 4 + 19 files changed, 1263 insertions(+), 31 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/arm/xilinx_zynq.h create mode 100644 include/hw/misc/xlnx-zynq-ddrc.h
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 27 lines · Alex Bennée
Corvin Köhne <corvin. koehne@ gmail. com> writes: > From: Corvin Köhne <c. koehne@ beckhoff. com> > > Hi, > > Beckhoff has build a board, called CX7200, based on the Xilinx Zynq A9 > platform. This commit series adds
Quoted 21 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.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])
Quoted 7 lines
Quoted 2 lines
[1] https://github.com/beckhoff/ccat
[2] https://www.beckhoff.com/en-us/products/automation/Is it possible to host a binary build somewhere so there can be a functional test?
Sry for the quite late response. There's currently no binary build publicly available. We're planning to release one but things are moving (very) slowly.
Signature · 17 lines
Best regards, Corvin This email contains confidential information. If you have received it in error, you must not read, use, copy or pass on this e-mail or its attachments. If you have received the e-mail in error, please inform me immediately by reply e-mail and then delete this e-mail from your system. Thank you Diese E-Mail enthält vertrauliche Informationen. Sollten Sie sie irrtümlich erhalten haben, dürfen Sie diese E-Mail oder ihre Anhänge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die Mail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per Antwort-E-Mail mit und löschen Sie diese E-Mail dann aus Ihrem System. Vielen Dank Beckhoff Automation GmbH & Co. KG Managing Director: Dipl. Phys. Hans Beckhoff Registered office: Verl, Germany Register court: Guetersloh HRA 7075 DisclaimerID:x9d5u140