AMD Versal Gen 2 support
v3 cover AMD Versal Gen 2 support
v3:
- Dropped qemu_get_cpu() usage in the machine code. Added an getter on the SoC interface to retrieve the boot CPU instead. [Phil]
- Cleaned the mp_affinity logic. Drop the mask attribute and assume it's always 0xff (the Affx fields in MPIDR are 8 bits long). Use the ARM_AFFx_SHIFT constant instead of hardcoded values in .mp_affinity description. [Phil]
- Avocado test renaming in patch 41 instead of 47. [Phil]
- Documentation tweak. [Phil]
v2:
- Addressed formatting/typo issues [Francisco]
- Patch 23: GICv3 first-cpu-idx: addressed the KVM case by bailing out if not 0 at realize. I chose this path as I don't have a clear view of what it means to implement that for KVM. It seems to make sense anyway as this property is meant to be used for modeling of non-SMP systems. [Peter]
- Patch 39: added a comment to clarify cortex-a78ae != cortex-a78 [Peter]
Hello,
This series brings support for the AMD Versal Gen 2 (versal2) SoC in QEMU. This SoC is the next iteration of the existing Versal SoC.
It is organized as follows:
- The first and biggest part of the series performs refactoring of the existing versal SoC implementation. This consists in:
- splitting existing device types into base/concrete classes,
- moving from an in-place to dynamic device creation approach in the SoC code for flexibility,
- describing the SoC using a new structure called VersalMap,
- moving the DTB creation logic in the SoC code itself alongside device creation.
Patches are split such that each device is individually converted to use this new approach. Behaviour changes are minimal and are emphasised in the commit messages. This gets the SoC code ready for versal2 addition and leverage the fact that Versal family SoCs are quite similar in term of architecture.
- versal2 SoC support is then added by adding the corresponding VersalMap description. This allows to reuse the existing code without duplication and almost no special case.
- The amd-versal2-virt machine is finally added, following the same idea as amd-versal-virt. The documentation and tests are updated accordingly.
Note that the xlnx-versal-virt machine is renamed amd-versal-virt to follow current branding guidelines and stay coherent with the new amd-versal2-virt machine. The xlnx-versal-virt name is kept as an alias to amd-versal-virt for command line backward compatibility.
Thanks
Luc
Francisco Iglesias (1):
hw/intc/arm_gicv3: Introduce a 'first-cpu-index' property
Luc Michel (46):
hw/arm/xlnx-versal: split the xlnx-versal type hw/arm/xlnx-versal: prepare for FDT creation hw/arm/xlnx-versal: uart: refactor creation hw/arm/xlnx-versal: canfd: refactor creation hw/arm/xlnx-versal: sdhci: refactor creation hw/arm/xlnx-versal: gem: refactor creation hw/arm/xlnx-versal: adma: refactor creation hw/arm/xlnx-versal: xram: refactor creation hw/arm/xlnx-versal: usb: refactor creation hw/arm/xlnx-versal: efuse: refactor creation hw/arm/xlnx-versal: ospi: refactor creation hw/arm/xlnx-versal: VersalMap: add support for OR'ed IRQs hw/arm/xlnx-versal: PMC IOU SCLR: refactor creation hw/arm/xlnx-versal: bbram: refactor creation hw/arm/xlnx-versal: trng: refactor creation hw/arm/xlnx-versal: rtc: refactor creation hw/arm/xlnx-versal: cfu: refactor creation hw/arm/xlnx-versal: crl: refactor creation hw/arm/xlnx-versal-virt: virtio: refactor creation hw/arm/xlnx-versal: refactor CPU cluster creation hw/arm/xlnx-versal: add the mp_affinity property to the CPU mapping hw/arm/xlnx-versal: instantiate the GIC ITS in the APU hw/arm/xlnx-versal: add support for multiple GICs hw/arm/xlnx-versal: add support for GICv2 hw/arm/xlnx-versal: rpu: refactor creation hw/arm/xlnx-versal: ocm: refactor creation hw/arm/xlnx-versal: ddr: refactor creation hw/arm/xlnx-versal: add the versal_get_num_cpu accessor hw/misc/xlnx-versal-crl: remove unnecessary include directives hw/misc/xlnx-versal-crl: split into base/concrete classes hw/misc/xlnx-versal-crl: refactor device reset logic hw/arm/xlnx-versal: reconnect the CRL to the other devices hw/arm/xlnx-versal: use hw/arm/bsa.h for timer IRQ indices hw/arm/xlnx-versal: tidy up
hw/misc/xlnx-versal-crl: add the versal2 version hw/arm/xlnx-versal: add a per_cluster_gic switch to
VersalCpuClusterMap
hw/arm/xlnx-versal: add the target field in IRQ descriptor target/arm/tcg/cpu64: add the cortex-a78ae CPU hw/arm/xlnx-versal: add versal2 SoC hw/arm/xlnx-versal-virt: rename the machine to amd-versal-virt hw/arm/xlnx-versal-virt: split into base/concrete classes hw/arm/xlnx-versal-virt: tidy up docs/system/arm/xlnx-versal-virt: update supported devices docs/system/arm/xlnx-versal-virt: add a note about dumpdtb hw/arm/xlnx-versal-virt: add the xlnx-versal2-virt machine tests/functional/test_aarch64_xlnx_versal: test the versal2 machine
docs/system/arm/xlnx-versal-virt.rst | 80 +- include/hw/arm/xlnx-versal-version.h | 16 + include/hw/arm/xlnx-versal.h | 342 +-- include/hw/intc/arm_gicv3_common.h | 1 + include/hw/misc/xlnx-versal-crl.h | 378 ++- hw/arm/xlnx-versal-virt.c | 742 ++---- hw/arm/xlnx-versal.c | 2455 +++++++++++++----- hw/intc/arm_gicv3_common.c | 3 +- hw/intc/arm_gicv3_cpuif.c | 2 +- hw/intc/arm_gicv3_kvm.c | 6 + hw/misc/xlnx-versal-crl.c | 602 ++++- target/arm/tcg/cpu64.c | 79 + tests/functional/test_aarch64_xlnx_versal.py | 12 +- 13 files changed, 3057 insertions(+), 1661 deletions(-) create mode 100644 include/hw/arm/xlnx-versal-version.h
Signature · 1 line
2.50.1
PATCH v3 1/47 hw/arm/xlnx-versal: split the xlnx-versal type
Split the xlnx-versal device into two classes, a base, abstract class and the existing concrete one. Introduce a VersalVersion type that will be used across several device models when versal2 implementation is added.
This is in preparation for versal2 implementation.
--- include/hw/arm/xlnx-versal-version.h | 15 ++++++++++++++ include/hw/arm/xlnx-versal.h | 12 ++++++++++- hw/arm/xlnx-versal.c | 31 +++++++++++++++++++++------- 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 include/hw/arm/xlnx-versal-version.h
include/hw/arm/xlnx-versal-version.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* AMD Versal versions +* +* Copyright (c) 2025 Advanced Micro Devices, Inc. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_ARM_XLNX_VERSAL_VERSION_H +#define HW_ARM_XLNX_VERSAL_VERSION_H + +typedef enum VersalVersion { +VERSAL_VER_VERSAL , +}VersalVersion ; + +#endif
include/hw/arm/xlnx-versal.h +11 -1
@@ -1,9 +1,10 @@/* * Model of the Xilinx Versal * * Copyright (c) 2018 Xilinx Inc. +* Copyright (c) 2025 Advanced Micro Devices, Inc. * Written by Edgar E. Iglesias * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 or * (at your option) any later version.
@@ -33,13 +34,16 @@#include "hw/misc/xlnx-versal-trng.h" #include "hw/net/xlnx-versal-canfd.h" #include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h" #include "target/arm/cpu.h" +#include "hw/arm/xlnx-versal-version.h" + +#define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base" +OBJECT_DECLARE_TYPE(Versal, VersalClass, XLNX_VERSAL_BASE)#define TYPE_XLNX_VERSAL "xlnx-versal" -OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL)#define XLNX_VERSAL_NR_ACPUS 2#define XLNX_VERSAL_NR_RCPUS 2#define XLNX_VERSAL_NR_UARTS 2#define XLNX_VERSAL_NR_GEMS 2
@@ -135,10 +139,16 @@ struct Versal {struct {MemoryRegion *mr_ddr; } cfg; }; +struct VersalClass { +SysBusDeviceClass parent; + +VersalVersion version; +}; +/* Memory-map and IRQ definitions. Copied a subset from * auto-generated files. */ #define VERSAL_GIC_MAINT_IRQ 9#define VERSAL_TIMER_VIRT_IRQ 11
hw/arm/xlnx-versal.c +24 -7
@@ -1,9 +1,10 @@/* * Xilinx Versal SoC model. * * Copyright (c) 2018 Xilinx Inc. +* Copyright (c) 2025 Advanced Micro Devices, Inc. * Written by Edgar E. Iglesias * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 or * (at your option) any later version.
@@ -918,11 +919,11 @@ static void versal_unimp(Versal *s) gpio_in); }static void versal_realize (DeviceState *dev,Error **errp) { -Versal *s =XLNX_VERSAL (dev); +Versal *s =XLNX_VERSAL_BASE (dev);qemu_irq pic[XLNX_VERSAL_NR_IRQS ];versal_create_apu_cpus (s);versal_create_apu_gic (s, pic);versal_create_rpu_cpus (s);
@@ -953,13 +954,13 @@ static void versal_realize(DeviceState *dev, Error **errp)memory_region_add_subregion_overlap (&s->fpd.apu.mr,0 , &s->mr_ps,0 );memory_region_add_subregion_overlap (&s->lpd.rpu.mr,0 , &s->lpd.rpu.mr_ps_alias,0 ); } -static void versal_init (Object *obj) +static void versal_base_init (Object *obj) { -Versal *s =XLNX_VERSAL (obj); +Versal *s =XLNX_VERSAL_BASE (obj);memory_region_init (&s->fpd.apu.mr, obj,"mr-apu" ,UINT64_MAX );memory_region_init (&s->lpd.rpu.mr, obj,"mr-rpu" ,UINT64_MAX );memory_region_init (&s->mr_ps, obj,"mr-ps-switch" ,UINT64_MAX ); memory_region_init_alias(&s->lpd.rpu.mr_ps_alias, OBJECT(s),
@@ -973,28 +974,44 @@ static const Property versal_properties[] = { TYPE_CAN_BUS, CanBusState *),DEFINE_PROP_LINK ("canbus1" , Versal, lpd.iou.canbus[1 ], TYPE_CAN_BUS, CanBusState *), }; -static void versal_class_init (ObjectClass *klass,const void *data) +static void versal_base_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->realize = versal_realize;device_class_set_props (dc, versal_properties);/* No VMSD since we haven't got any top-level SoC state to save. */ } -static const TypeInfo versal_info = { - .name =TYPE_XLNX_VERSAL , +static void versal_class_init (ObjectClass *klass,const void *data) +{ +VersalClass *vc =XLNX_VERSAL_BASE_CLASS (klass); + + vc->version =VERSAL_VER_VERSAL ; +} + +static const TypeInfo versal_base_info = { + .name =TYPE_XLNX_VERSAL_BASE , .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (Versal), - .instance_init = versal_init, + .instance_init = versal_base_init, + .class_init = versal_base_class_init, + .class_size =sizeof (VersalClass), + .abstract = true, +}; + +static const TypeInfo versal_info = { + .name =TYPE_XLNX_VERSAL , + .parent =TYPE_XLNX_VERSAL_BASE , .class_init = versal_class_init, };static void versal_register_types (void ) { +type_register_static (&versal_base_info);type_register_static (&versal_info); }type_init (versal_register_types);
Signature · 1 line
2.50.1
PATCH v3 2/47 hw/arm/xlnx-versal: prepare for FDT creation
In reply to Luc MichelThe following commits will move FDT creation logic from the xlnx-versal-virt machine to the xlnx-versal SoC itself. Prepare this by passing the FDT handle to the SoC before it is realized. If no FDT is passed, a dummy one is created internally as a stub to the fdt function calls.
For now the SoC only creates the two clock nodes. The ones from the xlnx-versal virt machine are renamed with a `old-' prefix and will be removed once they are not referenced anymore.
--- include/hw/arm/xlnx-versal.h | 12 ++++++++++++ hw/arm/xlnx-versal-virt.c | 11 +++++++---- hw/arm/xlnx-versal.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-)
include/hw/arm/xlnx-versal.h +12 -0
@@ -134,21 +134,33 @@ struct Versal {XlnxVersalCFrameBcastReg cframe_bcast;OrIRQState apb_irq_orgate; } pmc; +struct { +uint32_t clk_25mhz; +uint32_t clk_125mhz; + } phandle; +struct {MemoryRegion *mr_ddr; +void *fdt; } cfg; };struct VersalClass {SysBusDeviceClass parent;VersalVersion version; }; +static inline void versal_set_fdt (Versal *s,void *fdt) +{ +g_assert (!qdev_is_realized (DEVICE (s))); + s->cfg.fdt = fdt; +} +/* Memory-map and IRQ definitions. Copied a subset from * auto-generated files. */ #define VERSAL_GIC_MAINT_IRQ 9#define VERSAL_TIMER_VIRT_IRQ 11
hw/arm/xlnx-versal-virt.c +7 -4
@@ -1,9 +1,10 @@/* * Xilinx Versal Virtual board. * * Copyright (c) 2018 Xilinx Inc. +* Copyright (c) 2025 Advanced Micro Devices, Inc. * Written by Edgar E. Iglesias * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 or * (at your option) any later version.
@@ -695,14 +696,13 @@ static void versal_virt_init(MachineState *machine) &error_abort);object_property_set_link (OBJECT (&s->soc),"canbus0" ,OBJECT (s->canbus[0 ]), &error_abort);object_property_set_link (OBJECT (&s->soc),"canbus1" ,OBJECT (s->canbus[1 ]), &error_abort); -sysbus_realize (SYS_BUS_DEVICE (&s->soc), &error_fatal);fdt_create (s); -create_virtio_regions (s); +versal_set_fdt (&s->soc, s->fdt);fdt_add_gem_nodes (s);fdt_add_uart_nodes (s);fdt_add_canfd_nodes (s);fdt_add_gic_nodes (s);fdt_add_timer_nodes (s);
@@ -712,12 +712,15 @@ static void versal_virt_init(MachineState *machine)fdt_add_rtc_node (s);fdt_add_bbram_node (s);fdt_add_efuse_ctrl_node (s);fdt_add_efuse_cache_node (s);fdt_add_cpu_nodes (s, psci_conduit); -fdt_add_clk_node (s,"/clk125" ,125000000 , s->phandle.clk_125Mhz); -fdt_add_clk_node (s,"/clk25" ,25000000 , s->phandle.clk_25Mhz); +fdt_add_clk_node (s,"/old-clk125" ,125000000 , s->phandle.clk_125Mhz); +fdt_add_clk_node (s,"/old-clk25" ,25000000 , s->phandle.clk_25Mhz); + +sysbus_realize (SYS_BUS_DEVICE (&s->soc), &error_fatal); +create_virtio_regions (s);/* Make the APU cpu address space visible to virtio and other * modules unaware of multiple address-spaces. */ memory_region_add_subregion_overlap (get_system_memory (),0 , &s->soc.fpd.apu.mr,0 );
hw/arm/xlnx-versal.c +30 -0
@@ -22,10 +22,12 @@#include "hw/misc/unimp.h" #include "hw/arm/xlnx-versal.h" #include "qemu/log.h" #include "target/arm/cpu-qom.h" #include "target/arm/gtimer.h" +#include "system/device_tree.h" +#include "hw/arm/fdt.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106
@@ -917,14 +919,42 @@ static void versal_unimp(Versal *s)qdev_connect_gpio_out_named (DEVICE (&s->pmc.iou.slcr),SYSBUS_DEVICE_GPIO_IRQ ,0 , gpio_in); } +static uint32_t fdt_add_clk_node (Versal *s,const char *name, +unsigned int freq_hz) +{ +uint32_t phandle; + + phandle =qemu_fdt_alloc_phandle (s->cfg.fdt); + +qemu_fdt_add_subnode (s->cfg.fdt, name); +qemu_fdt_setprop_cell (s->cfg.fdt, name,"phandle" , phandle); +qemu_fdt_setprop_cell (s->cfg.fdt, name,"clock-frequency" , freq_hz); +qemu_fdt_setprop_cell (s->cfg.fdt, name,"#clock-cells" ,0x0 ); +qemu_fdt_setprop_string (s->cfg.fdt, name,"compatible" ,"fixed-clock" ); +qemu_fdt_setprop (s->cfg.fdt, name,"u-boot,dm-pre-reloc" ,NULL ,0 ); + +return phandle; +} +static void versal_realize (DeviceState *dev,Error **errp) {Versal *s =XLNX_VERSAL_BASE (dev);qemu_irq pic[XLNX_VERSAL_NR_IRQS ]; +const VersalMap *map =versal_get_map (s); +size_t i; + +if (s->cfg.fdt ==NULL ) { +int fdt_size; + + s->cfg.fdt =create_device_tree (&fdt_size); + } + + s->phandle.clk_25mhz =fdt_add_clk_node (s,"/clk25" ,25 *1000 *1000 ); + s->phandle.clk_125mhz =fdt_add_clk_node (s,"/clk125" ,125 *1000 *1000 );versal_create_apu_cpus (s);versal_create_apu_gic (s, pic);versal_create_rpu_cpus (s);versal_create_uarts (s, pic);
Signature · 1 line
2.50.1
PATCH v3 3/47 hw/arm/xlnx-versal: uart: refactor creation
In reply to Luc MichelRefactor the UARTs creations. The VersalMap struct is now used to describe the SoC and its peripherals. For now it contains the two UARTs mapping information. The creation function now embeds the FDT creation logic as well. The devices are now created dynamically using qdev_new and (qdev|sysbus)_realize_and_unref.
This will allow to rely entirely on the VersalMap structure to create the SoC and allow easy addition of new SoCs of the same family (like versal2 coming with next commits).
Note that the connection to the CRL is removed for now and will be re-added by next commits.
--- include/hw/arm/xlnx-versal.h | 2 - hw/arm/xlnx-versal-virt.c | 36 +-------- hw/arm/xlnx-versal.c | 142 ++++++++++++++++++++++++++++------- 3 files changed, 117 insertions(+), 63 deletions(-)
include/hw/arm/xlnx-versal.h +0 -2
@@ -16,11 +16,10 @@#include "hw/sysbus.h" #include "hw/cpu/cluster.h" #include "hw/or-irq.h" #include "hw/sd/sdhci.h" #include "hw/intc/arm_gicv3.h" -#include "hw/char/pl011.h" #include "hw/dma/xlnx-zdma.h" #include "hw/net/cadence_gem.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/usb/xlnx-usb-subsystem.h"
@@ -78,11 +77,10 @@ struct Versal {struct {MemoryRegion mr_ocm;struct { -PL011State uart[XLNX_VERSAL_NR_UARTS ];CadenceGEMState gem[XLNX_VERSAL_NR_GEMS ];OrIRQState gem_irq_orgate[XLNX_VERSAL_NR_GEMS ];XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ];VersalUsb2 usb;CanBusState *canbus[XLNX_VERSAL_NR_CANFD ];
hw/arm/xlnx-versal-virt.c +1 -35
@@ -75,10 +75,11 @@ static void fdt_create(VersalVirt *s) s->phandle.usb =qemu_fdt_alloc_phandle (s->fdt); s->phandle.dwc =qemu_fdt_alloc_phandle (s->fdt);/* Create /chosen node for load_dtb. */ qemu_fdt_add_subnode (s->fdt,"/chosen" ); +qemu_fdt_add_subnode (s->fdt,"/aliases" );/* Header */ qemu_fdt_setprop_cell (s->fdt,"/" ,"interrupt-parent" , s->phandle.gic);qemu_fdt_setprop_cell (s->fdt,"/" ,"#size-cells" ,0x2 );qemu_fdt_setprop_cell (s->fdt,"/" ,"#address-cells" ,0x2 );
@@ -206,44 +207,10 @@ static void fdt_add_usb_xhci_nodes(VersalVirt *s)qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.dwc);qemu_fdt_setprop_string (s->fdt, name,"maximum-speed" ,"high-speed" );g_free (name); } -static void fdt_add_uart_nodes (VersalVirt *s) -{ -uint64_t addrs[] = {MM_UART1 ,MM_UART0 }; -unsigned int irqs[] = {VERSAL_UART1_IRQ_0 ,VERSAL_UART0_IRQ_0 }; -const char compat[] ="arm,pl011\0arm,sbsa-uart" ; -const char clocknames[] ="uartclk\0apb_pclk" ; -int i; - -for (i =0 ; i <ARRAY_SIZE (addrs); i++) { -char *name =g_strdup_printf ("/uart@%" PRIx64, addrs[i]); -qemu_fdt_add_subnode (s->fdt, name); -qemu_fdt_setprop_cell (s->fdt, name,"current-speed" ,115200 ); -qemu_fdt_setprop_cells (s->fdt, name,"clocks" , - s->phandle.clk_125Mhz, s->phandle.clk_125Mhz); -qemu_fdt_setprop (s->fdt, name,"clock-names" , - clocknames,sizeof (clocknames)); - -qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , -GIC_FDT_IRQ_TYPE_SPI , irqs[i], -GIC_FDT_IRQ_FLAGS_LEVEL_HI ); -qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , -2 , addrs[i],2 ,0x1000 ); -qemu_fdt_setprop (s->fdt, name,"compatible" , - compat,sizeof (compat)); -qemu_fdt_setprop (s->fdt, name,"u-boot,dm-pre-reloc" ,NULL ,0 ); - -if (addrs[i] ==MM_UART0 ) { -/* Select UART0. */ -qemu_fdt_setprop_string (s->fdt,"/chosen" ,"stdout-path" , name); - } -g_free (name); - } -} -static void fdt_add_canfd_nodes (VersalVirt *s) {uint64_t addrs[] = {MM_CANFD1 ,MM_CANFD0 };uint32_t size[] = {MM_CANFD1_SIZE ,MM_CANFD0_SIZE };unsigned int irqs[] = {VERSAL_CANFD1_IRQ_0 ,VERSAL_CANFD0_IRQ_0 };
@@ -700,11 +667,10 @@ static void versal_virt_init(MachineState *machine) &error_abort);fdt_create (s);versal_set_fdt (&s->soc, s->fdt);fdt_add_gem_nodes (s); -fdt_add_uart_nodes (s);fdt_add_canfd_nodes (s);fdt_add_gic_nodes (s);fdt_add_timer_nodes (s);fdt_add_zdma_nodes (s);fdt_add_usb_xhci_nodes (s);
hw/arm/xlnx-versal.c +116 -26
195 lines not on this page · raw message
Signature · 1 line
2.50.1
Re: [PATCH v3 03/47] hw/arm/xlnx-versal: uart: refactor creation
Quoted 6 lines · Luc Michel
Refactor the UARTs creations. The VersalMap struct is now used to describe the SoC and its peripherals. For now it contains the two UARTs mapping information. The creation function now embeds the FDT creation logic as well. The devices are now created dynamically using
qdev_newand (qdev|sysbus)_realize_and_unref.
Quoted 6 lines
This will allow to rely entirely on the VersalMap structure to create the SoC and allow easy addition of new SoCs of the same family (like versal2 coming with next commits).
Note that the connection to the CRL is removed for now and will be re-added by next commits.
Hi Luc,
I see the following on this patch:
Starting program: /home/edgar/src/c/qemu/patchew/build/qemu-system-aarch64 -M xlnx-versal-virt -m 2g -serial stdio -display none -net nic,model=cadence_gem,netdev=n0 -netdev user,id=n0 -kernel Image -device virtio-blk-device,drive=d0 -drive format=qcow2,if=none,file=rootfs.qcow2,id=d0 -append root=/dev/vda1\ console=ttyAMA0 [Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff5a4c640 (LWP 130095)]
[New Thread 0x7ffff4889640 (LWP 130096)]
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault. arm_cpu_mp_affinity (cpu=cpu@entry=0x0) at ../qemu/target/arm/cpu.c:1446
1446 return cpu->mp_affinity;
(gdb) bt
#0 arm_cpu_mp_affinity (cpu=cpu@entry=0x0) at ../qemu/target/arm/cpu.c:1446 #1 0x0000555555d8517d in fdt_add_cpu_nodes (psci_conduit=1, s=0x7ffff4a7b010)
at ../qemu/hw/arm/xlnx-versal-virt.c:114
#2 versal_virt_init (machine=0x7ffff4a7b010) at ../qemu/hw/arm/xlnx-versal-virt.c:682 #3 0x00005555559b766d in machine_run_board_init
(machine=<optimized out>, mem_path=<optimized out>, errp=<optimized out>, errp@entry=0x555557602858 <error_fatal>) at ../qemu/hw/core/machine.c:1694
#4 0x0000555555bfda6c in qemu_init_board () at ../qemu/system/vl.c:2710 #5 qmp_x_exit_preconfig (errp=0x555557602858 <error_fatal>) at ../qemu/system/vl.c:2804 #6 0x0000555555c013de in qemu_init (argc=<optimized out>, argv=<optimized out>) at ../qemu/system/vl.c:3840 #7 0x000055555590253d in main (argc=<optimized out>, argv=<optimized out>) at ../qemu/system/main.c:71
(gdb)
Quoted 316 lines
Signed-off-by Luc Michel <[email protected]>Reviewed-by Francisco Iglesias <[email protected]>--- include/hw/arm/xlnx-versal.h | 2 - hw/arm/xlnx-versal-virt.c | 36 +-------- hw/arm/xlnx-versal.c | 142 ++++++++++++++++++++++++++++------- 3 files changed, 117 insertions(+), 63 deletions(-)include/hw/arm/xlnx-versal.h +0
-2@@ -16,11 +16,10 @@#include "hw/sysbus.h" #include "hw/cpu/cluster.h" #include "hw/or-irq.h" #include "hw/sd/sdhci.h" #include "hw/intc/arm_gicv3.h" -#include "hw/char/pl011.h" #include "hw/dma/xlnx-zdma.h" #include "hw/net/cadence_gem.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/usb/xlnx-usb-subsystem.h" @@ -78,11 +77,10 @@ struct Versal {struct {MemoryRegion mr_ocm;struct { -PL011State uart[XLNX_VERSAL_NR_UARTS ];CadenceGEMState gem[XLNX_VERSAL_NR_GEMS ];OrIRQState gem_irq_orgate[XLNX_VERSAL_NR_GEMS ];XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ];VersalUsb2 usb;CanBusState *canbus[XLNX_VERSAL_NR_CANFD ];hw/arm/xlnx-versal-virt.c +1
-35@@ -75,10 +75,11 @@ static void fdt_create(VersalVirt *s) s->phandle.usb =qemu_fdt_alloc_phandle (s->fdt); s->phandle.dwc =qemu_fdt_alloc_phandle (s->fdt);/* Create /chosen node for load_dtb. */ qemu_fdt_add_subnode (s->fdt,"/chosen" ); +qemu_fdt_add_subnode (s->fdt,"/aliases" );/* Header */ qemu_fdt_setprop_cell (s->fdt,"/" ,"interrupt-parent" , s->phandle.gic);qemu_fdt_setprop_cell (s->fdt,"/" ,"#size-cells" ,0x2 );qemu_fdt_setprop_cell (s->fdt,"/" ,"#address-cells" ,0x2 );@@ -206,44 +207,10 @@ static void fdt_add_usb_xhci_nodes(VersalVirt *s)qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.dwc);qemu_fdt_setprop_string (s->fdt, name,"maximum-speed" ,"high-speed" );g_free (name); } -static void fdt_add_uart_nodes (VersalVirt *s) -{ -uint64_t addrs[] = {MM_UART1 ,MM_UART0 }; -unsigned int irqs[] = {VERSAL_UART1_IRQ_0 ,VERSAL_UART0_IRQ_0 }; -const char compat[] ="arm,pl011\0arm,sbsa-uart" ; -const char clocknames[] ="uartclk\0apb_pclk" ; -int i; - -for (i =0 ; i <ARRAY_SIZE (addrs); i++) { -char *name =g_strdup_printf ("/uart@%" PRIx64, addrs[i]); -qemu_fdt_add_subnode (s->fdt, name); -qemu_fdt_setprop_cell (s->fdt, name,"current-speed" ,115200 ); -qemu_fdt_setprop_cells (s->fdt, name,"clocks" , - s->phandle.clk_125Mhz, s->phandle.clk_125Mhz); -qemu_fdt_setprop (s->fdt, name,"clock-names" , - clocknames,sizeof (clocknames)); - -qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , -GIC_FDT_IRQ_TYPE_SPI , irqs[i], -GIC_FDT_IRQ_FLAGS_LEVEL_HI ); -qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , -2 , addrs[i],2 ,0x1000 ); -qemu_fdt_setprop (s->fdt, name,"compatible" , - compat,sizeof (compat)); -qemu_fdt_setprop (s->fdt, name,"u-boot,dm-pre-reloc" ,NULL ,0 ); - -if (addrs[i] ==MM_UART0 ) { -/* Select UART0. */ -qemu_fdt_setprop_string (s->fdt,"/chosen" ,"stdout-path" , name); - } -g_free (name); - } -} -static void fdt_add_canfd_nodes (VersalVirt *s) {uint64_t addrs[] = {MM_CANFD1 ,MM_CANFD0 };uint32_t size[] = {MM_CANFD1_SIZE ,MM_CANFD0_SIZE };unsigned int irqs[] = {VERSAL_CANFD1_IRQ_0 ,VERSAL_CANFD0_IRQ_0 };@@ -700,11 +667,10 @@ static void versal_virt_init(MachineState *machine) &error_abort);fdt_create (s);versal_set_fdt (&s->soc, s->fdt);fdt_add_gem_nodes (s); -fdt_add_uart_nodes (s);fdt_add_canfd_nodes (s);fdt_add_gic_nodes (s);fdt_add_timer_nodes (s);fdt_add_zdma_nodes (s);fdt_add_usb_xhci_nodes (s);hw/arm/xlnx-versal.c +116
-26@@ -24,18 +24,96 @@#include "qemu/log.h" #include "target/arm/cpu-qom.h" #include "target/arm/gtimer.h" #include "system/device_tree.h" #include "hw/arm/fdt.h" +#include "hw/char/pl011.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106#define VERSAL_NUM_PMC_APB_IRQS 18#define NUM_OSPI_IRQ_LINES 3 +typedef struct VersalSimplePeriphMap { +uint64_t addr; +int irq; +}VersalSimplePeriphMap ; + +typedef struct VersalMap { +VersalSimplePeriphMap uart[2 ]; +size_t num_uart; +}VersalMap ; + +static const VersalMap VERSAL_MAP = { + .uart[0 ] = {0xff000000 ,18 }, + .uart[1 ] = {0xff010000 ,19 }, + .num_uart =2 , +}; + +static const VersalMap *VERSION_TO_MAP [] = { + [VERSAL_VER_VERSAL ] = &VERSAL_MAP , +}; + +static inline VersalVersion versal_get_version (Versal *s) +{ +return XLNX_VERSAL_BASE_GET_CLASS (s)->version; +} + +static inline const VersalMap *versal_get_map (Versal *s) +{ +return VERSION_TO_MAP [versal_get_version (s)]; +} + + +static qemu_irq versal_get_irq (Versal *s,int irq_idx) +{ +return qdev_get_gpio_in (DEVICE (&s->fpd.apu.gic), irq_idx); +} + +static void versal_sysbus_connect_irq (Versal *s,SysBusDevice *sbd, +int sbd_idx,int irq_idx) +{ +qemu_irq irq =versal_get_irq (s, irq_idx); + +if (irq ==NULL ) { +return ; + } + +sysbus_connect_irq (sbd, sbd_idx, irq); +} + +static inline char *versal_fdt_add_subnode (Versal *s,const char *path, +uint64_t at,const char *compat, +size_t compat_sz) +{ +char *p; + + p =g_strdup_printf ("%s@%" PRIx64, path, at); +qemu_fdt_add_subnode (s->cfg.fdt, p); + +if (!strncmp (compat,"memory" , compat_sz)) { +qemu_fdt_setprop (s->cfg.fdt, p,"device_type" , compat, compat_sz); + }else { +qemu_fdt_setprop (s->cfg.fdt, p,"compatible" , compat, compat_sz); + } + +return p; +} + +static inline char *versal_fdt_add_simple_subnode (Versal *s,const char *path, +uint64_t addr,uint64_t len, +const char *compat, +size_t compat_sz) +{ +char *p =versal_fdt_add_subnode (s, path, addr, compat, compat_sz); + +qemu_fdt_setprop_sized_cells (s->cfg.fdt, p,"reg" ,2 , addr,2 , len); +return p; +} +static void versal_create_apu_cpus (Versal *s) {int i; object_initialize_child(OBJECT(s), "apu-cluster", &s->fpd.apu.cluster,@@ -165,32 +243,48 @@ static void versal_create_rpu_cpus(Versal *s) }qdev_realize (DEVICE (&s->lpd.rpu.cluster),NULL , &error_fatal); } -static void versal_create_uarts (Versal *s,qemu_irq *pic) +static void versal_create_uart (Versal *s, +const VersalSimplePeriphMap *map, +int chardev_idx) { -int i; +DeviceState *dev; +MemoryRegion *mr; + g_autofree char *node; + g_autofree char *alias; +const char compatible[] ="arm,pl011\0arm,sbsa-uart" ; +const char clocknames[] ="uartclk\0apb_pclk" ; -for (i =0 ; i <ARRAY_SIZE (s->lpd.iou.uart); i++) { -static const int irqs[] = {VERSAL_UART0_IRQ_0 ,VERSAL_UART1_IRQ_0 }; -static const uint64_t addrs[] = {MM_UART0 ,MM_UART1 }; -char *name =g_strdup_printf ("uart%d" , i); -DeviceState *dev; -MemoryRegion *mr; + dev =qdev_new (TYPE_PL011 ); +object_property_add_child (OBJECT (s),"uart[*]" ,OBJECT (dev)); +qdev_prop_set_chr (dev,"chardev" ,serial_hd (chardev_idx)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); -object_initialize_child (OBJECT (s), name, &s->lpd.iou.uart[i], -TYPE_PL011 ); - dev =DEVICE (&s->lpd.iou.uart[i]); -qdev_prop_set_chr (dev,"chardev" ,serial_hd (i)); -sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); +memory_region_add_subregion (&s->mr_ps, map->addr, mr); - mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ); -memory_region_add_subregion (&s->mr_ps, addrs[i], mr); +versal_sysbus_connect_irq (s,SYS_BUS_DEVICE (dev),0 , map->irq); -sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[irqs[i]]); -g_free (name); + node =versal_fdt_add_simple_subnode (s,"/uart" , map->addr,0x1000 , + compatible,sizeof (compatible)); +qemu_fdt_setprop_cell (s->cfg.fdt, node,"current-speed" ,115200 ); +qemu_fdt_setprop_cells (s->cfg.fdt, node,"clocks" , + s->phandle.clk_125mhz, s->phandle.clk_125mhz); +qemu_fdt_setprop (s->cfg.fdt, node,"clock-names" , clocknames, +sizeof (clocknames)); +qemu_fdt_setprop_cells (s->cfg.fdt, node,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI , map->irq, +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop (s->cfg.fdt, node,"u-boot,dm-pre-reloc" ,NULL ,0 ); + + alias =g_strdup_printf ("serial%d" , chardev_idx); +qemu_fdt_setprop_string (s->cfg.fdt,"/aliases" , alias, node); + +if (chardev_idx ==0 ) { +qemu_fdt_setprop_string (s->cfg.fdt,"/chosen" ,"stdout-path" , node); } }static void versal_create_canfds (Versal *s,qemu_irq *pic) {@@ -781,18 +875,10 @@ static void versal_create_crl(Versal *s, qemu_irq *pic)object_property_set_link (OBJECT (&s->lpd.crl), name,OBJECT (&s->lpd.iou.adma[i]), &error_abort); } -for (i =0 ; i <ARRAY_SIZE (s->lpd.iou.uart); i++) { - g_autofree gchar *name = g_strdup_printf("uart[%d]", i); - -object_property_set_link (OBJECT (&s->lpd.crl), - name,OBJECT (&s->lpd.iou.uart[i]), - &error_abort); - } -object_property_set_link (OBJECT (&s->lpd.crl),"usb" ,OBJECT (&s->lpd.iou.usb), &error_abort);sysbus_realize (sbd, &error_fatal);@@ -955,11 +1041,15 @@ static void versal_realize(DeviceState *dev, Error **errp) s->phandle.clk_125mhz =fdt_add_clk_node (s,"/clk125" ,125 *1000 *1000 );versal_create_apu_cpus (s);versal_create_apu_gic (s, pic);versal_create_rpu_cpus (s); -versal_create_uarts (s, pic); + +for (i =0 ; i < map->num_uart; i++) { +versal_create_uart (s, &map->uart[i], i); + } +versal_create_canfds (s, pic);versal_create_usbs (s, pic);versal_create_gems (s, pic);versal_create_admas (s, pic);versal_create_sds (s, pic);Signature · 1 line
2.50.1
PATCH v3 4/47 hw/arm/xlnx-versal: canfd: refactor creation
In reply to Luc MichelRefactor the CAN controllers creation using the VersalMap structure.
Note that the connection to the CRL is removed for now and will be re-added by next commits.
The xlnx-versal-virt machine now dynamically creates the correct amount of CAN bus link properties based on the number of CAN controller advertised by the SoC.
--- include/hw/arm/xlnx-versal.h | 7 +-- hw/arm/xlnx-versal-virt.c | 73 ++++++++++-------------------- hw/arm/xlnx-versal.c | 86 +++++++++++++++++++++++++----------- 3 files changed, 87 insertions(+), 79 deletions(-)
include/hw/arm/xlnx-versal.h +4 -3
@@ -29,11 +29,11 @@#include "hw/ssi/xlnx-versal-ospi.h" #include "hw/dma/xlnx_csu_dma.h" #include "hw/misc/xlnx-versal-crl.h" #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/misc/xlnx-versal-trng.h" -#include "hw/net/xlnx-versal-canfd.h" +#include "net/can_emu.h" #include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h" #include "target/arm/cpu.h" #include "hw/arm/xlnx-versal-version.h"
@@ -81,12 +81,10 @@ struct Versal {struct {CadenceGEMState gem[XLNX_VERSAL_NR_GEMS ];OrIRQState gem_irq_orgate[XLNX_VERSAL_NR_GEMS ];XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ];VersalUsb2 usb; -CanBusState *canbus[XLNX_VERSAL_NR_CANFD ]; -XlnxVersalCANFDState canfd[XLNX_VERSAL_NR_CANFD ]; } iou;/* Real-time Processing Unit. */ struct {MemoryRegion mr;
@@ -139,10 +137,11 @@ struct Versal {uint32_t clk_125mhz; } phandle;struct {MemoryRegion *mr_ddr; +CanBusState **canbus;void *fdt; } cfg; };struct VersalClass {
@@ -155,10 +154,12 @@ static inline void versal_set_fdt(Versal *s, void *fdt) {g_assert (!qdev_is_realized (DEVICE (s))); s->cfg.fdt = fdt; } +int versal_get_num_can (VersalVersion version); +/* Memory-map and IRQ definitions. Copied a subset from * auto-generated files. */ #define VERSAL_GIC_MAINT_IRQ 9#define VERSAL_TIMER_VIRT_IRQ 11
hw/arm/xlnx-versal-virt.c +24 -49
130 lines not on this page · raw message
hw/arm/xlnx-versal.c +59 -27
164 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 5/47 hw/arm/xlnx-versal: sdhci: refactor creation
In reply to Luc MichelRefactor the SDHCI controllers creation using the VersalMap structure.
--- include/hw/arm/xlnx-versal.h | 5 +- hw/arm/xlnx-versal-virt.c | 43 ++-------------- hw/arm/xlnx-versal.c | 96 ++++++++++++++++++++++++++++-------- 3 files changed, 83 insertions(+), 61 deletions(-)
include/hw/arm/xlnx-versal.h +3 -2
@@ -14,11 +14,10 @@#define XLNX_VERSAL_H #include "hw/sysbus.h" #include "hw/cpu/cluster.h" #include "hw/or-irq.h" -#include "hw/sd/sdhci.h" #include "hw/intc/arm_gicv3.h" #include "hw/dma/xlnx-zdma.h" #include "hw/net/cadence_gem.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h"
@@ -103,11 +102,10 @@ struct Versal { } lpd;/* The Platform Management Controller subsystem. */ struct { struct { - SDHCIState sd[XLNX_VERSAL_NR_SDS]; XlnxVersalPmcIouSlcr slcr; struct { XlnxVersalOspi ospi; XlnxCSUDMA dma_src;
@@ -154,11 +152,14 @@ static inline void versal_set_fdt(Versal *s, void *fdt) {g_assert (!qdev_is_realized (DEVICE (s))); s->cfg.fdt = fdt; } +void versal_sdhci_plug_card (Versal *s,int sd_idx,BlockBackend *blk); +int versal_get_num_can (VersalVersion version); +int versal_get_num_sdhci (VersalVersion version);/* Memory-map and IRQ definitions. Copied a subset from * auto-generated files. */ #define VERSAL_GIC_MAINT_IRQ 9
hw/arm/xlnx-versal-virt.c +5 -38
86 lines not on this page · raw message
hw/arm/xlnx-versal.c +75 -21
182 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 6/47 hw/arm/xlnx-versal: gem: refactor creation
In reply to Luc MichelRefactor the GEM ethernet controllers creation using the VersalMap structure.
Note that the connection to the CRL is removed for now and will be re-added by next commits.
--- include/hw/arm/xlnx-versal.h | 3 - hw/arm/xlnx-versal-virt.c | 54 ------------- hw/arm/xlnx-versal.c | 151 +++++++++++++++++++++++++---------- 3 files changed, 108 insertions(+), 100 deletions(-)
include/hw/arm/xlnx-versal.h +0 -3
@@ -16,11 +16,10 @@#include "hw/sysbus.h" #include "hw/cpu/cluster.h" #include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "hw/dma/xlnx-zdma.h" -#include "hw/net/cadence_gem.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/usb/xlnx-usb-subsystem.h" #include "hw/misc/xlnx-versal-xramc.h" #include "hw/nvram/xlnx-bbram.h"
@@ -76,12 +75,10 @@ struct Versal {struct {MemoryRegion mr_ocm;struct { -CadenceGEMState gem[XLNX_VERSAL_NR_GEMS ]; -OrIRQState gem_irq_orgate[XLNX_VERSAL_NR_GEMS ];XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ];VersalUsb2 usb; } iou;/* Real-time Processing Unit. */
hw/arm/xlnx-versal-virt.c +0 -54
103 lines not on this page · raw message
hw/arm/xlnx-versal.c +108 -43
238 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 7/47 hw/arm/xlnx-versal: adma: refactor creation
In reply to Luc MichelRefactor the ADMA creation using the VersalMap structure.
Note that the connection to the CRL is removed for now and will be re-added by next commits.
--- include/hw/arm/xlnx-versal.h | 2 - hw/arm/xlnx-versal-virt.c | 28 -------------- hw/arm/xlnx-versal.c | 72 ++++++++++++++++++++++++------------ 3 files changed, 48 insertions(+), 54 deletions(-)
include/hw/arm/xlnx-versal.h +0 -2
@@ -15,11 +15,10 @@#include "hw/sysbus.h" #include "hw/cpu/cluster.h" #include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" -#include "hw/dma/xlnx-zdma.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/usb/xlnx-usb-subsystem.h" #include "hw/misc/xlnx-versal-xramc.h" #include "hw/nvram/xlnx-bbram.h"
@@ -75,11 +74,10 @@ struct Versal {struct {MemoryRegion mr_ocm;struct { -XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS ];VersalUsb2 usb; } iou;/* Real-time Processing Unit. */ struct {
hw/arm/xlnx-versal-virt.c +0 -28
@@ -202,37 +202,10 @@ static void fdt_add_usb_xhci_nodes(VersalVirt *s)qemu_fdt_setprop_cell (s->fdt, name,"phandle" , s->phandle.dwc);qemu_fdt_setprop_string (s->fdt, name,"maximum-speed" ,"high-speed" );g_free (name); } -static void fdt_add_zdma_nodes (VersalVirt *s) -{ -const char clocknames[] ="clk_main\0clk_apb" ; -const char compat[] ="xlnx,zynqmp-dma-1.0" ; -int i; - -for (i =XLNX_VERSAL_NR_ADMAS -1 ; i >=0 ; i--) { -uint64_t addr =MM_ADMA_CH0 +MM_ADMA_CH0_SIZE * i; -char *name =g_strdup_printf ("/dma@%" PRIx64, addr); - -qemu_fdt_add_subnode (s->fdt, name); - -qemu_fdt_setprop_cell (s->fdt, name,"xlnx,bus-width" ,64 ); -qemu_fdt_setprop_cells (s->fdt, name,"clocks" , - s->phandle.clk_25Mhz, s->phandle.clk_25Mhz); -qemu_fdt_setprop (s->fdt, name,"clock-names" , - clocknames,sizeof (clocknames)); -qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , -GIC_FDT_IRQ_TYPE_SPI ,VERSAL_ADMA_IRQ_0 + i, -GIC_FDT_IRQ_FLAGS_LEVEL_HI ); -qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , -2 , addr,2 ,0x1000 ); -qemu_fdt_setprop (s->fdt, name,"compatible" , compat,sizeof (compat)); -g_free (name); - } -} -static void fdt_add_rtc_node (VersalVirt *s) {const char compat[] ="xlnx,zynqmp-rtc" ;const char interrupt_names[] ="alarm\0sec" ;char *name =g_strdup_printf ("/rtc@%x" ,MM_PMC_RTC );
@@ -556,11 +529,10 @@ static void versal_virt_init(MachineState *machine)fdt_create (s);versal_set_fdt (&s->soc, s->fdt);fdt_add_gic_nodes (s);fdt_add_timer_nodes (s); -fdt_add_zdma_nodes (s);fdt_add_usb_xhci_nodes (s);fdt_add_rtc_node (s);fdt_add_bbram_node (s);fdt_add_efuse_ctrl_node (s);fdt_add_efuse_cache_node (s);
hw/arm/xlnx-versal.c +48 -24
142 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 8/47 hw/arm/xlnx-versal: xram: refactor creation
In reply to Luc MichelRefactor the XRAM devices creation using the VersalMap structure.
--- include/hw/arm/xlnx-versal.h | 6 ---- hw/arm/xlnx-versal.c | 59 +++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 30 deletions(-)
include/hw/arm/xlnx-versal.h +0 -6
@@ -18,11 +18,10 @@#include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/usb/xlnx-usb-subsystem.h" -#include "hw/misc/xlnx-versal-xramc.h" #include "hw/nvram/xlnx-bbram.h" #include "hw/nvram/xlnx-versal-efuse.h" #include "hw/ssi/xlnx-versal-ospi.h" #include "hw/dma/xlnx_csu_dma.h" #include "hw/misc/xlnx-versal-crl.h"
@@ -86,15 +85,10 @@ struct Versal {CPUClusterState cluster;ARMCPU cpu[XLNX_VERSAL_NR_RCPUS ]; } rpu; -struct { -OrIRQState irq_orgate; -XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM ]; - } xram; -XlnxVersalCRL crl; } lpd;/* The Platform Management Controller subsystem. */ struct {
hw/arm/xlnx-versal.c +35 -24
121 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 9/47 hw/arm/xlnx-versal: usb: refactor creation
In reply to Luc MichelRefactor the USB controller creation using the VersalMap structure.
Note that the connection to the CRL is removed for now and will be re-added by next commits.
--- include/hw/arm/xlnx-versal.h | 5 --- hw/arm/xlnx-versal-virt.c | 56 +-------------------------- hw/arm/xlnx-versal.c | 74 +++++++++++++++++++++++++++++------- 3 files changed, 62 insertions(+), 73 deletions(-)
include/hw/arm/xlnx-versal.h +0 -5
@@ -17,11 +17,10 @@#include "hw/cpu/cluster.h" #include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" -#include "hw/usb/xlnx-usb-subsystem.h" #include "hw/nvram/xlnx-bbram.h" #include "hw/nvram/xlnx-versal-efuse.h" #include "hw/ssi/xlnx-versal-ospi.h" #include "hw/dma/xlnx_csu_dma.h" #include "hw/misc/xlnx-versal-crl.h"
@@ -72,14 +71,10 @@ struct Versal { } noc;struct {MemoryRegion mr_ocm; -struct { -VersalUsb2 usb; - } iou; -/* Real-time Processing Unit. */ struct {MemoryRegion mr;MemoryRegion mr_ps_alias;
hw/arm/xlnx-versal-virt.c +1 -55
106 lines not on this page · raw message
hw/arm/xlnx-versal.c +61 -13
149 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 10/47 hw/arm/xlnx-versal: efuse: refactor creation
In reply to Luc MichelRefactore the eFuse devices creation using the VersalMap structure.
Note that the corresponding FDT nodes are removed. They do not correspond to any real node in standard Versal DTBs. No matching drivers exist for them.
--- include/hw/arm/xlnx-versal.h | 5 +-- hw/arm/xlnx-versal-virt.c | 43 ++------------------ hw/arm/xlnx-versal.c | 78 +++++++++++++++++++++++------------- 3 files changed, 54 insertions(+), 72 deletions(-)
include/hw/arm/xlnx-versal.h +1 -4
@@ -18,11 +18,10 @@#include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/nvram/xlnx-bbram.h" -#include "hw/nvram/xlnx-versal-efuse.h" #include "hw/ssi/xlnx-versal-ospi.h" #include "hw/dma/xlnx_csu_dma.h" #include "hw/misc/xlnx-versal-crl.h" #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/misc/xlnx-versal-trng.h"
@@ -100,13 +99,10 @@ struct Versal { } iou;XlnxZynqMPRTC rtc;XlnxVersalTRng trng;XlnxBBRam bbram; -XlnxEFuse efuse; -XlnxVersalEFuseCtrl efuse_ctrl; -XlnxVersalEFuseCache efuse_cache;XlnxVersalCFUAPB cfu_apb;XlnxVersalCFUFDRO cfu_fdro;XlnxVersalCFUSFR cfu_sfr;XlnxVersalCFrameReg cframe[XLNX_VERSAL_NR_CFRAME ];XlnxVersalCFrameBcastReg cframe_bcast;
@@ -137,10 +133,11 @@ static inline void versal_set_fdt(Versal *s, void *fdt)g_assert (!qdev_is_realized (DEVICE (s))); s->cfg.fdt = fdt; }void versal_sdhci_plug_card (Versal *s,int sd_idx,BlockBackend *blk); +void versal_efuse_attach_drive (Versal *s,BlockBackend *blk);int versal_get_num_can (VersalVersion version);int versal_get_num_sdhci (VersalVersion version);/* Memory-map and IRQ definitions. Copied a subset from
hw/arm/xlnx-versal-virt.c +3 -40
90 lines not on this page · raw message
hw/arm/xlnx-versal.c +50 -28
151 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 11/47 hw/arm/xlnx-versal: ospi: refactor creation
In reply to Luc MichelRefactor the OSPI controller creation using the VersalMap structure.
Note that the connection to the PMC IOU SLCR is removed for now and will be re-added by next commits.
--- include/hw/arm/xlnx-versal.h | 12 +-- hw/arm/xlnx-versal-virt.c | 41 ++++------ hw/arm/xlnx-versal.c | 142 ++++++++++++++++++++--------------- 3 files changed, 98 insertions(+), 97 deletions(-)
include/hw/arm/xlnx-versal.h +2 -10
@@ -18,12 +18,10 @@#include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/nvram/xlnx-bbram.h" -#include "hw/ssi/xlnx-versal-ospi.h" -#include "hw/dma/xlnx_csu_dma.h" #include "hw/misc/xlnx-versal-crl.h" #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/misc/xlnx-versal-trng.h" #include "net/can_emu.h" #include "hw/misc/xlnx-versal-cfu.h"
@@ -86,18 +84,10 @@ struct Versal {/* The Platform Management Controller subsystem. */ struct {struct {XlnxVersalPmcIouSlcr slcr; - -struct { -XlnxVersalOspi ospi; -XlnxCSUDMA dma_src; -XlnxCSUDMA dma_dst; -MemoryRegion linear_mr; -OrIRQState irq_orgate; - } ospi; } iou;XlnxZynqMPRTC rtc;XlnxVersalTRng trng;XlnxBBRam bbram;
@@ -134,10 +124,12 @@ static inline void versal_set_fdt(Versal *s, void *fdt) s->cfg.fdt = fdt; }void versal_sdhci_plug_card (Versal *s,int sd_idx,BlockBackend *blk);void versal_efuse_attach_drive (Versal *s,BlockBackend *blk); +void versal_ospi_create_flash (Versal *s,int flash_idx,const char *flash_mdl, +BlockBackend *blk);int versal_get_num_can (VersalVersion version);int versal_get_num_sdhci (VersalVersion version);/* Memory-map and IRQ definitions. Copied a subset from
hw/arm/xlnx-versal-virt.c +15 -26
99 lines not on this page · raw message
hw/arm/xlnx-versal.c +81 -61
237 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 12/47 hw/arm/xlnx-versal: VersalMap: add support for OR'ed IRQs
In reply to Luc MichelImprove the IRQ index in the VersalMap structure to turn it into a descriptor:
- the lower 16 bits still represent the IRQ index
- bit 18 is used to indicate a shared IRQ connected to a OR gate
- bits 19 to 22 indicate the index on the OR gate.
This allows to share an IRQ among multiple devices. An OR gate is created to connect the devices to the actual IRQ pin.
--- hw/arm/xlnx-versal.c | 62 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)
hw/arm/xlnx-versal.c +61 -1
@@ -41,10 +41,21 @@#define GEM_REVISION 0x40070106#define VERSAL_NUM_PMC_APB_IRQS 18#define NUM_OSPI_IRQ_LINES 3 +/* +* IRQ descriptor to catch the following cases: +* - Multiple devices can connect to the same IRQ. They are OR'ed together. +*/ +FIELD(VERSAL_IRQ, IRQ, 0, 16) +FIELD(VERSAL_IRQ, ORED, 18, 1) +FIELD(VERSAL_IRQ, OR_IDX, 19, 4) /* input index on the IRQ OR gate */ + +#define OR_IRQ (irq, or_idx) \ + (R_VERSAL_IRQ_ORED_MASK | ((or_idx) << R_VERSAL_IRQ_OR_IDX_SHIFT) | (irq)) +typedef struct VersalSimplePeriphMap {uint64_t addr;int irq; }VersalSimplePeriphMap ;
@@ -172,13 +183,56 @@ static inline Object *versal_get_child_idx(Versal *s, const char *child, g_autofree char *n = g_strdup_printf("%s[%zu]", child, idx);return versal_get_child (s, n); } +/* +* When the R_VERSAL_IRQ_ORED flag is set on an IRQ descriptor, this function is +* used to return the corresponding or gate input IRQ. The or gate is created if +* not already existant. +* +* Or gates are placed under the /soc/irq-or-gates QOM container. +*/ +static qemu_irq versal_get_irq_or_gate_in (Versal *s,int irq_idx, +qemu_irq target_irq) +{ +Object *container =versal_get_child (s,"irq-or-gates" ); +DeviceState *dev; + g_autofree char *name; +int idx, or_idx; + + idx =FIELD_EX32 (irq_idx,VERSAL_IRQ ,IRQ ); + or_idx =FIELD_EX32 (irq_idx,VERSAL_IRQ ,OR_IDX ); + + name =g_strdup_printf ("irq[%d]" , idx); + dev =DEVICE (object_resolve_path_at (container, name)); + +if (dev ==NULL ) { + dev =qdev_new (TYPE_OR_IRQ ); +object_property_add_child (container, name,OBJECT (dev)); +qdev_prop_set_uint16 (dev,"num-lines" ,1 <<R_VERSAL_IRQ_OR_IDX_LENGTH ); +qdev_realize_and_unref (dev,NULL , &error_abort); +qdev_connect_gpio_out (dev,0 , target_irq); + } + +return qdev_get_gpio_in (dev, or_idx); +} +static qemu_irq versal_get_irq (Versal *s,int irq_idx) { -return qdev_get_gpio_in (DEVICE (&s->fpd.apu.gic), irq_idx); +qemu_irq irq; +bool ored; + + ored =FIELD_EX32 (irq_idx,VERSAL_IRQ ,ORED ); + + irq =qdev_get_gpio_in (DEVICE (&s->fpd.apu.gic), irq_idx); + +if (ored) { + irq =versal_get_irq_or_gate_in (s, irq_idx, irq); + } + +return irq; }static void versal_sysbus_connect_irq (Versal *s,SysBusDevice *sbd,int sbd_idx,int irq_idx) {
@@ -1209,10 +1263,11 @@ static uint32_t fdt_add_clk_node(Versal *s, const char *name,static void versal_realize (DeviceState *dev,Error **errp) {Versal *s =XLNX_VERSAL_BASE (dev);qemu_irq pic[XLNX_VERSAL_NR_IRQS ]; +Object *container;const VersalMap *map =versal_get_map (s);size_t i;if (s->cfg.fdt ==NULL ) {int fdt_size;
@@ -1223,10 +1278,15 @@ static void versal_realize(DeviceState *dev, Error **errp) s->phandle.clk_25mhz =fdt_add_clk_node (s,"/clk25" ,25 *1000 *1000 ); s->phandle.clk_125mhz =fdt_add_clk_node (s,"/clk125" ,125 *1000 *1000 );versal_create_apu_cpus (s);versal_create_apu_gic (s, pic); + + container =object_new (TYPE_CONTAINER ); +object_property_add_child (OBJECT (s),"irq-or-gates" , container); +object_unref (container); +versal_create_rpu_cpus (s);for (i =0 ; i < map->num_uart; i++) {versal_create_uart (s, &map->uart[i], i); }
Signature · 1 line
2.50.1
PATCH v3 13/47 hw/arm/xlnx-versal: PMC IOU SCLR: refactor creation
In reply to Luc MichelRefactor the PMC IOU SLCR device creation using the VersalMap structure. This is the first user of a shared IRQ using an OR gate. The OSPI controller is reconnected to the SLCR.
--- include/hw/arm/xlnx-versal.h | 5 ---- hw/arm/xlnx-versal.c | 48 +++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 25 deletions(-)
include/hw/arm/xlnx-versal.h +0 -5
@@ -19,11 +19,10 @@#include "hw/intc/arm_gicv3.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/nvram/xlnx-bbram.h" #include "hw/misc/xlnx-versal-crl.h" -#include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/misc/xlnx-versal-trng.h" #include "net/can_emu.h" #include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h" #include "target/arm/cpu.h"
@@ -82,14 +81,10 @@ struct Versal {XlnxVersalCRL crl; } lpd;/* The Platform Management Controller subsystem. */ struct { -struct { -XlnxVersalPmcIouSlcr slcr; - } iou; -XlnxZynqMPRTC rtc;XlnxVersalTRng trng;XlnxBBRam bbram;XlnxVersalCFUAPB cfu_apb;XlnxVersalCFUFDRO cfu_fdro;
hw/arm/xlnx-versal.c +28 -20
147 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 14/47 hw/arm/xlnx-versal: bbram: refactor creation
In reply to Luc MichelRefactor the BBRAM device creation using the VersalMap structure.
Note that the corresponding FDT node is removed. It does not correspond to any real node in standard Versal DTBs. No matching drivers exist for it.
--- include/hw/arm/xlnx-versal.h | 3 +-- hw/arm/xlnx-versal-virt.c | 27 +++--------------------- hw/arm/xlnx-versal.c | 41 +++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 38 deletions(-)
include/hw/arm/xlnx-versal.h +1 -2
@@ -17,11 +17,10 @@#include "hw/cpu/cluster.h" #include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" -#include "hw/nvram/xlnx-bbram.h" #include "hw/misc/xlnx-versal-crl.h" #include "hw/misc/xlnx-versal-trng.h" #include "net/can_emu.h" #include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h"
@@ -83,11 +82,10 @@ struct Versal {/* The Platform Management Controller subsystem. */ struct {XlnxZynqMPRTC rtc;XlnxVersalTRng trng; -XlnxBBRam bbram;XlnxVersalCFUAPB cfu_apb;XlnxVersalCFUFDRO cfu_fdro;XlnxVersalCFUSFR cfu_sfr;XlnxVersalCFrameReg cframe[XLNX_VERSAL_NR_CFRAME ];XlnxVersalCFrameBcastReg cframe_bcast;
@@ -119,10 +117,11 @@ static inline void versal_set_fdt(Versal *s, void *fdt) s->cfg.fdt = fdt; }void versal_sdhci_plug_card (Versal *s,int sd_idx,BlockBackend *blk);void versal_efuse_attach_drive (Versal *s,BlockBackend *blk); +void versal_bbram_attach_drive (Versal *s,BlockBackend *blk);void versal_ospi_create_flash (Versal *s,int flash_idx,const char *flash_mdl,BlockBackend *blk);int versal_get_num_can (VersalVersion version);int versal_get_num_sdhci (VersalVersion version);
hw/arm/xlnx-versal-virt.c +3 -24
@@ -170,30 +170,10 @@ static void fdt_add_rtc_node(VersalVirt *s) 2, MM_PMC_RTC, 2, MM_PMC_RTC_SIZE);qemu_fdt_setprop (s->fdt, name,"compatible" , compat,sizeof (compat));g_free (name); } -static void fdt_add_bbram_node (VersalVirt *s) -{ -const char compat[] =TYPE_XLNX_BBRAM ; -const char interrupt_names[] ="bbram-error" ; -char *name =g_strdup_printf ("/bbram@%x" ,MM_PMC_BBRAM_CTRL ); - -qemu_fdt_add_subnode (s->fdt, name); - -qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , -GIC_FDT_IRQ_TYPE_SPI ,VERSAL_PMC_APB_IRQ , -GIC_FDT_IRQ_FLAGS_LEVEL_HI ); -qemu_fdt_setprop (s->fdt, name,"interrupt-names" , - interrupt_names,sizeof (interrupt_names)); -qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , -2 ,MM_PMC_BBRAM_CTRL , -2 ,MM_PMC_BBRAM_CTRL_SIZE ); -qemu_fdt_setprop (s->fdt, name,"compatible" , compat,sizeof (compat)); -g_free (name); -} -static void fdt_nop_memory_nodes (void *fdt,Error **errp) {Error *err =NULL ;char **node_path;int n =0 ;
@@ -344,19 +324,19 @@ static void create_virtio_regions(VersalVirt *s)qemu_fdt_setprop_string (s->fdt, name,"compatible" ,"virtio,mmio" );g_free (name); } } -static void bbram_attach_drive (XlnxBBRam *dev) +static void bbram_attach_drive (VersalVirt *s) {DriveInfo *dinfo;BlockBackend *blk; dinfo =drive_get_by_index (IF_PFLASH ,0 ); blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ;if (blk) { -qdev_prop_set_drive (DEVICE (dev),"drive" , blk); +versal_bbram_attach_drive (&s->soc, blk); } }static void efuse_attach_drive (VersalVirt *s) {
@@ -442,11 +422,10 @@ static void versal_virt_init(MachineState *machine)fdt_create (s);versal_set_fdt (&s->soc, s->fdt);fdt_add_gic_nodes (s);fdt_add_timer_nodes (s);fdt_add_rtc_node (s); -fdt_add_bbram_node (s);fdt_add_cpu_nodes (s, psci_conduit);fdt_add_clk_node (s,"/old-clk125" ,125000000 , s->phandle.clk_125Mhz);fdt_add_clk_node (s,"/old-clk25" ,25000000 , s->phandle.clk_25Mhz);sysbus_realize (SYS_BUS_DEVICE (&s->soc), &error_fatal);
@@ -456,11 +435,11 @@ static void versal_virt_init(MachineState *machine)* modules unaware of multiple address-spaces. */ memory_region_add_subregion_overlap (get_system_memory (),0 , &s->soc.fpd.apu.mr,0 );/* Attach bbram backend, if given */ -bbram_attach_drive (&s->soc.pmc.bbram); +bbram_attach_drive (s);/* Attach efuse backend, if given */ efuse_attach_drive (s);/* Plug SD cards */
hw/arm/xlnx-versal.c +29 -12
109 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 15/47 hw/arm/xlnx-versal: trng: refactor creation
In reply to Luc MichelRefactor the TRNG device creation using the VersalMap structure.
--- include/hw/arm/xlnx-versal.h | 2 -- hw/arm/xlnx-versal.c | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-)
include/hw/arm/xlnx-versal.h +0 -2
@@ -18,11 +18,10 @@#include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/misc/xlnx-versal-crl.h" -#include "hw/misc/xlnx-versal-trng.h" #include "net/can_emu.h" #include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h" #include "target/arm/cpu.h" #include "hw/arm/xlnx-versal-version.h"
@@ -81,11 +80,10 @@ struct Versal { } lpd;/* The Platform Management Controller subsystem. */ struct {XlnxZynqMPRTC rtc; -XlnxVersalTRng trng;XlnxVersalCFUAPB cfu_apb;XlnxVersalCFUFDRO cfu_fdro;XlnxVersalCFUSFR cfu_sfr;XlnxVersalCFrameReg cframe[XLNX_VERSAL_NR_CFRAME ];XlnxVersalCFrameBcastReg cframe_bcast;
hw/arm/xlnx-versal.c +10 -8
@@ -35,10 +35,11 @@#include "hw/usb/xlnx-usb-subsystem.h" #include "hw/nvram/xlnx-versal-efuse.h" #include "hw/ssi/xlnx-versal-ospi.h" #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/nvram/xlnx-bbram.h" +#include "hw/misc/xlnx-versal-trng.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106
@@ -119,10 +120,11 @@ typedef struct VersalMap {int irq; } ospi;VersalSimplePeriphMap pmc_iou_slcr;VersalSimplePeriphMap bbram; +VersalSimplePeriphMap trng; } VersalMap;static const VersalMap VERSAL_MAP = { .uart[0 ] = {0xff000000 ,18 }, .uart[1 ] = {0xff010000 ,19 },
@@ -162,10 +164,11 @@ static const VersalMap VERSAL_MAP = { .irq = 124, }, .pmc_iou_slcr = { 0xf1060000, OR_IRQ(121, 0) }, .bbram = { 0xf11f0000, OR_IRQ(121, 1) }, + .trng = { 0xf1230000, 141 }, };static const VersalMap *VERSION_TO_MAP [] = { [VERSAL_VER_VERSAL ] = &VERSAL_MAP , };
@@ -771,23 +774,22 @@ static void versal_create_rtc(Versal *s, qemu_irq *pic)*/ sysbus_connect_irq (sbd,1 ,qdev_get_gpio_in (DEVICE (&s->pmc.apb_irq_orgate),0 )); } -static void versal_create_trng (Versal *s,qemu_irq *pic) +static void versal_create_trng (Versal *s,const VersalSimplePeriphMap *map) {SysBusDevice *sbd;MemoryRegion *mr; -object_initialize_child (OBJECT (s),"trng" , &s->pmc.trng, -TYPE_XLNX_VERSAL_TRNG ); - sbd =SYS_BUS_DEVICE (&s->pmc.trng); -sysbus_realize (sbd, &error_fatal); + sbd =SYS_BUS_DEVICE (qdev_new (TYPE_XLNX_VERSAL_TRNG )); +object_property_add_child (OBJECT (s),"trng" ,OBJECT (sbd)); +sysbus_realize_and_unref (sbd, &error_abort); mr =sysbus_mmio_get_region (sbd,0 ); -memory_region_add_subregion (&s->mr_ps,MM_PMC_TRNG , mr); -sysbus_connect_irq (sbd,0 , pic[VERSAL_TRNG_IRQ ]); +memory_region_add_subregion (&s->mr_ps, map->addr, mr); +versal_sysbus_connect_irq (s, sbd,0 , map->irq); }static void versal_create_xrams (Versal *s,const struct VersalXramMap *map) {SysBusDevice *sbd;
@@ -1327,14 +1329,14 @@ static void versal_realize(DeviceState *dev, Error **errp)qdev_connect_gpio_out_named (slcr,"ospi-mux-sel" ,0 ,qdev_get_gpio_in_named (ospi,"ospi-mux-sel" ,0 ));versal_create_bbram (s, &map->bbram); +versal_create_trng (s, &map->trng);versal_create_pmc_apb_irq_orgate (s, pic);versal_create_rtc (s, pic); -versal_create_trng (s, pic);versal_create_crl (s, pic);versal_create_cfu (s, pic);versal_map_ddr (s);versal_unimp (s);
Signature · 1 line
2.50.1
PATCH v3 16/47 hw/arm/xlnx-versal: rtc: refactor creation
In reply to Luc MichelRefactor the RTC device creation using the VersalMap structure.
The sysbus IRQ output 0 (APB IRQ) is connected instead of the output 1 (addr error IRQ). This does not change the current behaviour since the RTC model does not implement those IRQs anyway.
--- include/hw/arm/xlnx-versal.h | 2 -- hw/arm/xlnx-versal-virt.c | 22 -------------------- hw/arm/xlnx-versal.c | 40 ++++++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 33 deletions(-)
include/hw/arm/xlnx-versal.h +0 -2
@@ -15,11 +15,10 @@#include "hw/sysbus.h" #include "hw/cpu/cluster.h" #include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" -#include "hw/rtc/xlnx-zynqmp-rtc.h" #include "qom/object.h" #include "hw/misc/xlnx-versal-crl.h" #include "net/can_emu.h" #include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h"
@@ -79,11 +78,10 @@ struct Versal {XlnxVersalCRL crl; } lpd;/* The Platform Management Controller subsystem. */ struct { -XlnxZynqMPRTC rtc;XlnxVersalCFUAPB cfu_apb;XlnxVersalCFUFDRO cfu_fdro;XlnxVersalCFUSFR cfu_sfr;XlnxVersalCFrameReg cframe[XLNX_VERSAL_NR_CFRAME ];XlnxVersalCFrameBcastReg cframe_bcast;
hw/arm/xlnx-versal-virt.c +0 -22
@@ -149,31 +149,10 @@ static void fdt_add_timer_nodes(VersalVirt *s) GIC_FDT_IRQ_TYPE_PPI, VERSAL_TIMER_NS_EL2_IRQ, irqflags);qemu_fdt_setprop (s->fdt,"/timer" ,"compatible" , compat,sizeof (compat)); } -static void fdt_add_rtc_node (VersalVirt *s) -{ -const char compat[] ="xlnx,zynqmp-rtc" ; -const char interrupt_names[] ="alarm\0sec" ; -char *name =g_strdup_printf ("/rtc@%x" ,MM_PMC_RTC ); - -qemu_fdt_add_subnode (s->fdt, name); - -qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , -GIC_FDT_IRQ_TYPE_SPI ,VERSAL_RTC_ALARM_IRQ , -GIC_FDT_IRQ_FLAGS_LEVEL_HI , -GIC_FDT_IRQ_TYPE_SPI ,VERSAL_RTC_SECONDS_IRQ , -GIC_FDT_IRQ_FLAGS_LEVEL_HI ); -qemu_fdt_setprop (s->fdt, name,"interrupt-names" , - interrupt_names,sizeof (interrupt_names)); -qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , -2 ,MM_PMC_RTC ,2 ,MM_PMC_RTC_SIZE ); -qemu_fdt_setprop (s->fdt, name,"compatible" , compat,sizeof (compat)); -g_free (name); -} -static void fdt_nop_memory_nodes (void *fdt,Error **errp) {Error *err =NULL ;char **node_path;int n =0 ;
@@ -421,11 +400,10 @@ static void versal_virt_init(MachineState *machine)fdt_create (s);versal_set_fdt (&s->soc, s->fdt);fdt_add_gic_nodes (s);fdt_add_timer_nodes (s); -fdt_add_rtc_node (s);fdt_add_cpu_nodes (s, psci_conduit);fdt_add_clk_node (s,"/old-clk125" ,125000000 , s->phandle.clk_125Mhz);fdt_add_clk_node (s,"/old-clk25" ,25000000 , s->phandle.clk_25Mhz);sysbus_realize (SYS_BUS_DEVICE (&s->soc), &error_fatal);
hw/arm/xlnx-versal.c +31 -9
@@ -36,10 +36,11 @@#include "hw/nvram/xlnx-versal-efuse.h" #include "hw/ssi/xlnx-versal-ospi.h" #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/nvram/xlnx-bbram.h" #include "hw/misc/xlnx-versal-trng.h" +#include "hw/rtc/xlnx-zynqmp-rtc.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106
@@ -121,10 +122,16 @@ typedef struct VersalMap { } ospi;VersalSimplePeriphMap pmc_iou_slcr;VersalSimplePeriphMap bbram;VersalSimplePeriphMap trng; + +struct VersalRtcMap { +VersalSimplePeriphMap map; +int alarm_irq; +int second_irq; + } rtc; } VersalMap;static const VersalMap VERSAL_MAP = { .uart[0 ] = {0xff000000 ,18 }, .uart[1 ] = {0xff010000 ,19 },
@@ -165,10 +172,14 @@ static const VersalMap VERSAL_MAP = { }, .pmc_iou_slcr = { 0xf1060000, OR_IRQ(121, 0) }, .bbram = { 0xf11f0000, OR_IRQ(121, 1) }, .trng = { 0xf1230000, 141 }, + .rtc = { + { 0xf12a0000, OR_IRQ(121, 2) }, + .alarm_irq = 142, .second_irq = 143 + }, };static const VersalMap *VERSION_TO_MAP [] = { [VERSAL_VER_VERSAL ] = &VERSAL_MAP , };
@@ -753,29 +764,40 @@ static void versal_create_pmc_apb_irq_orgate(Versal *s, qemu_irq *pic) "num-lines", VERSAL_NUM_PMC_APB_IRQS, &error_fatal);qdev_realize (orgate,NULL , &error_fatal);qdev_connect_gpio_out (orgate,0 , pic[VERSAL_PMC_APB_IRQ ]); } -static void versal_create_rtc (Versal *s,qemu_irq *pic) +static void versal_create_rtc (Versal *s,const struct VersalRtcMap *map) {SysBusDevice *sbd;MemoryRegion *mr; + g_autofree char *node; +const char compatible[] ="xlnx,zynqmp-rtc" ; +const char interrupt_names[] ="alarm\0sec" ; -object_initialize_child (OBJECT (s),"rtc" , &s->pmc.rtc, -TYPE_XLNX_ZYNQMP_RTC ); - sbd =SYS_BUS_DEVICE (&s->pmc.rtc); -sysbus_realize (sbd, &error_fatal); + sbd =SYS_BUS_DEVICE (qdev_new (TYPE_XLNX_ZYNQMP_RTC )); +object_property_add_child (OBJECT (s),"rtc" ,OBJECT (sbd)); +sysbus_realize_and_unref (sbd, &error_abort); mr =sysbus_mmio_get_region (sbd,0 ); -memory_region_add_subregion (&s->mr_ps,MM_PMC_RTC , mr); +memory_region_add_subregion (&s->mr_ps, map->map.addr, mr);/* * TODO: Connect the ALARM and SECONDS interrupts once our RTC model * supports them. */ -sysbus_connect_irq (sbd,1 , -qdev_get_gpio_in (DEVICE (&s->pmc.apb_irq_orgate),0 )); +versal_sysbus_connect_irq (s, sbd,0 , map->map.irq); + + node =versal_fdt_add_simple_subnode (s,"/rtc" , map->map.addr,0x10000 , + compatible,sizeof (compatible)); +qemu_fdt_setprop_cells (s->cfg.fdt, node,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI , map->alarm_irq, +GIC_FDT_IRQ_FLAGS_LEVEL_HI , +GIC_FDT_IRQ_TYPE_SPI , map->second_irq, +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop (s->cfg.fdt, node,"interrupt-names" , + interrupt_names,sizeof (interrupt_names)); }static void versal_create_trng (Versal *s,const VersalSimplePeriphMap *map) {SysBusDevice *sbd;
@@ -1330,13 +1352,13 @@ static void versal_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in_named (ospi, "ospi-mux-sel", 0));versal_create_bbram (s, &map->bbram);versal_create_trng (s, &map->trng); +versal_create_rtc (s, &map->rtc);versal_create_pmc_apb_irq_orgate (s, pic); -versal_create_rtc (s, pic);versal_create_crl (s, pic);versal_create_cfu (s, pic);versal_map_ddr (s);versal_unimp (s);
Signature · 1 line
2.50.1
PATCH v3 17/47 hw/arm/xlnx-versal: cfu: refactor creation
In reply to Luc MichelRefactor the CFU device creation using the VersalMap structure. All users of the APB IRQ OR gate have now been converted. The OR gate device can be dropped.
--- include/hw/arm/xlnx-versal.h | 14 -- hw/arm/xlnx-versal.c | 258 ++++++++++++++++------------------- 2 files changed, 115 insertions(+), 157 deletions(-)
include/hw/arm/xlnx-versal.h +0 -14
@@ -13,17 +13,14 @@#ifndef XLNX_VERSAL_H #define XLNX_VERSAL_H #include "hw/sysbus.h" #include "hw/cpu/cluster.h" -#include "hw/or-irq.h" #include "hw/intc/arm_gicv3.h" #include "qom/object.h" #include "hw/misc/xlnx-versal-crl.h" #include "net/can_emu.h" -#include "hw/misc/xlnx-versal-cfu.h" -#include "hw/misc/xlnx-versal-cframe-reg.h" #include "target/arm/cpu.h" #include "hw/arm/xlnx-versal-version.h" #define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base"OBJECT_DECLARE_TYPE (Versal, VersalClass,XLNX_VERSAL_BASE )
@@ -76,21 +73,10 @@ struct Versal { } rpu;XlnxVersalCRL crl; } lpd; -/* The Platform Management Controller subsystem. */ -struct { -XlnxVersalCFUAPB cfu_apb; -XlnxVersalCFUFDRO cfu_fdro; -XlnxVersalCFUSFR cfu_sfr; -XlnxVersalCFrameReg cframe[XLNX_VERSAL_NR_CFRAME ]; -XlnxVersalCFrameBcastReg cframe_bcast; - -OrIRQState apb_irq_orgate; - } pmc; -struct {uint32_t clk_25mhz;uint32_t clk_125mhz; } phandle;
hw/arm/xlnx-versal.c +115 -143
348 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 18/47 hw/arm/xlnx-versal: crl: refactor creation
In reply to Luc MichelRefactor the CRL device creation using the VersalMap structure. The connections to the RPU CPUs are temporarily removed and will be reintroduced with next refactoring commits.
--- include/hw/arm/xlnx-versal.h | 3 --- hw/arm/xlnx-versal.c | 36 +++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 20 deletions(-)
include/hw/arm/xlnx-versal.h +0 -3
@@ -15,11 +15,10 @@#include "hw/sysbus.h" #include "hw/cpu/cluster.h" #include "hw/intc/arm_gicv3.h" #include "qom/object.h" -#include "hw/misc/xlnx-versal-crl.h" #include "net/can_emu.h" #include "target/arm/cpu.h" #include "hw/arm/xlnx-versal-version.h" #define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base"
@@ -69,12 +68,10 @@ struct Versal {MemoryRegion mr_ps_alias;CPUClusterState cluster;ARMCPU cpu[XLNX_VERSAL_NR_RCPUS ]; } rpu; - -XlnxVersalCRL crl; } lpd;struct {uint32_t clk_25mhz;uint32_t clk_125mhz;
hw/arm/xlnx-versal.c +19 -17
@@ -40,10 +40,11 @@#include "hw/misc/xlnx-versal-trng.h" #include "hw/rtc/xlnx-zynqmp-rtc.h" #include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h" #include "hw/or-irq.h" +#include "hw/misc/xlnx-versal-crl.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106
@@ -149,10 +150,12 @@ typedef struct VersalMap {size_t num_cframe;struct VersalCfuCframeCfg {uint32_t blktype_frames[7 ]; } cframe_cfg[15 ]; } cfu; + +VersalSimplePeriphMap crl; } VersalMap;static const VersalMap VERSAL_MAP = { .uart[0 ] = {0xff000000 ,18 }, .uart[1 ] = {0xff010000 ,19 },
@@ -213,10 +216,12 @@ static const VersalMap VERSAL_MAP = { { { 38498, 3841, 15361, 13, 7, 3, 1 } }, { { 38498, 3841, 15361, 13, 7, 3, 1 } }, { { 38498, 3841, 15361, 13, 7, 3, 1 } }, }, }, + + .crl = { 0xff5e0000, 10 }, };static const VersalMap *VERSION_TO_MAP [] = { [VERSAL_VER_VERSAL ] = &VERSAL_MAP , };
@@ -1106,31 +1111,28 @@ static void versal_create_cfu(Versal *s, const struct VersalCfuMap *map)sysbus_realize_and_unref (sbd, &error_fatal);memory_region_add_subregion (&s->mr_ps, map->cfu_sfr,sysbus_mmio_get_region (sbd,0 )); } -static void versal_create_crl (Versal *s,qemu_irq *pic) +static inline void versal_create_crl (Versal *s) { -SysBusDevice *sbd; -int i; +const VersalMap *map; +const char *crl_class; +DeviceState *dev; -object_initialize_child (OBJECT (s),"crl" , &s->lpd.crl, -TYPE_XLNX_VERSAL_CRL ); - sbd =SYS_BUS_DEVICE (&s->lpd.crl); + map =versal_get_map (s); -for (i =0 ; i <ARRAY_SIZE (s->lpd.rpu.cpu); i++) { - g_autofree gchar *name = g_strdup_printf("cpu_r5[%d]", i); + crl_class =TYPE_XLNX_VERSAL_CRL ; + dev =qdev_new (crl_class); +object_property_add_child (OBJECT (s),"crl" ,OBJECT (dev)); -object_property_set_link (OBJECT (&s->lpd.crl), - name,OBJECT (&s->lpd.rpu.cpu[i]), - &error_abort); - } +sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_abort); -sysbus_realize (sbd, &error_fatal); -memory_region_add_subregion (&s->mr_ps,MM_CRL , -sysbus_mmio_get_region (sbd,0 )); -sysbus_connect_irq (sbd,0 , pic[VERSAL_CRL_IRQ ]); +memory_region_add_subregion (&s->mr_ps, map->crl.addr, +sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 )); + +versal_sysbus_connect_irq (s,SYS_BUS_DEVICE (dev),0 , map->crl.irq); }/* This takes the board allocated linear DDR memory and creates aliases * for each split DDR range/aperture on the Versal address map. */
@@ -1327,12 +1329,12 @@ static void versal_realize(DeviceState *dev, Error **errp)versal_create_bbram (s, &map->bbram);versal_create_trng (s, &map->trng);versal_create_rtc (s, &map->rtc);versal_create_cfu (s, &map->cfu); +versal_create_crl (s); -versal_create_crl (s, pic);versal_map_ddr (s);versal_unimp (s);/* Create the On Chip Memory (OCM). */ memory_region_init_ram(&s->lpd.mr_ocm, OBJECT(s), "ocm",
Signature · 1 line
2.50.1
PATCH v3 19/47 hw/arm/xlnx-versal-virt: virtio: refactor creation
In reply to Luc MichelRefactor the creation of virtio devices. Use the accessors provided by the Versal SoC to retrieve the reserved MMIO and IRQ space. Those are defined in the VersalMap structure.
--- include/hw/arm/xlnx-versal.h | 3 +++ hw/arm/xlnx-versal-virt.c | 31 ++++++++++++------------------- hw/arm/xlnx-versal.c | 26 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 19 deletions(-)
include/hw/arm/xlnx-versal.h +3 -0
@@ -100,10 +100,13 @@ void versal_sdhci_plug_card(Versal *s, int sd_idx, BlockBackend *blk);void versal_efuse_attach_drive (Versal *s,BlockBackend *blk);void versal_bbram_attach_drive (Versal *s,BlockBackend *blk);void versal_ospi_create_flash (Versal *s,int flash_idx,const char *flash_mdl,BlockBackend *blk); +qemu_irq versal_get_reserved_irq (Versal *s,int idx,int *dtb_idx); +hwaddr versal_get_reserved_mmio_addr (Versal *s); +int versal_get_num_can (VersalVersion version);int versal_get_num_sdhci (VersalVersion version);/* Memory-map and IRQ definitions. Copied a subset from * auto-generated files. */
hw/arm/xlnx-versal-virt.c +12 -19
@@ -269,41 +269,34 @@ static void create_virtio_regions(VersalVirt *s) {int virtio_mmio_size =0x200 ;int i;for (i =0 ; i <NUM_VIRTIO_TRANSPORT ; i++) { -char *name =g_strdup_printf ("virtio%d" , i); -hwaddr base =MM_TOP_RSVD + i * virtio_mmio_size; -int irq =VERSAL_RSVD_IRQ_FIRST + i; +hwaddr base =versal_get_reserved_mmio_addr (&s->soc) + + i * virtio_mmio_size; + g_autofree char *node = g_strdup_printf("/virtio_mmio@%" PRIx64, base); +int dtb_irq;MemoryRegion *mr;DeviceState *dev;qemu_irq pic_irq; - pic_irq =qdev_get_gpio_in (DEVICE (&s->soc.fpd.apu.gic), irq); + pic_irq =versal_get_reserved_irq (&s->soc, i, &dtb_irq); dev =qdev_new ("virtio-mmio" ); -object_property_add_child (OBJECT (&s->soc), name,OBJECT (dev)); +object_property_add_child (OBJECT (s),"virtio-mmio[*]" ,OBJECT (dev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic_irq); mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 );memory_region_add_subregion (&s->soc.mr_ps, base, mr); -g_free (name); - } -for (i =0 ; i <NUM_VIRTIO_TRANSPORT ; i++) { -hwaddr base =MM_TOP_RSVD + i * virtio_mmio_size; -int irq =VERSAL_RSVD_IRQ_FIRST + i; -char *name =g_strdup_printf ("/virtio_mmio@%" PRIx64, base); - -qemu_fdt_add_subnode (s->fdt, name); -qemu_fdt_setprop (s->fdt, name,"dma-coherent" ,NULL ,0 ); -qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , -GIC_FDT_IRQ_TYPE_SPI , irq, +qemu_fdt_add_subnode (s->fdt, node); +qemu_fdt_setprop (s->fdt, node,"dma-coherent" ,NULL ,0 ); +qemu_fdt_setprop_cells (s->fdt, node,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI , dtb_irq,GIC_FDT_IRQ_FLAGS_EDGE_LO_HI ); -qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +qemu_fdt_setprop_sized_cells (s->fdt, node,"reg" ,2 , base,2 , virtio_mmio_size); -qemu_fdt_setprop_string (s->fdt, name,"compatible" ,"virtio,mmio" ); -g_free (name); +qemu_fdt_setprop_string (s->fdt, node,"compatible" ,"virtio,mmio" ); } }static void bbram_attach_drive (VersalVirt *s) {
hw/arm/xlnx-versal.c +26 -0
@@ -152,10 +152,17 @@ typedef struct VersalMap {uint32_t blktype_frames[7 ]; } cframe_cfg[15 ]; } cfu;VersalSimplePeriphMap crl; + +/* reserved MMIO/IRQ space that can safely be used for virtio devices */ +struct VersalReserved { +uint64_t mmio_start; +int irq_start; +int irq_num; + } reserved; } VersalMap;static const VersalMap VERSAL_MAP = { .uart[0 ] = {0xff000000 ,18 }, .uart[1 ] = {0xff010000 ,19 },
@@ -218,10 +225,12 @@ static const VersalMap VERSAL_MAP = { { { 38498, 3841, 15361, 13, 7, 3, 1 } }, }, }, .crl = { 0xff5e0000, 10 }, + + .reserved = { 0xa0000000, 111, 8 }, };static const VersalMap *VERSION_TO_MAP [] = { [VERSAL_VER_VERSAL ] = &VERSAL_MAP , };
@@ -1411,10 +1420,27 @@ void versal_ospi_create_flash(Versal *s, int flash_idx, const char *flash_mdl,sysbus_connect_irq (SYS_BUS_DEVICE (ospi), flash_idx +1 , cs_line); } +qemu_irq versal_get_reserved_irq (Versal *s,int idx,int *dtb_idx) +{ +const VersalMap *map =versal_get_map (s); + +g_assert (idx < map->reserved.irq_num); + + *dtb_idx = map->reserved.irq_start + idx; +return versal_get_irq (s, *dtb_idx); +} + +hwaddr versal_get_reserved_mmio_addr (Versal *s) +{ +const VersalMap *map =versal_get_map (s); + +return map->reserved.mmio_start; +} +int versal_get_num_can (VersalVersion version) {const VersalMap *map =VERSION_TO_MAP [version];return map->num_canfd;
Signature · 1 line
2.50.1
PATCH v3 20/47 hw/arm/xlnx-versal: refactor CPU cluster creation
In reply to Luc MichelRefactor the CPU cluster creation using the VersalMap structure. There is no functional change. The clusters properties are now described in the VersalMap structure. For now only the APU is converted. The RPU will be taken care of by next commits.
--- include/hw/arm/xlnx-versal.h | 12 +- hw/arm/xlnx-versal-virt.c | 80 +------- hw/arm/xlnx-versal.c | 351 ++++++++++++++++++++++++++--------- 3 files changed, 275 insertions(+), 168 deletions(-)
include/hw/arm/xlnx-versal.h +2 -10
@@ -13,11 +13,10 @@#ifndef XLNX_VERSAL_H #define XLNX_VERSAL_H #include "hw/sysbus.h" #include "hw/cpu/cluster.h" -#include "hw/intc/arm_gicv3.h" #include "qom/object.h" #include "net/can_emu.h" #include "target/arm/cpu.h" #include "hw/arm/xlnx-versal-version.h"
@@ -41,19 +40,10 @@ OBJECT_DECLARE_TYPE(Versal, VersalClass, XLNX_VERSAL_BASE)struct Versal {/*< private >*/ SysBusDevice parent_obj;/*< public >*/ -struct { -struct { -MemoryRegion mr; -CPUClusterState cluster; -ARMCPU cpu[XLNX_VERSAL_NR_ACPUS ]; -GICv3State gic; - } apu; - } fpd; -MemoryRegion mr_ps;struct {/* 4 ranges to access DDR. */ MemoryRegion mr_ddr_ranges[4 ];
@@ -73,10 +63,11 @@ struct Versal { } lpd;struct {uint32_t clk_25mhz;uint32_t clk_125mhz; +uint32_t gic; } phandle;struct {MemoryRegion *mr_ddr;CanBusState **canbus;
@@ -94,10 +85,11 @@ static inline void versal_set_fdt(Versal *s, void *fdt) {g_assert (!qdev_is_realized (DEVICE (s))); s->cfg.fdt = fdt; } +DeviceState *versal_get_boot_cpu (Versal *s);void versal_sdhci_plug_card (Versal *s,int sd_idx,BlockBackend *blk);void versal_efuse_attach_drive (Versal *s,BlockBackend *blk);void versal_bbram_attach_drive (Versal *s,BlockBackend *blk);void versal_ospi_create_flash (Versal *s,int flash_idx,const char *flash_mdl,BlockBackend *blk);
hw/arm/xlnx-versal-virt.c +6 -74
144 lines not on this page · raw message
hw/arm/xlnx-versal.c +267 -84
478 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 21/47 hw/arm/xlnx-versal: add the mp_affinity property to the CPU mapping
In reply to Luc MichelAdd a way to configure the MP affinity value of the CPUs given their core and cluster IDs. For the Versal APU CPUs, the MP affinity value is given by the core ID in Aff0.
--- hw/arm/xlnx-versal.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
hw/arm/xlnx-versal.c +16 -0
@@ -88,10 +88,16 @@ typedef struct VersalCpuClusterMap {size_t num_core;size_t num_cluster;uint32_t qemu_cluster_id;bool dtb_expose; +struct { +uint64_t base; +uint64_t core_shift; +uint64_t cluster_shift; + } mp_affinity; +enum StartPoweredOffMode start_powered_off; } VersalCpuClusterMap; typedef struct VersalMap { VersalCpuClusterMap apu;
@@ -196,10 +202,14 @@ static const VersalMap VERSAL_MAP = { .name = "apu", .cpu_model = ARM_CPU_TYPE_NAME("cortex-a72"), .num_cluster = 1, .num_core = 2, .qemu_cluster_id = 0, + .mp_affinity = { + .core_shift = ARM_AFF0_SHIFT, + .cluster_shift = ARM_AFF1_SHIFT, + }, .start_powered_off = SPO_SECONDARIES, .dtb_expose = true, .gic = { .version = 3, .dist = 0xf9000000,
@@ -565,23 +575,29 @@ static DeviceState *versal_create_cpu(Versal *s, size_t core_idx) {DeviceState *cpu =qdev_new (map->cpu_model);ARMCPU *arm_cpu =ARM_CPU (cpu);Object *obj =OBJECT (cpu); +uint64_t affinity;bool start_off;size_t idx = cluster_idx * map->num_core + core_idx; g_autofree char *name; g_autofree char *node = NULL; + affinity = map->mp_affinity.base; + affinity |= (cluster_idx &0xff ) << map->mp_affinity.cluster_shift; + affinity |= (core_idx &0xff ) << map->mp_affinity.core_shift; + start_off = map->start_powered_off ==SPO_ALL || ((map->start_powered_off ==SPO_SECONDARIES ) && (cluster_idx || core_idx)); name =g_strdup_printf ("%s[*]" , map->name);object_property_add_child (OBJECT (qemu_cluster), name, obj);object_property_set_bool (obj,"start-powered-off" , start_off, &error_abort); +qdev_prop_set_uint64 (cpu,"mp-affinity" , affinity);qdev_prop_set_int32 (cpu,"core-count" , map->num_core);object_property_set_link (obj,"memory" ,OBJECT (cpu_mr), &error_abort);qdev_realize_and_unref (cpu,NULL , &error_fatal);if (!map->dtb_expose) {
Signature · 1 line
2.50.1
PATCH v3 22/47 hw/arm/xlnx-versal: instantiate the GIC ITS in the APU
In reply to Luc MichelAdd the instance of the GIC ITS in the APU.
--- hw/arm/xlnx-versal.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
hw/arm/xlnx-versal.c +50 -0
@@ -42,10 +42,11 @@#include "hw/misc/xlnx-versal-cfu.h" #include "hw/misc/xlnx-versal-cframe-reg.h" #include "hw/or-irq.h" #include "hw/misc/xlnx-versal-crl.h" #include "hw/intc/arm_gicv3_common.h" +#include "hw/intc/arm_gicv3_its_common.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106
@@ -70,11 +71,13 @@ typedef struct VersalSimplePeriphMap {typedef struct VersalGicMap {int version;uint64_t dist;uint64_t redist; +uint64_t its;size_t num_irq; +bool has_its; }VersalGicMap ;enum StartPoweredOffMode {SPO_SECONDARIES ,SPO_ALL ,
@@ -213,10 +216,12 @@ static const VersalMap VERSAL_MAP = { .gic = { .version = 3, .dist = 0xf9000000, .redist = 0xf9080000, .num_irq = 192, + .has_its = true, + .its = 0xf9020000, }, }, .uart[0] = { 0xff000000, 18 }, .uart[1] = { 0xff010000, 19 },
@@ -449,10 +454,52 @@ static MemoryRegion *create_cpu_mr(Versal *s, DeviceState *cluster,memory_region_add_subregion (mr,0 , root_alias);return mr; } +static void versal_create_gic_its (Versal *s, +const VersalCpuClusterMap *map, +DeviceState *gic, +MemoryRegion *mr, +char *gic_node) +{ +DeviceState *dev; +SysBusDevice *sbd; + g_autofree char *node_pat = NULL, *node = NULL; +const char compatible[] ="arm,gic-v3-its" ; + +if (!map->gic.has_its) { +return ; + } + + dev =qdev_new (TYPE_ARM_GICV3_ITS ); + sbd =SYS_BUS_DEVICE (dev); + +object_property_add_child (OBJECT (gic),"its" ,OBJECT (dev)); +object_property_set_link (OBJECT (dev),"parent-gicv3" ,OBJECT (gic), + &error_abort); + +sysbus_realize_and_unref (sbd, &error_abort); + +memory_region_add_subregion (mr, map->gic.its, +sysbus_mmio_get_region (sbd,0 )); + +if (!map->dtb_expose) { +return ; + } + +qemu_fdt_setprop (s->cfg.fdt, gic_node,"ranges" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->cfg.fdt, gic_node,"#address-cells" ,2 ); +qemu_fdt_setprop_cell (s->cfg.fdt, gic_node,"#size-cells" ,2 ); + + node_pat =g_strdup_printf ("%s/its" , gic_node); + node =versal_fdt_add_simple_subnode (s, node_pat, map->gic.its,0x20000 , + compatible,sizeof (compatible)); +qemu_fdt_setprop (s->cfg.fdt, node,"msi-controller" ,NULL ,0 ); +qemu_fdt_setprop_cell (s->cfg.fdt, node,"#msi-cells" ,1 ); +} +static DeviceState *versal_create_gic (Versal *s,const VersalCpuClusterMap *map,MemoryRegion *mr,size_t num_cpu) {
@@ -474,10 +521,11 @@ static DeviceState *versal_create_gic(Versal *s, redist_region_count =qlist_new ();qlist_append_int (redist_region_count, num_cpu);qdev_prop_set_array (dev,"redist-region-count" , redist_region_count);qdev_prop_set_bit (dev,"has-security-extensions" , true); +qdev_prop_set_bit (dev,"has-lpi" , map->gic.has_its);object_property_set_link (OBJECT (dev),"sysmem" ,OBJECT (mr), &error_abort);sysbus_realize_and_unref (sbd, &error_fatal); memory_region_add_subregion(mr, map->gic.dist,
@@ -499,10 +547,12 @@ static DeviceState *versal_create_gic(Versal *s,GIC_FDT_IRQ_TYPE_PPI ,VERSAL_GIC_MAINT_IRQ , GIC_FDT_IRQ_FLAGS_LEVEL_HI);qemu_fdt_setprop (s->cfg.fdt, node,"interrupt-controller" ,NULL ,0 ); } +versal_create_gic_its (s, map, dev, mr, node); +return dev; } static void connect_gic_to_cpu(const VersalCpuClusterMap *map, DeviceState *gic, DeviceState *cpu, size_t idx,
Signature · 1 line
2.50.1
PATCH v3 23/47 hw/intc/arm_gicv3: Introduce a 'first-cpu-index' property
In reply to Luc MichelFrom: Francisco Iglesias <[email protected]>
Introduce a 'first-cpu-index' property for specifying the first QEMU CPU connected to the GICv3. This makes it possible to have multiple instances of the GICv3 connected to different CPU clusters.
For KVM, mark this property has unsupported. It probably does not make much sense as it is intented to be used to model non-SMP systems.
--- include/hw/intc/arm_gicv3_common.h | 1 + hw/intc/arm_gicv3_common.c | 3 ++- hw/intc/arm_gicv3_cpuif.c | 2 +- hw/intc/arm_gicv3_kvm.c | 6 ++++++ 4 files changed, 10 insertions(+), 2 deletions(-)
include/hw/intc/arm_gicv3_common.h +1 -0
@@ -226,10 +226,11 @@ struct GICv3State {MemoryRegion iomem_dist;/* Distributor */ GICv3RedistRegion *redist_regions;/* Redistributor Regions */ uint32_t *redist_region_count;/* redistributor count within each region */ uint32_t nb_redist_regions;/* number of redist regions */ +uint32_t first_cpu_idx;uint32_t num_cpu;uint32_t num_irq;uint32_t revision;uint32_t maint_irq;bool lpi_enable;
hw/intc/arm_gicv3_common.c +2 -1
@@ -434,11 +434,11 @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) } s->cpu =g_new0 (GICv3CPUState, s->num_cpu);for (i =0 ; i < s->num_cpu; i++) { -CPUState *cpu =qemu_get_cpu (i); +CPUState *cpu =qemu_get_cpu (s->first_cpu_idx + i);uint64_t cpu_affid; s->cpu[i].cpu = cpu; s->cpu[i].gic = s;/* Store GICv3CPUState in CPUARMState gicv3state pointer */
@@ -620,10 +620,11 @@ static const Property arm_gicv3_common_properties[] = {DEFINE_PROP_BOOL ("force-8-bit-prio" , GICv3State, force_8bit_prio,0 ),DEFINE_PROP_ARRAY ("redist-region-count" , GICv3State, nb_redist_regions, redist_region_count, qdev_prop_uint32, uint32_t),DEFINE_PROP_LINK ("sysmem" , GICv3State, dma,TYPE_MEMORY_REGION , MemoryRegion *), + DEFINE_PROP_UINT32("first-cpu-index", GICv3State, first_cpu_idx, 0), };static void arm_gicv3_common_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
hw/intc/arm_gicv3_cpuif.c +1 -1
@@ -3022,11 +3022,11 @@ void gicv3_init_cpuif(GICv3State *s)* registers with the CPU */ int i;for (i =0 ; i < s->num_cpu; i++) { -ARMCPU *cpu =ARM_CPU (qemu_get_cpu (i)); +ARMCPU *cpu =ARM_CPU (qemu_get_cpu (s->first_cpu_idx + i));GICv3CPUState *cs = &s->cpu[i];/* * If the CPU doesn't define a GICv3 configuration, probably because * in real hardware it doesn't have one, then we use default values
hw/intc/arm_gicv3_kvm.c +6 -0
@@ -807,10 +807,16 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)if (s->nmi_support) {error_setg (errp,"NMI is not supported with the in-kernel GIC" );return ; } +if (s->first_cpu_idx !=0 ) { +error_setg (errp,"Non-zero first-cpu-idx is unsupported with the " +"in-kernel GIC" ); +return ; + } +gicv3_init_irqs_and_mmio (s, kvm_arm_gicv3_set_irq,NULL );for (i =0 ; i < s->num_cpu; i++) {ARMCPU *cpu =ARM_CPU (qemu_get_cpu (i));
Signature · 1 line
2.50.1
PATCH v3 24/47 hw/arm/xlnx-versal: add support for multiple GICs
In reply to Luc MichelThe Versal SoC contains two GICs: one GICv3 in the APU and one GICv2 in the RPU (currently not instantiated). To prepare for the GICv2 instantiation, add support for multiple GICs when connecting interrupts.
When a GIC is created, the first-cpu-index property is set on it, and a pointer to the GIC is stored in the intc array. When connecting an IRQ, a TYPE_SPLIT_IRQ device is created with its num-lines property set to the number of GICs in the SoC. The split device is used to fan out the IRQ to all the GICs.
--- include/hw/arm/xlnx-versal.h | 1 + hw/arm/xlnx-versal.c | 55 +++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 4 deletions(-)
include/hw/arm/xlnx-versal.h +1 -0
@@ -40,10 +40,11 @@ OBJECT_DECLARE_TYPE(Versal, VersalClass, XLNX_VERSAL_BASE)struct Versal {/*< private >*/ SysBusDevice parent_obj;/*< public >*/ +GArray *intc;MemoryRegion mr_ps;struct {/* 4 ranges to access DDR. */ MemoryRegion mr_ddr_ranges[4 ];
hw/arm/xlnx-versal.c +51 -4
150 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 25/47 hw/arm/xlnx-versal: add support for GICv2
In reply to Luc MichelAdd support for GICv2 instantiation in the Versal SoC. This is in preparation for the RPU refactoring.
--- hw/arm/xlnx-versal.c | 82 +++++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 20 deletions(-)
hw/arm/xlnx-versal.c +62 -20
@@ -43,10 +43,11 @@#include "hw/misc/xlnx-versal-cframe-reg.h" #include "hw/or-irq.h" #include "hw/misc/xlnx-versal-crl.h" #include "hw/intc/arm_gicv3_common.h" #include "hw/intc/arm_gicv3_its_common.h" +#include "hw/intc/arm_gic.h" #include "hw/core/split-irq.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106
@@ -72,10 +73,11 @@ typedef struct VersalSimplePeriphMap {typedef struct VersalGicMap {int version;uint64_t dist;uint64_t redist; +uint64_t cpu_iface;uint64_t its;size_t num_irq;bool has_its; }VersalGicMap ;
@@ -501,10 +503,14 @@ static void versal_create_gic_its(Versal *s,DeviceState *dev;SysBusDevice *sbd; g_autofree char *node_pat = NULL, *node = NULL;const char compatible[] ="arm,gic-v3-its" ; +if (map->gic.version !=3 ) { +return ; + } +if (!map->gic.has_its) {return ; } dev =qdev_new (TYPE_ARM_GICV3_ITS );
@@ -540,49 +546,85 @@ static DeviceState *versal_create_gic(Versal *s, int first_cpu_idx, size_t num_cpu) {DeviceState *dev;SysBusDevice *sbd; -QList *redist_region_count; g_autofree char *node = NULL; g_autofree char *name = NULL; -const char compatible[] ="arm,gic-v3" ; +const char gicv3_compat[] ="arm,gic-v3" ; +const char gicv2_compat[] ="arm,cortex-a15-gic" ; + +switch (map->gic.version) { +case 2 : + dev =qdev_new (gic_class_name ()); +break ; + +case 3 : + dev =qdev_new (gicv3_class_name ()); +break ; + +default : +g_assert_not_reached (); + } - dev =qdev_new (gicv3_class_name ()); name =g_strdup_printf ("%s-gic[*]" , map->name);object_property_add_child (OBJECT (s), name,OBJECT (dev)); sbd =SYS_BUS_DEVICE (dev); -qdev_prop_set_uint32 (dev,"revision" ,3 ); +qdev_prop_set_uint32 (dev,"revision" , map->gic.version);qdev_prop_set_uint32 (dev,"num-cpu" , num_cpu);qdev_prop_set_uint32 (dev,"num-irq" , map->gic.num_irq +32 ); - - redist_region_count =qlist_new (); -qlist_append_int (redist_region_count, num_cpu); -qdev_prop_set_array (dev,"redist-region-count" , redist_region_count); -qdev_prop_set_bit (dev,"has-security-extensions" , true); -qdev_prop_set_bit (dev,"has-lpi" , map->gic.has_its); -object_property_set_link (OBJECT (dev),"sysmem" ,OBJECT (mr), &error_abort);qdev_prop_set_uint32 (dev,"first-cpu-index" , first_cpu_idx); +if (map->gic.version ==3 ) { +QList *redist_region_count; + + redist_region_count =qlist_new (); +qlist_append_int (redist_region_count, num_cpu); +qdev_prop_set_array (dev,"redist-region-count" , redist_region_count); +qdev_prop_set_bit (dev,"has-lpi" , map->gic.has_its); +object_property_set_link (OBJECT (dev),"sysmem" ,OBJECT (mr), + &error_abort); + + } +sysbus_realize_and_unref (sbd, &error_fatal);memory_region_add_subregion (mr, map->gic.dist,sysbus_mmio_get_region (sbd,0 )); -memory_region_add_subregion (mr, map->gic.redist, -sysbus_mmio_get_region (sbd,1 )); + +if (map->gic.version ==3 ) { +memory_region_add_subregion (mr, map->gic.redist, +sysbus_mmio_get_region (sbd,1 )); + }else { +memory_region_add_subregion (mr, map->gic.cpu_iface, +sysbus_mmio_get_region (sbd,1 )); + }if (map->dtb_expose) { - node =versal_fdt_add_subnode (s,"/gic" , map->gic.dist, compatible, -sizeof (compatible)); +if (map->gic.version ==3 ) { + node =versal_fdt_add_subnode (s,"/gic" , map->gic.dist, + gicv3_compat, +sizeof (gicv3_compat)); +qemu_fdt_setprop_sized_cells (s->cfg.fdt, node,"reg" , +2 , map->gic.dist, +2 ,0x10000 , +2 , map->gic.redist, +2 ,GICV3_REDIST_SIZE * num_cpu); + }else { + node =versal_fdt_add_subnode (s,"/gic" , map->gic.dist, + gicv2_compat, +sizeof (gicv2_compat)); +qemu_fdt_setprop_sized_cells (s->cfg.fdt, node,"reg" , +2 , map->gic.dist, +2 ,0x1000 , +2 , map->gic.cpu_iface, +2 ,0x1000 ); + } +qemu_fdt_setprop_cell (s->cfg.fdt, node,"phandle" , s->phandle.gic);qemu_fdt_setprop_cell (s->cfg.fdt, node,"#interrupt-cells" ,3 ); -qemu_fdt_setprop_sized_cells (s->cfg.fdt, node,"reg" , -2 , map->gic.dist, -2 ,0x10000 , -2 , map->gic.redist, -2 ,GICV3_REDIST_SIZE * num_cpu);qemu_fdt_setprop_cells (s->cfg.fdt, node,"interrupts" ,GIC_FDT_IRQ_TYPE_PPI ,VERSAL_GIC_MAINT_IRQ ,GIC_FDT_IRQ_FLAGS_LEVEL_HI );qemu_fdt_setprop (s->cfg.fdt, node,"interrupt-controller" ,NULL ,0 ); }
Signature · 1 line
2.50.1
PATCH v3 26/47 hw/arm/xlnx-versal: rpu: refactor creation
In reply to Luc MichelRefactor the RPU cluster creation using the VersalMap structure. This effectively instantiate the RPU GICv2 which was not instantiated before.
--- include/hw/arm/xlnx-versal.h | 11 ------- hw/arm/xlnx-versal-virt.c | 1 + hw/arm/xlnx-versal.c | 60 +++++++++++++++--------------------- 3 files changed, 26 insertions(+), 46 deletions(-)
include/hw/arm/xlnx-versal.h +0 -11
@@ -12,14 +12,12 @@#ifndef XLNX_VERSAL_H #define XLNX_VERSAL_H #include "hw/sysbus.h" -#include "hw/cpu/cluster.h" #include "qom/object.h" #include "net/can_emu.h" -#include "target/arm/cpu.h" #include "hw/arm/xlnx-versal-version.h" #define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base"OBJECT_DECLARE_TYPE (Versal, VersalClass,XLNX_VERSAL_BASE )
@@ -50,19 +48,10 @@ struct Versal {MemoryRegion mr_ddr_ranges[4 ]; } noc;struct {MemoryRegion mr_ocm; - -/* Real-time Processing Unit. */ -struct { -MemoryRegion mr; -MemoryRegion mr_ps_alias; - -CPUClusterState cluster; -ARMCPU cpu[XLNX_VERSAL_NR_RCPUS ]; - } rpu; } lpd;struct {uint32_t clk_25mhz;uint32_t clk_125mhz;
hw/arm/xlnx-versal-virt.c +1 -0
@@ -22,10 +22,11 @@#include "hw/qdev-properties.h" #include "hw/arm/xlnx-versal.h" #include "hw/arm/boot.h" #include "target/arm/multiprocessing.h" #include "qom/object.h" +#include "target/arm/cpu.h" #define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt") OBJECT_DECLARE_SIMPLE_TYPE(VersalVirt, XLNX_VERSAL_VIRT_MACHINE)#define XLNX_VERSAL_NUM_OSPI_FLASH 4
hw/arm/xlnx-versal.c +25 -35
131 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 27/47 hw/arm/xlnx-versal: ocm: refactor creation
In reply to Luc MichelRefactor the OCM creation using the VersalMap structure.
--- include/hw/arm/xlnx-versal.h | 4 ---- hw/arm/xlnx-versal.c | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-)
include/hw/arm/xlnx-versal.h +0 -4
@@ -46,14 +46,10 @@ struct Versal {struct {/* 4 ranges to access DDR. */ MemoryRegion mr_ddr_ranges[4 ]; } noc; -struct { -MemoryRegion mr_ocm; - } lpd; -struct {uint32_t clk_25mhz;uint32_t clk_125mhz;uint32_t gic; } phandle;
hw/arm/xlnx-versal.c +16 -4
@@ -71,10 +71,15 @@ FIELD(VERSAL_IRQ, OR_IDX, 19, 4) /* input index on the IRQ OR gate */typedef struct VersalSimplePeriphMap {uint64_t addr;int irq; }VersalSimplePeriphMap ; +typedef struct VersalMemMap { +uint64_t addr; +uint64_t size; +}VersalMemMap ; + typedef struct VersalGicMap { int version; uint64_t dist; uint64_t redist; uint64_t cpu_iface;
@@ -106,10 +111,12 @@ typedef struct VersalCpuClusterMap {enum StartPoweredOffMode start_powered_off; } VersalCpuClusterMap; typedef struct VersalMap { + VersalMemMap ocm; + VersalCpuClusterMap apu; VersalCpuClusterMap rpu; VersalSimplePeriphMap uart[2]; size_t num_uart;
@@ -205,10 +212,15 @@ typedef struct VersalMap {int irq_num; } reserved; } VersalMap;static const VersalMap VERSAL_MAP = { + .ocm = { + .addr =0xfffc0000 , + .size =0x40000 , + }, + .apu = { .name ="apu" , .cpu_model =ARM_CPU_TYPE_NAME ("cortex-a72" ), .num_cluster =1 , .num_core =2 ,
@@ -1600,10 +1612,11 @@ static uint32_t fdt_add_clk_node(Versal *s, const char *name,static void versal_realize (DeviceState *dev,Error **errp) {Versal *s =XLNX_VERSAL_BASE (dev);DeviceState *slcr, *ospi; +MemoryRegion *ocm;Object *container;const VersalMap *map =versal_get_map (s);size_t i;if (s->cfg.fdt ==NULL ) {
@@ -1673,14 +1686,13 @@ static void versal_realize(DeviceState *dev, Error **errp)versal_map_ddr (s);versal_unimp (s);/* Create the On Chip Memory (OCM). */ -memory_region_init_ram (&s->lpd.mr_ocm,OBJECT (s),"ocm" , -MM_OCM_SIZE , &error_fatal); - -memory_region_add_subregion_overlap (&s->mr_ps,MM_OCM , &s->lpd.mr_ocm,0 ); + ocm =g_new (MemoryRegion,1 ); +memory_region_init_ram (ocm,OBJECT (s),"ocm" , map->ocm.size, &error_fatal); +memory_region_add_subregion_overlap (&s->mr_ps, map->ocm.addr, ocm,0 ); }DeviceState *versal_get_boot_cpu (Versal *s) {return DEVICE (versal_get_child_idx (s,"apu-cluster/apu" ,0 ));
Signature · 1 line
2.50.1
PATCH v3 28/47 hw/arm/xlnx-versal: ddr: refactor creation
In reply to Luc MichelRefactor the DDR aperture regions creation using the VersalMap structure. Device creation and FDT node creation are split into two functions because the later must happen during ARM virtual bootloader modify_dtb callback.
--- include/hw/arm/xlnx-versal.h | 7 +--- hw/arm/xlnx-versal-virt.c | 79 +----------------------------------- hw/arm/xlnx-versal.c | 73 ++++++++++++++++++++++----------- 3 files changed, 53 insertions(+), 106 deletions(-)
include/hw/arm/xlnx-versal.h +2 -5
@@ -41,15 +41,10 @@ struct Versal {/*< public >*/ GArray *intc;MemoryRegion mr_ps; -struct { -/* 4 ranges to access DDR. */ -MemoryRegion mr_ddr_ranges[4 ]; - } noc; -struct {uint32_t clk_25mhz;uint32_t clk_125mhz;uint32_t gic; } phandle;
@@ -71,10 +66,12 @@ static inline void versal_set_fdt(Versal *s, void *fdt) {g_assert (!qdev_is_realized (DEVICE (s))); s->cfg.fdt = fdt; } +void versal_fdt_add_memory_nodes (Versal *s,uint64_t ram_size); +DeviceState *versal_get_boot_cpu (Versal *s);void versal_sdhci_plug_card (Versal *s,int sd_idx,BlockBackend *blk);void versal_efuse_attach_drive (Versal *s,BlockBackend *blk);void versal_bbram_attach_drive (Versal *s,BlockBackend *blk); void versal_ospi_create_flash(Versal *s, int flash_idx, const char *flash_mdl,
hw/arm/xlnx-versal-virt.c +2 -77
94 lines not on this page · raw message
hw/arm/xlnx-versal.c +49 -24
130 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 29/47 hw/arm/xlnx-versal: add the versal_get_num_cpu accessor
In reply to Luc MichelAdd the versal_get_num_cpu accessor to the Versal SoC to retrieve the number of CPUs in the SoC. Use it in the xlnx-versal-virt machine.
--- include/hw/arm/xlnx-versal.h | 1 + hw/arm/xlnx-versal-virt.c | 7 ++++--- hw/arm/xlnx-versal.c | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-)
include/hw/arm/xlnx-versal.h +1 -0
@@ -78,10 +78,11 @@ void versal_ospi_create_flash(Versal *s, int flash_idx, const char *flash_mdl, BlockBackend *blk);qemu_irq versal_get_reserved_irq (Versal *s,int idx,int *dtb_idx);hwaddr versal_get_reserved_mmio_addr (Versal *s); +int versal_get_num_cpu (VersalVersion version);int versal_get_num_can (VersalVersion version);int versal_get_num_sdhci (VersalVersion version);/* Memory-map and IRQ definitions. Copied a subset from * auto-generated files. */
hw/arm/xlnx-versal-virt.c +4 -3
@@ -344,16 +344,17 @@ static void versal_virt_machine_finalize(Object *obj) }static void versal_virt_machine_class_init (ObjectClass *oc,const void *data) {MachineClass *mc =MACHINE_CLASS (oc); +int num_cpu =versal_get_num_cpu (VERSAL_VER_VERSAL ); mc->desc ="Xilinx Versal Virtual development board" ; mc->init = versal_virt_init; - mc->min_cpus =XLNX_VERSAL_NR_ACPUS +XLNX_VERSAL_NR_RCPUS ; - mc->max_cpus =XLNX_VERSAL_NR_ACPUS +XLNX_VERSAL_NR_RCPUS ; - mc->default_cpus =XLNX_VERSAL_NR_ACPUS +XLNX_VERSAL_NR_RCPUS ; + mc->min_cpus = num_cpu; + mc->max_cpus = num_cpu; + mc->default_cpus = num_cpu; mc->no_cdrom = true; mc->auto_create_sdcard = true; mc->default_ram_id ="ddr" ;object_class_property_add_str (oc,"ospi-flash" , versal_get_ospi_model, versal_set_ospi_model);
hw/arm/xlnx-versal.c +8 -0
@@ -1805,10 +1805,18 @@ hwaddr versal_get_reserved_mmio_addr(Versal *s)const VersalMap *map =versal_get_map (s);return map->reserved.mmio_start; } +int versal_get_num_cpu (VersalVersion version) +{ +const VersalMap *map =VERSION_TO_MAP [version]; + +return map->apu.num_cluster * map->apu.num_core + + map->rpu.num_cluster * map->rpu.num_core; +} +int versal_get_num_can (VersalVersion version) {const VersalMap *map =VERSION_TO_MAP [version];return map->num_canfd;
Signature · 1 line
2.50.1
PATCH v3 30/47 hw/misc/xlnx-versal-crl: remove unnecessary include directives
In reply to Luc MichelDrop unused include directives from xlnx-versal-crl.c
--- hw/misc/xlnx-versal-crl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/misc/xlnx-versal-crl.c +1 -4
@@ -1,18 +1,15 @@/* * QEMU model of the Clock-Reset-LPD (CRL). * -* Copyright (c) 2022 Advanced Micro Devices, Inc. +* Copyright (c) 2022-2025 Advanced Micro Devices, Inc. * SPDX-License-Identifier: GPL-2.0-or-later * * Written by Edgar E. Iglesias <[email protected]> */ #include "qemu/osdep.h" -#include "qapi/error.h" -#include "qemu/log.h" -#include "qemu/bitops.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/sysbus.h" #include "hw/irq.h" #include "hw/register.h"
Signature · 1 line
2.50.1
PATCH v3 31/47 hw/misc/xlnx-versal-crl: split into base/concrete classes
In reply to Luc MichelSplit the TYPE_XLNX_VERSAL_CRL type into base and concrete classes. This is in preparation for the versal2 version of the CRL.
--- include/hw/misc/xlnx-versal-crl.h | 31 ++++++++++++++++++-- hw/misc/xlnx-versal-crl.c | 48 +++++++++++++++++++------------ 2 files changed, 58 insertions(+), 21 deletions(-)
include/hw/misc/xlnx-versal-crl.h +29 -2
@@ -1,21 +1,27 @@/* * QEMU model of the Clock-Reset-LPD (CRL). * * Copyright (c) 2022 Xilinx Inc. +* Copyright (c) 2025 Advanced Micro Devices, Inc. * SPDX-License-Identifier: GPL-2.0-or-later * * Written by Edgar E. Iglesias <[email protected]> */ #ifndef HW_MISC_XLNX_VERSAL_CRL_H #define HW_MISC_XLNX_VERSAL_CRL_H #include "hw/sysbus.h" #include "hw/register.h" #include "target/arm/cpu-qom.h" +#include "hw/arm/xlnx-versal-version.h" +#define TYPE_XLNX_VERSAL_CRL_BASE "xlnx-versal-crl-base"#define TYPE_XLNX_VERSAL_CRL "xlnx-versal-crl" + +OBJECT_DECLARE_TYPE (XlnxVersalCRLBase, XlnxVersalCRLBaseClass, + XLNX_VERSAL_CRL_BASE) OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCRL, XLNX_VERSAL_CRL) REG32(ERR_CTRL, 0x0) FIELD(ERR_CTRL, SLVERR_ENABLE, 0, 1)REG32 (IR_STATUS ,0x4 )
@@ -214,22 +220,43 @@ REG32(PSM_RST_MODE, 0x370)#define CRL_R_MAX (R_PSM_RST_MODE + 1)#define RPU_MAX_CPU 2 -struct XlnxVersalCRL { +struct XlnxVersalCRLBase {SysBusDevice parent_obj; + +RegisterInfoArray *reg_array; +uint32_t *regs; +}; + +struct XlnxVersalCRLBaseClass { +SysBusDeviceClass parent_class; +}; + +struct XlnxVersalCRL { +XlnxVersalCRLBase parent_obj;qemu_irq irq;struct {ARMCPU *cpu_r5[RPU_MAX_CPU ];DeviceState *adma[8 ];DeviceState *uart[2 ];DeviceState *gem[2 ];DeviceState *usb; } cfg; -RegisterInfoArray *reg_array;uint32_t regs[CRL_R_MAX ];RegisterInfo regs_info[CRL_R_MAX ]; }; + +static inline const char *xlnx_versal_crl_class_name (VersalVersion ver) +{ +switch (ver) { +case VERSAL_VER_VERSAL : +return TYPE_XLNX_VERSAL_CRL ; +default : +g_assert_not_reached (); + } +} +#endif
hw/misc/xlnx-versal-crl.c +29 -19
119 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 32/47 hw/misc/xlnx-versal-crl: refactor device reset logic
In reply to Luc MichelRefactor the device reset logic to have a common register write callback for all the devices. This uses a decode function to map the register address to the actual peripheral to reset. This refactoring changes the CPU property name from cpu_r5[*] to rpu[*] to ease with the connections in the Versal SoC. It also fixes a bug where the gem device pointer was mapped to the usb link property.
--- include/hw/misc/xlnx-versal-crl.h | 8 +- hw/misc/xlnx-versal-crl.c | 163 ++++++++++++++++-------------- 2 files changed, 92 insertions(+), 79 deletions(-)
include/hw/misc/xlnx-versal-crl.h +4 -4
@@ -218,33 +218,33 @@ REG32(PSM_RST_MODE, 0x370) FIELD(PSM_RST_MODE, WAKEUP, 2, 1) FIELD(PSM_RST_MODE, RST_MODE, 0, 2)#define CRL_R_MAX (R_PSM_RST_MODE + 1) -#define RPU_MAX_CPU 2 -struct XlnxVersalCRLBase {SysBusDevice parent_obj;RegisterInfoArray *reg_array;uint32_t *regs; };struct XlnxVersalCRLBaseClass {SysBusDeviceClass parent_class; + +DeviceState ** (*decode_periph_rst)(XlnxVersalCRLBase *s,hwaddr ,size_t *); };struct XlnxVersalCRL {XlnxVersalCRLBase parent_obj;qemu_irq irq;struct { -ARMCPU *cpu_r5[RPU_MAX_CPU ]; +DeviceState *rpu[2 ];DeviceState *adma[8 ];DeviceState *uart[2 ];DeviceState *gem[2 ]; -DeviceState *usb; +DeviceState *usb[1 ]; } cfg;uint32_t regs[CRL_R_MAX ];RegisterInfo regs_info[CRL_R_MAX ]; };
hw/misc/xlnx-versal-crl.c +88 -75
255 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 33/47 hw/arm/xlnx-versal: reconnect the CRL to the other devices
In reply to Luc MichelThe CRL connects to various devices through link properties to be able to reset them. The connections were dropped during the SoC refactoring. Reintroduce them now.
Rely on the QOM tree to retrieve the devices to connect. The component parts of the device names are chosen to match the properties on the CRL.
--- hw/arm/xlnx-versal.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
hw/arm/xlnx-versal.c +30 -1
@@ -1468,21 +1468,50 @@ static void versal_create_cfu(Versal *s, const struct VersalCfuMap *map)sysbus_realize_and_unref (sbd, &error_fatal);memory_region_add_subregion (&s->mr_ps, map->cfu_sfr,sysbus_mmio_get_region (sbd,0 )); } +static inline void crl_connect_dev (Object *crl,Object *dev) +{ +const char *prop =object_get_canonical_path_component (dev); + +/* The component part of the device path matches the CRL property name */ +object_property_set_link (crl, prop, dev, &error_abort); +} + +static inline void crl_connect_dev_by_name (Versal *s,Object *crl, +const char *name,size_t num) +{ +size_t i; + +for (i =0 ; i < num; i++) { +Object *dev =versal_get_child_idx (s, name, i); + +crl_connect_dev (crl, dev); + } +} +static inline void versal_create_crl (Versal *s) {const VersalMap *map;const char *crl_class;DeviceState *dev; +Object *obj; map =versal_get_map (s); crl_class =TYPE_XLNX_VERSAL_CRL ; dev =qdev_new (crl_class); -object_property_add_child (OBJECT (s),"crl" ,OBJECT (dev)); + obj =OBJECT (dev); +object_property_add_child (OBJECT (s),"crl" , obj); + +crl_connect_dev_by_name (s, obj,"rpu-cluster/rpu" , + map->rpu.num_cluster * map->rpu.num_core); +crl_connect_dev_by_name (s, obj, map->zdma[0 ].name, map->zdma[0 ].num_chan); +crl_connect_dev_by_name (s, obj,"uart" , map->num_uart); +crl_connect_dev_by_name (s, obj,"gem" , map->num_gem); +crl_connect_dev_by_name (s, obj,"usb" , map->num_usb);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_abort);memory_region_add_subregion (&s->mr_ps, map->crl.addr,sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ));
Signature · 1 line
2.50.1
PATCH v3 34/47 hw/arm/xlnx-versal: use hw/arm/bsa.h for timer IRQ indices
In reply to Luc MichelUse the bsa.h header for ARM timer and maintainance IRQ indices instead of redefining our owns.
--- include/hw/arm/xlnx-versal.h | 6 ------ hw/arm/xlnx-versal.c | 28 +++++++++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-)
include/hw/arm/xlnx-versal.h +0 -6
@@ -85,16 +85,10 @@ int versal_get_num_can(VersalVersion version);int versal_get_num_sdhci (VersalVersion version);/* Memory-map and IRQ definitions. Copied a subset from * auto-generated files. */ -#define VERSAL_GIC_MAINT_IRQ 9 -#define VERSAL_TIMER_VIRT_IRQ 11 -#define VERSAL_TIMER_S_EL1_IRQ 13 -#define VERSAL_TIMER_NS_EL1_IRQ 14 -#define VERSAL_TIMER_NS_EL2_IRQ 10 -#define VERSAL_CRL_IRQ 10#define VERSAL_UART0_IRQ_0 18#define VERSAL_UART1_IRQ_0 19#define VERSAL_CANFD0_IRQ_0 20#define VERSAL_CANFD1_IRQ_0 21
hw/arm/xlnx-versal.c +17 -11
@@ -47,10 +47,11 @@#include "hw/intc/arm_gicv3_its_common.h" #include "hw/intc/arm_gic.h" #include "hw/core/split-irq.h" #include "target/arm/cpu.h" #include "hw/cpu/cluster.h" +#include "hw/arm/bsa.h" #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")#define GEM_REVISION 0x40070106
@@ -671,11 +672,12 @@ static DeviceState *versal_create_gic(Versal *s, }qemu_fdt_setprop_cell (s->cfg.fdt, node,"phandle" , s->phandle.gic);qemu_fdt_setprop_cell (s->cfg.fdt, node,"#interrupt-cells" ,3 );qemu_fdt_setprop_cells (s->cfg.fdt, node,"interrupts" , -GIC_FDT_IRQ_TYPE_PPI ,VERSAL_GIC_MAINT_IRQ , +GIC_FDT_IRQ_TYPE_PPI , +INTID_TO_PPI (ARCH_GIC_MAINT_IRQ ),GIC_FDT_IRQ_FLAGS_LEVEL_HI );qemu_fdt_setprop (s->cfg.fdt, node,"interrupt-controller" ,NULL ,0 ); }versal_create_gic_its (s, map, dev, mr, node);
@@ -696,14 +698,14 @@ static void connect_gic_to_cpu(const VersalCpuClusterMap *map,/* * Mapping from the output timer irq lines from the CPU to the * GIC PPI inputs. */ const int timer_irq[] = { - [GTIMER_PHYS ] =VERSAL_TIMER_NS_EL1_IRQ , - [GTIMER_VIRT ] =VERSAL_TIMER_VIRT_IRQ , - [GTIMER_HYP ] =VERSAL_TIMER_NS_EL2_IRQ , - [GTIMER_SEC ] =VERSAL_TIMER_S_EL1_IRQ , + [GTIMER_PHYS ] =INTID_TO_PPI (ARCH_TIMER_NS_EL1_IRQ ), + [GTIMER_VIRT ] =INTID_TO_PPI (ARCH_TIMER_VIRT_IRQ ), + [GTIMER_HYP ] =INTID_TO_PPI (ARCH_TIMER_NS_EL2_IRQ ), + [GTIMER_SEC ] =INTID_TO_PPI (ARCH_TIMER_S_EL1_IRQ ), }; has_gtimer =arm_feature (&ARM_CPU (cpu)->env,ARM_FEATURE_GENERIC_TIMER );if (has_gtimer) {
@@ -714,13 +716,13 @@ static void connect_gic_to_cpu(const VersalCpuClusterMap *map, } }if (map->gic.version ==3 ) {qemu_irq maint_irq; +int maint_idx = ppibase +INTID_TO_PPI (ARCH_GIC_MAINT_IRQ ); - maint_irq =qdev_get_gpio_in (gic, - ppibase +VERSAL_GIC_MAINT_IRQ ); + maint_irq =qdev_get_gpio_in (gic, maint_idx);qdev_connect_gpio_out_named (cpu,"gicv3-maintenance-interrupt" ,0 , maint_irq); }sysbus_connect_irq (sbd, idx,qdev_get_gpio_in (cpu,ARM_CPU_IRQ ));
@@ -840,17 +842,21 @@ static void versal_create_cpu_cluster(Versal *s, const VersalCpuClusterMap *map) has_gtimer =arm_feature (&ARM_CPU (cpus[0 ])->env,ARM_FEATURE_GENERIC_TIMER );if (map->dtb_expose && has_gtimer) {qemu_fdt_add_subnode (s->cfg.fdt,"/timer" );qemu_fdt_setprop_cells (s->cfg.fdt,"/timer" ,"interrupts" , -GIC_FDT_IRQ_TYPE_PPI ,VERSAL_TIMER_S_EL1_IRQ , +GIC_FDT_IRQ_TYPE_PPI , +INTID_TO_PPI (ARCH_TIMER_S_EL1_IRQ ),GIC_FDT_IRQ_FLAGS_LEVEL_HI , -GIC_FDT_IRQ_TYPE_PPI ,VERSAL_TIMER_NS_EL1_IRQ , +GIC_FDT_IRQ_TYPE_PPI , +INTID_TO_PPI (ARCH_TIMER_NS_EL1_IRQ ),GIC_FDT_IRQ_FLAGS_LEVEL_HI , -GIC_FDT_IRQ_TYPE_PPI ,VERSAL_TIMER_VIRT_IRQ , +GIC_FDT_IRQ_TYPE_PPI , +INTID_TO_PPI (ARCH_TIMER_VIRT_IRQ ),GIC_FDT_IRQ_FLAGS_LEVEL_HI , -GIC_FDT_IRQ_TYPE_PPI ,VERSAL_TIMER_NS_EL2_IRQ , +GIC_FDT_IRQ_TYPE_PPI , +INTID_TO_PPI (ARCH_TIMER_NS_EL2_IRQ ),GIC_FDT_IRQ_FLAGS_LEVEL_HI );qemu_fdt_setprop (s->cfg.fdt,"/timer" ,"compatible" , compatible,sizeof (compatible)); } }
Signature · 1 line
2.50.1
PATCH v3 35/47 hw/arm/xlnx-versal: tidy up
In reply to Luc MichelRemove now unused macros in xlnx-versal.[ch]. Those macros have been replaced by the VersalMap structure that serves as a central description for the SoC. The ones still in use in the versal_unimp function are inlined.
--- include/hw/arm/xlnx-versal.h | 204 ----------------------------------- hw/arm/xlnx-versal.c | 28 ++--- 2 files changed, 7 insertions(+), 225 deletions(-)
include/hw/arm/xlnx-versal.h +0 -204
@@ -21,22 +21,10 @@#define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base" OBJECT_DECLARE_TYPE(Versal, VersalClass, XLNX_VERSAL_BASE)#define TYPE_XLNX_VERSAL "xlnx-versal" -#define XLNX_VERSAL_NR_ACPUS 2 -#define XLNX_VERSAL_NR_RCPUS 2 -#define XLNX_VERSAL_NR_UARTS 2 -#define XLNX_VERSAL_NR_GEMS 2 -#define XLNX_VERSAL_NR_ADMAS 8 -#define XLNX_VERSAL_NR_SDS 2 -#define XLNX_VERSAL_NR_XRAM 4 -#define XLNX_VERSAL_NR_IRQS 192 -#define XLNX_VERSAL_NR_CANFD 2 -#define XLNX_VERSAL_CANFD_REF_CLK (24 * 1000 * 1000) -#define XLNX_VERSAL_NR_CFRAME 15 -struct Versal {/*< private >*/ SysBusDevice parent_obj;/*< public >*/
@@ -82,198 +70,6 @@ hwaddr versal_get_reserved_mmio_addr(Versal *s);int versal_get_num_cpu (VersalVersion version);int versal_get_num_can (VersalVersion version);int versal_get_num_sdhci (VersalVersion version); -/* Memory-map and IRQ definitions. Copied a subset from -* auto-generated files. */ - -#define VERSAL_CRL_IRQ 10 -#define VERSAL_UART0_IRQ_0 18 -#define VERSAL_UART1_IRQ_0 19 -#define VERSAL_CANFD0_IRQ_0 20 -#define VERSAL_CANFD1_IRQ_0 21 -#define VERSAL_USB0_IRQ_0 22 -#define VERSAL_GEM0_IRQ_0 56 -#define VERSAL_GEM0_WAKE_IRQ_0 57 -#define VERSAL_GEM1_IRQ_0 58 -#define VERSAL_GEM1_WAKE_IRQ_0 59 -#define VERSAL_ADMA_IRQ_0 60 -#define VERSAL_XRAM_IRQ_0 79 -#define VERSAL_CFU_IRQ_0 120 -#define VERSAL_PMC_APB_IRQ 121 -#define VERSAL_OSPI_IRQ 124 -#define VERSAL_SD0_IRQ_0 126 -#define VERSAL_EFUSE_IRQ 139 -#define VERSAL_TRNG_IRQ 141 -#define VERSAL_RTC_ALARM_IRQ 142 -#define VERSAL_RTC_SECONDS_IRQ 143 - -/* Architecturally reserved IRQs suitable for virtualization. */ -#define VERSAL_RSVD_IRQ_FIRST 111 -#define VERSAL_RSVD_IRQ_LAST 118 - -#define MM_TOP_RSVD 0xa0000000U -#define MM_TOP_RSVD_SIZE 0x4000000 -#define MM_GIC_APU_DIST_MAIN 0xf9000000U -#define MM_GIC_APU_DIST_MAIN_SIZE 0x10000 -#define MM_GIC_APU_REDIST_0 0xf9080000U -#define MM_GIC_APU_REDIST_0_SIZE 0x80000 - -#define MM_UART0 0xff000000U -#define MM_UART0_SIZE 0x10000 -#define MM_UART1 0xff010000U -#define MM_UART1_SIZE 0x10000 - -#define MM_CANFD0 0xff060000U -#define MM_CANFD0_SIZE 0x10000 -#define MM_CANFD1 0xff070000U -#define MM_CANFD1_SIZE 0x10000 - -#define MM_GEM0 0xff0c0000U -#define MM_GEM0_SIZE 0x10000 -#define MM_GEM1 0xff0d0000U -#define MM_GEM1_SIZE 0x10000 - -#define MM_ADMA_CH0 0xffa80000U -#define MM_ADMA_CH0_SIZE 0x10000 - -#define MM_OCM 0xfffc0000U -#define MM_OCM_SIZE 0x40000 - -#define MM_XRAM 0xfe800000 -#define MM_XRAMC 0xff8e0000 -#define MM_XRAMC_SIZE 0x10000 - -#define MM_USB2_CTRL_REGS 0xFF9D0000 -#define MM_USB2_CTRL_REGS_SIZE 0x10000 - -#define MM_USB_0 0xFE200000 -#define MM_USB_0_SIZE 0x10000 - -#define MM_TOP_DDR 0x0 -#define MM_TOP_DDR_SIZE 0x80000000U -#define MM_TOP_DDR_2 0x800000000ULL -#define MM_TOP_DDR_2_SIZE 0x800000000ULL -#define MM_TOP_DDR_3 0xc000000000ULL -#define MM_TOP_DDR_3_SIZE 0x4000000000ULL -#define MM_TOP_DDR_4 0x10000000000ULL -#define MM_TOP_DDR_4_SIZE 0xb780000000ULL - -#define MM_PSM_START 0xffc80000U -#define MM_PSM_END 0xffcf0000U - -#define MM_CRL 0xff5e0000U -#define MM_CRL_SIZE 0x300000 -#define MM_IOU_SCNTR 0xff130000U -#define MM_IOU_SCNTR_SIZE 0x10000 -#define MM_IOU_SCNTRS 0xff140000U -#define MM_IOU_SCNTRS_SIZE 0x10000 -#define MM_FPD_CRF 0xfd1a0000U -#define MM_FPD_CRF_SIZE 0x140000 -#define MM_FPD_FPD_APU 0xfd5c0000 -#define MM_FPD_FPD_APU_SIZE 0x100 - -#define MM_PMC_PMC_IOU_SLCR 0xf1060000 -#define MM_PMC_PMC_IOU_SLCR_SIZE 0x10000 - -#define MM_PMC_OSPI 0xf1010000 -#define MM_PMC_OSPI_SIZE 0x10000 - -#define MM_PMC_OSPI_DAC 0xc0000000 -#define MM_PMC_OSPI_DAC_SIZE 0x20000000 - -#define MM_PMC_OSPI_DMA_DST 0xf1011800 -#define MM_PMC_OSPI_DMA_SRC 0xf1011000 - -#define MM_PMC_SD0 0xf1040000U -#define MM_PMC_SD0_SIZE 0x10000 -#define MM_PMC_BBRAM_CTRL 0xf11f0000 -#define MM_PMC_BBRAM_CTRL_SIZE 0x00050 -#define MM_PMC_EFUSE_CTRL 0xf1240000 -#define MM_PMC_EFUSE_CTRL_SIZE 0x00104 -#define MM_PMC_EFUSE_CACHE 0xf1250000 -#define MM_PMC_EFUSE_CACHE_SIZE 0x00C00 - -#define MM_PMC_CFU_APB 0xf12b0000 -#define MM_PMC_CFU_APB_SIZE 0x10000 -#define MM_PMC_CFU_STREAM 0xf12c0000 -#define MM_PMC_CFU_STREAM_SIZE 0x1000 -#define MM_PMC_CFU_SFR 0xf12c1000 -#define MM_PMC_CFU_SFR_SIZE 0x1000 -#define MM_PMC_CFU_FDRO 0xf12c2000 -#define MM_PMC_CFU_FDRO_SIZE 0x1000 -#define MM_PMC_CFU_STREAM_2 0xf1f80000 -#define MM_PMC_CFU_STREAM_2_SIZE 0x40000 - -#define MM_PMC_CFRAME0_REG 0xf12d0000 -#define MM_PMC_CFRAME0_REG_SIZE 0x1000 -#define MM_PMC_CFRAME0_FDRI 0xf12d1000 -#define MM_PMC_CFRAME0_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME1_REG 0xf12d2000 -#define MM_PMC_CFRAME1_REG_SIZE 0x1000 -#define MM_PMC_CFRAME1_FDRI 0xf12d3000 -#define MM_PMC_CFRAME1_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME2_REG 0xf12d4000 -#define MM_PMC_CFRAME2_REG_SIZE 0x1000 -#define MM_PMC_CFRAME2_FDRI 0xf12d5000 -#define MM_PMC_CFRAME2_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME3_REG 0xf12d6000 -#define MM_PMC_CFRAME3_REG_SIZE 0x1000 -#define MM_PMC_CFRAME3_FDRI 0xf12d7000 -#define MM_PMC_CFRAME3_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME4_REG 0xf12d8000 -#define MM_PMC_CFRAME4_REG_SIZE 0x1000 -#define MM_PMC_CFRAME4_FDRI 0xf12d9000 -#define MM_PMC_CFRAME4_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME5_REG 0xf12da000 -#define MM_PMC_CFRAME5_REG_SIZE 0x1000 -#define MM_PMC_CFRAME5_FDRI 0xf12db000 -#define MM_PMC_CFRAME5_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME6_REG 0xf12dc000 -#define MM_PMC_CFRAME6_REG_SIZE 0x1000 -#define MM_PMC_CFRAME6_FDRI 0xf12dd000 -#define MM_PMC_CFRAME6_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME7_REG 0xf12de000 -#define MM_PMC_CFRAME7_REG_SIZE 0x1000 -#define MM_PMC_CFRAME7_FDRI 0xf12df000 -#define MM_PMC_CFRAME7_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME8_REG 0xf12e0000 -#define MM_PMC_CFRAME8_REG_SIZE 0x1000 -#define MM_PMC_CFRAME8_FDRI 0xf12e1000 -#define MM_PMC_CFRAME8_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME9_REG 0xf12e2000 -#define MM_PMC_CFRAME9_REG_SIZE 0x1000 -#define MM_PMC_CFRAME9_FDRI 0xf12e3000 -#define MM_PMC_CFRAME9_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME10_REG 0xf12e4000 -#define MM_PMC_CFRAME10_REG_SIZE 0x1000 -#define MM_PMC_CFRAME10_FDRI 0xf12e5000 -#define MM_PMC_CFRAME10_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME11_REG 0xf12e6000 -#define MM_PMC_CFRAME11_REG_SIZE 0x1000 -#define MM_PMC_CFRAME11_FDRI 0xf12e7000 -#define MM_PMC_CFRAME11_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME12_REG 0xf12e8000 -#define MM_PMC_CFRAME12_REG_SIZE 0x1000 -#define MM_PMC_CFRAME12_FDRI 0xf12e9000 -#define MM_PMC_CFRAME12_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME13_REG 0xf12ea000 -#define MM_PMC_CFRAME13_REG_SIZE 0x1000 -#define MM_PMC_CFRAME13_FDRI 0xf12eb000 -#define MM_PMC_CFRAME13_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME14_REG 0xf12ec000 -#define MM_PMC_CFRAME14_REG_SIZE 0x1000 -#define MM_PMC_CFRAME14_FDRI 0xf12ed000 -#define MM_PMC_CFRAME14_FDRI_SIZE 0x1000 -#define MM_PMC_CFRAME_BCAST_REG 0xf12ee000 -#define MM_PMC_CFRAME_BCAST_REG_SIZE 0x1000 -#define MM_PMC_CFRAME_BCAST_FDRI 0xf12ef000 -#define MM_PMC_CFRAME_BCAST_FDRI_SIZE 0x1000 - -#define MM_PMC_CRP 0xf1260000U -#define MM_PMC_CRP_SIZE 0x10000 -#define MM_PMC_RTC 0xf12a0000 -#define MM_PMC_RTC_SIZE 0x10000 -#define MM_PMC_TRNG 0xf1230000 -#define MM_PMC_TRNG_SIZE 0x10000#endif
hw/arm/xlnx-versal.c +7 -21
@@ -16,11 +16,10 @@#include "qobject/qlist.h" #include "qemu/module.h" #include "hw/sysbus.h" #include "net/net.h" #include "system/system.h" -#include "hw/arm/boot.h" #include "hw/misc/unimp.h" #include "hw/arm/xlnx-versal.h" #include "qemu/log.h" #include "target/arm/cpu-qom.h" #include "target/arm/gtimer.h"
@@ -49,17 +48,10 @@#include "hw/core/split-irq.h" #include "target/arm/cpu.h" #include "hw/cpu/cluster.h" #include "hw/arm/bsa.h" -#define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72") -#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f") -#define GEM_REVISION 0x40070106 - -#define VERSAL_NUM_PMC_APB_IRQS 18 -#define NUM_OSPI_IRQ_LINES 3 -/* * IRQ descriptor to catch the following cases: * - Multiple devices can connect to the same IRQ. They are OR'ed together. */ FIELD (VERSAL_IRQ ,IRQ ,0 ,16 )
@@ -1356,11 +1348,11 @@ static DeviceState *versal_create_ospi(Versal *s,memory_region_add_subregion (&s->mr_ps, map->dac, linear_mr);/* OSPI irq */ - orgate =create_or_gate (s,OBJECT (dev),"irq-orgate" ,NUM_OSPI_IRQ_LINES , + orgate =create_or_gate (s,OBJECT (dev),"irq-orgate" ,3 , map->irq);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (orgate,0 ));sysbus_connect_irq (SYS_BUS_DEVICE (dma_src),0 ,qdev_get_gpio_in (orgate,1 ));sysbus_connect_irq (SYS_BUS_DEVICE (dma_dst),0 ,qdev_get_gpio_in (orgate,2 ));
@@ -1617,22 +1609,16 @@ static void versal_unimp_irq_parity_imr(void *opaque, int n, int level)static void versal_unimp (Versal *s) {DeviceState *slcr;qemu_irq gpio_in; -versal_unimp_area (s,"psm" , &s->mr_ps, -MM_PSM_START ,MM_PSM_END -MM_PSM_START ); -versal_unimp_area (s,"crf" , &s->mr_ps, -MM_FPD_CRF ,MM_FPD_CRF_SIZE ); -versal_unimp_area (s,"apu" , &s->mr_ps, -MM_FPD_FPD_APU ,MM_FPD_FPD_APU_SIZE ); -versal_unimp_area (s,"crp" , &s->mr_ps, -MM_PMC_CRP ,MM_PMC_CRP_SIZE ); -versal_unimp_area (s,"iou-scntr" , &s->mr_ps, -MM_IOU_SCNTR ,MM_IOU_SCNTR_SIZE ); -versal_unimp_area (s,"iou-scntr-seucre" , &s->mr_ps, -MM_IOU_SCNTRS ,MM_IOU_SCNTRS_SIZE ); +versal_unimp_area (s,"psm" , &s->mr_ps,0xffc80000 ,0x70000 ); +versal_unimp_area (s,"crf" , &s->mr_ps,0xfd1a0000 ,0x140000 ); +versal_unimp_area (s,"apu" , &s->mr_ps,0xfd5c0000 ,0x100 ); +versal_unimp_area (s,"crp" , &s->mr_ps,0xf1260000 ,0x10000 ); +versal_unimp_area (s,"iou-scntr" , &s->mr_ps,0xff130000 ,0x10000 ); +versal_unimp_area (s,"iou-scntr-seucre" , &s->mr_ps,0xff140000 ,0x10000 );qdev_init_gpio_in_named (DEVICE (s), versal_unimp_sd_emmc_sel,"sd-emmc-sel-dummy" ,2 );qdev_init_gpio_in_named (DEVICE (s), versal_unimp_qspi_ospi_mux_sel,"qspi-ospi-mux-sel-dummy" ,1 );
Signature · 1 line
2.50.1
PATCH v3 36/47 hw/misc/xlnx-versal-crl: add the versal2 version
In reply to Luc MichelAdd the versal2 version of the CRL device. For the implemented part, it is similar to the versal version but drives reset line of more devices.
--- include/hw/arm/xlnx-versal-version.h | 1 + include/hw/misc/xlnx-versal-crl.h | 329 ++++++++++++++++++++++ hw/misc/xlnx-versal-crl.c | 392 +++++++++++++++++++++++++++ 3 files changed, 722 insertions(+)
include/hw/arm/xlnx-versal-version.h +1 -0
@@ -8,8 +8,9 @@#ifndef HW_ARM_XLNX_VERSAL_VERSION_H #define HW_ARM_XLNX_VERSAL_VERSION_H typedef enum VersalVersion {VERSAL_VER_VERSAL , +VERSAL_VER_VERSAL2 , }VersalVersion ;#endif
include/hw/misc/xlnx-versal-crl.h +329 -0
368 lines not on this page · raw message
hw/misc/xlnx-versal-crl.c +392 -0
464 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 37/47 hw/arm/xlnx-versal: add a per_cluster_gic switch to VersalCpuClusterMap
In reply to Luc MichelAdd the per_cluster_gic switch to the VersalCpuClusterMap structure. When set, this indicates that a GIC instance should by created per-cluster instead of globally for the whole RPU or APU. This is in preparation for versal2.
--- hw/arm/xlnx-versal.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
hw/arm/xlnx-versal.c +13 -2
@@ -86,10 +86,15 @@ enum StartPoweredOffMode { SPO_ALL, }; typedef struct VersalCpuClusterMap { VersalGicMap gic; + /* + * true: one GIC per cluster. + * false: one GIC for all CPUs + */ + bool per_cluster_gic; const char *name; const char *cpu_model; size_t num_core; size_t num_cluster;
@@ -823,16 +828,22 @@ static void versal_create_cpu_cluster(Versal *s, const VersalCpuClusterMap *map)DeviceState *cpu =versal_create_cpu (s, map, cluster, mr, i, j); cpus[i * map->num_core + j] = cpu; } +if (map->per_cluster_gic) { +versal_create_and_connect_gic (s, map, mr, &cpus[i * map->num_core], + map->num_core); + } }qdev_realize_and_unref (cluster,NULL , &error_fatal); -versal_create_and_connect_gic (s, map, mr, cpus, - map->num_cluster * map->num_core); +if (!map->per_cluster_gic) { +versal_create_and_connect_gic (s, map, mr, cpus, + map->num_cluster * map->num_core); + } has_gtimer =arm_feature (&ARM_CPU (cpus[0 ])->env,ARM_FEATURE_GENERIC_TIMER );if (map->dtb_expose && has_gtimer) {qemu_fdt_add_subnode (s->cfg.fdt,"/timer" ); qemu_fdt_setprop_cells(s->cfg.fdt, "/timer", "interrupts",
Signature · 1 line
2.50.1
PATCH v3 38/47 hw/arm/xlnx-versal: add the target field in IRQ descriptor
In reply to Luc MichelAdd the target field in the IRQ descriptor. This allows to target an IRQ to another IRQ controller than the GIC(s). Other supported targets are the PMC PPU1 CPU interrupt controller and the EAM (Error management) device. Those two devices are currently not implemented so IRQs targeting those will be left unconnected. This is in preparation for versal2.
--- hw/arm/xlnx-versal.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
hw/arm/xlnx-versal.c +39 -2
@@ -50,18 +50,30 @@#include "hw/cpu/cluster.h" #include "hw/arm/bsa.h" /* * IRQ descriptor to catch the following cases: +* - An IRQ can either connect to the GICs, to the PPU1 intc, or the the EAM * - Multiple devices can connect to the same IRQ. They are OR'ed together. */ FIELD(VERSAL_IRQ, IRQ, 0, 16) +FIELD(VERSAL_IRQ, TARGET, 16, 2) FIELD(VERSAL_IRQ, ORED, 18, 1) FIELD(VERSAL_IRQ, OR_IDX, 19, 4) /* input index on the IRQ OR gate */ +typedef enum VersalIrqTarget { +IRQ_TARGET_GIC , +IRQ_TARGET_PPU1 , +IRQ_TARGET_EAM , +}VersalIrqTarget ; + +#define PPU1_IRQ (irq) ((IRQ_TARGET_PPU1 << R_VERSAL_IRQ_TARGET_SHIFT) | (irq)) +#define EAM_IRQ (irq) ((IRQ_TARGET_EAM << R_VERSAL_IRQ_TARGET_SHIFT) | (irq))#define OR_IRQ (irq, or_idx) \ (R_VERSAL_IRQ_ORED_MASK | ((or_idx) << R_VERSAL_IRQ_OR_IDX_SHIFT) | (irq)) +#define PPU1_OR_IRQ (irq, or_idx) \ + ((IRQ_TARGET_PPU1 << R_VERSAL_IRQ_TARGET_SHIFT) | OR_IRQ(irq, or_idx))typedef struct VersalSimplePeriphMap {uint64_t addr;int irq; }VersalSimplePeriphMap ;
@@ -412,19 +424,27 @@ static qemu_irq versal_get_gic_irq(Versal *s, int irq_idx)* Or gates are placed under the /soc/irq-or-gates QOM container. */ static qemu_irq versal_get_irq_or_gate_in (Versal *s,int irq_idx,qemu_irq target_irq) { +static const char *TARGET_STR [] = { + [IRQ_TARGET_GIC ] ="gic" , + [IRQ_TARGET_PPU1 ] ="ppu1" , + [IRQ_TARGET_EAM ] ="eam" , + }; + +VersalIrqTarget target;Object *container =versal_get_child (s,"irq-or-gates" );DeviceState *dev; g_autofree char *name;int idx, or_idx; idx =FIELD_EX32 (irq_idx,VERSAL_IRQ ,IRQ ); or_idx =FIELD_EX32 (irq_idx,VERSAL_IRQ ,OR_IDX ); + target =FIELD_EX32 (irq_idx,VERSAL_IRQ ,TARGET ); - name =g_strdup_printf ("irq[%d]" , idx); + name =g_strdup_printf ("%s-irq[%d]" ,TARGET_STR [target], idx); dev =DEVICE (object_resolve_path_at (container, name));if (dev ==NULL ) { dev =qdev_new (TYPE_OR_IRQ );object_property_add_child (container, name,OBJECT (dev));
@@ -436,16 +456,33 @@ static qemu_irq versal_get_irq_or_gate_in(Versal *s, int irq_idx,return qdev_get_gpio_in (dev, or_idx); }static qemu_irq versal_get_irq (Versal *s,int irq_idx) { +VersalIrqTarget target;qemu_irq irq;bool ored; + target =FIELD_EX32 (irq_idx,VERSAL_IRQ ,TARGET ); ored =FIELD_EX32 (irq_idx,VERSAL_IRQ ,ORED ); - irq =versal_get_gic_irq (s, irq_idx); +switch (target) { +case IRQ_TARGET_EAM : +/* EAM not implemented */ +return NULL ; + +case IRQ_TARGET_PPU1 : +/* PPU1 CPU not implemented */ +return NULL ; + +case IRQ_TARGET_GIC : + irq =versal_get_gic_irq (s, irq_idx); +break ; + +default : +g_assert_not_reached (); + }if (ored) { irq =versal_get_irq_or_gate_in (s, irq_idx, irq); }
Signature · 1 line
2.50.1
PATCH v3 39/47 target/arm/tcg/cpu64: add the cortex-a78ae CPU
In reply to Luc MichelAdd support for the ARM Cortex-A78AE CPU.
--- target/arm/tcg/cpu64.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
target/arm/tcg/cpu64.c +79 -0
@@ -404,10 +404,84 @@ static void aarch64_a76_initfn(Object *obj)/* From D5.1 AArch64 PMU register summary */ cpu->isar.reset_pmcr_el0 =0x410b3000 ; } +static void aarch64_a78ae_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMISARegisters *isar = &cpu->isar; + + cpu->dtb_compatible ="arm,cortex-a78ae" ; +set_feature (&cpu->env,ARM_FEATURE_V8 ); +set_feature (&cpu->env,ARM_FEATURE_NEON ); +set_feature (&cpu->env,ARM_FEATURE_GENERIC_TIMER ); +set_feature (&cpu->env,ARM_FEATURE_BACKCOMPAT_CNTFRQ ); +set_feature (&cpu->env,ARM_FEATURE_AARCH64 ); +set_feature (&cpu->env,ARM_FEATURE_CBAR_RO ); +set_feature (&cpu->env,ARM_FEATURE_EL2 ); +set_feature (&cpu->env,ARM_FEATURE_EL3 ); +set_feature (&cpu->env,ARM_FEATURE_PMU ); + +/* Ordered by B2.4 AArch64 registers by functional group */ +SET_IDREG (isar,CLIDR ,0x82000023 ); + cpu->ctr =0x9444c004 ; + cpu->dcz_blocksize =4 ; +SET_IDREG (isar,ID_AA64DFR0 ,0x0000000110305408ull ); +SET_IDREG (isar,ID_AA64ISAR0 ,0x0010100010211120ull ); +SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000001200031ull ); +SET_IDREG (isar,ID_AA64MMFR0 ,0x0000000000101125ull ); +SET_IDREG (isar,ID_AA64MMFR1 ,0x0000000010212122ull ); +SET_IDREG (isar,ID_AA64MMFR2 ,0x0000000100001011ull ); +SET_IDREG (isar,ID_AA64PFR0 ,0x1100000010111112ull );/* GIC filled in later */ +SET_IDREG (isar,ID_AA64PFR1 ,0x0000000000000010ull ); +SET_IDREG (isar,ID_AFR0 ,0x00000000 ); +SET_IDREG (isar,ID_DFR0 ,0x04010088 ); +SET_IDREG (isar,ID_ISAR0 ,0x02101110 ); +SET_IDREG (isar,ID_ISAR1 ,0x13112111 ); +SET_IDREG (isar,ID_ISAR2 ,0x21232042 ); +SET_IDREG (isar,ID_ISAR3 ,0x01112131 ); +SET_IDREG (isar,ID_ISAR4 ,0x00010142 ); +SET_IDREG (isar,ID_ISAR5 ,0x01011121 ); +SET_IDREG (isar,ID_ISAR6 ,0x00000010 ); +SET_IDREG (isar,ID_MMFR0 ,0x10201105 ); +SET_IDREG (isar,ID_MMFR1 ,0x40000000 ); +SET_IDREG (isar,ID_MMFR2 ,0x01260000 ); +SET_IDREG (isar,ID_MMFR3 ,0x02122211 ); +SET_IDREG (isar,ID_MMFR4 ,0x00021110 ); +SET_IDREG (isar,ID_PFR0 ,0x10010131 ); +SET_IDREG (isar,ID_PFR1 ,0x00010000 );/* GIC filled in later */ +SET_IDREG (isar,ID_PFR2 ,0x00000011 ); + cpu->midr =0x410fd421 ;/* r0p1 */ + cpu->revidr =0 ; + +/* From B2.18 CCSIDR_EL1 */ +/* 64KB L1 dcache */ + cpu->ccsidr[0 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,64 ,64 * KiB,7 ); +/* 64KB L1 icache */ + cpu->ccsidr[1 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,64 ,64 * KiB,2 ); +/* 512KB L2 cache */ + cpu->ccsidr[2 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,8 ,64 ,512 * KiB,7 ); + +/* From B2.93 SCTLR_EL3 */ + cpu->reset_sctlr =0x30c50838 ; + +/* From B4.23 ICH_VTR_EL2 */ + cpu->gic_num_lrs =4 ; + cpu->gic_vpribits =5 ; + cpu->gic_vprebits =5 ; + cpu->gic_pribits =5 ; + +/* From B5.1 AdvSIMD AArch64 register summary */ + cpu->isar.mvfr0 =0x10110222 ; + cpu->isar.mvfr1 =0x13211111 ; + cpu->isar.mvfr2 =0x00000043 ; + +/* From D5.1 AArch64 PMU register summary */ + cpu->isar.reset_pmcr_el0 =0x41223000 ; +} +static void aarch64_a64fx_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj);ARMISARegisters *isar = &cpu->isar;
@@ -1313,10 +1387,15 @@ void aarch64_max_tcg_initfn(Object *obj)static const ARMCPUInfo aarch64_cpus[] = { { .name ="cortex-a35" , .initfn = aarch64_a35_initfn }, { .name ="cortex-a55" , .initfn = aarch64_a55_initfn }, { .name ="cortex-a72" , .initfn = aarch64_a72_initfn }, { .name ="cortex-a76" , .initfn = aarch64_a76_initfn }, +/* +* The Cortex-A78AE differs slightly from the plain Cortex-A78. We don't +* currently model the latter. +*/ + { .name ="cortex-a78ae" , .initfn = aarch64_a78ae_initfn }, { .name ="cortex-a710" , .initfn = aarch64_a710_initfn }, { .name ="a64fx" , .initfn = aarch64_a64fx_initfn }, { .name ="neoverse-n1" , .initfn = aarch64_neoverse_n1_initfn }, { .name ="neoverse-v1" , .initfn = aarch64_neoverse_v1_initfn }, { .name ="neoverse-n2" , .initfn = aarch64_neoverse_n2_initfn },
Signature · 1 line
2.50.1
PATCH v3 40/47 hw/arm/xlnx-versal: add versal2 SoC
In reply to Luc MichelAdd the Versal Gen 2 (versal2) version of the Versal SoC family. This version embeds up to 8 Cortex-A78AE cores (split into 4 clusters) and 10 Cortex-R52 cores (split into 5 clusters). The similarities between versal and versal2 in term of architecture allow to reuse the VersalMap structure to almost fully describe the implemented parts of versal2.
The versal2 eFuse device differs quite a lot from the versal one and is left as future work.
--- include/hw/arm/xlnx-versal.h | 17 ++- hw/arm/xlnx-versal.c | 207 ++++++++++++++++++++++++++++++++--- 2 files changed, 209 insertions(+), 15 deletions(-)
include/hw/arm/xlnx-versal.h +16 -1
@@ -1,7 +1,7 @@/* -* Model of the Xilinx Versal +* AMD/Xilinx Versal family SoC model. * * Copyright (c) 2018 Xilinx Inc. * Copyright (c) 2025 Advanced Micro Devices, Inc. * Written by Edgar E. Iglesias *
@@ -20,10 +20,11 @@#define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base" OBJECT_DECLARE_TYPE(Versal, VersalClass, XLNX_VERSAL_BASE)#define TYPE_XLNX_VERSAL "xlnx-versal" +#define TYPE_XLNX_VERSAL2 "xlnx-versal2"struct Versal {/*< private >*/ SysBusDevice parent_obj;
@@ -70,6 +71,20 @@ hwaddr versal_get_reserved_mmio_addr(Versal *s);int versal_get_num_cpu (VersalVersion version);int versal_get_num_can (VersalVersion version);int versal_get_num_sdhci (VersalVersion version); +static inline const char *versal_get_class (VersalVersion version) +{ +switch (version) { +case VERSAL_VER_VERSAL : +return TYPE_XLNX_VERSAL ; + +case VERSAL_VER_VERSAL2 : +return TYPE_XLNX_VERSAL2 ; + +default : +g_assert_not_reached (); + } +} +#endif
hw/arm/xlnx-versal.c +193 -14
350 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH v3 41/47 hw/arm/xlnx-versal-virt: rename the machine to amd-versal-virt
In reply to Luc MichelTo align with current branding and ensure coherency with the upcoming versal2 machine, rename the xlnx-versal-virt machine to amd-versal-virt. Keep an alias of the old name to the new one for command-line backward compatibility.
--- docs/system/arm/xlnx-versal-virt.rst | 26 +++++++++++--------- hw/arm/xlnx-versal-virt.c | 11 ++++++--- tests/functional/test_aarch64_xlnx_versal.py | 6 ++--- 3 files changed, 25 insertions(+), 18 deletions(-)
docs/system/arm/xlnx-versal-virt.rst +15 -11
@@ -1,21 +1,25 @@ -Xilinx Versal Virt (``xlnx-versal-virt``) -========================================= +AMD Versal Virt (``amd-versal-virt``) +===================================== -Xilinx Versal is a family of heterogeneous multi-core SoCs +AMD Versal is a family of heterogeneous multi-core SoCs (System on Chip) that combine traditional hardened CPUs and I/O peripherals in a Processing System (PS) with runtime programmable FPGA logic (PL) and an Artificial Intelligence Engine (AIE). +QEMU implements the Versal Series variant of Versal SoCs, with the +``amd-versal-virt`` machine. The alias ``xlnx-versal-virt`` is kept for +backward compatibility. + More details here: -https://www.xilinx.com/products/silicon-devices/acap/versal.html +https://www.amd.com/en/products/adaptive-socs-and-fpgas/versal.html The family of Versal SoCs share a single architecture but come in different parts with different speed grades, amounts of PL and other differences. -The Xilinx Versal Virt board in QEMU is a model of a virtual board +The AMD Versal Virt board in QEMU is a model of a virtual board (does not exist in reality) with a virtual Versal SoC without I/O limitations. Currently, we support the following cores and devices: Implemented CPU cores:
@@ -72,11 +76,11 @@ A few examples: Direct Linux boot of a generic ARM64 upstream Linux kernel: .. code-block:: bash - $ qemu-system-aarch64 -M xlnx-versal-virt -m 2G \ + $ qemu-system-aarch64 -M amd-versal-virt -m 2G \ -serial mon:stdio -display none \ -kernel arch/arm64/boot/Image \ -nic user -nic user \ -device virtio-rng-device,bus=virtio-mmio-bus.0 \ -drive if=none,index=0,file=hd0.qcow2,id=hd0,snapshot \
@@ -85,11 +89,11 @@ Direct Linux boot of a generic ARM64 upstream Linux kernel: Direct Linux boot of PetaLinux 2019.2: .. code-block:: bash - $ qemu-system-aarch64 -M xlnx-versal-virt -m 2G \ + $ qemu-system-aarch64 -M amd-versal-virt -m 2G \ -serial mon:stdio -display none \ -kernel petalinux-v2019.2/Image \ -append "rdinit=/sbin/init console=ttyAMA0,115200n8 earlycon=pl011,mmio,0xFF000000,115200n8" \ -net nic,model=cadence_gem,netdev=net0 -netdev user,id=net0 \ -device virtio-rng-device,bus=virtio-mmio-bus.0,rng=rng0 \
@@ -98,11 +102,11 @@ Direct Linux boot of PetaLinux 2019.2: Boot PetaLinux 2019.2 via ARM Trusted Firmware (2018.3 because the 2019.2 version of ATF tries to configure the CCI which we don't model) and U-boot: .. code-block:: bash - $ qemu-system-aarch64 -M xlnx-versal-virt -m 2G \ + $ qemu-system-aarch64 -M amd-versal-virt -m 2G \ -serial stdio -display none \ -device loader,file=petalinux-v2018.3/bl31.elf,cpu-num=0 \ -device loader,file=petalinux-v2019.2/u-boot.elf \ -device loader,addr=0x20000000,file=petalinux-v2019.2/Image \ -nic user -nic user \
@@ -123,11 +127,11 @@ Run the following at the U-Boot prompt: Boot Linux as DOM0 on Xen via U-Boot: .. code-block:: bash - $ qemu-system-aarch64 -M xlnx-versal-virt -m 4G \ + $ qemu-system-aarch64 -M amd-versal-virt -m 4G \ -serial stdio -display none \ -device loader,file=petalinux-v2019.2/u-boot.elf,cpu-num=0 \ -device loader,addr=0x30000000,file=linux/2018-04-24/xen \ -device loader,addr=0x40000000,file=petalinux-v2019.2/Image \ -nic user -nic user \
@@ -151,11 +155,11 @@ Run the following at the U-Boot prompt: Boot Linux as Dom0 on Xen via ARM Trusted Firmware and U-Boot: .. code-block:: bash - $ qemu-system-aarch64 -M xlnx-versal-virt -m 4G \ + $ qemu-system-aarch64 -M amd-versal-virt -m 4G \ -serial stdio -display none \ -device loader,file=petalinux-v2018.3/bl31.elf,cpu-num=0 \ -device loader,file=petalinux-v2019.2/u-boot.elf \ -device loader,addr=0x30000000,file=linux/2018-04-24/xen \ -device loader,addr=0x40000000,file=petalinux-v2019.2/Image \
@@ -225,11 +229,11 @@ To use a different index value, N, from default of 1, add: Thus, a file backend should be used with caution, and 'format=luks' is highly recommended (albeit with usage complexity). Better yet, do not use actual product data when running guest image - on this Xilinx Versal Virt board. + on this AMD Versal Virt board. Using CANFDs for Versal Virt """""""""""""""""""""""""""" Versal CANFD controller is developed based on SocketCAN and QEMU CAN bus implementation. Bus connection and socketCAN connection for each CAN module
hw/arm/xlnx-versal-virt.c +7 -4
@@ -1,7 +1,7 @@/* -* Xilinx Versal Virtual board. +* AMD/Xilinx Versal Virtual board. * * Copyright (c) 2018 Xilinx Inc. * Copyright (c) 2025 Advanced Micro Devices, Inc. * Written by Edgar E. Iglesias *
@@ -24,11 +24,11 @@#include "hw/arm/boot.h" #include "target/arm/multiprocessing.h" #include "qom/object.h" #include "target/arm/cpu.h" -#define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt") +#define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("amd-versal-virt") OBJECT_DECLARE_SIMPLE_TYPE(VersalVirt, XLNX_VERSAL_VIRT_MACHINE)#define XLNX_VERSAL_NUM_OSPI_FLASH 4struct VersalVirt {
@@ -53,10 +53,11 @@ struct VersalVirt { };static void fdt_create (VersalVirt *s) {MachineClass *mc =MACHINE_GET_CLASS (s); +const char versal_compat[] ="amd-versal-virt\0xlnx-versal-virt" ; s->fdt =create_device_tree (&s->fdt_size);if (!s->fdt) {error_report ("create_device_tree() failed" );exit (1 );
@@ -70,11 +71,12 @@ static void fdt_create(VersalVirt *s)qemu_fdt_add_subnode (s->fdt,"/chosen" );qemu_fdt_add_subnode (s->fdt,"/aliases" );/* Header */ qemu_fdt_setprop_string (s->fdt,"/" ,"model" , mc->desc); -qemu_fdt_setprop_string (s->fdt,"/" ,"compatible" ,"xlnx-versal-virt" ); +qemu_fdt_setprop (s->fdt,"/" ,"compatible" , versal_compat, +sizeof (versal_compat)); }static void fdt_add_clk_node (VersalVirt *s,const char *name,unsigned int freq_hz,uint32_t phandle) {
@@ -346,11 +348,12 @@ static void versal_virt_machine_finalize(Object *obj)static void versal_virt_machine_class_init (ObjectClass *oc,const void *data) {MachineClass *mc =MACHINE_CLASS (oc);int num_cpu =versal_get_num_cpu (VERSAL_VER_VERSAL ); - mc->desc ="Xilinx Versal Virtual development board" ; + mc->desc ="AMD Versal Virtual development board" ; + mc->alias ="xlnx-versal-virt" ; mc->init = versal_virt_init; mc->min_cpus = num_cpu; mc->max_cpus = num_cpu; mc->default_cpus = num_cpu; mc->no_cdrom = true;
tests/functional/test_aarch64_xlnx_versal.py +3 -3
@@ -4,11 +4,11 @@ # # SPDX-License-Identifier: GPL-2.0-or-later from qemu_test import LinuxKernelTest, Asset -class XlnxVersalVirtMachine(LinuxKernelTest): +class AmdVersalVirtMachine(LinuxKernelTest): ASSET_KERNEL = Asset( ('http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/' 'installer-arm64/20101020ubuntu543.19/images/netboot/' 'ubuntu-installer/arm64/linux'),
@@ -18,12 +18,12 @@ class XlnxVersalVirtMachine(LinuxKernelTest): ('http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/' 'installer-arm64/20101020ubuntu543.19/images/netboot/' '/ubuntu-installer/arm64/initrd.gz'), 'e7a5e716b6f516d8be315c06e7331aaf16994fe4222e0e7cfb34bc015698929e') - def test_aarch64_xlnx_versal_virt(self): - self.set_machine('xlnx-versal-virt') + def test_aarch64_amd_versal_virt(self): + self.set_machine('amd-versal-virt') kernel_path = self.ASSET_KERNEL.fetch() initrd_path = self.ASSET_INITRD.fetch() self.vm.set_console() self.vm.add_args('-m', '2G',
Signature · 1 line
2.50.1
PATCH v3 42/47 hw/arm/xlnx-versal-virt: split into base/concrete classes
In reply to Luc MichelSplit the xlnx-versal-virt machine type into a base abstract type and a concrete type. There is no functional change. This is in preparation for the versal2 machine.
--- hw/arm/xlnx-versal-virt.c | 74 +++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 22 deletions(-)
hw/arm/xlnx-versal-virt.c +52 -22
@@ -24,12 +24,15 @@#include "hw/arm/boot.h" #include "target/arm/multiprocessing.h" #include "qom/object.h" #include "target/arm/cpu.h" +#define TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE \ + MACHINE_TYPE_NAME("amd-versal-virt-base") +OBJECT_DECLARE_TYPE(VersalVirt, VersalVirtClass, XLNX_VERSAL_VIRT_BASE_MACHINE) +#define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("amd-versal-virt") -OBJECT_DECLARE_SIMPLE_TYPE(VersalVirt, XLNX_VERSAL_VIRT_MACHINE)#define XLNX_VERSAL_NUM_OSPI_FLASH 4struct VersalVirt {MachineState parent_obj;
@@ -50,10 +53,16 @@ struct VersalVirt {bool secure;char *ospi_model; } cfg; }; +struct VersalVirtClass { +MachineClass parent_class; + +VersalVersion version; +}; +static void fdt_create (VersalVirt *s) {MachineClass *mc =MACHINE_GET_CLASS (s);const char versal_compat[] ="amd-versal-virt\0xlnx-versal-virt" ;
@@ -191,27 +200,28 @@ static void sd_plug_card(VersalVirt *s, int idx, DriveInfo *di)versal_sdhci_plug_card (&s->soc, idx, blk); }static char *versal_get_ospi_model (Object *obj,Error **errp) { -VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (obj); +VersalVirt *s =XLNX_VERSAL_VIRT_BASE_MACHINE (obj);return g_strdup (s->cfg.ospi_model); }static void versal_set_ospi_model (Object *obj,const char *value,Error **errp) { -VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (obj); +VersalVirt *s =XLNX_VERSAL_VIRT_BASE_MACHINE (obj);g_free (s->cfg.ospi_model); s->cfg.ospi_model =g_strdup (value); }static void versal_virt_init (MachineState *machine) { -VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (machine); +VersalVirt *s =XLNX_VERSAL_VIRT_BASE_MACHINE (machine); +VersalVirtClass *vvc =XLNX_VERSAL_VIRT_BASE_MACHINE_GET_CLASS (machine);int psci_conduit =QEMU_PSCI_CONDUIT_DISABLED ;int i;/* * If the user provides an Operating System to be loaded, we expect them
@@ -239,15 +249,15 @@ static void versal_virt_init(MachineState *machine)if (machine->kernel_filename) { psci_conduit =QEMU_PSCI_CONDUIT_SMC ; }object_initialize_child (OBJECT (machine),"xlnx-versal" , &s->soc, -TYPE_XLNX_VERSAL ); +versal_get_class (vvc->version));object_property_set_link (OBJECT (&s->soc),"ddr" ,OBJECT (machine->ram), &error_abort); -for (i =0 ; i <versal_get_num_can (VERSAL_VER_VERSAL ); i++) { +for (i =0 ; i <versal_get_num_can (vvc->version); i++) { g_autofree char *prop_name = g_strdup_printf("canbus%d", i);object_property_set_link (OBJECT (&s->soc), prop_name,OBJECT (s->canbus[i]), &error_abort);
@@ -272,11 +282,11 @@ static void versal_virt_init(MachineState *machine)/* Attach efuse backend, if given */ efuse_attach_drive (s);/* Plug SD cards */ -for (i =0 ; i <versal_get_num_sdhci (VERSAL_VER_VERSAL ); i++) { +for (i =0 ; i <versal_get_num_sdhci (vvc->version); i++) {sd_plug_card (s, i,drive_get (IF_SD ,0 , i)); } s->binfo.ram_size = machine->ram_size; s->binfo.loader_start =0x0 ;
@@ -316,14 +326,15 @@ static void versal_virt_init(MachineState *machine) } }static void versal_virt_machine_instance_init (Object *obj) { -VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (obj); +VersalVirt *s =XLNX_VERSAL_VIRT_BASE_MACHINE (obj); +VersalVirtClass *vvc =XLNX_VERSAL_VIRT_BASE_MACHINE_GET_CLASS (s);size_t i, num_can; - num_can =versal_get_num_can (VERSAL_VER_VERSAL ); + num_can =versal_get_num_can (vvc->version); s->canbus = g_new0(CanBusState *, num_can);/* * User can set canbusx properties to can-bus object and optionally connect * to socketcan interface via command line.
@@ -337,47 +348,66 @@ static void versal_virt_machine_instance_init(Object *obj) } }static void versal_virt_machine_finalize (Object *obj) { -VersalVirt *s =XLNX_VERSAL_VIRT_MACHINE (obj); +VersalVirt *s =XLNX_VERSAL_VIRT_BASE_MACHINE (obj);g_free (s->cfg.ospi_model);g_free (s->canbus); } -static void versal_virt_machine_class_init (ObjectClass *oc,const void *data) +static void versal_virt_machine_class_init_common (ObjectClass *oc) {MachineClass *mc =MACHINE_CLASS (oc); -int num_cpu =versal_get_num_cpu (VERSAL_VER_VERSAL ); +VersalVirtClass *vvc =XLNX_VERSAL_VIRT_BASE_MACHINE_CLASS (mc); +int num_cpu =versal_get_num_cpu (vvc->version); - mc->desc ="AMD Versal Virtual development board" ; - mc->alias ="xlnx-versal-virt" ; - mc->init = versal_virt_init; - mc->min_cpus = num_cpu; - mc->max_cpus = num_cpu; - mc->default_cpus = num_cpu; mc->no_cdrom = true; mc->auto_create_sdcard = true; mc->default_ram_id ="ddr" ; + mc->min_cpus = num_cpu; + mc->max_cpus = num_cpu; + mc->default_cpus = num_cpu; + mc->init = versal_virt_init; +object_class_property_add_str (oc,"ospi-flash" , versal_get_ospi_model, versal_set_ospi_model);object_class_property_set_description (oc,"ospi-flash" ,"Change the OSPI Flash model" ); } -static const TypeInfo versal_virt_machine_init_typeinfo = { - .name =TYPE_XLNX_VERSAL_VIRT_MACHINE , +static void versal_virt_machine_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +VersalVirtClass *vvc =XLNX_VERSAL_VIRT_BASE_MACHINE_CLASS (oc); + + mc->desc ="AMD Versal Virtual development board" ; + mc->alias ="xlnx-versal-virt" ; + vvc->version =VERSAL_VER_VERSAL ; + +versal_virt_machine_class_init_common (oc); +} + +static const TypeInfo versal_virt_base_machine_init_typeinfo = { + .name =TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE , .parent =TYPE_MACHINE , - .class_init = versal_virt_machine_class_init, + .class_size =sizeof (VersalVirtClass), .instance_init = versal_virt_machine_instance_init, .instance_size =sizeof (VersalVirt), .instance_finalize = versal_virt_machine_finalize, + .abstract = true, +}; + +static const TypeInfo versal_virt_machine_init_typeinfo = { + .name =TYPE_XLNX_VERSAL_VIRT_MACHINE , + .parent =TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE , + .class_init = versal_virt_machine_class_init, };static void versal_virt_machine_init_register_types (void ) { +type_register_static (&versal_virt_base_machine_init_typeinfo);type_register_static (&versal_virt_machine_init_typeinfo); }type_init (versal_virt_machine_init_register_types) -
Signature · 1 line
2.50.1
PATCH v3 43/47 hw/arm/xlnx-versal-virt: tidy up
In reply to Luc MichelRemove now unused clock nodes. They have been replaced by the ones created in the SoC. Remove the unused cfg.secure VersalVirt field. Remove unecessary include directives.
--- hw/arm/xlnx-versal-virt.c | 24 ------------------------ 1 file changed, 24 deletions(-)
hw/arm/xlnx-versal-virt.c +0 -24
@@ -17,14 +17,12 @@#include "system/address-spaces.h" #include "hw/block/flash.h" #include "hw/boards.h" #include "hw/sysbus.h" #include "hw/arm/fdt.h" -#include "hw/qdev-properties.h" #include "hw/arm/xlnx-versal.h" #include "hw/arm/boot.h" -#include "target/arm/multiprocessing.h" #include "qom/object.h" #include "target/arm/cpu.h" #define TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE \ MACHINE_TYPE_NAME("amd-versal-virt-base")
@@ -39,20 +37,15 @@ struct VersalVirt {Versal soc;void *fdt;int fdt_size; -struct { -uint32_t clk_125Mhz; -uint32_t clk_25Mhz; - } phandle;struct arm_boot_info binfo;CanBusState **canbus;struct { -bool secure;char *ospi_model; } cfg; };struct VersalVirtClass {
@@ -70,35 +63,20 @@ static void fdt_create(VersalVirt *s)if (!s->fdt) {error_report ("create_device_tree() failed" );exit (1 ); } -/* Allocate all phandles. */ - s->phandle.clk_25Mhz =qemu_fdt_alloc_phandle (s->fdt); - s->phandle.clk_125Mhz =qemu_fdt_alloc_phandle (s->fdt); -/* Create /chosen node for load_dtb. */ qemu_fdt_add_subnode (s->fdt,"/chosen" );qemu_fdt_add_subnode (s->fdt,"/aliases" );/* Header */ qemu_fdt_setprop_string (s->fdt,"/" ,"model" , mc->desc);qemu_fdt_setprop (s->fdt,"/" ,"compatible" , versal_compat,sizeof (versal_compat)); } -static void fdt_add_clk_node (VersalVirt *s,const char *name, -unsigned int freq_hz,uint32_t phandle) -{ -qemu_fdt_add_subnode (s->fdt, name); -qemu_fdt_setprop_cell (s->fdt, name,"phandle" , phandle); -qemu_fdt_setprop_cell (s->fdt, name,"clock-frequency" , freq_hz); -qemu_fdt_setprop_cell (s->fdt, name,"#clock-cells" ,0x0 ); -qemu_fdt_setprop_string (s->fdt, name,"compatible" ,"fixed-clock" ); -qemu_fdt_setprop (s->fdt, name,"u-boot,dm-pre-reloc" ,NULL ,0 ); -} -static void fdt_nop_memory_nodes (void *fdt,Error **errp) {Error *err =NULL ;char **node_path;int n =0 ;
@@ -263,12 +241,10 @@ static void versal_virt_init(MachineState *machine) &error_abort); }fdt_create (s);versal_set_fdt (&s->soc, s->fdt); -fdt_add_clk_node (s,"/old-clk125" ,125000000 , s->phandle.clk_125Mhz); -fdt_add_clk_node (s,"/old-clk25" ,25000000 , s->phandle.clk_25Mhz);sysbus_realize (SYS_BUS_DEVICE (&s->soc), &error_fatal);create_virtio_regions (s);/*
Signature · 1 line
2.50.1
PATCH v3 44/47 docs/system/arm/xlnx-versal-virt: update supported devices
In reply to Luc MichelUpdate the list of supported devices in the Versal SoCs.
--- docs/system/arm/xlnx-versal-virt.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
docs/system/arm/xlnx-versal-virt.rst +5 -2
@@ -21,15 +21,15 @@ The AMD Versal Virt board in QEMU is a model of a virtual board (does not exist in reality) with a virtual Versal SoC without I/O limitations. Currently, we support the following cores and devices: Implemented CPU cores: -- 2 ACPUs (ARM Cortex-A72) +- 2 ACPUs (ARM Cortex-A72) with their GICv3 and ITS +- 2 RCPUs (ARM Cortex-R5F) with their GICv2 Implemented devices: -- Interrupt controller (ARM GICv3) - 2 UARTs (ARM PL011) - An RTC (Versal built-in) - 2 GEMs (Cadence MACB Ethernet MACs) - 8 ADMA (Xilinx zDMA) channels - 2 SD Controllers
@@ -37,10 +37,13 @@ Implemented devices: - XRAM (4MB of on chip Accelerator RAM) - DDR memory - BBRAM (36 bytes of Battery-backed RAM) - eFUSE (3072 bytes of one-time field-programmable bit array) - 2 CANFDs +- USB controller +- OSPI controller +- TRNG controller QEMU does not yet model any other devices, including the PL and the AI Engine. Other differences between the hardware and the QEMU model:
Signature · 1 line
2.50.1
PATCH v3 45/47 docs/system/arm/xlnx-versal-virt: add a note about dumpdtb
In reply to Luc MichelAdd a note in the DTB section explaining how to dump the generated DTB using the dumpdtb machine option.
--- docs/system/arm/xlnx-versal-virt.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
docs/system/arm/xlnx-versal-virt.rst +7 -1
@@ -63,11 +63,17 @@ Users can load firmware or boot-loaders with the ``-device loader`` options. When loading an OS, QEMU generates a DTB and selects an appropriate address where it gets loaded. This DTB will be passed to the kernel in register x0. If there's no ``-kernel`` option, we generate a DTB and place it at 0x1000 -for boot-loaders or firmware to pick it up. +for boot-loaders or firmware to pick it up. To dump and observe the generated +DTB, one can use the ``dumpdtb`` machine option: + +.. code-block:: bash + + $ qemu-system-aarch64 -M amd-versal-virt,dumpdtb=example.dtb -m 2G + If users want to provide their own DTB, they can use the ``-dtb`` option. These DTBs will have their memory nodes modified to match QEMU's selected ram_size option before they get passed to the kernel or FW.
Signature · 1 line
2.50.1
PATCH v3 46/47 hw/arm/xlnx-versal-virt: add the xlnx-versal2-virt machine
In reply to Luc MichelAdd the Versal Gen 2 Virtual development machine embedding a versal2 SoC. This machine follows the same principle than the xlnx-versal-virt machine. It creates its own DTB and feeds it to the software payload. This way only implemented devices are exposed to the guest and the user does not need to provide a DTB.
--- docs/system/arm/xlnx-versal-virt.rst | 49 ++++++++++++++++++++++++---- hw/arm/xlnx-versal-virt.c | 37 +++++++++++++++++++-- 2 files changed, 76 insertions(+), 10 deletions(-)
docs/system/arm/xlnx-versal-virt.rst +42 -7
@@ -1,16 +1,18 @@ -AMD Versal Virt (``amd-versal-virt``) -===================================== +AMD Versal Virt (``amd-versal-virt``, ``amd-versal2-virt``) +=========================================================== AMD Versal is a family of heterogeneous multi-core SoCs (System on Chip) that combine traditional hardened CPUs and I/O peripherals in a Processing System (PS) with runtime programmable FPGA logic (PL) and an Artificial Intelligence Engine (AIE). -QEMU implements the Versal Series variant of Versal SoCs, with the -``amd-versal-virt`` machine. The alias ``xlnx-versal-virt`` is kept for -backward compatibility. +QEMU implements the following Versal SoCs variants: + +- Versal (the ``amd-versal-virt`` machine, the alias ``xlnx-versal-virt`` is + kept for backward compatibility) +- Versal Gen 2 (the ``amd-versal2-virt`` machine) More details here: https://www.amd.com/en/products/adaptive-socs-and-fpgas/versal.html The family of Versal SoCs share a single architecture but come in
@@ -19,10 +21,12 @@ other differences. The AMD Versal Virt board in QEMU is a model of a virtual board (does not exist in reality) with a virtual Versal SoC without I/O limitations. Currently, we support the following cores and devices: +Versal +"""""" Implemented CPU cores: - 2 ACPUs (ARM Cortex-A72) with their GICv3 and ITS - 2 RCPUs (ARM Cortex-R5F) with their GICv2
@@ -41,20 +45,42 @@ Implemented devices: - 2 CANFDs - USB controller - OSPI controller - TRNG controller +Versal Gen 2 +"""""""""""" +Implemented CPU cores: + +- 8 ACPUs (ARM Cortex-A78AE) with their GICv3 and ITS +- 10 RCPUs (ARM Cortex-R52) with their GICv3 (one per cluster) + +Implemented devices: + +- 2 UARTs (ARM PL011) +- An RTC (Versal built-in) +- 3 GEMs (Cadence MACB Ethernet MACs) +- 8 ADMA (Xilinx zDMA) channels +- 2 SD Controllers +- OCM (256KB of On Chip Memory) +- DDR memory +- BBRAM (36 bytes of Battery-backed RAM) +- 2 CANFDs +- 2 USB controllers +- OSPI controller +- TRNG controller + QEMU does not yet model any other devices, including the PL and the AI Engine. Other differences between the hardware and the QEMU model: - QEMU allows the amount of DDR memory provided to be specified with the ``-m`` argument. If a DTB is provided on the command line then QEMU will edit it to include suitable entries describing the Versal DDR memory ranges. -- QEMU provides 8 virtio-mmio virtio transports; these start at - address ``0xa0000000`` and have IRQs from 111 and upwards. +- QEMU provides 8 virtio-mmio virtio transports. They use reserved memory + regions and IRQ pins to avoid conflicts with real SoC peripherals. Running """"""" If the user provides an Operating System to be loaded, we expect users to use the ``-kernel`` command line option.
@@ -212,10 +238,15 @@ To use a different index value, N, from default of 0, add: -global driver=xlnx.bbram-ctrl,property=drive-index,value=N eFUSE File Backend """""""""""""""""" + +.. note:: + The eFUSE device is not implemented in the Versal Gen 2 QEMU model + yet. + eFUSE can have an optional file backend, which must be a seekable binary file with a size of 3072 bytes or larger. A file with all binary 0s is a 'blank'. To add a file-backend for the eFUSE:
@@ -269,5 +300,9 @@ To connect CANFD0 and CANFD1 to host machine's CAN interface can0: .. code-block:: bash -object can-bus,id=canbus -machine canbus0=canbus -machine canbus1=canbus -object can-host-socketcan,id=canhost0,if=can0,canbus=canbus + +.. note:: + Versal Gen 2 has 4 CAN controllers. ``canbus0`` to ``canbus3`` can + be specified on the command line.
hw/arm/xlnx-versal-virt.c +34 -3
@@ -1,7 +1,7 @@/* -* AMD/Xilinx Versal Virtual board. +* AMD/Xilinx Versal family Virtual board. * * Copyright (c) 2018 Xilinx Inc. * Copyright (c) 2025 Advanced Micro Devices, Inc. * Written by Edgar E. Iglesias *
@@ -27,10 +27,11 @@#define TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE \ MACHINE_TYPE_NAME("amd-versal-virt-base") OBJECT_DECLARE_TYPE(VersalVirt, VersalVirtClass, XLNX_VERSAL_VIRT_BASE_MACHINE)#define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("amd-versal-virt") +#define TYPE_XLNX_VERSAL2_VIRT_MACHINE MACHINE_TYPE_NAME("amd-versal2-virt")#define XLNX_VERSAL_NUM_OSPI_FLASH 4struct VersalVirt {MachineState parent_obj;
@@ -55,11 +56,13 @@ struct VersalVirtClass { };static void fdt_create (VersalVirt *s) {MachineClass *mc =MACHINE_GET_CLASS (s); +VersalVirtClass *vvc =XLNX_VERSAL_VIRT_BASE_MACHINE_GET_CLASS (s);const char versal_compat[] ="amd-versal-virt\0xlnx-versal-virt" ; +const char versal2_compat[] ="amd-versal2-virt" ; s->fdt =create_device_tree (&s->fdt_size);if (!s->fdt) {error_report ("create_device_tree() failed" );exit (1 );
@@ -69,12 +72,22 @@ static void fdt_create(VersalVirt *s)qemu_fdt_add_subnode (s->fdt,"/chosen" );qemu_fdt_add_subnode (s->fdt,"/aliases" );/* Header */ qemu_fdt_setprop_string (s->fdt,"/" ,"model" , mc->desc); -qemu_fdt_setprop (s->fdt,"/" ,"compatible" , versal_compat, -sizeof (versal_compat)); + +switch (vvc->version) { +case VERSAL_VER_VERSAL : +qemu_fdt_setprop (s->fdt,"/" ,"compatible" , versal_compat, +sizeof (versal_compat)); +break ; + +case VERSAL_VER_VERSAL2 : +qemu_fdt_setprop (s->fdt,"/" ,"compatible" , versal2_compat, +sizeof (versal2_compat)); +break ; + } }static void fdt_nop_memory_nodes (void *fdt,Error **errp) {Error *err =NULL ;
@@ -362,10 +375,21 @@ static void versal_virt_machine_class_init(ObjectClass *oc, const void *data) vvc->version =VERSAL_VER_VERSAL ;versal_virt_machine_class_init_common (oc); } +static void versal2_virt_machine_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +VersalVirtClass *vvc =XLNX_VERSAL_VIRT_BASE_MACHINE_CLASS (oc); + + mc->desc ="AMD Versal Gen 2 Virtual development board" ; + vvc->version =VERSAL_VER_VERSAL2 ; + +versal_virt_machine_class_init_common (oc); +} +static const TypeInfo versal_virt_base_machine_init_typeinfo = { .name =TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE , .parent =TYPE_MACHINE , .class_size =sizeof (VersalVirtClass), .instance_init = versal_virt_machine_instance_init,
@@ -378,12 +402,19 @@ static const TypeInfo versal_virt_machine_init_typeinfo = { .name = TYPE_XLNX_VERSAL_VIRT_MACHINE, .parent = TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE, .class_init = versal_virt_machine_class_init, }; +static const TypeInfo versal2_virt_machine_init_typeinfo = { + .name =TYPE_XLNX_VERSAL2_VIRT_MACHINE , + .parent =TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE , + .class_init = versal2_virt_machine_class_init, +}; +static void versal_virt_machine_init_register_types (void ) {type_register_static (&versal_virt_base_machine_init_typeinfo);type_register_static (&versal_virt_machine_init_typeinfo); +type_register_static (&versal2_virt_machine_init_typeinfo); }type_init (versal_virt_machine_init_register_types)
Signature · 1 line
2.50.1
PATCH v3 47/47 tests/functional/test_aarch64_xlnx_versal: test the versal2 machine
In reply to Luc MichelAdd a test for the amd-versal2-virt machine using the same command line, kernel, initrd than the ones used for amd-versal-virt.
--- tests/functional/test_aarch64_xlnx_versal.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tests/functional/test_aarch64_xlnx_versal.py +8 -2
@@ -18,12 +18,12 @@ class AmdVersalVirtMachine(LinuxKernelTest): ('http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/' 'installer-arm64/20101020ubuntu543.19/images/netboot/' '/ubuntu-installer/arm64/initrd.gz'), 'e7a5e716b6f516d8be315c06e7331aaf16994fe4222e0e7cfb34bc015698929e') - def test_aarch64_amd_versal_virt(self): - self.set_machine('amd-versal-virt') + def common_aarch64_amd_versal_virt(self, machine): + self.set_machine(machine) kernel_path = self.ASSET_KERNEL.fetch() initrd_path = self.ASSET_INITRD.fetch() self.vm.set_console() self.vm.add_args('-m', '2G',
@@ -31,7 +31,13 @@ def test_aarch64_amd_versal_virt(self): '-kernel', kernel_path, '-initrd', initrd_path) self.vm.launch() self.wait_for_console_pattern('Checked W+X mappings: passed') + def test_aarch64_amd_versal_virt(self): + self.common_aarch64_amd_versal_virt('amd-versal-virt') + + def test_aarch64_amd_versal2_virt(self): + self.common_aarch64_amd_versal_virt('amd-versal2-virt') + if __name__ == '__main__': LinuxKernelTest.main()
Signature · 1 line
2.50.1
Quoted 43 lines · Luc Michel
v3:
- Droppedqemu_get_cpu()usage in the machine code. Added an getter on the SoC interface to retrieve the boot CPU instead. [Phil]
- Cleaned themp_affinitylogic. Drop the mask attribute and assume it's always0xff(the Affx fields in MPIDR are 8 bits long). Use theARM_AFFx_SHIFTconstant instead of hardcoded values in .mp_affinity description. [Phil]
- Avocado test renaming in patch 41 instead of 47. [Phil]
- Documentation tweak. [Phil]v2:
- Addressed formatting/typo issues [Francisco]
- Patch 23: GICv3 first-cpu-idx: addressed the KVM case by bailing out if not 0 at realize. I chose this path as I don't have a clear view of what it means to implement that for KVM. It seems to make sense anyway as this property is meant to be used for modeling of non-SMP systems. [Peter]
- Patch 39: added a comment to clarify cortex-a78ae != cortex-a78 [Peter]Hello,
This series brings support for the AMD Versal Gen 2 (versal2) SoC in QEMU. This SoC is the next iteration of the existing Versal SoC.
It is organized as follows:
- The first and biggest part of the series performs refactoring of the existing versal SoC implementation. This consists in:
- splitting existing device types into base/concrete classes,
- moving from an in-place to dynamic device creation approach in the SoC code for flexibility,
- describing the SoC using a new structure called VersalMap,
- moving the DTB creation logic in the SoC code itself alongside device creation.
Patches are split such that each device is individually converted to use this new approach. Behaviour changes are minimal and are emphasised in the commit messages. This gets the SoC code ready for versal2 addition and leverage the fact that Versal family SoCs are quite similar in term of architecture.- versal2 SoC support is then added by adding the corresponding VersalMap description. This allows to reuse the existing code without duplication and almost no special case.
Quoted 8 lines
- The amd-versal2-virt machine is finally added, following the same idea as amd-versal-virt. The documentation and tests are updated accordingly.
Note that the xlnx-versal-virt machine is renamed amd-versal-virt to follow current branding guidelines and stay coherent with the new amd-versal2-virt machine. The xlnx-versal-virt name is kept as an alias to amd-versal-virt for command line backward compatibility.
Hi Luc,
I run with this command-line:
qemu-system-aarch64 -M xlnx-versal-virt -m 2g -serial stdio -display none -net nic,model=cadence_gem,netdev=n0 -netdev user,id=n0 -kernel Image -device virtio-blk-device,drive=d0 -drive format=qcow2,if=none,file=rootfs.qcow2,id=d0 -append "root=/dev/vda1 console=ttyAMA0"
Before these patches, ethernet comes up fine but with this series applied, ethernet stops working. The kernel finds device and the driver comes up but it looks like it can't receive packets:
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
--> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:4988 (4.8 KiB) Interrupt:17
Quoted 77 lines
Thanks
Luc
Francisco Iglesias (1):
hw/intc/arm_gicv3: Introduce a 'first-cpu-index' propertyLuc Michel (46):
hw/arm/xlnx-versal: split the xlnx-versal type hw/arm/xlnx-versal: prepare for FDT creation hw/arm/xlnx-versal: uart: refactor creation hw/arm/xlnx-versal: canfd: refactor creation hw/arm/xlnx-versal: sdhci: refactor creation hw/arm/xlnx-versal: gem: refactor creation hw/arm/xlnx-versal: adma: refactor creation hw/arm/xlnx-versal: xram: refactor creation hw/arm/xlnx-versal: usb: refactor creation hw/arm/xlnx-versal: efuse: refactor creation hw/arm/xlnx-versal: ospi: refactor creation hw/arm/xlnx-versal: VersalMap: add support for OR'ed IRQs hw/arm/xlnx-versal: PMC IOU SCLR: refactor creation hw/arm/xlnx-versal: bbram: refactor creation hw/arm/xlnx-versal: trng: refactor creation hw/arm/xlnx-versal: rtc: refactor creation hw/arm/xlnx-versal: cfu: refactor creation hw/arm/xlnx-versal: crl: refactor creation hw/arm/xlnx-versal-virt: virtio: refactor creation hw/arm/xlnx-versal: refactor CPU cluster creation hw/arm/xlnx-versal: add themp_affinityproperty to the CPU mapping hw/arm/xlnx-versal: instantiate the GIC ITS in the APU hw/arm/xlnx-versal: add support for multiple GICs hw/arm/xlnx-versal: add support for GICv2 hw/arm/xlnx-versal: rpu: refactor creation hw/arm/xlnx-versal: ocm: refactor creation hw/arm/xlnx-versal: ddr: refactor creation hw/arm/xlnx-versal: add theversal_get_num_cpuaccessor hw/misc/xlnx-versal-crl: remove unnecessary include directives hw/misc/xlnx-versal-crl: split into base/concrete classes hw/misc/xlnx-versal-crl: refactor device reset logic hw/arm/xlnx-versal: reconnect the CRL to the other devices hw/arm/xlnx-versal: usehw/arm/bsa.hfor timer IRQ indices hw/arm/xlnx-versal: tidy up
hw/misc/xlnx-versal-crl: add the versal2 version hw/arm/xlnx-versal: add aper_cluster_gicswitch to
VersalCpuClusterMap
hw/arm/xlnx-versal: add the target field in IRQ descriptor target/arm/tcg/cpu64: add the cortex-a78ae CPU hw/arm/xlnx-versal: add versal2 SoC hw/arm/xlnx-versal-virt: rename the machine to amd-versal-virt hw/arm/xlnx-versal-virt: split into base/concrete classes hw/arm/xlnx-versal-virt: tidy up docs/system/arm/xlnx-versal-virt: update supported devices docs/system/arm/xlnx-versal-virt: add a note about dumpdtb hw/arm/xlnx-versal-virt: add the xlnx-versal2-virt machine tests/functional/test_aarch64_xlnx_versal: test the versal2 machinedocs/system/arm/xlnx-versal-virt.rst | 80 +- include/hw/arm/xlnx-versal-version.h | 16 + include/hw/arm/xlnx-versal.h | 342 +-- include/hw/intc/arm_gicv3_common.h | 1 + include/hw/misc/xlnx-versal-crl.h | 378 ++- hw/arm/xlnx-versal-virt.c | 742 ++---- hw/arm/xlnx-versal.c | 2455 +++++++++++++----- hw/intc/arm_gicv3_common.c | 3 +- hw/intc/arm_gicv3_cpuif.c | 2 +- hw/intc/arm_gicv3_kvm.c | 6 + hw/misc/xlnx-versal-crl.c | 602 ++++- target/arm/tcg/cpu64.c | 79 + tests/functional/test_aarch64_xlnx_versal.py | 12 +- 13 files changed, 3057 insertions(+), 1661 deletions(-) create mode 100644 include/hw/arm/xlnx-versal-version.hSignature · 1 line
2.50.1
Quoted 63 lines · Edgar E. Iglesias
Quoted 43 lines · Luc Michel
v3:
- Droppedqemu_get_cpu()usage in the machine code. Added an getter on the SoC interface to retrieve the boot CPU instead. [Phil]
- Cleaned themp_affinitylogic. Drop the mask attribute and assume it's always0xff(the Affx fields in MPIDR are 8 bits long). Use theARM_AFFx_SHIFTconstant instead of hardcoded values in .mp_affinity description. [Phil]
- Avocado test renaming in patch 41 instead of 47. [Phil]
- Documentation tweak. [Phil]v2:
- Addressed formatting/typo issues [Francisco]
- Patch 23: GICv3 first-cpu-idx: addressed the KVM case by bailing out if not 0 at realize. I chose this path as I don't have a clear view of what it means to implement that for KVM. It seems to make sense anyway as this property is meant to be used for modeling of non-SMP systems. [Peter]
- Patch 39: added a comment to clarify cortex-a78ae != cortex-a78 [Peter]Hello,
This series brings support for the AMD Versal Gen 2 (versal2) SoC in QEMU. This SoC is the next iteration of the existing Versal SoC.
It is organized as follows:
- The first and biggest part of the series performs refactoring of the existing versal SoC implementation. This consists in:
- splitting existing device types into base/concrete classes,
- moving from an in-place to dynamic device creation approach in the SoC code for flexibility,
- describing the SoC using a new structure called VersalMap,
- moving the DTB creation logic in the SoC code itself alongside device creation.
Patches are split such that each device is individually converted to use this new approach. Behaviour changes are minimal and are emphasised in the commit messages. This gets the SoC code ready for versal2 addition and leverage the fact that Versal family SoCs are quite similar in term of architecture.- versal2 SoC support is then added by adding the corresponding VersalMap description. This allows to reuse the existing code without duplication and almost no special case.
Quoted 8 lines
- The amd-versal2-virt machine is finally added, following the same idea as amd-versal-virt. The documentation and tests are updated accordingly.
Note that the xlnx-versal-virt machine is renamed amd-versal-virt to follow current branding guidelines and stay coherent with the new amd-versal2-virt machine. The xlnx-versal-virt name is kept as an alias to amd-versal-virt for command line backward compatibility.
Hi Luc,
I run with this command-line:
qemu-system-aarch64 -M xlnx-versal-virt -m 2g -serial stdio -display none -net nic,model=cadence_gem,netdev=n0 -netdev user,id=n0 -kernel Image -device virtio-blk-device,drive=d0 -drive format=qcow2,if=none,file=rootfs.qcow2,id=d0 -append "root=/dev/vda1 console=ttyAMA0"Before these patches, ethernet comes up fine but with this series applied, ethernet stops working. The kernel finds device and the driver comes up but it looks like it can't receive packets:
Quoted 9 lines
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
--> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:4988 (4.8 KiB) Interrupt:17
It seems that eth0 and eth1 have been swapped, because of the FDT node ordering.
This is the issue of the non-predictable naming scheme, used by default by the kernel. I tried fixing it using aliases properties as I did for the UARTs. Unfortunately whether this works or not is driver dependent, and it does not work for the Cadence GEM driver.
So my only option is to create the nodes in the same order as before, to stay backward-compatible. I'll introduce a small hack to do so in v4.
Please note though that the FDT node order brings no guarantee of any kind regarding the device probing order in the kernel.
Thanks
Luc