[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 04/45] Introduce BCM2838 SoC
From: |
Peter Maydell |
Subject: |
Re: [PATCH v4 04/45] Introduce BCM2838 SoC |
Date: |
Mon, 18 Dec 2023 16:07:22 +0000 |
On Fri, 8 Dec 2023 at 02:33, Sergey Kambalin <serg.oker@gmail.com> wrote:
>
> Signed-off-by: Sergey Kambalin <sergey.kambalin@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.ovchinnikov@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-philmd@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-philmd@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.maydell@linaro.org>
thanks
-- PMM
- [PATCH v4 00/45] Raspberry Pi 4B machine, Sergey Kambalin, 2023/12/07
- [PATCH v4 01/45] Split out common part of BCM283X classes, Sergey Kambalin, 2023/12/07
- [PATCH v4 02/45] Split out common part of peripherals, Sergey Kambalin, 2023/12/07
- [PATCH v4 03/45] Split out raspi machine common part, Sergey Kambalin, 2023/12/07
- [PATCH v4 04/45] Introduce BCM2838 SoC, Sergey Kambalin, 2023/12/07
- Re: [PATCH v4 04/45] Introduce BCM2838 SoC,
Peter Maydell <=
- [PATCH v4 05/45] Add GIC-400 to BCM2838 SoC, Sergey Kambalin, 2023/12/07
- [PATCH v4 06/45] Add BCM2838 GPIO stub, Sergey Kambalin, 2023/12/07
- [PATCH v4 08/45] Connect SD controller to BCM2838 GPIO, Sergey Kambalin, 2023/12/07
- [PATCH v4 09/45] Add GPIO and SD to BCM2838 periph, Sergey Kambalin, 2023/12/07
- [PATCH v4 10/45] Add BCM2838 checkpoint support, Sergey Kambalin, 2023/12/07