From nobody Tue Nov 26 09:43:18 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=1709041448; cv=none; d=zohomail.com; s=zohoarc; b=NnfhZUfwPUdq5ezCJtyHyvOF//Qi0/hggjSMIWo9hmY2sV1l9AlYL8Y2aGBPh2UG4yY9ruTFgIuinfO1FxBQYLdkYma37T7zcGOMhuEhWuSqbw5Up0PUPRcbuFacy3p1pAVmE8t7n5KnzlH+No0t+brNbU0OclYAY8y7GLGVhqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709041448; 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=+u19NxduId3LkBZhgtLn+B43jbfMKvvN4h7CCw7jvfE=; b=Soqgsi1IkbJfFcj1K6OmqDFPPvHEDpzYNKq8IqUE1a/qsTbl3raaZm4dUDjZmTnalFKVfmOfHz9ncj/clTA6It2Xb6MGALHeg3QZ5JbkolKzNWo9njdX4IfSyB2XR3sJ+TXTqh3Yqj1G5NRpL9x08sqJshj3i4ZR5W5OyAX8u1s= 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 170904144842857.14896851810363; Tue, 27 Feb 2024 05:44:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rexas-0000z1-3C; 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 1rexab-0000pl-Ft for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:47 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rexaM-0002tQ-Ak for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:43 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33d146737e6so3209308f8f.0 for ; Tue, 27 Feb 2024 05:33:28 -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.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 05:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709040808; x=1709645608; 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=+u19NxduId3LkBZhgtLn+B43jbfMKvvN4h7CCw7jvfE=; b=FvtYA+ZdSWYuC17e+FEnbSuxtYiZlACXMh8q64rHZRWl8Y53BKVG2aXfZl52OEDHdp aloabu//gJR1xbuj/fGoyb6dQrI6WKjGbiZvY497fCXc5ffmNtZUBA/nzOm7gCAUVNJK P9llGFElfzgOJ/Cqs/UAo3KW0IV/Q04A+1TsQ7l6k5NYT8WPeifWZYqLY1s5ABgrT6tQ 5H3RRH6Kd8HrtZhDW/al7jZooCkulvQMf9AU0d5TEcK7FZn4FHoRh9Vk1PyZoZMPzWeY hTDNtyRtskowXteyKe2kcuPEBugJ+/bMX31XT8nfeuTOWfvNCf1nKsv7MIu59hnkQ1KJ GdAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709040808; x=1709645608; 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=+u19NxduId3LkBZhgtLn+B43jbfMKvvN4h7CCw7jvfE=; b=YYruv951oeL8aGYIBAEpL3LLJgljaaxMNweNETKBfSO+kdyw7epaJ/T75wDWsnfFTV aWq56HmsFTRGP4EvTxqAZN5nL+++a817oiBQpsyY+Km5Rd5vyT6NUk7AqdVEwdzSp9B+ qCmh5/IduZcEcjKyHIaqinfF7eOGif65n1YTeLjMpCAQIuTfgfg3CQcHAatU6+CTfMQ2 Ip9bOEovLVp0ISne4lXA453eTHXBgm51o1WpTLNuMnHyX4bWLNdBekXp0z3gLh/HpRgO xSDlba1w8hQ61sDZ42HTVDYjt3QHQiq6tMWYc+BIUiHsjCn9beiyJTh0nhDUspaYguc6 aiPQ== X-Gm-Message-State: AOJu0YzIAyPYxpHVSfM443IEq7+goN4SICRZm4skLayhkCKl+ZZw7DgF UFoKhxm4Tekhw0yIhNoHp8afJBcm2SE5rk1u2edD7GxpbZhwFJoZrlTziRtYum2a/Mef+QPqFYN 3 X-Google-Smtp-Source: AGHT+IEIUBhPYqIPvi2TjHSdAF452WonLSlkJLy5btgHdwrVjRHQwxlgtMqCjxoEyeS4AdoIsrW+QQ== X-Received: by 2002:a5d:4443:0:b0:33d:31dc:cff7 with SMTP id x3-20020a5d4443000000b0033d31dccff7mr6925215wrr.32.1709040807642; Tue, 27 Feb 2024 05:33:27 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/45] hw/arm/bcm2853_peripherals: Split out common part of peripherals Date: Tue, 27 Feb 2024 13:32:51 +0000 Message-Id: <20240227133314.1721857-23-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::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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: 1709041448845100006 Content-Type: text/plain; charset="utf-8" From: Sergey Kambalin Pre-setup for BCM2838 introduction Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell Message-id: 20240226000259.2752893-3-sergey.kambalin@auriga.com Signed-off-by: Peter Maydell --- include/hw/arm/bcm2835_peripherals.h | 29 +++- include/hw/arm/bcm2836.h | 3 +- hw/arm/bcm2835_peripherals.c | 198 +++++++++++++++------------ hw/arm/bcm2836.c | 24 ++-- 4 files changed, 154 insertions(+), 100 deletions(-) diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_= peripherals.h index 0203bb79d8c..1fc96218f82 100644 --- a/include/hw/arm/bcm2835_peripherals.h +++ b/include/hw/arm/bcm2835_peripherals.h @@ -35,10 +35,13 @@ #include "hw/misc/unimp.h" #include "qom/object.h" =20 +#define TYPE_BCM_SOC_PERIPHERALS_BASE "bcm-soc-peripherals-base" +OBJECT_DECLARE_TYPE(BCMSocPeripheralBaseState, BCMSocPeripheralBaseClass, + BCM_SOC_PERIPHERALS_BASE) #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PeripheralState, BCM2835_PERIPHERALS) =20 -struct BCM2835PeripheralState { +struct BCMSocPeripheralBaseState { /*< private >*/ SysBusDevice parent_obj; /*< public >*/ @@ -60,12 +63,9 @@ struct BCM2835PeripheralState { OrIRQState orgated_dma_irq; BCM2835ICState ic; BCM2835PropertyState property; - BCM2835RngState rng; BCM2835MboxState mboxes; SDHCIState sdhci; BCM2835SDHostState sdhost; - BCM2835GpioState gpio; - Bcm2835ThermalState thermal; UnimplementedDeviceState i2s; BCM2835SPIState spi[1]; UnimplementedDeviceState i2c[3]; @@ -79,4 +79,25 @@ struct BCM2835PeripheralState { UnimplementedDeviceState sdramc; }; =20 +struct BCMSocPeripheralBaseClass { + /*< private >*/ + SysBusDeviceClass parent_class; + /*< public >*/ + uint64_t peri_size; /* Peripheral range size */ +}; + +struct BCM2835PeripheralState { + /*< private >*/ + BCMSocPeripheralBaseState parent_obj; + /*< public >*/ + BCM2835RngState rng; + Bcm2835ThermalState thermal; + BCM2835GpioState gpio; +}; + +void create_unimp(BCMSocPeripheralBaseState *ps, + UnimplementedDeviceState *uds, + const char *name, hwaddr ofs, hwaddr size); +void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp); + #endif /* BCM2835_PERIPHERALS_H */ diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h index 5a6717ca91e..918fb3bf142 100644 --- a/include/hw/arm/bcm2836.h +++ b/include/hw/arm/bcm2836.h @@ -64,6 +64,7 @@ struct BCM283XState { BCM2835PeripheralState peripherals; }; =20 -bool bcm283x_common_realize(DeviceState *dev, Error **errp); +bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *p= s, + Error **errp); =20 #endif /* BCM2836_H */ diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index d5573fd9545..ed38a08a577 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -30,9 +30,9 @@ #define SEPARATE_DMA_IRQ_MAX 10 #define ORGATED_DMA_IRQ_COUNT 4 =20 -static void create_unimp(BCM2835PeripheralState *ps, - UnimplementedDeviceState *uds, - const char *name, hwaddr ofs, hwaddr size) +void create_unimp(BCMSocPeripheralBaseState *ps, + UnimplementedDeviceState *uds, + const char *name, hwaddr ofs, hwaddr size) { object_initialize_child(OBJECT(ps), name, uds, TYPE_UNIMPLEMENTED_DEVI= CE); qdev_prop_set_string(DEVICE(uds), "name", name); @@ -45,9 +45,36 @@ static void create_unimp(BCM2835PeripheralState *ps, static void bcm2835_peripherals_init(Object *obj) { BCM2835PeripheralState *s =3D BCM2835_PERIPHERALS(obj); + BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(obj); + + /* Random Number Generator */ + object_initialize_child(obj, "rng", &s->rng, TYPE_BCM2835_RNG); + + /* Thermal */ + object_initialize_child(obj, "thermal", &s->thermal, TYPE_BCM2835_THER= MAL); + + /* GPIO */ + object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2835_GPIO); + + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", + OBJECT(&s_base->sdhci.sdbus)); + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", + OBJECT(&s_base->sdhost.sdbus)); + + /* Gated DMA interrupts */ + object_initialize_child(obj, "orgated-dma-irq", + &s_base->orgated_dma_irq, TYPE_OR_IRQ); + object_property_set_int(OBJECT(&s_base->orgated_dma_irq), "num-lines", + ORGATED_DMA_IRQ_COUNT, &error_abort); +} + +static void raspi_peripherals_base_init(Object *obj) +{ + BCMSocPeripheralBaseState *s =3D BCM_SOC_PERIPHERALS_BASE(obj); + BCMSocPeripheralBaseClass *bc =3D BCM_SOC_PERIPHERALS_BASE_GET_CLASS(o= bj); =20 /* Memory region for peripheral devices, which we export to our parent= */ - memory_region_init(&s->peri_mr, obj,"bcm2835-peripherals", 0x1000000); + memory_region_init(&s->peri_mr, obj, "bcm2835-peripherals", bc->peri_s= ize); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_mr); =20 /* Internal memory region for peripheral bus addresses (not exported) = */ @@ -98,9 +125,6 @@ static void bcm2835_peripherals_init(Object *obj) object_property_add_const_link(OBJECT(&s->property), "dma-mr", OBJECT(&s->gpu_bus_mr)); =20 - /* Random Number Generator */ - object_initialize_child(obj, "rng", &s->rng, TYPE_BCM2835_RNG); - /* Extended Mass Media Controller */ object_initialize_child(obj, "sdhci", &s->sdhci, TYPE_SYSBUS_SDHCI); =20 @@ -110,25 +134,9 @@ static void bcm2835_peripherals_init(Object *obj) /* DMA Channels */ object_initialize_child(obj, "dma", &s->dma, TYPE_BCM2835_DMA); =20 - object_initialize_child(obj, "orgated-dma-irq", - &s->orgated_dma_irq, TYPE_OR_IRQ); - object_property_set_int(OBJECT(&s->orgated_dma_irq), "num-lines", - ORGATED_DMA_IRQ_COUNT, &error_abort); - object_property_add_const_link(OBJECT(&s->dma), "dma-mr", OBJECT(&s->gpu_bus_mr)); =20 - /* Thermal */ - object_initialize_child(obj, "thermal", &s->thermal, TYPE_BCM2835_THER= MAL); - - /* GPIO */ - object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2835_GPIO); - - object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", - OBJECT(&s->sdhci.sdbus)); - object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", - OBJECT(&s->sdhost.sdbus)); - /* Mphi */ object_initialize_child(obj, "mphi", &s->mphi, TYPE_BCM2835_MPHI); =20 @@ -152,7 +160,72 @@ static void bcm2835_peripherals_init(Object *obj) =20 static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) { + MemoryRegion *mphi_mr; BCM2835PeripheralState *s =3D BCM2835_PERIPHERALS(dev); + BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(dev); + int n; + + bcm_soc_peripherals_common_realize(dev, errp); + + /* Extended Mass Media Controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->sdhci), 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), BCM2835_IC_GPU_IRQ, + INTERRUPT_ARASANSDIO)); + + /* Connect DMA 0-12 to the interrupt controller */ + for (n =3D 0; n <=3D SEPARATE_DMA_IRQ_MAX; n++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), n, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + INTERRUPT_DMA0 + n)); + } + + if (!qdev_realize(DEVICE(&s_base->orgated_dma_irq), NULL, errp)) { + return; + } + for (n =3D 0; n < ORGATED_DMA_IRQ_COUNT; n++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), + SEPARATE_DMA_IRQ_MAX + 1 + n, + qdev_get_gpio_in(DEVICE(&s_base->orgated_dma_ir= q), n)); + } + qdev_connect_gpio_out(DEVICE(&s_base->orgated_dma_irq), 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + INTERRUPT_DMA0 + SEPARATE_DMA_IRQ_MAX + 1)); + + /* Random Number Generator */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) { + return; + } + memory_region_add_subregion( + &s_base->peri_mr, RNG_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0)); + + /* THERMAL */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) { + return; + } + memory_region_add_subregion(&s_base->peri_mr, THERMAL_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); + + /* Map MPHI to the peripherals memory map */ + mphi_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s_base->mphi), 0); + memory_region_add_subregion(&s_base->peri_mr, MPHI_OFFSET, mphi_mr); + + /* GPIO */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { + return; + } + memory_region_add_subregion( + &s_base->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-b= us"); +} + +void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp) +{ + BCMSocPeripheralBaseState *s =3D BCM_SOC_PERIPHERALS_BASE(dev); Object *obj; MemoryRegion *ram; Error *err =3D NULL; @@ -285,14 +358,6 @@ static void bcm2835_peripherals_realize(DeviceState *d= ev, Error **errp) sysbus_connect_irq(SYS_BUS_DEVICE(&s->property), 0, qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_PROPE= RTY)); =20 - /* Random Number Generator */ - if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) { - return; - } - - memory_region_add_subregion(&s->peri_mr, RNG_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0)); - /* Extended Mass Media Controller * * Compatible with: @@ -315,9 +380,6 @@ static void bcm2835_peripherals_realize(DeviceState *de= v, Error **errp) =20 memory_region_add_subregion(&s->peri_mr, EMMC1_OFFSET, 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)); =20 /* SDHOST */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhost), errp)) { @@ -340,49 +402,11 @@ static void bcm2835_peripherals_realize(DeviceState *= dev, Error **errp) memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET, sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1)); =20 - for (n =3D 0; n <=3D SEPARATE_DMA_IRQ_MAX; 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)); - } - if (!qdev_realize(DEVICE(&s->orgated_dma_irq), NULL, errp)) { - return; - } - for (n =3D 0; n < ORGATED_DMA_IRQ_COUNT; n++) { - sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), - SEPARATE_DMA_IRQ_MAX + 1 + n, - qdev_get_gpio_in(DEVICE(&s->orgated_dma_irq), n= )); - } - qdev_connect_gpio_out(DEVICE(&s->orgated_dma_irq), 0, - qdev_get_gpio_in_named(DEVICE(&s->ic), - BCM2835_IC_GPU_IRQ, - INTERRUPT_DMA0 + SEPARATE_DMA_IRQ_MAX + 1)); - - /* THERMAL */ - if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) { - return; - } - memory_region_add_subregion(&s->peri_mr, THERMAL_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); - - /* GPIO */ - if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { - 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-b= us"); - /* Mphi */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mphi), errp)) { return; } =20 - memory_region_add_subregion(&s->peri_mr, MPHI_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mphi), 0)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->mphi), 0, qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, INTERRUPT_HOSTPORT)); @@ -436,21 +460,27 @@ static void bcm2835_peripherals_realize(DeviceState *= dev, Error **errp) static void bcm2835_peripherals_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); + BCMSocPeripheralBaseClass *bc =3D BCM_SOC_PERIPHERALS_BASE_CLASS(oc); =20 + bc->peri_size =3D 0x1000000; dc->realize =3D bcm2835_peripherals_realize; } =20 -static const TypeInfo bcm2835_peripherals_type_info =3D { - .name =3D TYPE_BCM2835_PERIPHERALS, - .parent =3D TYPE_SYS_BUS_DEVICE, - .instance_size =3D sizeof(BCM2835PeripheralState), - .instance_init =3D bcm2835_peripherals_init, - .class_init =3D bcm2835_peripherals_class_init, +static const TypeInfo bcm2835_peripherals_types[] =3D { + { + .name =3D TYPE_BCM2835_PERIPHERALS, + .parent =3D TYPE_BCM_SOC_PERIPHERALS_BASE, + .instance_size =3D sizeof(BCM2835PeripheralState), + .instance_init =3D bcm2835_peripherals_init, + .class_init =3D bcm2835_peripherals_class_init, + }, { + .name =3D TYPE_BCM_SOC_PERIPHERALS_BASE, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(BCMSocPeripheralBaseState), + .instance_init =3D raspi_peripherals_base_init, + .class_size =3D sizeof(BCMSocPeripheralBaseClass), + .abstract =3D true, + } }; =20 -static void bcm2835_peripherals_register_types(void) -{ - type_register_static(&bcm2835_peripherals_type_info); -} - -type_init(bcm2835_peripherals_register_types) +DEFINE_TYPES(bcm2835_peripherals_types) diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index e9768f2ab96..7e4c60dd804 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -68,10 +68,10 @@ static void bcm283x_init(Object *obj) "vcram-size"); } =20 -bool bcm283x_common_realize(DeviceState *dev, Error **errp) +bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *p= s, + Error **errp) { - BCM283XState *s =3D BCM283X(dev); - BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCM283XBaseState *s =3D BCM283X_BASE(dev); BCM283XBaseClass *bc =3D BCM283X_BASE_GET_CLASS(dev); Object *obj; =20 @@ -79,17 +79,15 @@ bool bcm283x_common_realize(DeviceState *dev, Error **e= rrp) =20 obj =3D object_property_get_link(OBJECT(dev), "ram", &error_abort); =20 - object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj); + object_property_add_const_link(OBJECT(ps), "ram", obj); =20 - if (!sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), errp)) { + if (!sysbus_realize(SYS_BUS_DEVICE(ps), errp)) { return false; } =20 - object_property_add_alias(OBJECT(s_base), "sd-bus", - OBJECT(&s->peripherals), "sd-bus"); + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(ps), "sd-bus"); =20 - sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), - 0, bc->peri_base, 1); + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(ps), 0, bc->peri_base, 1); return true; } =20 @@ -97,8 +95,10 @@ static void bcm2835_realize(DeviceState *dev, Error **er= rp) { BCM283XState *s =3D BCM283X(dev); BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCMSocPeripheralBaseState *ps_base + =3D BCM_SOC_PERIPHERALS_BASE(&s->peripherals); =20 - if (!bcm283x_common_realize(dev, errp)) { + if (!bcm283x_common_realize(dev, ps_base, errp)) { return; } =20 @@ -119,8 +119,10 @@ static void bcm2836_realize(DeviceState *dev, Error **= errp) BCM283XState *s =3D BCM283X(dev); BCM283XBaseState *s_base =3D BCM283X_BASE(dev); BCM283XBaseClass *bc =3D BCM283X_BASE_GET_CLASS(dev); + BCMSocPeripheralBaseState *ps_base + =3D BCM_SOC_PERIPHERALS_BASE(&s->peripherals); =20 - if (!bcm283x_common_realize(dev, errp)) { + if (!bcm283x_common_realize(dev, ps_base, errp)) { return; } =20 --=20 2.34.1