xref: /qemu/hw/arm/xlnx-zynqmp.c (revision f0a902f76452211cadbdf1d25ef9b94732b096e8)
1 /*
2  * Xilinx Zynq MPSoC emulation
3  *
4  * Copyright (C) 2015 Xilinx Inc
5  * Written by Peter Crosthwaite <peter.crosthwaite@xilinx.com>
6  *
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.
11  *
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
15  * for more details.
16  */
17 
18 #include "hw/arm/xlnx-zynqmp.h"
19 
20 static void xlnx_zynqmp_init(Object *obj)
21 {
22     XlnxZynqMPState *s = XLNX_ZYNQMP(obj);
23     int i;
24 
25     for (i = 0; i < XLNX_ZYNQMP_NUM_CPUS; i++) {
26         object_initialize(&s->cpu[i], sizeof(s->cpu[i]),
27                           "cortex-a53-" TYPE_ARM_CPU);
28         object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpu[i]),
29                                   &error_abort);
30     }
31 }
32 
33 static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
34 {
35     XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
36     uint8_t i;
37     Error *err = NULL;
38 
39     for (i = 0; i < XLNX_ZYNQMP_NUM_CPUS; i++) {
40         object_property_set_int(OBJECT(&s->cpu[i]), QEMU_PSCI_CONDUIT_SMC,
41                                 "psci-conduit", &error_abort);
42         if (i > 0) {
43             /* Secondary CPUs start in PSCI powered-down state */
44             object_property_set_bool(OBJECT(&s->cpu[i]), true,
45                                      "start-powered-off", &error_abort);
46         }
47 
48         object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err);
49         if (err) {
50             error_propagate((errp), (err));
51             return;
52         }
53     }
54 }
55 
56 static void xlnx_zynqmp_class_init(ObjectClass *oc, void *data)
57 {
58     DeviceClass *dc = DEVICE_CLASS(oc);
59 
60     dc->realize = xlnx_zynqmp_realize;
61 }
62 
63 static const TypeInfo xlnx_zynqmp_type_info = {
64     .name = TYPE_XLNX_ZYNQMP,
65     .parent = TYPE_DEVICE,
66     .instance_size = sizeof(XlnxZynqMPState),
67     .instance_init = xlnx_zynqmp_init,
68     .class_init = xlnx_zynqmp_class_init,
69 };
70 
71 static void xlnx_zynqmp_register_types(void)
72 {
73     type_register_static(&xlnx_zynqmp_type_info);
74 }
75 
76 type_init(xlnx_zynqmp_register_types)
77