On Fri, 8 Dec 2023 at 02:33, Sergey Kambalin <serg.o...@gmail.com> wrote: > > Signed-off-by: Sergey Kambalin <sergey.kamba...@auriga.com> > --- > hw/arm/bcm2838.c | 100 +++++++++++++++++++++++++++ > hw/arm/bcm2838_peripherals.c | 72 +++++++++++++++++++ > hw/arm/meson.build | 2 + > include/hw/arm/bcm2838.h | 29 ++++++++ > include/hw/arm/bcm2838_peripherals.h | 36 ++++++++++ > 5 files changed, 239 insertions(+) > create mode 100644 hw/arm/bcm2838.c > create mode 100644 hw/arm/bcm2838_peripherals.c > create mode 100644 include/hw/arm/bcm2838.h > create mode 100644 include/hw/arm/bcm2838_peripherals.h > > diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c > new file mode 100644 > index 0000000000..c61c59661b > --- /dev/null > +++ b/hw/arm/bcm2838.c > @@ -0,0 +1,100 @@ > +/* > + * BCM2838 SoC emulation > + * > + * Copyright (C) 2022 Ovchinnikov Vitalii <vitalii.ovchinni...@auriga.com> > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > + > +#include "qemu/osdep.h" > +#include "qapi/error.h" > +#include "qemu/module.h" > +#include "hw/arm/raspi_platform.h" > +#include "hw/sysbus.h" > +#include "hw/arm/bcm2838.h" > +#include "trace.h" > + > +#define VIRTUAL_PMU_IRQ 7 > + > +static void bcm2838_init(Object *obj) > +{ > + BCM2838State *s = BCM2838(obj); > + > + object_initialize_child(obj, "peripherals", &s->peripherals, > + TYPE_BCM2838_PERIPHERALS); > + object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals), > + "board-rev"); > + object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), > + "vcram-size"); > + object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals), > + "command-line"); > +} > + > +static void bcm2838_realize(DeviceState *dev, Error **errp) > +{ > + int n; > + BCM2838State *s = BCM2838(dev); > + BCM283XBaseState *s_base = BCM283X_BASE(dev); > + BCM283XBaseClass *bc_base = BCM283X_BASE_GET_CLASS(dev); > + BCM2838PeripheralState *ps = BCM2838_PERIPHERALS(&s->peripherals); > + BCMSocPeripheralBaseState *ps_base = > + BCM_SOC_PERIPHERALS_BASE(&s->peripherals); > + > + if (!bcm283x_common_realize(dev, ps_base, errp)) { > + return; > + } > + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(ps), 1, BCM2838_PERI_LOW_BASE, 1); > + > + /* bcm2836 interrupt controller (and mailboxes, etc.) */ > + if (!sysbus_realize(SYS_BUS_DEVICE(&s_base->control), errp)) { > + return; > + } > + sysbus_mmio_map(SYS_BUS_DEVICE(&s_base->control), 0, bc_base->ctrl_base); > + > + /* Create cores */ > + for (n = 0; n < bc_base->core_count; n++) { > + /* TODO: this should be converted to a property of ARM_CPU */ > + s_base->cpu[n].core.mp_affinity = (bc_base->clusterid << 8) | n;
We have a property now, so we can do: object_property_set_int(OBJECT(&s->cpu[n].core), "mp-affinity", (bc->clusterid << 8) | n, &error_abort); rather than propagating a TODO item. https://lore.kernel.org/qemu-devel/20231123143813.42632-4-phi...@linaro.org/ is the patch (still pending) that does this in the existing rpi code. > + > + /* start powered off if not enabled */ > + if (!object_property_set_bool(OBJECT(&s_base->cpu[n].core), > + "start-powered-off", > + n >= s_base->enabled_cpus, > + errp)) { > + return; > + } Trying to set start-powered-off can never fail, so we don't need to error-check it, but can just error_abort. https://lore.kernel.org/qemu-devel/20231123143813.42632-5-phi...@linaro.org/ is the patch which does that for the existing uses. > + > + if (!qdev_realize(DEVICE(&s_base->cpu[n].core), NULL, errp)) { > + return; > + } > + } > +} Otherwise Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> thanks -- PMM