xref: /qemu/hw/arm/xlnx-zynqmp.c (revision 0b8fa32f)
1f0a902f7SPeter Crosthwaite /*
2f0a902f7SPeter Crosthwaite  * Xilinx Zynq MPSoC emulation
3f0a902f7SPeter Crosthwaite  *
4f0a902f7SPeter Crosthwaite  * Copyright (C) 2015 Xilinx Inc
5f0a902f7SPeter Crosthwaite  * Written by Peter Crosthwaite <peter.crosthwaite@xilinx.com>
6f0a902f7SPeter Crosthwaite  *
7f0a902f7SPeter Crosthwaite  * This program is free software; you can redistribute it and/or modify it
8f0a902f7SPeter Crosthwaite  * under the terms of the GNU General Public License as published by the
9f0a902f7SPeter Crosthwaite  * Free Software Foundation; either version 2 of the License, or
10f0a902f7SPeter Crosthwaite  * (at your option) any later version.
11f0a902f7SPeter Crosthwaite  *
12f0a902f7SPeter Crosthwaite  * This program is distributed in the hope that it will be useful, but WITHOUT
13f0a902f7SPeter Crosthwaite  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14f0a902f7SPeter Crosthwaite  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15f0a902f7SPeter Crosthwaite  * for more details.
16f0a902f7SPeter Crosthwaite  */
17f0a902f7SPeter Crosthwaite 
1812b16722SPeter Maydell #include "qemu/osdep.h"
19da34e65cSMarkus Armbruster #include "qapi/error.h"
20*0b8fa32fSMarkus Armbruster #include "qemu/module.h"
214771d756SPaolo Bonzini #include "cpu.h"
22f0a902f7SPeter Crosthwaite #include "hw/arm/xlnx-zynqmp.h"
23bf4cb109SPeter Crosthwaite #include "hw/intc/arm_gic_common.h"
247729e1f4SPeter Crosthwaite #include "exec/address-spaces.h"
252a0ee672SEdgar E. Iglesias #include "sysemu/kvm.h"
262a0ee672SEdgar E. Iglesias #include "kvm_arm.h"
277729e1f4SPeter Crosthwaite 
287729e1f4SPeter Crosthwaite #define GIC_NUM_SPI_INTR 160
297729e1f4SPeter Crosthwaite 
30bf4cb109SPeter Crosthwaite #define ARM_PHYS_TIMER_PPI  30
31bf4cb109SPeter Crosthwaite #define ARM_VIRT_TIMER_PPI  27
3275b749afSLuc Michel #define ARM_HYP_TIMER_PPI   26
3375b749afSLuc Michel #define ARM_SEC_TIMER_PPI   29
3475b749afSLuc Michel #define GIC_MAINTENANCE_PPI 25
35bf4cb109SPeter Crosthwaite 
3620bff213SAlistair Francis #define GEM_REVISION        0x40070106
3720bff213SAlistair Francis 
387729e1f4SPeter Crosthwaite #define GIC_BASE_ADDR       0xf9000000
397729e1f4SPeter Crosthwaite #define GIC_DIST_ADDR       0xf9010000
407729e1f4SPeter Crosthwaite #define GIC_CPU_ADDR        0xf9020000
4175b749afSLuc Michel #define GIC_VIFACE_ADDR     0xf9040000
4275b749afSLuc Michel #define GIC_VCPU_ADDR       0xf9060000
437729e1f4SPeter Crosthwaite 
446fdf3282SAlistair Francis #define SATA_INTR           133
456fdf3282SAlistair Francis #define SATA_ADDR           0xFD0C0000
466fdf3282SAlistair Francis #define SATA_NUM_PORTS      2
476fdf3282SAlistair Francis 
48babc1f30SFrancisco Iglesias #define QSPI_ADDR           0xff0f0000
49babc1f30SFrancisco Iglesias #define LQSPI_ADDR          0xc0000000
50babc1f30SFrancisco Iglesias #define QSPI_IRQ            15
51babc1f30SFrancisco Iglesias 
52b93dbcddSKONRAD Frederic #define DP_ADDR             0xfd4a0000
53b93dbcddSKONRAD Frederic #define DP_IRQ              113
54b93dbcddSKONRAD Frederic 
55b93dbcddSKONRAD Frederic #define DPDMA_ADDR          0xfd4c0000
56b93dbcddSKONRAD Frederic #define DPDMA_IRQ           116
57b93dbcddSKONRAD Frederic 
580ab7bbc7SAlistair Francis #define IPI_ADDR            0xFF300000
590ab7bbc7SAlistair Francis #define IPI_IRQ             64
600ab7bbc7SAlistair Francis 
6108b2f15eSAlistair Francis #define RTC_ADDR            0xffa60000
6208b2f15eSAlistair Francis #define RTC_IRQ             26
6308b2f15eSAlistair Francis 
64b630d3d4SPhilippe Mathieu-Daudé #define SDHCI_CAPABILITIES  0x280737ec6481 /* Datasheet: UG1085 (v1.7) */
65b630d3d4SPhilippe Mathieu-Daudé 
6614ca2e46SPeter Crosthwaite static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS] = {
6714ca2e46SPeter Crosthwaite     0xFF0B0000, 0xFF0C0000, 0xFF0D0000, 0xFF0E0000,
6814ca2e46SPeter Crosthwaite };
6914ca2e46SPeter Crosthwaite 
7014ca2e46SPeter Crosthwaite static const int gem_intr[XLNX_ZYNQMP_NUM_GEMS] = {
7114ca2e46SPeter Crosthwaite     57, 59, 61, 63,
7214ca2e46SPeter Crosthwaite };
7314ca2e46SPeter Crosthwaite 
743bade2a9SPeter Crosthwaite static const uint64_t uart_addr[XLNX_ZYNQMP_NUM_UARTS] = {
753bade2a9SPeter Crosthwaite     0xFF000000, 0xFF010000,
763bade2a9SPeter Crosthwaite };
773bade2a9SPeter Crosthwaite 
783bade2a9SPeter Crosthwaite static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = {
793bade2a9SPeter Crosthwaite     21, 22,
803bade2a9SPeter Crosthwaite };
813bade2a9SPeter Crosthwaite 
8233108e9fSSai Pavan Boddu static const uint64_t sdhci_addr[XLNX_ZYNQMP_NUM_SDHCI] = {
8333108e9fSSai Pavan Boddu     0xFF160000, 0xFF170000,
8433108e9fSSai Pavan Boddu };
8533108e9fSSai Pavan Boddu 
8633108e9fSSai Pavan Boddu static const int sdhci_intr[XLNX_ZYNQMP_NUM_SDHCI] = {
8733108e9fSSai Pavan Boddu     48, 49,
8833108e9fSSai Pavan Boddu };
8933108e9fSSai Pavan Boddu 
9002d07eb4SAlistair Francis static const uint64_t spi_addr[XLNX_ZYNQMP_NUM_SPIS] = {
9102d07eb4SAlistair Francis     0xFF040000, 0xFF050000,
9202d07eb4SAlistair Francis };
9302d07eb4SAlistair Francis 
9402d07eb4SAlistair Francis static const int spi_intr[XLNX_ZYNQMP_NUM_SPIS] = {
9502d07eb4SAlistair Francis     19, 20,
9602d07eb4SAlistair Francis };
9702d07eb4SAlistair Francis 
9804965bcaSFrancisco Iglesias static const uint64_t gdma_ch_addr[XLNX_ZYNQMP_NUM_GDMA_CH] = {
9904965bcaSFrancisco Iglesias     0xFD500000, 0xFD510000, 0xFD520000, 0xFD530000,
10004965bcaSFrancisco Iglesias     0xFD540000, 0xFD550000, 0xFD560000, 0xFD570000
10104965bcaSFrancisco Iglesias };
10204965bcaSFrancisco Iglesias 
10304965bcaSFrancisco Iglesias static const int gdma_ch_intr[XLNX_ZYNQMP_NUM_GDMA_CH] = {
10404965bcaSFrancisco Iglesias     124, 125, 126, 127, 128, 129, 130, 131
10504965bcaSFrancisco Iglesias };
10604965bcaSFrancisco Iglesias 
10704965bcaSFrancisco Iglesias static const uint64_t adma_ch_addr[XLNX_ZYNQMP_NUM_ADMA_CH] = {
10804965bcaSFrancisco Iglesias     0xFFA80000, 0xFFA90000, 0xFFAA0000, 0xFFAB0000,
10904965bcaSFrancisco Iglesias     0xFFAC0000, 0xFFAD0000, 0xFFAE0000, 0xFFAF0000
11004965bcaSFrancisco Iglesias };
11104965bcaSFrancisco Iglesias 
11204965bcaSFrancisco Iglesias static const int adma_ch_intr[XLNX_ZYNQMP_NUM_ADMA_CH] = {
11304965bcaSFrancisco Iglesias     77, 78, 79, 80, 81, 82, 83, 84
11404965bcaSFrancisco Iglesias };
11504965bcaSFrancisco Iglesias 
1167729e1f4SPeter Crosthwaite typedef struct XlnxZynqMPGICRegion {
1177729e1f4SPeter Crosthwaite     int region_index;
1187729e1f4SPeter Crosthwaite     uint32_t address;
11975b749afSLuc Michel     uint32_t offset;
12075b749afSLuc Michel     bool virt;
1217729e1f4SPeter Crosthwaite } XlnxZynqMPGICRegion;
1227729e1f4SPeter Crosthwaite 
1237729e1f4SPeter Crosthwaite static const XlnxZynqMPGICRegion xlnx_zynqmp_gic_regions[] = {
12475b749afSLuc Michel     /* Distributor */
12575b749afSLuc Michel     {
12675b749afSLuc Michel         .region_index = 0,
12775b749afSLuc Michel         .address = GIC_DIST_ADDR,
12875b749afSLuc Michel         .offset = 0,
12975b749afSLuc Michel         .virt = false
13075b749afSLuc Michel     },
13175b749afSLuc Michel 
13275b749afSLuc Michel     /* CPU interface */
13375b749afSLuc Michel     {
13475b749afSLuc Michel         .region_index = 1,
13575b749afSLuc Michel         .address = GIC_CPU_ADDR,
13675b749afSLuc Michel         .offset = 0,
13775b749afSLuc Michel         .virt = false
13875b749afSLuc Michel     },
13975b749afSLuc Michel     {
14075b749afSLuc Michel         .region_index = 1,
14175b749afSLuc Michel         .address = GIC_CPU_ADDR + 0x10000,
14275b749afSLuc Michel         .offset = 0x1000,
14375b749afSLuc Michel         .virt = false
14475b749afSLuc Michel     },
14575b749afSLuc Michel 
14675b749afSLuc Michel     /* Virtual interface */
14775b749afSLuc Michel     {
14875b749afSLuc Michel         .region_index = 2,
14975b749afSLuc Michel         .address = GIC_VIFACE_ADDR,
15075b749afSLuc Michel         .offset = 0,
15175b749afSLuc Michel         .virt = true
15275b749afSLuc Michel     },
15375b749afSLuc Michel 
15475b749afSLuc Michel     /* Virtual CPU interface */
15575b749afSLuc Michel     {
15675b749afSLuc Michel         .region_index = 3,
15775b749afSLuc Michel         .address = GIC_VCPU_ADDR,
15875b749afSLuc Michel         .offset = 0,
15975b749afSLuc Michel         .virt = true
16075b749afSLuc Michel     },
16175b749afSLuc Michel     {
16275b749afSLuc Michel         .region_index = 3,
16375b749afSLuc Michel         .address = GIC_VCPU_ADDR + 0x10000,
16475b749afSLuc Michel         .offset = 0x1000,
16575b749afSLuc Michel         .virt = true
16675b749afSLuc Michel     },
1677729e1f4SPeter Crosthwaite };
168f0a902f7SPeter Crosthwaite 
169bf4cb109SPeter Crosthwaite static inline int arm_gic_ppi_index(int cpu_nr, int ppi_index)
170bf4cb109SPeter Crosthwaite {
171bf4cb109SPeter Crosthwaite     return GIC_NUM_SPI_INTR + cpu_nr * GIC_INTERNAL + ppi_index;
172bf4cb109SPeter Crosthwaite }
173bf4cb109SPeter Crosthwaite 
1746ed92b14SEdgar E. Iglesias static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu,
1756ed92b14SEdgar E. Iglesias                                    Error **errp)
1766ed92b14SEdgar E. Iglesias {
1776ed92b14SEdgar E. Iglesias     Error *err = NULL;
1786ed92b14SEdgar E. Iglesias     int i;
1796908ec44SAlistair Francis     int num_rpus = MIN(smp_cpus - XLNX_ZYNQMP_NUM_APU_CPUS, XLNX_ZYNQMP_NUM_RPU_CPUS);
1806ed92b14SEdgar E. Iglesias 
181e5b51753SPeter Maydell     if (num_rpus <= 0) {
182e5b51753SPeter Maydell         /* Don't create rpu-cluster object if there's nothing to put in it */
183e5b51753SPeter Maydell         return;
184e5b51753SPeter Maydell     }
185e5b51753SPeter Maydell 
186816fd397SLuc Michel     object_initialize_child(OBJECT(s), "rpu-cluster", &s->rpu_cluster,
187816fd397SLuc Michel                             sizeof(s->rpu_cluster), TYPE_CPU_CLUSTER,
188816fd397SLuc Michel                             &error_abort, NULL);
189816fd397SLuc Michel     qdev_prop_set_uint32(DEVICE(&s->rpu_cluster), "cluster-id", 1);
190816fd397SLuc Michel 
1916908ec44SAlistair Francis     for (i = 0; i < num_rpus; i++) {
1926ed92b14SEdgar E. Iglesias         char *name;
1936ed92b14SEdgar E. Iglesias 
194d0313798SPhilippe Mathieu-Daudé         object_initialize_child(OBJECT(&s->rpu_cluster), "rpu-cpu[*]",
195d0313798SPhilippe Mathieu-Daudé                                 &s->rpu_cpu[i], sizeof(s->rpu_cpu[i]),
196d0313798SPhilippe Mathieu-Daudé                                 "cortex-r5f-" TYPE_ARM_CPU, &error_abort,
197d0313798SPhilippe Mathieu-Daudé                                 NULL);
1986ed92b14SEdgar E. Iglesias 
1996ed92b14SEdgar E. Iglesias         name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));
2006ed92b14SEdgar E. Iglesias         if (strcmp(name, boot_cpu)) {
2016ed92b14SEdgar E. Iglesias             /* Secondary CPUs start in PSCI powered-down state */
2026ed92b14SEdgar E. Iglesias             object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true,
2036ed92b14SEdgar E. Iglesias                                      "start-powered-off", &error_abort);
2046ed92b14SEdgar E. Iglesias         } else {
2056ed92b14SEdgar E. Iglesias             s->boot_cpu_ptr = &s->rpu_cpu[i];
2066ed92b14SEdgar E. Iglesias         }
2076ed92b14SEdgar E. Iglesias         g_free(name);
2086ed92b14SEdgar E. Iglesias 
2096ed92b14SEdgar E. Iglesias         object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs",
2106ed92b14SEdgar E. Iglesias                                  &error_abort);
2116ed92b14SEdgar E. Iglesias         object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "realized",
2126ed92b14SEdgar E. Iglesias                                  &err);
2136ed92b14SEdgar E. Iglesias         if (err) {
2146ed92b14SEdgar E. Iglesias             error_propagate(errp, err);
2156ed92b14SEdgar E. Iglesias             return;
2166ed92b14SEdgar E. Iglesias         }
2176ed92b14SEdgar E. Iglesias     }
218fa434424SPeter Maydell 
219fa434424SPeter Maydell     qdev_init_nofail(DEVICE(&s->rpu_cluster));
2206ed92b14SEdgar E. Iglesias }
2216ed92b14SEdgar E. Iglesias 
222f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_init(Object *obj)
223f0a902f7SPeter Crosthwaite {
224f0a902f7SPeter Crosthwaite     XlnxZynqMPState *s = XLNX_ZYNQMP(obj);
225f0a902f7SPeter Crosthwaite     int i;
2266908ec44SAlistair Francis     int num_apus = MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS);
227f0a902f7SPeter Crosthwaite 
228816fd397SLuc Michel     object_initialize_child(obj, "apu-cluster", &s->apu_cluster,
229816fd397SLuc Michel                             sizeof(s->apu_cluster), TYPE_CPU_CLUSTER,
230816fd397SLuc Michel                             &error_abort, NULL);
231816fd397SLuc Michel     qdev_prop_set_uint32(DEVICE(&s->apu_cluster), "cluster-id", 0);
232816fd397SLuc Michel 
2336908ec44SAlistair Francis     for (i = 0; i < num_apus; i++) {
234816fd397SLuc Michel         object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]",
235816fd397SLuc Michel                                 &s->apu_cpu[i], sizeof(s->apu_cpu[i]),
236816fd397SLuc Michel                                 "cortex-a53-" TYPE_ARM_CPU, &error_abort,
237816fd397SLuc Michel                                 NULL);
238f0a902f7SPeter Crosthwaite     }
2397729e1f4SPeter Crosthwaite 
240ccf02d73SThomas Huth     sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic),
241ccf02d73SThomas Huth                           gic_class_name());
24214ca2e46SPeter Crosthwaite 
24314ca2e46SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
244ccf02d73SThomas Huth         sysbus_init_child_obj(obj, "gem[*]", &s->gem[i], sizeof(s->gem[i]),
245ccf02d73SThomas Huth                               TYPE_CADENCE_GEM);
24614ca2e46SPeter Crosthwaite     }
2473bade2a9SPeter Crosthwaite 
2483bade2a9SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
249ccf02d73SThomas Huth         sysbus_init_child_obj(obj, "uart[*]", &s->uart[i], sizeof(s->uart[i]),
250ccf02d73SThomas Huth                               TYPE_CADENCE_UART);
2513bade2a9SPeter Crosthwaite     }
2526fdf3282SAlistair Francis 
253ccf02d73SThomas Huth     sysbus_init_child_obj(obj, "sata", &s->sata, sizeof(s->sata),
254ccf02d73SThomas Huth                           TYPE_SYSBUS_AHCI);
25533108e9fSSai Pavan Boddu 
25633108e9fSSai Pavan Boddu     for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
257ccf02d73SThomas Huth         sysbus_init_child_obj(obj, "sdhci[*]", &s->sdhci[i],
258ccf02d73SThomas Huth                               sizeof(s->sdhci[i]), TYPE_SYSBUS_SDHCI);
25933108e9fSSai Pavan Boddu     }
26002d07eb4SAlistair Francis 
26102d07eb4SAlistair Francis     for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
262ccf02d73SThomas Huth         sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]),
26302d07eb4SAlistair Francis                               TYPE_XILINX_SPIPS);
26402d07eb4SAlistair Francis     }
265b93dbcddSKONRAD Frederic 
266ccf02d73SThomas Huth     sysbus_init_child_obj(obj, "qspi", &s->qspi, sizeof(s->qspi),
267ccf02d73SThomas Huth                           TYPE_XLNX_ZYNQMP_QSPIPS);
268babc1f30SFrancisco Iglesias 
269ccf02d73SThomas Huth     sysbus_init_child_obj(obj, "xxxdp", &s->dp, sizeof(s->dp), TYPE_XLNX_DP);
270b93dbcddSKONRAD Frederic 
271ccf02d73SThomas Huth     sysbus_init_child_obj(obj, "dp-dma", &s->dpdma, sizeof(s->dpdma),
272ccf02d73SThomas Huth                           TYPE_XLNX_DPDMA);
2730ab7bbc7SAlistair Francis 
274ccf02d73SThomas Huth     sysbus_init_child_obj(obj, "ipi", &s->ipi, sizeof(s->ipi),
275ccf02d73SThomas Huth                           TYPE_XLNX_ZYNQMP_IPI);
27608b2f15eSAlistair Francis 
277ccf02d73SThomas Huth     sysbus_init_child_obj(obj, "rtc", &s->rtc, sizeof(s->rtc),
278ccf02d73SThomas Huth                           TYPE_XLNX_ZYNQMP_RTC);
27904965bcaSFrancisco Iglesias 
28004965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
281ccf02d73SThomas Huth         sysbus_init_child_obj(obj, "gdma[*]", &s->gdma[i], sizeof(s->gdma[i]),
282ccf02d73SThomas Huth                               TYPE_XLNX_ZDMA);
28304965bcaSFrancisco Iglesias     }
28404965bcaSFrancisco Iglesias 
28504965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) {
286ccf02d73SThomas Huth         sysbus_init_child_obj(obj, "adma[*]", &s->adma[i], sizeof(s->adma[i]),
287ccf02d73SThomas Huth                               TYPE_XLNX_ZDMA);
28804965bcaSFrancisco Iglesias     }
289f0a902f7SPeter Crosthwaite }
290f0a902f7SPeter Crosthwaite 
291f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
292f0a902f7SPeter Crosthwaite {
293f0a902f7SPeter Crosthwaite     XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
2947729e1f4SPeter Crosthwaite     MemoryRegion *system_memory = get_system_memory();
295f0a902f7SPeter Crosthwaite     uint8_t i;
296dc3b89efSAlistair Francis     uint64_t ram_size;
2976908ec44SAlistair Francis     int num_apus = MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS);
2986396a193SPeter Crosthwaite     const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
299dc3b89efSAlistair Francis     ram_addr_t ddr_low_size, ddr_high_size;
30014ca2e46SPeter Crosthwaite     qemu_irq gic_spi[GIC_NUM_SPI_INTR];
301f0a902f7SPeter Crosthwaite     Error *err = NULL;
302f0a902f7SPeter Crosthwaite 
303dc3b89efSAlistair Francis     ram_size = memory_region_size(s->ddr_ram);
304dc3b89efSAlistair Francis 
305dc3b89efSAlistair Francis     /* Create the DDR Memory Regions. User friendly checks should happen at
306dc3b89efSAlistair Francis      * the board level
307dc3b89efSAlistair Francis      */
308dc3b89efSAlistair Francis     if (ram_size > XLNX_ZYNQMP_MAX_LOW_RAM_SIZE) {
309dc3b89efSAlistair Francis         /* The RAM size is above the maximum available for the low DDR.
310dc3b89efSAlistair Francis          * Create the high DDR memory region as well.
311dc3b89efSAlistair Francis          */
312dc3b89efSAlistair Francis         assert(ram_size <= XLNX_ZYNQMP_MAX_RAM_SIZE);
313dc3b89efSAlistair Francis         ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
314dc3b89efSAlistair Francis         ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
315dc3b89efSAlistair Francis 
316dc3b89efSAlistair Francis         memory_region_init_alias(&s->ddr_ram_high, NULL,
317dc3b89efSAlistair Francis                                  "ddr-ram-high", s->ddr_ram,
318dc3b89efSAlistair Francis                                   ddr_low_size, ddr_high_size);
319dc3b89efSAlistair Francis         memory_region_add_subregion(get_system_memory(),
320dc3b89efSAlistair Francis                                     XLNX_ZYNQMP_HIGH_RAM_START,
321dc3b89efSAlistair Francis                                     &s->ddr_ram_high);
322dc3b89efSAlistair Francis     } else {
323dc3b89efSAlistair Francis         /* RAM must be non-zero */
324dc3b89efSAlistair Francis         assert(ram_size);
325dc3b89efSAlistair Francis         ddr_low_size = ram_size;
326dc3b89efSAlistair Francis     }
327dc3b89efSAlistair Francis 
328dc3b89efSAlistair Francis     memory_region_init_alias(&s->ddr_ram_low, NULL,
329dc3b89efSAlistair Francis                              "ddr-ram-low", s->ddr_ram,
330dc3b89efSAlistair Francis                               0, ddr_low_size);
331dc3b89efSAlistair Francis     memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);
332dc3b89efSAlistair Francis 
3336675d719SAlistair Francis     /* Create the four OCM banks */
3346675d719SAlistair Francis     for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) {
3356675d719SAlistair Francis         char *ocm_name = g_strdup_printf("zynqmp.ocm_ram_bank_%d", i);
3366675d719SAlistair Francis 
33798a99ce0SPeter Maydell         memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name,
338f8ed85acSMarkus Armbruster                                XLNX_ZYNQMP_OCM_RAM_SIZE, &error_fatal);
3396675d719SAlistair Francis         memory_region_add_subregion(get_system_memory(),
3406675d719SAlistair Francis                                     XLNX_ZYNQMP_OCM_RAM_0_ADDRESS +
3416675d719SAlistair Francis                                         i * XLNX_ZYNQMP_OCM_RAM_SIZE,
3426675d719SAlistair Francis                                     &s->ocm_ram[i]);
3436675d719SAlistair Francis 
3446675d719SAlistair Francis         g_free(ocm_name);
3456675d719SAlistair Francis     }
3466675d719SAlistair Francis 
3477729e1f4SPeter Crosthwaite     qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32);
3487729e1f4SPeter Crosthwaite     qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2);
3496908ec44SAlistair Francis     qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", num_apus);
35075b749afSLuc Michel     qdev_prop_set_bit(DEVICE(&s->gic), "has-security-extensions", s->secure);
35175b749afSLuc Michel     qdev_prop_set_bit(DEVICE(&s->gic),
35275b749afSLuc Michel                       "has-virtualization-extensions", s->virt);
3537729e1f4SPeter Crosthwaite 
354816fd397SLuc Michel     qdev_init_nofail(DEVICE(&s->apu_cluster));
355816fd397SLuc Michel 
3560776d967SEdgar E. Iglesias     /* Realize APUs before realizing the GIC. KVM requires this.  */
3576908ec44SAlistair Francis     for (i = 0; i < num_apus; i++) {
3586396a193SPeter Crosthwaite         char *name;
359bf4cb109SPeter Crosthwaite 
3602e5577bcSPeter Crosthwaite         object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,
361f0a902f7SPeter Crosthwaite                                 "psci-conduit", &error_abort);
3626396a193SPeter Crosthwaite 
3636396a193SPeter Crosthwaite         name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));
3646396a193SPeter Crosthwaite         if (strcmp(name, boot_cpu)) {
365f0a902f7SPeter Crosthwaite             /* Secondary CPUs start in PSCI powered-down state */
3662e5577bcSPeter Crosthwaite             object_property_set_bool(OBJECT(&s->apu_cpu[i]), true,
367f0a902f7SPeter Crosthwaite                                      "start-powered-off", &error_abort);
3686396a193SPeter Crosthwaite         } else {
3696396a193SPeter Crosthwaite             s->boot_cpu_ptr = &s->apu_cpu[i];
370f0a902f7SPeter Crosthwaite         }
3715348c62cSGonglei         g_free(name);
372f0a902f7SPeter Crosthwaite 
37337d42473SEdgar E. Iglesias         object_property_set_bool(OBJECT(&s->apu_cpu[i]),
37437d42473SEdgar E. Iglesias                                  s->secure, "has_el3", NULL);
375c25bd18aSPeter Maydell         object_property_set_bool(OBJECT(&s->apu_cpu[i]),
3761946809eSAlistair Francis                                  s->virt, "has_el2", NULL);
3772e5577bcSPeter Crosthwaite         object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR,
378e1292517SAlistair Francis                                 "reset-cbar", &error_abort);
3798f2ba1f2SAlistair Francis         object_property_set_int(OBJECT(&s->apu_cpu[i]), num_apus,
3808f2ba1f2SAlistair Francis                                 "core-count", &error_abort);
3812e5577bcSPeter Crosthwaite         object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
3822e5577bcSPeter Crosthwaite                                  &err);
383f0a902f7SPeter Crosthwaite         if (err) {
38424cfc8dcSAlistair Francis             error_propagate(errp, err);
385f0a902f7SPeter Crosthwaite             return;
386f0a902f7SPeter Crosthwaite         }
3870776d967SEdgar E. Iglesias     }
3880776d967SEdgar E. Iglesias 
3890776d967SEdgar E. Iglesias     object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
3900776d967SEdgar E. Iglesias     if (err) {
3910776d967SEdgar E. Iglesias         error_propagate(errp, err);
3920776d967SEdgar E. Iglesias         return;
3930776d967SEdgar E. Iglesias     }
3940776d967SEdgar E. Iglesias 
3950776d967SEdgar E. Iglesias     assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS);
3960776d967SEdgar E. Iglesias     for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) {
3970776d967SEdgar E. Iglesias         SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic);
3980776d967SEdgar E. Iglesias         const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i];
39975b749afSLuc Michel         MemoryRegion *mr;
4000776d967SEdgar E. Iglesias         uint32_t addr = r->address;
4010776d967SEdgar E. Iglesias         int j;
4020776d967SEdgar E. Iglesias 
40375b749afSLuc Michel         if (r->virt && !s->virt) {
40475b749afSLuc Michel             continue;
40575b749afSLuc Michel         }
4060776d967SEdgar E. Iglesias 
40775b749afSLuc Michel         mr = sysbus_mmio_get_region(gic, r->region_index);
4080776d967SEdgar E. Iglesias         for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) {
4090776d967SEdgar E. Iglesias             MemoryRegion *alias = &s->gic_mr[i][j];
4100776d967SEdgar E. Iglesias 
4110776d967SEdgar E. Iglesias             memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr,
41275b749afSLuc Michel                                      r->offset, XLNX_ZYNQMP_GIC_REGION_SIZE);
4130776d967SEdgar E. Iglesias             memory_region_add_subregion(system_memory, addr, alias);
41475b749afSLuc Michel 
41575b749afSLuc Michel             addr += XLNX_ZYNQMP_GIC_REGION_SIZE;
4160776d967SEdgar E. Iglesias         }
4170776d967SEdgar E. Iglesias     }
4180776d967SEdgar E. Iglesias 
4196908ec44SAlistair Francis     for (i = 0; i < num_apus; i++) {
4200776d967SEdgar E. Iglesias         qemu_irq irq;
4217729e1f4SPeter Crosthwaite 
4227729e1f4SPeter Crosthwaite         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i,
4232e5577bcSPeter Crosthwaite                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
4242e5577bcSPeter Crosthwaite                                             ARM_CPU_IRQ));
42575b749afSLuc Michel         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus,
42675b749afSLuc Michel                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
42775b749afSLuc Michel                                             ARM_CPU_FIQ));
42875b749afSLuc Michel         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 2,
42975b749afSLuc Michel                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
43075b749afSLuc Michel                                             ARM_CPU_VIRQ));
43175b749afSLuc Michel         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 3,
43275b749afSLuc Michel                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
43375b749afSLuc Michel                                             ARM_CPU_VFIQ));
434bf4cb109SPeter Crosthwaite         irq = qdev_get_gpio_in(DEVICE(&s->gic),
435bf4cb109SPeter Crosthwaite                                arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI));
43675b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_PHYS, irq);
437bf4cb109SPeter Crosthwaite         irq = qdev_get_gpio_in(DEVICE(&s->gic),
438bf4cb109SPeter Crosthwaite                                arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI));
43975b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_VIRT, irq);
44075b749afSLuc Michel         irq = qdev_get_gpio_in(DEVICE(&s->gic),
44175b749afSLuc Michel                                arm_gic_ppi_index(i, ARM_HYP_TIMER_PPI));
44275b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_HYP, irq);
44375b749afSLuc Michel         irq = qdev_get_gpio_in(DEVICE(&s->gic),
44475b749afSLuc Michel                                arm_gic_ppi_index(i, ARM_SEC_TIMER_PPI));
44575b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_SEC, irq);
44675b749afSLuc Michel 
44775b749afSLuc Michel         if (s->virt) {
44875b749afSLuc Michel             irq = qdev_get_gpio_in(DEVICE(&s->gic),
44975b749afSLuc Michel                                    arm_gic_ppi_index(i, GIC_MAINTENANCE_PPI));
45075b749afSLuc Michel             sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 4, irq);
45175b749afSLuc Michel         }
452f0a902f7SPeter Crosthwaite     }
45314ca2e46SPeter Crosthwaite 
4546ed92b14SEdgar E. Iglesias     if (s->has_rpu) {
4556908ec44SAlistair Francis         info_report("The 'has_rpu' property is no longer required, to use the "
4566908ec44SAlistair Francis                     "RPUs just use -smp 6.");
4576908ec44SAlistair Francis     }
4586908ec44SAlistair Francis 
4596ed92b14SEdgar E. Iglesias     xlnx_zynqmp_create_rpu(s, boot_cpu, &err);
460b58850e7SPeter Crosthwaite     if (err) {
46124cfc8dcSAlistair Francis         error_propagate(errp, err);
462b58850e7SPeter Crosthwaite         return;
463b58850e7SPeter Crosthwaite     }
464b58850e7SPeter Crosthwaite 
4656396a193SPeter Crosthwaite     if (!s->boot_cpu_ptr) {
4669af9e0feSMarkus Armbruster         error_setg(errp, "ZynqMP Boot cpu %s not found", boot_cpu);
4676396a193SPeter Crosthwaite         return;
4686396a193SPeter Crosthwaite     }
4696396a193SPeter Crosthwaite 
47014ca2e46SPeter Crosthwaite     for (i = 0; i < GIC_NUM_SPI_INTR; i++) {
47114ca2e46SPeter Crosthwaite         gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i);
47214ca2e46SPeter Crosthwaite     }
47314ca2e46SPeter Crosthwaite 
47414ca2e46SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
47514ca2e46SPeter Crosthwaite         NICInfo *nd = &nd_table[i];
47614ca2e46SPeter Crosthwaite 
47714ca2e46SPeter Crosthwaite         if (nd->used) {
47814ca2e46SPeter Crosthwaite             qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
47914ca2e46SPeter Crosthwaite             qdev_set_nic_properties(DEVICE(&s->gem[i]), nd);
48014ca2e46SPeter Crosthwaite         }
48120bff213SAlistair Francis         object_property_set_int(OBJECT(&s->gem[i]), GEM_REVISION, "revision",
48220bff213SAlistair Francis                                 &error_abort);
4831372fc0bSAlistair Francis         object_property_set_int(OBJECT(&s->gem[i]), 2, "num-priority-queues",
4841372fc0bSAlistair Francis                                 &error_abort);
48514ca2e46SPeter Crosthwaite         object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err);
48614ca2e46SPeter Crosthwaite         if (err) {
48724cfc8dcSAlistair Francis             error_propagate(errp, err);
48814ca2e46SPeter Crosthwaite             return;
48914ca2e46SPeter Crosthwaite         }
49014ca2e46SPeter Crosthwaite         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
49114ca2e46SPeter Crosthwaite         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,
49214ca2e46SPeter Crosthwaite                            gic_spi[gem_intr[i]]);
49314ca2e46SPeter Crosthwaite     }
4943bade2a9SPeter Crosthwaite 
4953bade2a9SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
4969bca0edbSPeter Maydell         qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
4973bade2a9SPeter Crosthwaite         object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
4983bade2a9SPeter Crosthwaite         if (err) {
49924cfc8dcSAlistair Francis             error_propagate(errp, err);
5003bade2a9SPeter Crosthwaite             return;
5013bade2a9SPeter Crosthwaite         }
5023bade2a9SPeter Crosthwaite         sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
5033bade2a9SPeter Crosthwaite         sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
5043bade2a9SPeter Crosthwaite                            gic_spi[uart_intr[i]]);
5053bade2a9SPeter Crosthwaite     }
5066fdf3282SAlistair Francis 
5076fdf3282SAlistair Francis     object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports",
5086fdf3282SAlistair Francis                             &error_abort);
5096fdf3282SAlistair Francis     object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
5106fdf3282SAlistair Francis     if (err) {
5116fdf3282SAlistair Francis         error_propagate(errp, err);
5126fdf3282SAlistair Francis         return;
5136fdf3282SAlistair Francis     }
5146fdf3282SAlistair Francis 
5156fdf3282SAlistair Francis     sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
5166fdf3282SAlistair Francis     sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
51733108e9fSSai Pavan Boddu 
51833108e9fSSai Pavan Boddu     for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
519b630d3d4SPhilippe Mathieu-Daudé         char *bus_name = g_strdup_printf("sd-bus%d", i);
520b630d3d4SPhilippe Mathieu-Daudé         SysBusDevice *sbd = SYS_BUS_DEVICE(&s->sdhci[i]);
521b630d3d4SPhilippe Mathieu-Daudé         Object *sdhci = OBJECT(&s->sdhci[i]);
522eb4f566bSPeter Maydell 
523b630d3d4SPhilippe Mathieu-Daudé         /* Compatible with:
524b630d3d4SPhilippe Mathieu-Daudé          * - SD Host Controller Specification Version 3.00
525b630d3d4SPhilippe Mathieu-Daudé          * - SDIO Specification Version 3.0
526b630d3d4SPhilippe Mathieu-Daudé          * - eMMC Specification Version 4.51
527b630d3d4SPhilippe Mathieu-Daudé          */
528b630d3d4SPhilippe Mathieu-Daudé         object_property_set_uint(sdhci, 3, "sd-spec-version", &err);
529b630d3d4SPhilippe Mathieu-Daudé         object_property_set_uint(sdhci, SDHCI_CAPABILITIES, "capareg", &err);
530a01c6554SPhilippe Mathieu-Daudé         object_property_set_uint(sdhci, UHS_I, "uhs", &err);
531b630d3d4SPhilippe Mathieu-Daudé         object_property_set_bool(sdhci, true, "realized", &err);
53233108e9fSSai Pavan Boddu         if (err) {
53333108e9fSSai Pavan Boddu             error_propagate(errp, err);
53433108e9fSSai Pavan Boddu             return;
53533108e9fSSai Pavan Boddu         }
536b630d3d4SPhilippe Mathieu-Daudé         sysbus_mmio_map(sbd, 0, sdhci_addr[i]);
537b630d3d4SPhilippe Mathieu-Daudé         sysbus_connect_irq(sbd, 0, gic_spi[sdhci_intr[i]]);
538b630d3d4SPhilippe Mathieu-Daudé 
539eb4f566bSPeter Maydell         /* Alias controller SD bus to the SoC itself */
540b630d3d4SPhilippe Mathieu-Daudé         object_property_add_alias(OBJECT(s), bus_name, sdhci, "sd-bus",
541eb4f566bSPeter Maydell                                   &error_abort);
542eb4f566bSPeter Maydell         g_free(bus_name);
54333108e9fSSai Pavan Boddu     }
54402d07eb4SAlistair Francis 
54502d07eb4SAlistair Francis     for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
54602d07eb4SAlistair Francis         gchar *bus_name;
54702d07eb4SAlistair Francis 
54802d07eb4SAlistair Francis         object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
54902d07eb4SAlistair Francis 
55002d07eb4SAlistair Francis         sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
55102d07eb4SAlistair Francis         sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
55202d07eb4SAlistair Francis                            gic_spi[spi_intr[i]]);
55302d07eb4SAlistair Francis 
55402d07eb4SAlistair Francis         /* Alias controller SPI bus to the SoC itself */
55502d07eb4SAlistair Francis         bus_name = g_strdup_printf("spi%d", i);
55602d07eb4SAlistair Francis         object_property_add_alias(OBJECT(s), bus_name,
55702d07eb4SAlistair Francis                                   OBJECT(&s->spi[i]), "spi0",
55802d07eb4SAlistair Francis                                   &error_abort);
55902d07eb4SAlistair Francis         g_free(bus_name);
56002d07eb4SAlistair Francis     }
561b93dbcddSKONRAD Frederic 
562babc1f30SFrancisco Iglesias     object_property_set_bool(OBJECT(&s->qspi), true, "realized", &err);
563babc1f30SFrancisco Iglesias     sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR);
564babc1f30SFrancisco Iglesias     sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 1, LQSPI_ADDR);
565babc1f30SFrancisco Iglesias     sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi), 0, gic_spi[QSPI_IRQ]);
566babc1f30SFrancisco Iglesias 
567babc1f30SFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_QSPI_BUS; i++) {
568babc1f30SFrancisco Iglesias         gchar *bus_name;
569babc1f30SFrancisco Iglesias         gchar *target_bus;
570babc1f30SFrancisco Iglesias 
571babc1f30SFrancisco Iglesias         /* Alias controller SPI bus to the SoC itself */
572babc1f30SFrancisco Iglesias         bus_name = g_strdup_printf("qspi%d", i);
573babc1f30SFrancisco Iglesias         target_bus = g_strdup_printf("spi%d", i);
574babc1f30SFrancisco Iglesias         object_property_add_alias(OBJECT(s), bus_name,
575babc1f30SFrancisco Iglesias                                   OBJECT(&s->qspi), target_bus,
576babc1f30SFrancisco Iglesias                                   &error_abort);
577babc1f30SFrancisco Iglesias         g_free(bus_name);
578babc1f30SFrancisco Iglesias         g_free(target_bus);
579babc1f30SFrancisco Iglesias     }
580babc1f30SFrancisco Iglesias 
581b93dbcddSKONRAD Frederic     object_property_set_bool(OBJECT(&s->dp), true, "realized", &err);
582b93dbcddSKONRAD Frederic     if (err) {
583b93dbcddSKONRAD Frederic         error_propagate(errp, err);
584b93dbcddSKONRAD Frederic         return;
585b93dbcddSKONRAD Frederic     }
586b93dbcddSKONRAD Frederic     sysbus_mmio_map(SYS_BUS_DEVICE(&s->dp), 0, DP_ADDR);
587b93dbcddSKONRAD Frederic     sysbus_connect_irq(SYS_BUS_DEVICE(&s->dp), 0, gic_spi[DP_IRQ]);
588b93dbcddSKONRAD Frederic 
589b93dbcddSKONRAD Frederic     object_property_set_bool(OBJECT(&s->dpdma), true, "realized", &err);
590b93dbcddSKONRAD Frederic     if (err) {
591b93dbcddSKONRAD Frederic         error_propagate(errp, err);
592b93dbcddSKONRAD Frederic         return;
593b93dbcddSKONRAD Frederic     }
594b93dbcddSKONRAD Frederic     object_property_set_link(OBJECT(&s->dp), OBJECT(&s->dpdma), "dpdma",
595b93dbcddSKONRAD Frederic                              &error_abort);
596b93dbcddSKONRAD Frederic     sysbus_mmio_map(SYS_BUS_DEVICE(&s->dpdma), 0, DPDMA_ADDR);
597b93dbcddSKONRAD Frederic     sysbus_connect_irq(SYS_BUS_DEVICE(&s->dpdma), 0, gic_spi[DPDMA_IRQ]);
5980ab7bbc7SAlistair Francis 
5990ab7bbc7SAlistair Francis     object_property_set_bool(OBJECT(&s->ipi), true, "realized", &err);
6000ab7bbc7SAlistair Francis     if (err) {
6010ab7bbc7SAlistair Francis         error_propagate(errp, err);
6020ab7bbc7SAlistair Francis         return;
6030ab7bbc7SAlistair Francis     }
6040ab7bbc7SAlistair Francis     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ipi), 0, IPI_ADDR);
6050ab7bbc7SAlistair Francis     sysbus_connect_irq(SYS_BUS_DEVICE(&s->ipi), 0, gic_spi[IPI_IRQ]);
60608b2f15eSAlistair Francis 
60708b2f15eSAlistair Francis     object_property_set_bool(OBJECT(&s->rtc), true, "realized", &err);
60808b2f15eSAlistair Francis     if (err) {
60908b2f15eSAlistair Francis         error_propagate(errp, err);
61008b2f15eSAlistair Francis         return;
61108b2f15eSAlistair Francis     }
61208b2f15eSAlistair Francis     sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, RTC_ADDR);
61308b2f15eSAlistair Francis     sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, gic_spi[RTC_IRQ]);
61404965bcaSFrancisco Iglesias 
61504965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
61604965bcaSFrancisco Iglesias         object_property_set_uint(OBJECT(&s->gdma[i]), 128, "bus-width", &err);
61704965bcaSFrancisco Iglesias         object_property_set_bool(OBJECT(&s->gdma[i]), true, "realized", &err);
61804965bcaSFrancisco Iglesias         if (err) {
61904965bcaSFrancisco Iglesias             error_propagate(errp, err);
62004965bcaSFrancisco Iglesias             return;
62104965bcaSFrancisco Iglesias         }
62204965bcaSFrancisco Iglesias 
62304965bcaSFrancisco Iglesias         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gdma[i]), 0, gdma_ch_addr[i]);
62404965bcaSFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gdma[i]), 0,
62504965bcaSFrancisco Iglesias                            gic_spi[gdma_ch_intr[i]]);
62604965bcaSFrancisco Iglesias     }
62704965bcaSFrancisco Iglesias 
62804965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) {
62904965bcaSFrancisco Iglesias         object_property_set_bool(OBJECT(&s->adma[i]), true, "realized", &err);
63004965bcaSFrancisco Iglesias         if (err) {
63104965bcaSFrancisco Iglesias             error_propagate(errp, err);
63204965bcaSFrancisco Iglesias             return;
63304965bcaSFrancisco Iglesias         }
63404965bcaSFrancisco Iglesias 
63504965bcaSFrancisco Iglesias         sysbus_mmio_map(SYS_BUS_DEVICE(&s->adma[i]), 0, adma_ch_addr[i]);
63604965bcaSFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->adma[i]), 0,
63704965bcaSFrancisco Iglesias                            gic_spi[adma_ch_intr[i]]);
63804965bcaSFrancisco Iglesias     }
639f0a902f7SPeter Crosthwaite }
640f0a902f7SPeter Crosthwaite 
6416396a193SPeter Crosthwaite static Property xlnx_zynqmp_props[] = {
6426396a193SPeter Crosthwaite     DEFINE_PROP_STRING("boot-cpu", XlnxZynqMPState, boot_cpu),
64337d42473SEdgar E. Iglesias     DEFINE_PROP_BOOL("secure", XlnxZynqMPState, secure, false),
6441946809eSAlistair Francis     DEFINE_PROP_BOOL("virtualization", XlnxZynqMPState, virt, false),
6456ed92b14SEdgar E. Iglesias     DEFINE_PROP_BOOL("has_rpu", XlnxZynqMPState, has_rpu, false),
646c3acfa01SFam Zheng     DEFINE_PROP_LINK("ddr-ram", XlnxZynqMPState, ddr_ram, TYPE_MEMORY_REGION,
647c3acfa01SFam Zheng                      MemoryRegion *),
6486396a193SPeter Crosthwaite     DEFINE_PROP_END_OF_LIST()
6496396a193SPeter Crosthwaite };
6506396a193SPeter Crosthwaite 
651f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_class_init(ObjectClass *oc, void *data)
652f0a902f7SPeter Crosthwaite {
653f0a902f7SPeter Crosthwaite     DeviceClass *dc = DEVICE_CLASS(oc);
654f0a902f7SPeter Crosthwaite 
6556396a193SPeter Crosthwaite     dc->props = xlnx_zynqmp_props;
656f0a902f7SPeter Crosthwaite     dc->realize = xlnx_zynqmp_realize;
657d8589144SThomas Huth     /* Reason: Uses serial_hds in realize function, thus can't be used twice */
658d8589144SThomas Huth     dc->user_creatable = false;
659f0a902f7SPeter Crosthwaite }
660f0a902f7SPeter Crosthwaite 
661f0a902f7SPeter Crosthwaite static const TypeInfo xlnx_zynqmp_type_info = {
662f0a902f7SPeter Crosthwaite     .name = TYPE_XLNX_ZYNQMP,
663f0a902f7SPeter Crosthwaite     .parent = TYPE_DEVICE,
664f0a902f7SPeter Crosthwaite     .instance_size = sizeof(XlnxZynqMPState),
665f0a902f7SPeter Crosthwaite     .instance_init = xlnx_zynqmp_init,
666f0a902f7SPeter Crosthwaite     .class_init = xlnx_zynqmp_class_init,
667f0a902f7SPeter Crosthwaite };
668f0a902f7SPeter Crosthwaite 
669f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_register_types(void)
670f0a902f7SPeter Crosthwaite {
671f0a902f7SPeter Crosthwaite     type_register_static(&xlnx_zynqmp_type_info);
672f0a902f7SPeter Crosthwaite }
673f0a902f7SPeter Crosthwaite 
674f0a902f7SPeter Crosthwaite type_init(xlnx_zynqmp_register_types)
675