[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 5/9] hw/arm/bcm2836: Split out common realize() code
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 5/9] hw/arm/bcm2836: Split out common realize() code |
Date: |
Sun, 18 Oct 2020 22:33:54 +0200 |
The realize() function is clearly composed of two parts,
each described by a comment:
void realize()
{
/* common peripherals from bcm2835 */
...
/* bcm2836 interrupt controller (and mailboxes, etc.) */
...
}
Split the two part, so we can reuse the common part with other
SoCs from this family.
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/arm/bcm2836.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index fcb2c9c3e73..7d975cf2f53 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -52,7 +52,10 @@ static void bcm2836_init(Object *obj)
qdev_prop_set_uint32(DEVICE(obj), "enabled-cpus", bc->core_count);
}
- object_initialize_child(obj, "control", &s->control, TYPE_BCM2836_CONTROL);
+ if (bc->ctrl_base) {
+ object_initialize_child(obj, "control", &s->control,
+ TYPE_BCM2836_CONTROL);
+ }
object_initialize_child(obj, "peripherals", &s->peripherals,
TYPE_BCM2835_PERIPHERALS);
@@ -62,12 +65,11 @@ static void bcm2836_init(Object *obj)
"vcram-size");
}
-static void bcm2836_realize(DeviceState *dev, Error **errp)
+static bool bcm283x_common_realize(DeviceState *dev, Error **errp)
{
BCM283XState *s = BCM283X(dev);
BCM283XClass *bc = BCM283X_GET_CLASS(dev);
Object *obj;
- int n;
/* common peripherals from bcm2835 */
@@ -76,7 +78,7 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj);
if (!sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), errp)) {
- return;
+ return false;
}
object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals),
@@ -84,6 +86,18 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0,
bc->peri_base, 1);
+ return true;
+}
+
+static void bcm2836_realize(DeviceState *dev, Error **errp)
+{
+ BCM283XState *s = BCM283X(dev);
+ BCM283XClass *bc = BCM283X_GET_CLASS(dev);
+ int n;
+
+ if (!bcm283x_common_realize(dev, errp)) {
+ return;
+ }
/* bcm2836 interrupt controller (and mailboxes, etc.) */
if (!sysbus_realize(SYS_BUS_DEVICE(&s->control), errp)) {
--
2.26.2
- [PATCH v3 0/9] hw/arm: Add raspi Zero, 1A+ and 3A+ machines, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 1/9] hw/arm/bcm2836: Restrict BCM283XInfo declaration to C source, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 2/9] hw/arm/bcm2836: QOM'ify more by adding class_init() to each SoC type, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 3/9] hw/arm/bcm2836: Introduce BCM283XClass::core_count, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 4/9] hw/arm/bcm2836: Only provide "enabled-cpus" property to multicore SoCs, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 6/9] hw/arm/bcm2836: Introduce the BCM2835 SoC, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 5/9] hw/arm/bcm2836: Split out common realize() code,
Philippe Mathieu-Daudé <=
- [PATCH v3 7/9] hw/arm/raspi: Add the Raspberry Pi A+ machine, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 8/9] hw/arm/raspi: Add the Raspberry Pi Zero machine, Philippe Mathieu-Daudé, 2020/10/18
- [PATCH v3 9/9] hw/arm/raspi: Add the Raspberry Pi 3 model A+, Philippe Mathieu-Daudé, 2020/10/18