2 * Xilinx Zynq MPSoC emulation
4 * Copyright (C) 2015 Xilinx Inc
5 * Written by Peter Crosthwaite <peter.crosthwaite@xilinx.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include "qemu/osdep.h"
19 #include "qapi/error.h"
20 #include "qemu-common.h"
22 #include "hw/arm/xlnx-zynqmp.h"
23 #include "hw/intc/arm_gic_common.h"
24 #include "exec/address-spaces.h"
25 #include "sysemu/kvm.h"
28 #define GIC_NUM_SPI_INTR 160
30 #define ARM_PHYS_TIMER_PPI 30
31 #define ARM_VIRT_TIMER_PPI 27
32 #define ARM_HYP_TIMER_PPI 26
33 #define ARM_SEC_TIMER_PPI 29
34 #define GIC_MAINTENANCE_PPI 25
36 #define GEM_REVISION 0x40070106
38 #define GIC_BASE_ADDR 0xf9000000
39 #define GIC_DIST_ADDR 0xf9010000
40 #define GIC_CPU_ADDR 0xf9020000
41 #define GIC_VIFACE_ADDR 0xf9040000
42 #define GIC_VCPU_ADDR 0xf9060000
45 #define SATA_ADDR 0xFD0C0000
46 #define SATA_NUM_PORTS 2
48 #define QSPI_ADDR 0xff0f0000
49 #define LQSPI_ADDR 0xc0000000
52 #define DP_ADDR 0xfd4a0000
55 #define DPDMA_ADDR 0xfd4c0000
58 #define IPI_ADDR 0xFF300000
61 #define RTC_ADDR 0xffa60000
64 #define SDHCI_CAPABILITIES 0x280737ec6481 /* Datasheet: UG1085 (v1.7) */
66 static const uint64_t gem_addr
[XLNX_ZYNQMP_NUM_GEMS
] = {
67 0xFF0B0000, 0xFF0C0000, 0xFF0D0000, 0xFF0E0000,
70 static const int gem_intr
[XLNX_ZYNQMP_NUM_GEMS
] = {
74 static const uint64_t uart_addr
[XLNX_ZYNQMP_NUM_UARTS
] = {
75 0xFF000000, 0xFF010000,
78 static const int uart_intr
[XLNX_ZYNQMP_NUM_UARTS
] = {
82 static const uint64_t sdhci_addr
[XLNX_ZYNQMP_NUM_SDHCI
] = {
83 0xFF160000, 0xFF170000,
86 static const int sdhci_intr
[XLNX_ZYNQMP_NUM_SDHCI
] = {
90 static const uint64_t spi_addr
[XLNX_ZYNQMP_NUM_SPIS
] = {
91 0xFF040000, 0xFF050000,
94 static const int spi_intr
[XLNX_ZYNQMP_NUM_SPIS
] = {
98 static const uint64_t gdma_ch_addr
[XLNX_ZYNQMP_NUM_GDMA_CH
] = {
99 0xFD500000, 0xFD510000, 0xFD520000, 0xFD530000,
100 0xFD540000, 0xFD550000, 0xFD560000, 0xFD570000
103 static const int gdma_ch_intr
[XLNX_ZYNQMP_NUM_GDMA_CH
] = {
104 124, 125, 126, 127, 128, 129, 130, 131
107 static const uint64_t adma_ch_addr
[XLNX_ZYNQMP_NUM_ADMA_CH
] = {
108 0xFFA80000, 0xFFA90000, 0xFFAA0000, 0xFFAB0000,
109 0xFFAC0000, 0xFFAD0000, 0xFFAE0000, 0xFFAF0000
112 static const int adma_ch_intr
[XLNX_ZYNQMP_NUM_ADMA_CH
] = {
113 77, 78, 79, 80, 81, 82, 83, 84
116 typedef struct XlnxZynqMPGICRegion
{
121 } XlnxZynqMPGICRegion
;
123 static const XlnxZynqMPGICRegion xlnx_zynqmp_gic_regions
[] = {
127 .address
= GIC_DIST_ADDR
,
135 .address
= GIC_CPU_ADDR
,
141 .address
= GIC_CPU_ADDR
+ 0x10000,
146 /* Virtual interface */
149 .address
= GIC_VIFACE_ADDR
,
154 /* Virtual CPU interface */
157 .address
= GIC_VCPU_ADDR
,
163 .address
= GIC_VCPU_ADDR
+ 0x10000,
169 static inline int arm_gic_ppi_index(int cpu_nr
, int ppi_index
)
171 return GIC_NUM_SPI_INTR
+ cpu_nr
* GIC_INTERNAL
+ ppi_index
;
174 static void xlnx_zynqmp_create_rpu(XlnxZynqMPState
*s
, const char *boot_cpu
,
179 int num_rpus
= MIN(smp_cpus
- XLNX_ZYNQMP_NUM_APU_CPUS
, XLNX_ZYNQMP_NUM_RPU_CPUS
);
182 /* Don't create rpu-cluster object if there's nothing to put in it */
186 object_initialize_child(OBJECT(s
), "rpu-cluster", &s
->rpu_cluster
,
187 sizeof(s
->rpu_cluster
), TYPE_CPU_CLUSTER
,
189 qdev_prop_set_uint32(DEVICE(&s
->rpu_cluster
), "cluster-id", 1);
191 for (i
= 0; i
< num_rpus
; i
++) {
194 object_initialize(&s
->rpu_cpu
[i
], sizeof(s
->rpu_cpu
[i
]),
195 "cortex-r5f-" TYPE_ARM_CPU
);
196 object_property_add_child(OBJECT(&s
->rpu_cluster
), "rpu-cpu[*]",
197 OBJECT(&s
->rpu_cpu
[i
]), &error_abort
);
199 name
= object_get_canonical_path_component(OBJECT(&s
->rpu_cpu
[i
]));
200 if (strcmp(name
, boot_cpu
)) {
201 /* Secondary CPUs start in PSCI powered-down state */
202 object_property_set_bool(OBJECT(&s
->rpu_cpu
[i
]), true,
203 "start-powered-off", &error_abort
);
205 s
->boot_cpu_ptr
= &s
->rpu_cpu
[i
];
209 object_property_set_bool(OBJECT(&s
->rpu_cpu
[i
]), true, "reset-hivecs",
211 object_property_set_bool(OBJECT(&s
->rpu_cpu
[i
]), true, "realized",
214 error_propagate(errp
, err
);
219 qdev_init_nofail(DEVICE(&s
->rpu_cluster
));
222 static void xlnx_zynqmp_init(Object
*obj
)
224 XlnxZynqMPState
*s
= XLNX_ZYNQMP(obj
);
226 int num_apus
= MIN(smp_cpus
, XLNX_ZYNQMP_NUM_APU_CPUS
);
228 object_initialize_child(obj
, "apu-cluster", &s
->apu_cluster
,
229 sizeof(s
->apu_cluster
), TYPE_CPU_CLUSTER
,
231 qdev_prop_set_uint32(DEVICE(&s
->apu_cluster
), "cluster-id", 0);
233 for (i
= 0; i
< num_apus
; i
++) {
234 object_initialize_child(OBJECT(&s
->apu_cluster
), "apu-cpu[*]",
235 &s
->apu_cpu
[i
], sizeof(s
->apu_cpu
[i
]),
236 "cortex-a53-" TYPE_ARM_CPU
, &error_abort
,
240 sysbus_init_child_obj(obj
, "gic", &s
->gic
, sizeof(s
->gic
),
243 for (i
= 0; i
< XLNX_ZYNQMP_NUM_GEMS
; i
++) {
244 sysbus_init_child_obj(obj
, "gem[*]", &s
->gem
[i
], sizeof(s
->gem
[i
]),
248 for (i
= 0; i
< XLNX_ZYNQMP_NUM_UARTS
; i
++) {
249 sysbus_init_child_obj(obj
, "uart[*]", &s
->uart
[i
], sizeof(s
->uart
[i
]),
253 sysbus_init_child_obj(obj
, "sata", &s
->sata
, sizeof(s
->sata
),
256 for (i
= 0; i
< XLNX_ZYNQMP_NUM_SDHCI
; i
++) {
257 sysbus_init_child_obj(obj
, "sdhci[*]", &s
->sdhci
[i
],
258 sizeof(s
->sdhci
[i
]), TYPE_SYSBUS_SDHCI
);
261 for (i
= 0; i
< XLNX_ZYNQMP_NUM_SPIS
; i
++) {
262 sysbus_init_child_obj(obj
, "spi[*]", &s
->spi
[i
], sizeof(s
->spi
[i
]),
266 sysbus_init_child_obj(obj
, "qspi", &s
->qspi
, sizeof(s
->qspi
),
267 TYPE_XLNX_ZYNQMP_QSPIPS
);
269 sysbus_init_child_obj(obj
, "xxxdp", &s
->dp
, sizeof(s
->dp
), TYPE_XLNX_DP
);
271 sysbus_init_child_obj(obj
, "dp-dma", &s
->dpdma
, sizeof(s
->dpdma
),
274 sysbus_init_child_obj(obj
, "ipi", &s
->ipi
, sizeof(s
->ipi
),
275 TYPE_XLNX_ZYNQMP_IPI
);
277 sysbus_init_child_obj(obj
, "rtc", &s
->rtc
, sizeof(s
->rtc
),
278 TYPE_XLNX_ZYNQMP_RTC
);
280 for (i
= 0; i
< XLNX_ZYNQMP_NUM_GDMA_CH
; i
++) {
281 sysbus_init_child_obj(obj
, "gdma[*]", &s
->gdma
[i
], sizeof(s
->gdma
[i
]),
285 for (i
= 0; i
< XLNX_ZYNQMP_NUM_ADMA_CH
; i
++) {
286 sysbus_init_child_obj(obj
, "adma[*]", &s
->adma
[i
], sizeof(s
->adma
[i
]),
291 static void xlnx_zynqmp_realize(DeviceState
*dev
, Error
**errp
)
293 XlnxZynqMPState
*s
= XLNX_ZYNQMP(dev
);
294 MemoryRegion
*system_memory
= get_system_memory();
297 int num_apus
= MIN(smp_cpus
, XLNX_ZYNQMP_NUM_APU_CPUS
);
298 const char *boot_cpu
= s
->boot_cpu
? s
->boot_cpu
: "apu-cpu[0]";
299 ram_addr_t ddr_low_size
, ddr_high_size
;
300 qemu_irq gic_spi
[GIC_NUM_SPI_INTR
];
303 ram_size
= memory_region_size(s
->ddr_ram
);
305 /* Create the DDR Memory Regions. User friendly checks should happen at
308 if (ram_size
> XLNX_ZYNQMP_MAX_LOW_RAM_SIZE
) {
309 /* The RAM size is above the maximum available for the low DDR.
310 * Create the high DDR memory region as well.
312 assert(ram_size
<= XLNX_ZYNQMP_MAX_RAM_SIZE
);
313 ddr_low_size
= XLNX_ZYNQMP_MAX_LOW_RAM_SIZE
;
314 ddr_high_size
= ram_size
- XLNX_ZYNQMP_MAX_LOW_RAM_SIZE
;
316 memory_region_init_alias(&s
->ddr_ram_high
, NULL
,
317 "ddr-ram-high", s
->ddr_ram
,
318 ddr_low_size
, ddr_high_size
);
319 memory_region_add_subregion(get_system_memory(),
320 XLNX_ZYNQMP_HIGH_RAM_START
,
323 /* RAM must be non-zero */
325 ddr_low_size
= ram_size
;
328 memory_region_init_alias(&s
->ddr_ram_low
, NULL
,
329 "ddr-ram-low", s
->ddr_ram
,
331 memory_region_add_subregion(get_system_memory(), 0, &s
->ddr_ram_low
);
333 /* Create the four OCM banks */
334 for (i
= 0; i
< XLNX_ZYNQMP_NUM_OCM_BANKS
; i
++) {
335 char *ocm_name
= g_strdup_printf("zynqmp.ocm_ram_bank_%d", i
);
337 memory_region_init_ram(&s
->ocm_ram
[i
], NULL
, ocm_name
,
338 XLNX_ZYNQMP_OCM_RAM_SIZE
, &error_fatal
);
339 memory_region_add_subregion(get_system_memory(),
340 XLNX_ZYNQMP_OCM_RAM_0_ADDRESS
+
341 i
* XLNX_ZYNQMP_OCM_RAM_SIZE
,
347 qdev_prop_set_uint32(DEVICE(&s
->gic
), "num-irq", GIC_NUM_SPI_INTR
+ 32);
348 qdev_prop_set_uint32(DEVICE(&s
->gic
), "revision", 2);
349 qdev_prop_set_uint32(DEVICE(&s
->gic
), "num-cpu", num_apus
);
350 qdev_prop_set_bit(DEVICE(&s
->gic
), "has-security-extensions", s
->secure
);
351 qdev_prop_set_bit(DEVICE(&s
->gic
),
352 "has-virtualization-extensions", s
->virt
);
354 qdev_init_nofail(DEVICE(&s
->apu_cluster
));
356 /* Realize APUs before realizing the GIC. KVM requires this. */
357 for (i
= 0; i
< num_apus
; i
++) {
360 object_property_set_int(OBJECT(&s
->apu_cpu
[i
]), QEMU_PSCI_CONDUIT_SMC
,
361 "psci-conduit", &error_abort
);
363 name
= object_get_canonical_path_component(OBJECT(&s
->apu_cpu
[i
]));
364 if (strcmp(name
, boot_cpu
)) {
365 /* Secondary CPUs start in PSCI powered-down state */
366 object_property_set_bool(OBJECT(&s
->apu_cpu
[i
]), true,
367 "start-powered-off", &error_abort
);
369 s
->boot_cpu_ptr
= &s
->apu_cpu
[i
];
373 object_property_set_bool(OBJECT(&s
->apu_cpu
[i
]),
374 s
->secure
, "has_el3", NULL
);
375 object_property_set_bool(OBJECT(&s
->apu_cpu
[i
]),
376 s
->virt
, "has_el2", NULL
);
377 object_property_set_int(OBJECT(&s
->apu_cpu
[i
]), GIC_BASE_ADDR
,
378 "reset-cbar", &error_abort
);
379 object_property_set_int(OBJECT(&s
->apu_cpu
[i
]), num_apus
,
380 "core-count", &error_abort
);
381 object_property_set_bool(OBJECT(&s
->apu_cpu
[i
]), true, "realized",
384 error_propagate(errp
, err
);
389 object_property_set_bool(OBJECT(&s
->gic
), true, "realized", &err
);
391 error_propagate(errp
, err
);
395 assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions
) == XLNX_ZYNQMP_GIC_REGIONS
);
396 for (i
= 0; i
< XLNX_ZYNQMP_GIC_REGIONS
; i
++) {
397 SysBusDevice
*gic
= SYS_BUS_DEVICE(&s
->gic
);
398 const XlnxZynqMPGICRegion
*r
= &xlnx_zynqmp_gic_regions
[i
];
400 uint32_t addr
= r
->address
;
403 if (r
->virt
&& !s
->virt
) {
407 mr
= sysbus_mmio_get_region(gic
, r
->region_index
);
408 for (j
= 0; j
< XLNX_ZYNQMP_GIC_ALIASES
; j
++) {
409 MemoryRegion
*alias
= &s
->gic_mr
[i
][j
];
411 memory_region_init_alias(alias
, OBJECT(s
), "zynqmp-gic-alias", mr
,
412 r
->offset
, XLNX_ZYNQMP_GIC_REGION_SIZE
);
413 memory_region_add_subregion(system_memory
, addr
, alias
);
415 addr
+= XLNX_ZYNQMP_GIC_REGION_SIZE
;
419 for (i
= 0; i
< num_apus
; i
++) {
422 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->gic
), i
,
423 qdev_get_gpio_in(DEVICE(&s
->apu_cpu
[i
]),
425 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->gic
), i
+ num_apus
,
426 qdev_get_gpio_in(DEVICE(&s
->apu_cpu
[i
]),
428 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->gic
), i
+ num_apus
* 2,
429 qdev_get_gpio_in(DEVICE(&s
->apu_cpu
[i
]),
431 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->gic
), i
+ num_apus
* 3,
432 qdev_get_gpio_in(DEVICE(&s
->apu_cpu
[i
]),
434 irq
= qdev_get_gpio_in(DEVICE(&s
->gic
),
435 arm_gic_ppi_index(i
, ARM_PHYS_TIMER_PPI
));
436 qdev_connect_gpio_out(DEVICE(&s
->apu_cpu
[i
]), GTIMER_PHYS
, irq
);
437 irq
= qdev_get_gpio_in(DEVICE(&s
->gic
),
438 arm_gic_ppi_index(i
, ARM_VIRT_TIMER_PPI
));
439 qdev_connect_gpio_out(DEVICE(&s
->apu_cpu
[i
]), GTIMER_VIRT
, irq
);
440 irq
= qdev_get_gpio_in(DEVICE(&s
->gic
),
441 arm_gic_ppi_index(i
, ARM_HYP_TIMER_PPI
));
442 qdev_connect_gpio_out(DEVICE(&s
->apu_cpu
[i
]), GTIMER_HYP
, irq
);
443 irq
= qdev_get_gpio_in(DEVICE(&s
->gic
),
444 arm_gic_ppi_index(i
, ARM_SEC_TIMER_PPI
));
445 qdev_connect_gpio_out(DEVICE(&s
->apu_cpu
[i
]), GTIMER_SEC
, irq
);
448 irq
= qdev_get_gpio_in(DEVICE(&s
->gic
),
449 arm_gic_ppi_index(i
, GIC_MAINTENANCE_PPI
));
450 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->gic
), i
+ num_apus
* 4, irq
);
455 info_report("The 'has_rpu' property is no longer required, to use the "
456 "RPUs just use -smp 6.");
459 xlnx_zynqmp_create_rpu(s
, boot_cpu
, &err
);
461 error_propagate(errp
, err
);
465 if (!s
->boot_cpu_ptr
) {
466 error_setg(errp
, "ZynqMP Boot cpu %s not found", boot_cpu
);
470 for (i
= 0; i
< GIC_NUM_SPI_INTR
; i
++) {
471 gic_spi
[i
] = qdev_get_gpio_in(DEVICE(&s
->gic
), i
);
474 for (i
= 0; i
< XLNX_ZYNQMP_NUM_GEMS
; i
++) {
475 NICInfo
*nd
= &nd_table
[i
];
478 qemu_check_nic_model(nd
, TYPE_CADENCE_GEM
);
479 qdev_set_nic_properties(DEVICE(&s
->gem
[i
]), nd
);
481 object_property_set_int(OBJECT(&s
->gem
[i
]), GEM_REVISION
, "revision",
483 object_property_set_int(OBJECT(&s
->gem
[i
]), 2, "num-priority-queues",
485 object_property_set_bool(OBJECT(&s
->gem
[i
]), true, "realized", &err
);
487 error_propagate(errp
, err
);
490 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->gem
[i
]), 0, gem_addr
[i
]);
491 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->gem
[i
]), 0,
492 gic_spi
[gem_intr
[i
]]);
495 for (i
= 0; i
< XLNX_ZYNQMP_NUM_UARTS
; i
++) {
496 qdev_prop_set_chr(DEVICE(&s
->uart
[i
]), "chardev", serial_hd(i
));
497 object_property_set_bool(OBJECT(&s
->uart
[i
]), true, "realized", &err
);
499 error_propagate(errp
, err
);
502 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->uart
[i
]), 0, uart_addr
[i
]);
503 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->uart
[i
]), 0,
504 gic_spi
[uart_intr
[i
]]);
507 object_property_set_int(OBJECT(&s
->sata
), SATA_NUM_PORTS
, "num-ports",
509 object_property_set_bool(OBJECT(&s
->sata
), true, "realized", &err
);
511 error_propagate(errp
, err
);
515 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->sata
), 0, SATA_ADDR
);
516 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->sata
), 0, gic_spi
[SATA_INTR
]);
518 for (i
= 0; i
< XLNX_ZYNQMP_NUM_SDHCI
; i
++) {
519 char *bus_name
= g_strdup_printf("sd-bus%d", i
);
520 SysBusDevice
*sbd
= SYS_BUS_DEVICE(&s
->sdhci
[i
]);
521 Object
*sdhci
= OBJECT(&s
->sdhci
[i
]);
524 * - SD Host Controller Specification Version 3.00
525 * - SDIO Specification Version 3.0
526 * - eMMC Specification Version 4.51
528 object_property_set_uint(sdhci
, 3, "sd-spec-version", &err
);
529 object_property_set_uint(sdhci
, SDHCI_CAPABILITIES
, "capareg", &err
);
530 object_property_set_uint(sdhci
, UHS_I
, "uhs", &err
);
531 object_property_set_bool(sdhci
, true, "realized", &err
);
533 error_propagate(errp
, err
);
536 sysbus_mmio_map(sbd
, 0, sdhci_addr
[i
]);
537 sysbus_connect_irq(sbd
, 0, gic_spi
[sdhci_intr
[i
]]);
539 /* Alias controller SD bus to the SoC itself */
540 object_property_add_alias(OBJECT(s
), bus_name
, sdhci
, "sd-bus",
545 for (i
= 0; i
< XLNX_ZYNQMP_NUM_SPIS
; i
++) {
548 object_property_set_bool(OBJECT(&s
->spi
[i
]), true, "realized", &err
);
550 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->spi
[i
]), 0, spi_addr
[i
]);
551 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->spi
[i
]), 0,
552 gic_spi
[spi_intr
[i
]]);
554 /* Alias controller SPI bus to the SoC itself */
555 bus_name
= g_strdup_printf("spi%d", i
);
556 object_property_add_alias(OBJECT(s
), bus_name
,
557 OBJECT(&s
->spi
[i
]), "spi0",
562 object_property_set_bool(OBJECT(&s
->qspi
), true, "realized", &err
);
563 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->qspi
), 0, QSPI_ADDR
);
564 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->qspi
), 1, LQSPI_ADDR
);
565 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->qspi
), 0, gic_spi
[QSPI_IRQ
]);
567 for (i
= 0; i
< XLNX_ZYNQMP_NUM_QSPI_BUS
; i
++) {
571 /* Alias controller SPI bus to the SoC itself */
572 bus_name
= g_strdup_printf("qspi%d", i
);
573 target_bus
= g_strdup_printf("spi%d", i
);
574 object_property_add_alias(OBJECT(s
), bus_name
,
575 OBJECT(&s
->qspi
), target_bus
,
581 object_property_set_bool(OBJECT(&s
->dp
), true, "realized", &err
);
583 error_propagate(errp
, err
);
586 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->dp
), 0, DP_ADDR
);
587 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->dp
), 0, gic_spi
[DP_IRQ
]);
589 object_property_set_bool(OBJECT(&s
->dpdma
), true, "realized", &err
);
591 error_propagate(errp
, err
);
594 object_property_set_link(OBJECT(&s
->dp
), OBJECT(&s
->dpdma
), "dpdma",
596 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->dpdma
), 0, DPDMA_ADDR
);
597 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->dpdma
), 0, gic_spi
[DPDMA_IRQ
]);
599 object_property_set_bool(OBJECT(&s
->ipi
), true, "realized", &err
);
601 error_propagate(errp
, err
);
604 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->ipi
), 0, IPI_ADDR
);
605 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->ipi
), 0, gic_spi
[IPI_IRQ
]);
607 object_property_set_bool(OBJECT(&s
->rtc
), true, "realized", &err
);
609 error_propagate(errp
, err
);
612 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->rtc
), 0, RTC_ADDR
);
613 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->rtc
), 0, gic_spi
[RTC_IRQ
]);
615 for (i
= 0; i
< XLNX_ZYNQMP_NUM_GDMA_CH
; i
++) {
616 object_property_set_uint(OBJECT(&s
->gdma
[i
]), 128, "bus-width", &err
);
617 object_property_set_bool(OBJECT(&s
->gdma
[i
]), true, "realized", &err
);
619 error_propagate(errp
, err
);
623 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->gdma
[i
]), 0, gdma_ch_addr
[i
]);
624 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->gdma
[i
]), 0,
625 gic_spi
[gdma_ch_intr
[i
]]);
628 for (i
= 0; i
< XLNX_ZYNQMP_NUM_ADMA_CH
; i
++) {
629 object_property_set_bool(OBJECT(&s
->adma
[i
]), true, "realized", &err
);
631 error_propagate(errp
, err
);
635 sysbus_mmio_map(SYS_BUS_DEVICE(&s
->adma
[i
]), 0, adma_ch_addr
[i
]);
636 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->adma
[i
]), 0,
637 gic_spi
[adma_ch_intr
[i
]]);
641 static Property xlnx_zynqmp_props
[] = {
642 DEFINE_PROP_STRING("boot-cpu", XlnxZynqMPState
, boot_cpu
),
643 DEFINE_PROP_BOOL("secure", XlnxZynqMPState
, secure
, false),
644 DEFINE_PROP_BOOL("virtualization", XlnxZynqMPState
, virt
, false),
645 DEFINE_PROP_BOOL("has_rpu", XlnxZynqMPState
, has_rpu
, false),
646 DEFINE_PROP_LINK("ddr-ram", XlnxZynqMPState
, ddr_ram
, TYPE_MEMORY_REGION
,
648 DEFINE_PROP_END_OF_LIST()
651 static void xlnx_zynqmp_class_init(ObjectClass
*oc
, void *data
)
653 DeviceClass
*dc
= DEVICE_CLASS(oc
);
655 dc
->props
= xlnx_zynqmp_props
;
656 dc
->realize
= xlnx_zynqmp_realize
;
657 /* Reason: Uses serial_hds in realize function, thus can't be used twice */
658 dc
->user_creatable
= false;
661 static const TypeInfo xlnx_zynqmp_type_info
= {
662 .name
= TYPE_XLNX_ZYNQMP
,
663 .parent
= TYPE_DEVICE
,
664 .instance_size
= sizeof(XlnxZynqMPState
),
665 .instance_init
= xlnx_zynqmp_init
,
666 .class_init
= xlnx_zynqmp_class_init
,
669 static void xlnx_zynqmp_register_types(void)
671 type_register_static(&xlnx_zynqmp_type_info
);
674 type_init(xlnx_zynqmp_register_types
)