From nobody Tue Nov 26 08:33:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709041158; cv=none; d=zohomail.com; s=zohoarc; b=B8v3X0EZ897R8oweQqPdZD/oDbWh2b0fk2eioKaZAlpHpW7xPu/BtFGbbOetBHcKthgip1KGeGwcCaE7MQpTL5RUqILfqCvl57NCSC9mtbZbd7Fzmv/OR0GEthJq6jTEv/kHVg1qupLXl00h6lk5v5hpAX1RYt8etoV8r1/Eq/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709041158; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=nQnB+AajkqUMtKF1ZeDIPH96ZWKHiQBABJWH1qjr8Ts=; b=G7I8fzEJa6P3cQEeySQv94URNBzVXa3QEg5ieEBl7YsPzbl4erh2BzWrpGlRZoo1eIUmM0qAYMQzUC6qE1vMtGTqfmKRtxThknpMlMSjfmQUVwYh/EhmczMEY+OcYHYBEWCfwLQhNvOmTTLLeiNcArhiBwgI6JSyG8gixgkDrEc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170904115819145.26647982490488; Tue, 27 Feb 2024 05:39:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rexas-00011X-Ru; Tue, 27 Feb 2024 08:34:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rexaT-0000mM-QT for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:37 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rexaM-0002tc-9v for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:37 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4129e8bc6c8so23957715e9.2 for ; Tue, 27 Feb 2024 05:33:29 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i13-20020adfe48d000000b0033ae7d768b2sm11319552wrm.117.2024.02.27.05.33.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 05:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709040809; x=1709645609; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nQnB+AajkqUMtKF1ZeDIPH96ZWKHiQBABJWH1qjr8Ts=; b=BOM/alxY+9nX4a6qbUnhhW9oVFpWv6et75nijjJ+G83XfdUrS+5ApZ71vhZ+PzhV+Q 92+I3EKXItGwBdbpc3dQFJJnbCOMOtYodnOponvDAtf48HukvzKvhx8EatsgZRY7njfT TwxGDq6/dBjn+cQam+I+QNPusBwPsYGK/I/oIoFpBNds2TDOvu7/KceEKcw9FsHnpDy5 Pr4UWqaIzCWjupWaLwBc8R9KzcEqb3CcxRMfTFguDoWUSI/TXPZ2eOX3QhwvgmafchGY DU97NlYZ5LuLIsE87bgEZahZ09nHtbVJIIZ+JltPpK6dZWyoMWEp6QuyZLht91R4S1vn er3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709040809; x=1709645609; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nQnB+AajkqUMtKF1ZeDIPH96ZWKHiQBABJWH1qjr8Ts=; b=Qil6uQ/qlZA0vvjnXmwksmRpbAFFNi3MpExKt2OzpbM5kCzPwYwrAbBW10NumQw+Kq Q8f1LnEm09OSVXaqaYW2hcwNBmcpdDUXEZuU/7J/dChc7dzqkLB8gXfQEw9m9hVznUpZ DPKwfMnp7+pRO0qwKgoNhocda9RRpOQCsq2P/lnI7kH/iTKhfgRIQvNHrv431eFtmJkd MHVe+JDL5viN6APF0JTcc8te0U7n0F6q9iBdleHPk7VHz12rcagaNY1l+RqpgmMj70d8 gKQKdp16y6rw8u4oc6Xr95n2i+f0DKwPy2g8dfDj8naT+sr6kzUEBgQHcKMsWnLvYyZU 2IGQ== X-Gm-Message-State: AOJu0YzlRhkX2uLFHiGw6wJ8r6YpcZne7X7QofW2WhG5iOUgU2Cq8+Rn 6Y/vDViGw1wxIGavubMw2pL45z6+0XBNcFzP9BF9tPicFBG7BQ6XGCM5U2mycsahqflwR02OkuO W X-Google-Smtp-Source: AGHT+IE0Tcl02FS7aLHDTUW7jDBgAsp09mHiOEViNuM6hGQRh61pGG3Ef2prRGeCk73y/27cUwYsvg== X-Received: by 2002:a5d:64e3:0:b0:33d:862c:1598 with SMTP id g3-20020a5d64e3000000b0033d862c1598mr9691534wri.50.1709040808779; Tue, 27 Feb 2024 05:33:28 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/45] hw/arm: Introduce BCM2838 SoC Date: Tue, 27 Feb 2024 13:32:53 +0000 Message-Id: <20240227133314.1721857-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227133314.1721857-1-peter.maydell@linaro.org> References: <20240227133314.1721857-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709041159843100007 Content-Type: text/plain; charset="utf-8" From: Sergey Kambalin Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell Message-id: 20240226000259.2752893-5-sergey.kambalin@auriga.com Signed-off-by: Peter Maydell --- include/hw/arm/bcm2838.h | 29 ++++++++ include/hw/arm/bcm2838_peripherals.h | 36 ++++++++++ hw/arm/bcm2838.c | 98 ++++++++++++++++++++++++++++ hw/arm/bcm2838_peripherals.c | 72 ++++++++++++++++++++ hw/arm/meson.build | 2 + 5 files changed, 237 insertions(+) create mode 100644 include/hw/arm/bcm2838.h create mode 100644 include/hw/arm/bcm2838_peripherals.h create mode 100644 hw/arm/bcm2838.c create mode 100644 hw/arm/bcm2838_peripherals.c diff --git a/include/hw/arm/bcm2838.h b/include/hw/arm/bcm2838.h new file mode 100644 index 00000000000..bddc25ca9af --- /dev/null +++ b/include/hw/arm/bcm2838.h @@ -0,0 +1,29 @@ +/* + * BCM2838 SoC emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef BCM2838_H +#define BCM2838_H + +#include "hw/arm/bcm2836.h" +#include "hw/arm/bcm2838_peripherals.h" + +#define BCM2838_PERI_LOW_BASE 0xfc000000 +#define BCM2838_GIC_BASE 0x40000 + +#define TYPE_BCM2838 "bcm2838" + +OBJECT_DECLARE_TYPE(BCM2838State, BCM2838Class, BCM2838) + +struct BCM2838State { + /*< private >*/ + BCM283XBaseState parent_obj; + /*< public >*/ + BCM2838PeripheralState peripherals; +}; + +#endif /* BCM2838_H */ diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h new file mode 100644 index 00000000000..7039b67cc96 --- /dev/null +++ b/include/hw/arm/bcm2838_peripherals.h @@ -0,0 +1,36 @@ +/* + * BCM2838 peripherals emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef BCM2838_PERIPHERALS_H +#define BCM2838_PERIPHERALS_H + +#include "hw/arm/bcm2835_peripherals.h" + + +#define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals" +OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass, + BCM2838_PERIPHERALS) + +struct BCM2838PeripheralState { + /*< private >*/ + BCMSocPeripheralBaseState parent_obj; + + /*< public >*/ + MemoryRegion peri_low_mr; + MemoryRegion peri_low_mr_alias; + MemoryRegion mphi_mr_alias; +}; + +struct BCM2838PeripheralClass { + /*< private >*/ + BCMSocPeripheralBaseClass parent_class; + /*< public >*/ + uint64_t peri_low_size; /* Peripheral lower range size */ +}; + +#endif /* BCM2838_PERIPHERALS_H */ diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c new file mode 100644 index 00000000000..05281e247fe --- /dev/null +++ b/hw/arm/bcm2838.c @@ -0,0 +1,98 @@ +/* + * BCM2838 SoC emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * 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 =3D 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 =3D BCM2838(dev); + BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCM283XBaseClass *bc_base =3D BCM283X_BASE_GET_CLASS(dev); + BCM2838PeripheralState *ps =3D BCM2838_PERIPHERALS(&s->peripherals); + BCMSocPeripheralBaseState *ps_base =3D + 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_bas= e); + + /* Create cores */ + for (n =3D 0; n < bc_base->core_count; n++) { + + object_property_set_int(OBJECT(&s_base->cpu[n].core), "mp-affinity= ", + (bc_base->clusterid << 8) | n, &error_abor= t); + + /* start powered off if not enabled */ + object_property_set_bool(OBJECT(&s_base->cpu[n].core), + "start-powered-off", + n >=3D s_base->enabled_cpus, &error_abort= ); + + if (!qdev_realize(DEVICE(&s_base->cpu[n].core), NULL, errp)) { + return; + } + } +} + +static void bcm2838_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + BCM283XBaseClass *bc_base =3D BCM283X_BASE_CLASS(oc); + + bc_base->cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a72"); + bc_base->core_count =3D BCM283X_NCPUS; + bc_base->peri_base =3D 0xfe000000; + bc_base->ctrl_base =3D 0xff800000; + bc_base->clusterid =3D 0x0; + dc->realize =3D bcm2838_realize; +} + +static const TypeInfo bcm2838_type =3D { + .name =3D TYPE_BCM2838, + .parent =3D TYPE_BCM283X_BASE, + .instance_size =3D sizeof(BCM2838State), + .instance_init =3D bcm2838_init, + .class_size =3D sizeof(BCM283XBaseClass), + .class_init =3D bcm2838_class_init, +}; + +static void bcm2838_register_types(void) +{ + type_register_static(&bcm2838_type); +} + +type_init(bcm2838_register_types); diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c new file mode 100644 index 00000000000..06110c724f8 --- /dev/null +++ b/hw/arm/bcm2838_peripherals.c @@ -0,0 +1,72 @@ +/* + * BCM2838 peripherals emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * 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/arm/bcm2838_peripherals.h" + +/* Lower peripheral base address on the VC (GPU) system bus */ +#define BCM2838_VC_PERI_LOW_BASE 0x7c000000 + +static void bcm2838_peripherals_init(Object *obj) +{ + BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(obj); + BCM2838PeripheralClass *bc =3D BCM2838_PERIPHERALS_GET_CLASS(obj); + + /* Lower memory region for peripheral devices (exported to the Soc) */ + memory_region_init(&s->peri_low_mr, obj, "bcm2838-peripherals", + bc->peri_low_size); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_low_mr); + +} + +static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) +{ + BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(dev); + BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(dev); + + bcm_soc_peripherals_common_realize(dev, errp); + + /* Map lower peripherals into the GPU address space */ + memory_region_init_alias(&s->peri_low_mr_alias, OBJECT(s), + "bcm2838-peripherals", &s->peri_low_mr, 0, + memory_region_size(&s->peri_low_mr)); + memory_region_add_subregion_overlap(&s_base->gpu_bus_mr, + BCM2838_VC_PERI_LOW_BASE, + &s->peri_low_mr_alias, 1); + +} + +static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + BCM2838PeripheralClass *bc =3D BCM2838_PERIPHERALS_CLASS(oc); + BCMSocPeripheralBaseClass *bc_base =3D BCM_SOC_PERIPHERALS_BASE_CLASS(= oc); + + bc->peri_low_size =3D 0x2000000; + bc_base->peri_size =3D 0x1800000; + dc->realize =3D bcm2838_peripherals_realize; +} + +static const TypeInfo bcm2838_peripherals_type_info =3D { + .name =3D TYPE_BCM2838_PERIPHERALS, + .parent =3D TYPE_BCM_SOC_PERIPHERALS_BASE, + .instance_size =3D sizeof(BCM2838PeripheralState), + .instance_init =3D bcm2838_peripherals_init, + .class_size =3D sizeof(BCM2838PeripheralClass), + .class_init =3D bcm2838_peripherals_class_init, +}; + +static void bcm2838_peripherals_register_types(void) +{ + type_register_static(&bcm2838_peripherals_type_info); +} + +type_init(bcm2838_peripherals_register_types) diff --git a/hw/arm/meson.build b/hw/arm/meson.build index a16d3479055..1390a9d7b51 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -30,6 +30,7 @@ arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('= allwinner-a10.c', 'cubi arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', '= orangepi.c')) arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c',= 'bananapi_m2u.c')) arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c')) +arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm28= 38.c')) arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c')) arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c')) arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c')) @@ -67,6 +68,7 @@ system_ss.add(when: 'CONFIG_GUMSTIX', if_true: files('gum= stix.c')) system_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c')) system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap2.c')) system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_peripherals.c'= )) +system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2838_peripherals.c'= )) system_ss.add(when: 'CONFIG_SPITZ', if_true: files('spitz.c')) system_ss.add(when: 'CONFIG_STRONGARM', if_true: files('strongarm.c')) system_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c')) --=20 2.34.1