From patchwork Mon Mar 19 18:34:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 132076 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp3053149ljb; Mon, 19 Mar 2018 11:37:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELuAvK4HQM+0jAskmLj6eDDLcf1hioNP+mxL+k26W0tHdMhzLQrVOBMX/X0+0e0hOEV+gLhV X-Received: by 10.200.63.6 with SMTP id c6mr20064843qtk.286.1521484676799; Mon, 19 Mar 2018 11:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521484676; cv=none; d=google.com; s=arc-20160816; b=ppqeXOtpAVeYoajCTeWL3RNDUdRAnrs1b7at0sBRZnrb4CniXwPiyWZjBKLHxUO5wW PDSzd6EF0f6RjA3oD3IbutPSH4FQJKy2gES2kmpLG/26MJQw5aGvrK0C5AckpgWDoHGD xYh6rg1nmLWiPC9N64/W5KcRyQ0AS+bDzTeBYIne65tHf9G20bvnd5vlSYzSALtgIq44 cSuZrz0yxve1zZvxbiCBG/qIS8PX+DAzsIq4yL2LSDMX18SkEyGFUhwXZlc6yLpizJka 2TnTmb+KXA8J5wvnTovDqihOKWsddOrlKPqP849IdpYJQ5v5YJrZOOSJ92UoB7kNYfkc +pAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=pxPT/TWBT7NEfgt0443ruLoS05ktUyJcbM7kxlXfAk4=; b=ZNqcdzLkMHw1UOy+PixjBelkGgabfvA3ogPJr7kl+H6uWA9elEBQqn4NuTHYAgz6C+ jVsWXIWZ1Qy+iRJXF9gnIhe3dmv6r3sjUtgQOZ9u+eom0g+nAYVW12ByCRziSzJyqy3m Gr6G6J+3W2DXvDyzQfKYMhcM5uYV7dlW+z+2HebQd0MqpKSdqe/jDpJyNpnVcOXbs5i7 h5Dvyv0GD3yhNOcZk76YGc7kiZCXZkD0JfA7r7C2Kg8l+1ObviEq911nYDdw8XMflpS8 C93gvCZBgAZigb5tOZBPQDWbsjyGFT8m8fAW/X1aGHGvLKyCgDaTTCtmUXooVB+/AMV9 CL3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j14si625870qkk.201.2018.03.19.11.37.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Mar 2018 11:37:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exzfQ-0004yX-7C for patch@linaro.org; Mon, 19 Mar 2018 14:37:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exzc3-0002Oh-DE for qemu-devel@nongnu.org; Mon, 19 Mar 2018 14:34:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exzc2-0007ju-8Q for qemu-devel@nongnu.org; Mon, 19 Mar 2018 14:34:27 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:40462) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1exzc1-0007hw-Vw for qemu-devel@nongnu.org; Mon, 19 Mar 2018 14:34:26 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1exzc0-000330-P3 for qemu-devel@nongnu.org; Mon, 19 Mar 2018 18:34:24 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 19 Mar 2018 18:34:12 +0000 Message-Id: <20180319183415.1976-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319183415.1976-1-peter.maydell@linaro.org> References: <20180319183415.1976-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 10/13] hw/arm/bcm2836: Create proper bcm2837 device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The bcm2837 is pretty similar to the bcm2836, but it does have some differences. Notably, the MPIDR affinity aff1 values it sets for the CPUs are 0x0, rather than the 0xf that the bcm2836 uses, and if this is wrong Linux will not boot. Rather than trying to have one device with properties that configure it differently for the two cases, create two separate QOM devices for the two SoCs. We use the same approach as hw/arm/aspeed_soc.c and share code and have a data table that might differ per-SoC. For the moment the two types don't actually have different behaviour. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20180313153458.26822-7-peter.maydell@linaro.org --- include/hw/arm/bcm2836.h | 19 +++++++++++++++++++ hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++----- hw/arm/raspi.c | 3 ++- 3 files changed, 53 insertions(+), 6 deletions(-) -- 2.16.2 diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h index 9a10a76631..93248399ba 100644 --- a/include/hw/arm/bcm2836.h +++ b/include/hw/arm/bcm2836.h @@ -20,6 +20,13 @@ #define BCM283X_NCPUS 4 +/* These type names are for specific SoCs; other than instantiating + * them, code using these devices should always handle them via the + * BCM283x base class, so they have no BCM2836(obj) etc macros. + */ +#define TYPE_BCM2836 "bcm2836" +#define TYPE_BCM2837 "bcm2837" + typedef struct BCM283XState { /*< private >*/ DeviceState parent_obj; @@ -33,4 +40,16 @@ typedef struct BCM283XState { BCM2835PeripheralState peripherals; } BCM283XState; +typedef struct BCM283XInfo BCM283XInfo; + +typedef struct BCM283XClass { + DeviceClass parent_class; + const BCM283XInfo *info; +} BCM283XClass; + +#define BCM283X_CLASS(klass) \ + OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X) +#define BCM283X_GET_CLASS(obj) \ + OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X) + #endif /* BCM2836_H */ diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 1d1908654b..07d2705f96 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -23,6 +23,19 @@ /* "QA7" (Pi2) interrupt controller and mailboxes etc. */ #define BCM2836_CONTROL_BASE 0x40000000 +struct BCM283XInfo { + const char *name; +}; + +static const BCM283XInfo bcm283x_socs[] = { + { + .name = TYPE_BCM2836, + }, + { + .name = TYPE_BCM2837, + }, +}; + static void bcm2836_init(Object *obj) { BCM283XState *s = BCM283X(obj); @@ -156,25 +169,39 @@ static Property bcm2836_props[] = { DEFINE_PROP_END_OF_LIST() }; -static void bcm2836_class_init(ObjectClass *oc, void *data) +static void bcm283x_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); + BCM283XClass *bc = BCM283X_CLASS(oc); - dc->props = bcm2836_props; + bc->info = data; dc->realize = bcm2836_realize; + dc->props = bcm2836_props; } -static const TypeInfo bcm2836_type_info = { +static const TypeInfo bcm283x_type_info = { .name = TYPE_BCM283X, .parent = TYPE_DEVICE, .instance_size = sizeof(BCM283XState), .instance_init = bcm2836_init, - .class_init = bcm2836_class_init, + .class_size = sizeof(BCM283XClass), + .abstract = true, }; static void bcm2836_register_types(void) { - type_register_static(&bcm2836_type_info); + int i; + + type_register_static(&bcm283x_type_info); + for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) { + TypeInfo ti = { + .name = bcm283x_socs[i].name, + .parent = TYPE_BCM283X, + .class_init = bcm283x_class_init, + .class_data = (void *) &bcm283x_socs[i], + }; + type_register(&ti); + } } type_init(bcm2836_register_types) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 58c6e80a17..f588720138 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -136,7 +136,8 @@ static void raspi_init(MachineState *machine, int version) BusState *bus; DeviceState *carddev; - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); + object_initialize(&s->soc, sizeof(s->soc), + version == 3 ? TYPE_BCM2837 : TYPE_BCM2836); object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), &error_abort);