2016-01-30 01:50:40 +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:40 +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-30 01:50:40 +03:00
|
|
|
#include "hw/arm/bcm2835_peripherals.h"
|
|
|
|
#include "hw/misc/bcm2835_mbox_defs.h"
|
|
|
|
#include "hw/arm/raspi_platform.h"
|
2016-06-06 18:59:31 +03:00
|
|
|
#include "sysemu/sysemu.h"
|
2016-01-30 01:50:40 +03:00
|
|
|
|
|
|
|
/* Peripheral base address on the VC (GPU) system bus */
|
|
|
|
#define BCM2835_VC_PERI_BASE 0x7e000000
|
|
|
|
|
|
|
|
/* Capabilities for SD controller: no DMA, high-speed, default clocks etc. */
|
2018-02-08 19:48:12 +03:00
|
|
|
#define BCM2835_SDHC_CAPAREG 0x52134b4
|
2016-01-30 01:50:40 +03:00
|
|
|
|
2019-09-26 20:34:13 +03:00
|
|
|
static void create_unimp(BCM2835PeripheralState *ps,
|
|
|
|
UnimplementedDeviceState *uds,
|
|
|
|
const char *name, hwaddr ofs, hwaddr size)
|
|
|
|
{
|
|
|
|
sysbus_init_child_obj(OBJECT(ps), name, uds,
|
|
|
|
sizeof(UnimplementedDeviceState),
|
|
|
|
TYPE_UNIMPLEMENTED_DEVICE);
|
|
|
|
qdev_prop_set_string(DEVICE(uds), "name", name);
|
|
|
|
qdev_prop_set_uint64(DEVICE(uds), "size", size);
|
|
|
|
object_property_set_bool(OBJECT(uds), true, "realized", &error_fatal);
|
|
|
|
memory_region_add_subregion_overlap(&ps->peri_mr, ofs,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0), -1000);
|
|
|
|
}
|
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
static void bcm2835_peripherals_init(Object *obj)
|
|
|
|
{
|
|
|
|
BCM2835PeripheralState *s = BCM2835_PERIPHERALS(obj);
|
|
|
|
|
|
|
|
/* Memory region for peripheral devices, which we export to our parent */
|
|
|
|
memory_region_init(&s->peri_mr, obj,"bcm2835-peripherals", 0x1000000);
|
|
|
|
object_property_add_child(obj, "peripheral-io", OBJECT(&s->peri_mr), NULL);
|
|
|
|
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_mr);
|
|
|
|
|
|
|
|
/* Internal memory region for peripheral bus addresses (not exported) */
|
|
|
|
memory_region_init(&s->gpu_bus_mr, obj, "bcm2835-gpu", (uint64_t)1 << 32);
|
|
|
|
object_property_add_child(obj, "gpu-bus", OBJECT(&s->gpu_bus_mr), NULL);
|
|
|
|
|
|
|
|
/* Internal memory region for request/response communication with
|
|
|
|
* mailbox-addressable peripherals (not exported)
|
|
|
|
*/
|
|
|
|
memory_region_init(&s->mbox_mr, obj, "bcm2835-mbox",
|
|
|
|
MBOX_CHAN_COUNT << MBOX_AS_CHAN_SHIFT);
|
|
|
|
|
|
|
|
/* Interrupt Controller */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "ic", &s->ic, sizeof(s->ic), TYPE_BCM2835_IC);
|
2016-01-30 01:50:40 +03:00
|
|
|
|
2019-10-20 02:47:03 +03:00
|
|
|
/* SYS Timer */
|
|
|
|
sysbus_init_child_obj(obj, "systimer", &s->systmr, sizeof(s->systmr),
|
|
|
|
TYPE_BCM2835_SYSTIMER);
|
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
/* UART0 */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "uart0", &s->uart0, sizeof(s->uart0),
|
|
|
|
TYPE_PL011);
|
2016-01-30 01:50:40 +03:00
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
/* AUX / UART1 */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "aux", &s->aux, sizeof(s->aux),
|
|
|
|
TYPE_BCM2835_AUX);
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
/* Mailboxes */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "mbox", &s->mboxes, sizeof(s->mboxes),
|
|
|
|
TYPE_BCM2835_MBOX);
|
2016-01-30 01:50:40 +03:00
|
|
|
|
|
|
|
object_property_add_const_link(OBJECT(&s->mboxes), "mbox-mr",
|
|
|
|
OBJECT(&s->mbox_mr), &error_abort);
|
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
/* Framebuffer */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "fb", &s->fb, sizeof(s->fb), TYPE_BCM2835_FB);
|
2016-03-16 20:06:01 +03:00
|
|
|
object_property_add_alias(obj, "vcram-size", OBJECT(&s->fb), "vcram-size",
|
|
|
|
&error_abort);
|
|
|
|
|
|
|
|
object_property_add_const_link(OBJECT(&s->fb), "dma-mr",
|
|
|
|
OBJECT(&s->gpu_bus_mr), &error_abort);
|
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
/* Property channel */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "property", &s->property, sizeof(s->property),
|
|
|
|
TYPE_BCM2835_PROPERTY);
|
2016-02-11 14:17:32 +03:00
|
|
|
object_property_add_alias(obj, "board-rev", OBJECT(&s->property),
|
|
|
|
"board-rev", &error_abort);
|
2016-01-30 01:50:40 +03:00
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
object_property_add_const_link(OBJECT(&s->property), "fb",
|
|
|
|
OBJECT(&s->fb), &error_abort);
|
2016-01-30 01:50:40 +03:00
|
|
|
object_property_add_const_link(OBJECT(&s->property), "dma-mr",
|
|
|
|
OBJECT(&s->gpu_bus_mr), &error_abort);
|
|
|
|
|
2017-02-28 15:08:13 +03:00
|
|
|
/* Random Number Generator */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "rng", &s->rng, sizeof(s->rng),
|
|
|
|
TYPE_BCM2835_RNG);
|
2017-02-28 15:08:13 +03:00
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
/* Extended Mass Media Controller */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "sdhci", &s->sdhci, sizeof(s->sdhci),
|
|
|
|
TYPE_SYSBUS_SDHCI);
|
2016-03-16 20:06:02 +03:00
|
|
|
|
2017-02-28 17:55:11 +03:00
|
|
|
/* SDHOST */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "sdhost", &s->sdhost, sizeof(s->sdhost),
|
|
|
|
TYPE_BCM2835_SDHOST);
|
2017-02-28 17:55:11 +03:00
|
|
|
|
2016-03-16 20:06:02 +03:00
|
|
|
/* DMA Channels */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "dma", &s->dma, sizeof(s->dma),
|
|
|
|
TYPE_BCM2835_DMA);
|
2016-03-16 20:06:02 +03:00
|
|
|
|
|
|
|
object_property_add_const_link(OBJECT(&s->dma), "dma-mr",
|
|
|
|
OBJECT(&s->gpu_bus_mr), &error_abort);
|
2017-02-28 17:55:11 +03:00
|
|
|
|
2019-10-20 02:47:01 +03:00
|
|
|
/* Thermal */
|
|
|
|
sysbus_init_child_obj(obj, "thermal", &s->thermal, sizeof(s->thermal),
|
|
|
|
TYPE_BCM2835_THERMAL);
|
|
|
|
|
2017-02-28 17:55:11 +03:00
|
|
|
/* GPIO */
|
hw/arm/bcm2835: Use object_initialize_child for correct ref. counting
As explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child()
increase the reference counter of the new object, so one of the
references has to be dropped afterwards to get the reference
counting right. Otherwise the child object will not be properly
cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the
reference counting here right.
This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):
@use_object_initialize_child@
expression parent_obj;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, &error_abort, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
...
?- object_unref(OBJECT(child_ptr));
|
- object_initialize(child_ptr, child_size, child_type);
+ object_initialize_child(parent_obj, child_name, child_ptr, child_size,
+ child_type, errp, NULL);
... when != parent_obj
- object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
...
?- object_unref(OBJECT(child_ptr));
)
@use_sysbus_init_child_obj@
expression parent_obj;
expression dev;
expression child_ptr;
expression child_name;
expression child_type;
expression child_size;
expression errp;
@@
(
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
...
- qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
|
- object_initialize_child(parent_obj, child_name, child_ptr, child_size,
- child_type, errp, NULL);
+ sysbus_init_child_obj(parent_obj, child_name, child_ptr, child_size,
+ child_type);
- dev = DEVICE(child_ptr);
- qdev_set_parent_bus(dev, sysbus_get_default());
)
While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:
void sysbus_init_child_obj(Object *parent,
const char *childname, void *child,
size_t childsize, const char *childtype)
{
object_initialize_child(parent, childname, child, childsize,
childtype, &error_abort, NULL);
qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
}
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-7-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-07 19:34:06 +03:00
|
|
|
sysbus_init_child_obj(obj, "gpio", &s->gpio, sizeof(s->gpio),
|
|
|
|
TYPE_BCM2835_GPIO);
|
2017-02-28 17:55:11 +03:00
|
|
|
|
|
|
|
object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci",
|
|
|
|
OBJECT(&s->sdhci.sdbus), &error_abort);
|
|
|
|
object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost",
|
|
|
|
OBJECT(&s->sdhost.sdbus), &error_abort);
|
2016-01-30 01:50:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
BCM2835PeripheralState *s = BCM2835_PERIPHERALS(dev);
|
|
|
|
Object *obj;
|
|
|
|
MemoryRegion *ram;
|
|
|
|
Error *err = NULL;
|
2017-06-07 19:36:17 +03:00
|
|
|
uint64_t ram_size, vcram_size;
|
2016-01-30 01:50:40 +03:00
|
|
|
int n;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
ram = MEMORY_REGION(obj);
|
|
|
|
ram_size = memory_region_size(ram);
|
|
|
|
|
|
|
|
/* Map peripherals and RAM into the GPU address space. */
|
|
|
|
memory_region_init_alias(&s->peri_mr_alias, OBJECT(s),
|
|
|
|
"bcm2835-peripherals", &s->peri_mr, 0,
|
|
|
|
memory_region_size(&s->peri_mr));
|
|
|
|
|
|
|
|
memory_region_add_subregion_overlap(&s->gpu_bus_mr, BCM2835_VC_PERI_BASE,
|
|
|
|
&s->peri_mr_alias, 1);
|
|
|
|
|
|
|
|
/* RAM is aliased four times (different cache configurations) on the GPU */
|
|
|
|
for (n = 0; n < 4; n++) {
|
|
|
|
memory_region_init_alias(&s->ram_alias[n], OBJECT(s),
|
|
|
|
"bcm2835-gpu-ram-alias[*]", ram, 0, ram_size);
|
|
|
|
memory_region_add_subregion_overlap(&s->gpu_bus_mr, (hwaddr)n << 30,
|
|
|
|
&s->ram_alias[n], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Interrupt Controller */
|
|
|
|
object_property_set_bool(OBJECT(&s->ic), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->peri_mr, ARMCTRL_IC_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->ic), 0));
|
|
|
|
sysbus_pass_irq(SYS_BUS_DEVICE(s), SYS_BUS_DEVICE(&s->ic));
|
|
|
|
|
2019-10-20 02:47:03 +03:00
|
|
|
/* Sys Timer */
|
|
|
|
object_property_set_bool(OBJECT(&s->systmr), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memory_region_add_subregion(&s->peri_mr, ST_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systmr), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 0,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ,
|
|
|
|
INTERRUPT_ARM_TIMER));
|
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
/* UART0 */
|
2019-05-07 19:34:05 +03:00
|
|
|
qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0));
|
|
|
|
object_property_set_bool(OBJECT(&s->uart0), true, "realized", &err);
|
2016-01-30 01:50:40 +03:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->peri_mr, UART0_OFFSET,
|
2019-05-07 19:34:05 +03:00
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->uart0), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart0), 0,
|
2016-01-30 01:50:40 +03:00
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
|
2019-09-26 20:34:12 +03:00
|
|
|
INTERRUPT_UART0));
|
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
/* AUX / UART1 */
|
2018-04-20 17:52:43 +03:00
|
|
|
qdev_prop_set_chr(DEVICE(&s->aux), "chardev", serial_hd(1));
|
2016-03-16 20:06:01 +03:00
|
|
|
|
|
|
|
object_property_set_bool(OBJECT(&s->aux), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-26 20:34:12 +03:00
|
|
|
memory_region_add_subregion(&s->peri_mr, AUX_OFFSET,
|
2016-03-16 20:06:01 +03:00
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->aux), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->aux), 0,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
|
|
|
|
INTERRUPT_AUX));
|
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
/* Mailboxes */
|
|
|
|
object_property_set_bool(OBJECT(&s->mboxes), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->peri_mr, ARMCTRL_0_SBM_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mboxes), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mboxes), 0,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ,
|
|
|
|
INTERRUPT_ARM_MAILBOX));
|
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
/* Framebuffer */
|
2017-06-07 19:36:17 +03:00
|
|
|
vcram_size = object_property_get_uint(OBJECT(s), "vcram-size", &err);
|
2016-03-16 20:06:01 +03:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-07 19:36:17 +03:00
|
|
|
object_property_set_uint(OBJECT(&s->fb), ram_size - vcram_size,
|
|
|
|
"vcram-base", &err);
|
2016-03-16 20:06:01 +03:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
object_property_set_bool(OBJECT(&s->fb), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->mbox_mr, MBOX_CHAN_FB << MBOX_AS_CHAN_SHIFT,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->fb), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fb), 0,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_FB));
|
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
/* Property channel */
|
|
|
|
object_property_set_bool(OBJECT(&s->property), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->mbox_mr,
|
|
|
|
MBOX_CHAN_PROPERTY << MBOX_AS_CHAN_SHIFT,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->property), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->property), 0,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_PROPERTY));
|
|
|
|
|
2017-02-28 15:08:13 +03:00
|
|
|
/* Random Number Generator */
|
|
|
|
object_property_set_bool(OBJECT(&s->rng), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->peri_mr, RNG_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0));
|
|
|
|
|
2018-02-08 19:48:11 +03:00
|
|
|
/* Extended Mass Media Controller
|
|
|
|
*
|
|
|
|
* Compatible with:
|
|
|
|
* - SD Host Controller Specification Version 3.0 Draft 1.0
|
|
|
|
* - SDIO Specification Version 3.0
|
|
|
|
* - MMC Specification Version 4.4
|
|
|
|
*
|
|
|
|
* For the exact details please refer to the Arasan documentation:
|
|
|
|
* SD3.0_Host_AHB_eMMC4.4_Usersguide_ver5.9_jan11_10.pdf
|
|
|
|
*/
|
|
|
|
object_property_set_uint(OBJECT(&s->sdhci), 3, "sd-spec-version", &err);
|
|
|
|
object_property_set_uint(OBJECT(&s->sdhci), BCM2835_SDHC_CAPAREG, "capareg",
|
|
|
|
&err);
|
2016-03-16 20:06:01 +03:00
|
|
|
object_property_set_bool(OBJECT(&s->sdhci), true, "pending-insert-quirk",
|
|
|
|
&err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-30 01:50:40 +03:00
|
|
|
object_property_set_bool(OBJECT(&s->sdhci), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-26 20:34:12 +03:00
|
|
|
memory_region_add_subregion(&s->peri_mr, EMMC1_OFFSET,
|
2016-01-30 01:50:40 +03:00
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->sdhci), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
|
|
|
|
INTERRUPT_ARASANSDIO));
|
2017-02-28 17:55:11 +03:00
|
|
|
|
|
|
|
/* SDHOST */
|
|
|
|
object_property_set_bool(OBJECT(&s->sdhost), true, "realized", &err);
|
2016-02-25 00:58:48 +03:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-28 17:55:11 +03:00
|
|
|
memory_region_add_subregion(&s->peri_mr, MMCI0_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->sdhost), 0));
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhost), 0,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
|
|
|
|
INTERRUPT_SDIO));
|
|
|
|
|
2016-03-16 20:06:02 +03:00
|
|
|
/* DMA Channels */
|
|
|
|
object_property_set_bool(OBJECT(&s->dma), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->peri_mr, DMA_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 0));
|
|
|
|
memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1));
|
|
|
|
|
|
|
|
for (n = 0; n <= 12; n++) {
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->ic),
|
|
|
|
BCM2835_IC_GPU_IRQ,
|
|
|
|
INTERRUPT_DMA0 + n));
|
|
|
|
}
|
2017-02-28 17:55:11 +03:00
|
|
|
|
2019-10-20 02:47:01 +03:00
|
|
|
/* THERMAL */
|
|
|
|
object_property_set_bool(OBJECT(&s->thermal), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memory_region_add_subregion(&s->peri_mr, THERMAL_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0));
|
|
|
|
|
2017-02-28 17:55:11 +03:00
|
|
|
/* GPIO */
|
|
|
|
object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(&s->peri_mr, GPIO_OFFSET,
|
|
|
|
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0));
|
|
|
|
|
|
|
|
object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus",
|
|
|
|
&err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
2019-09-26 20:34:13 +03:00
|
|
|
|
|
|
|
create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40);
|
|
|
|
create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000);
|
|
|
|
create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000);
|
|
|
|
create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100);
|
|
|
|
create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100);
|
|
|
|
create_unimp(s, &s->spi[0], "bcm2835-spi0", SPI0_OFFSET, 0x20);
|
|
|
|
create_unimp(s, &s->bscsl, "bcm2835-spis", BSC_SL_OFFSET, 0x100);
|
|
|
|
create_unimp(s, &s->i2c[0], "bcm2835-i2c0", BSC0_OFFSET, 0x20);
|
|
|
|
create_unimp(s, &s->i2c[1], "bcm2835-i2c1", BSC1_OFFSET, 0x20);
|
|
|
|
create_unimp(s, &s->i2c[2], "bcm2835-i2c2", BSC2_OFFSET, 0x20);
|
|
|
|
create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80);
|
|
|
|
create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000);
|
|
|
|
create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000);
|
|
|
|
create_unimp(s, &s->dwc2, "dwc-usb2", USB_OTG_OFFSET, 0x1000);
|
|
|
|
create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100);
|
2016-01-30 01:50:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_peripherals_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
|
|
|
|
dc->realize = bcm2835_peripherals_realize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo bcm2835_peripherals_type_info = {
|
|
|
|
.name = TYPE_BCM2835_PERIPHERALS,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(BCM2835PeripheralState),
|
|
|
|
.instance_init = bcm2835_peripherals_init,
|
|
|
|
.class_init = bcm2835_peripherals_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2835_peripherals_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&bcm2835_peripherals_type_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(bcm2835_peripherals_register_types)
|