2016-01-30 01:50:42 +03:00
|
|
|
/*
|
|
|
|
* Raspberry Pi emulation (c) 2012 Gregory Estrade
|
|
|
|
* Upstreaming code cleanup [including bcm2835_*] (c) 2013 Jan Petrous
|
|
|
|
*
|
|
|
|
* Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft
|
|
|
|
* Written by Andrew Baumann
|
|
|
|
*
|
2020-03-23 20:22:30 +03:00
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
2016-01-30 01:50:42 +03:00
|
|
|
*/
|
|
|
|
|
2016-02-08 22:01:23 +03:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 11:01:28 +03:00
|
|
|
#include "qapi/error.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2016-01-19 23:51:44 +03:00
|
|
|
#include "cpu.h"
|
2016-01-30 01:50:42 +03:00
|
|
|
#include "hw/arm/bcm2836.h"
|
|
|
|
#include "hw/arm/raspi_platform.h"
|
|
|
|
#include "hw/sysbus.h"
|
|
|
|
|
2018-03-13 18:34:55 +03:00
|
|
|
struct BCM283XInfo {
|
|
|
|
const char *name;
|
2018-03-13 18:34:57 +03:00
|
|
|
const char *cpu_type;
|
2019-10-20 02:47:04 +03:00
|
|
|
hwaddr peri_base; /* Peripheral base address seen by the CPU */
|
|
|
|
hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */
|
2018-03-13 18:34:56 +03:00
|
|
|
int clusterid;
|
2018-03-13 18:34:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const BCM283XInfo bcm283x_socs[] = {
|
|
|
|
{
|
|
|
|
.name = TYPE_BCM2836,
|
2018-03-23 21:26:45 +03:00
|
|
|
.cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"),
|
2019-10-20 02:47:04 +03:00
|
|
|
.peri_base = 0x3f000000,
|
|
|
|
.ctrl_base = 0x40000000,
|
2018-03-13 18:34:56 +03:00
|
|
|
.clusterid = 0xf,
|
2018-03-13 18:34:55 +03:00
|
|
|
},
|
2018-03-13 18:34:57 +03:00
|
|
|
#ifdef TARGET_AARCH64
|
2018-03-13 18:34:55 +03:00
|
|
|
{
|
|
|
|
.name = TYPE_BCM2837,
|
2018-03-13 18:34:57 +03:00
|
|
|
.cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"),
|
2019-10-20 02:47:04 +03:00
|
|
|
.peri_base = 0x3f000000,
|
|
|
|
.ctrl_base = 0x40000000,
|
2018-03-13 18:34:56 +03:00
|
|
|
.clusterid = 0x0,
|
2018-03-13 18:34:55 +03:00
|
|
|
},
|
2018-03-13 18:34:57 +03:00
|
|
|
#endif
|
2018-03-13 18:34:55 +03:00
|
|
|
};
|
|
|
|
|
2016-01-30 01:50:42 +03:00
|
|
|
static void bcm2836_init(Object *obj)
|
|
|
|
{
|
2018-03-13 18:34:54 +03:00
|
|
|
BCM283XState *s = BCM283X(obj);
|
2018-03-13 18:34:57 +03:00
|
|
|
BCM283XClass *bc = BCM283X_GET_CLASS(obj);
|
|
|
|
const BCM283XInfo *info = bc->info;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
for (n = 0; n < BCM283X_NCPUS; n++) {
|
2019-10-20 02:47:05 +03:00
|
|
|
object_initialize_child(obj, "cpu[*]", &s->cpu[n].core,
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
Note that Coccinelle chokes on ARMSSE typedef vs. macro in
hw/arm/armsse.c. Worked around by temporarily renaming the macro for
the spatch run.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 08:32:25 +03:00
|
|
|
info->cpu_type);
|
2018-03-13 18:34:57 +03:00
|
|
|
}
|
2016-01-30 01:50:42 +03:00
|
|
|
|
hw/arm/bcm2836: Fix crash with device_add bcm2837 on unsupported machines
When trying to "device_add bcm2837" on a machine that is not suitable for
this device, you can quickly crash QEMU afterwards, e.g. with "info qtree":
echo "{'execute':'qmp_capabilities'} {'execute':'device_add', " \
"'arguments':{'driver':'bcm2837'}} {'execute': 'human-monitor-command', " \
"'arguments': {'command-line': 'info qtree'}}" | \
aarch64-softmmu/qemu-system-aarch64 -M integratorcp,accel=qtest -S -qmp stdio
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 12, "major": 2},
"package": "build-all"}, "capabilities": []}}
{"return": {}}
{"error": {"class": "GenericError", "desc": "Device 'bcm2837' can not be
hotplugged on this machine"}}
Segmentation fault (core dumped)
The qdev_set_parent_bus() from instance_init adds a link to the child devices
which is not valid anymore after the bcm2837 instance has been destroyed.
Unfortunately, the child devices do not get destroyed / unlinked correctly
because both object_initialize() and object_property_add_child() increase
the reference count of the child objects by one, but only one reference
is dropped when the parent gets removed. So let's use the new functions
object_initialize_child() and sysbus_init_child_obj() instead to create
the objects, which will take care of creating the child objects with the
correct reference count of one.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-id: 1531745974-17187-4-git-send-email-thuth@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-07-16 15:59:20 +03:00
|
|
|
sysbus_init_child_obj(obj, "control", &s->control, sizeof(s->control),
|
|
|
|
TYPE_BCM2836_CONTROL);
|
2016-01-30 01:50:42 +03:00
|
|
|
|
hw/arm/bcm2836: Fix crash with device_add bcm2837 on unsupported machines
When trying to "device_add bcm2837" on a machine that is not suitable for
this device, you can quickly crash QEMU afterwards, e.g. with "info qtree":
echo "{'execute':'qmp_capabilities'} {'execute':'device_add', " \
"'arguments':{'driver':'bcm2837'}} {'execute': 'human-monitor-command', " \
"'arguments': {'command-line': 'info qtree'}}" | \
aarch64-softmmu/qemu-system-aarch64 -M integratorcp,accel=qtest -S -qmp stdio
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 12, "major": 2},
"package": "build-all"}, "capabilities": []}}
{"return": {}}
{"error": {"class": "GenericError", "desc": "Device 'bcm2837' can not be
hotplugged on this machine"}}
Segmentation fault (core dumped)
The qdev_set_parent_bus() from instance_init adds a link to the child devices
which is not valid anymore after the bcm2837 instance has been destroyed.
Unfortunately, the child devices do not get destroyed / unlinked correctly
because both object_initialize() and object_property_add_child() increase
the reference count of the child objects by one, but only one reference
is dropped when the parent gets removed. So let's use the new functions
object_initialize_child() and sysbus_init_child_obj() instead to create
the objects, which will take care of creating the child objects with the
correct reference count of one.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-id: 1531745974-17187-4-git-send-email-thuth@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-07-16 15:59:20 +03:00
|
|
|
sysbus_init_child_obj(obj, "peripherals", &s->peripherals,
|
|
|
|
sizeof(s->peripherals), TYPE_BCM2835_PERIPHERALS);
|
2016-02-11 14:17:32 +03:00
|
|
|
object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals),
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
"board-rev");
|
2016-03-16 20:06:01 +03:00
|
|
|
object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals),
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
"vcram-size");
|
2016-01-30 01:50:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2836_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2018-03-13 18:34:54 +03:00
|
|
|
BCM283XState *s = BCM283X(dev);
|
2018-03-13 18:34:56 +03:00
|
|
|
BCM283XClass *bc = BCM283X_GET_CLASS(dev);
|
|
|
|
const BCM283XInfo *info = bc->info;
|
2016-01-30 01:50:42 +03:00
|
|
|
Object *obj;
|
|
|
|
Error *err = NULL;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* common peripherals from bcm2835 */
|
|
|
|
|
|
|
|
obj = object_property_get_link(OBJECT(dev), "ram", &err);
|
|
|
|
if (obj == NULL) {
|
|
|
|
error_setg(errp, "%s: required ram link not found: %s",
|
|
|
|
__func__, error_get_pretty(err));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj);
|
2016-01-30 01:50:42 +03:00
|
|
|
|
|
|
|
object_property_set_bool(OBJECT(&s->peripherals), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-25 00:58:48 +03:00
|
|
|
object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals),
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
"sd-bus");
|
2016-02-25 00:58:48 +03:00
|
|
|
|
2016-01-30 01:50:42 +03:00
|
|
|
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0,
|
2019-10-20 02:47:04 +03:00
|
|
|
info->peri_base, 1);
|
2016-01-30 01:50:42 +03:00
|
|
|
|
|
|
|
/* bcm2836 interrupt controller (and mailboxes, etc.) */
|
|
|
|
object_property_set_bool(OBJECT(&s->control), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-20 02:47:04 +03:00
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, info->ctrl_base);
|
2016-01-30 01:50:42 +03:00
|
|
|
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
|
|
|
|
|
2018-03-13 18:34:54 +03:00
|
|
|
for (n = 0; n < BCM283X_NCPUS; n++) {
|
2018-03-13 18:34:56 +03:00
|
|
|
/* TODO: this should be converted to a property of ARM_CPU */
|
2019-10-20 02:47:05 +03:00
|
|
|
s->cpu[n].core.mp_affinity = (info->clusterid << 8) | n;
|
2016-01-30 01:50:42 +03:00
|
|
|
|
|
|
|
/* set periphbase/CBAR value for CPU-local registers */
|
2019-10-20 02:47:05 +03:00
|
|
|
object_property_set_int(OBJECT(&s->cpu[n].core),
|
2019-10-20 02:47:04 +03:00
|
|
|
info->peri_base,
|
2016-01-30 01:50:42 +03:00
|
|
|
"reset-cbar", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start powered off if not enabled */
|
2019-10-20 02:47:05 +03:00
|
|
|
object_property_set_bool(OBJECT(&s->cpu[n].core), n >= s->enabled_cpus,
|
2016-01-30 01:50:42 +03:00
|
|
|
"start-powered-off", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-20 02:47:05 +03:00
|
|
|
object_property_set_bool(OBJECT(&s->cpu[n].core), true,
|
|
|
|
"realized", &err);
|
2016-01-30 01:50:42 +03:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Connect irq/fiq outputs from the interrupt controller. */
|
|
|
|
qdev_connect_gpio_out_named(DEVICE(&s->control), "irq", n,
|
2019-10-20 02:47:05 +03:00
|
|
|
qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_IRQ));
|
2016-01-30 01:50:42 +03:00
|
|
|
qdev_connect_gpio_out_named(DEVICE(&s->control), "fiq", n,
|
2019-10-20 02:47:05 +03:00
|
|
|
qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_FIQ));
|
2016-01-30 01:50:42 +03:00
|
|
|
|
|
|
|
/* Connect timers from the CPU to the interrupt controller */
|
2019-10-20 02:47:05 +03:00
|
|
|
qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_PHYS,
|
2016-04-04 19:33:51 +03:00
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->control), "cntpnsirq", n));
|
2019-10-20 02:47:05 +03:00
|
|
|
qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_VIRT,
|
2016-01-30 01:50:42 +03:00
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->control), "cntvirq", n));
|
2019-10-20 02:47:05 +03:00
|
|
|
qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_HYP,
|
2016-04-04 19:33:51 +03:00
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n));
|
2019-10-20 02:47:05 +03:00
|
|
|
qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_SEC,
|
2016-04-04 19:33:51 +03:00
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n));
|
2016-01-30 01:50:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Property bcm2836_props[] = {
|
2018-03-13 18:34:54 +03:00
|
|
|
DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus,
|
|
|
|
BCM283X_NCPUS),
|
2016-01-30 01:50:42 +03:00
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
2018-03-13 18:34:55 +03:00
|
|
|
static void bcm283x_class_init(ObjectClass *oc, void *data)
|
2016-01-30 01:50:42 +03:00
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
2018-03-13 18:34:55 +03:00
|
|
|
BCM283XClass *bc = BCM283X_CLASS(oc);
|
2016-01-30 01:50:42 +03:00
|
|
|
|
2018-03-13 18:34:55 +03:00
|
|
|
bc->info = data;
|
2016-01-30 01:50:42 +03:00
|
|
|
dc->realize = bcm2836_realize;
|
2020-01-10 18:30:32 +03:00
|
|
|
device_class_set_props(dc, bcm2836_props);
|
2018-07-16 19:18:41 +03:00
|
|
|
/* Reason: Must be wired up in code (see raspi_init() function) */
|
|
|
|
dc->user_creatable = false;
|
2016-01-30 01:50:42 +03:00
|
|
|
}
|
|
|
|
|
2018-03-13 18:34:55 +03:00
|
|
|
static const TypeInfo bcm283x_type_info = {
|
2018-03-13 18:34:54 +03:00
|
|
|
.name = TYPE_BCM283X,
|
2018-03-13 18:34:53 +03:00
|
|
|
.parent = TYPE_DEVICE,
|
2018-03-13 18:34:54 +03:00
|
|
|
.instance_size = sizeof(BCM283XState),
|
2016-01-30 01:50:42 +03:00
|
|
|
.instance_init = bcm2836_init,
|
2018-03-13 18:34:55 +03:00
|
|
|
.class_size = sizeof(BCM283XClass),
|
|
|
|
.abstract = true,
|
2016-01-30 01:50:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2836_register_types(void)
|
|
|
|
{
|
2018-03-13 18:34:55 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
type_register_static(&bcm283x_type_info);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) {
|
|
|
|
TypeInfo ti = {
|
|
|
|
.name = bcm283x_socs[i].name,
|
|
|
|
.parent = TYPE_BCM283X,
|
|
|
|
.class_init = bcm283x_class_init,
|
|
|
|
.class_data = (void *) &bcm283x_socs[i],
|
|
|
|
};
|
|
|
|
type_register(&ti);
|
|
|
|
}
|
2016-01-30 01:50:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type_init(bcm2836_register_types)
|