From nobody Thu Nov 13 13:36:11 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580720519996375.0569263964916; Mon, 3 Feb 2020 01:01:59 -0800 (PST) Received: from localhost ([::1]:36306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyXcE-00028O-U1 for importer@patchew.org; Mon, 03 Feb 2020 04:01:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43663) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyXa9-0008AU-5v for qemu-devel@nongnu.org; Mon, 03 Feb 2020 03:59:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyXa8-0007b9-0M for qemu-devel@nongnu.org; Mon, 03 Feb 2020 03:59:49 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:55366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyXa7-0007aj-PS; Mon, 03 Feb 2020 03:59:47 -0500 Received: by mail-wm1-x341.google.com with SMTP id q9so14827167wmj.5; Mon, 03 Feb 2020 00:59:47 -0800 (PST) Received: from localhost.localdomain (162.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.162]) by smtp.gmail.com with ESMTPSA id j5sm10029678wrw.24.2020.02.03.00.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 00:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=skNJ/BGH0y+JxuI4sQ86g1cgznE5/NeuYWJkhvsn8Dw=; b=JWoYjOGx4J3bzpkjM9eH39hNTO5arMk/OVYxSDpCmrFdMB1YzuNMODQz3Yy43a8AvH z5/gjBkUbglSo49FzO7yh1E+3WMP7XWnhwZbbd96t6sC/QjKqyAzcXBDLlp9C8WC6Qlo qQjk+/YG2zx0nwZwTSCEalyYgpkVah0BD8hPhRRHUThByLxqW/qqkbTwKEse+7MqBuOQ Kz3Mtw7bkyDlHgEFOf70P2Ec9cyuiBmjrvzAkTiTckTk0kQ/Qq2Amfyfn7V895sDqpHp z7A3jsivK79J2WBMNe2l9AmnSPKSUEaiuyJPXR+cw/0mLehczrMaILw+/T7hPoN2hjDH T4Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=skNJ/BGH0y+JxuI4sQ86g1cgznE5/NeuYWJkhvsn8Dw=; b=Nq4KobhTI2mjaKsnOIPyZXcYvY3Oz8AWI2YaxGsNgZVI/kIWY3rOY44seo1QRnLlE6 7UGuz8NdqJUlEg0QSWema5QywOI4eyAdN6NeAm4TUpTEyI+BbSUJKhw1B9CqzOt7kOp/ XnFhVfO6DoSw0ArWpbTcrHeF9uRzS35urjj19Zl/vTImLmFZ1TsPTW6DvoAUdS79GG1Y c5ebndJOwO2NcF5YwtkQ3GqIdg0ueXPyFb1GP9gh5wUZlVQ0No5MM4rqSu25gUniImWp RPqVHIPv2vL/aXtW5ix6OwtvvIcszcCmRp6RPofi72qnC+E54itiwbO+sPUx1WgCvqwQ f7IQ== X-Gm-Message-State: APjAAAUtuGAAQhQy7HwGACdwcUi4SKQD6yOh3YVovQkPvd9jvdPTo2Iu rck4Ib6NtfMFKyoBJtjjwpDKjSfm X-Google-Smtp-Source: APXvYqyWlb/bxOVcHbLLOxd+Dng7VS/XOQnXJkgNHCk8yBPNDSFu0gKJJeEv+CbG/yfQtCPiMIaV6g== X-Received: by 2002:a1c:7dd4:: with SMTP id y203mr28278459wmc.67.1580720386519; Mon, 03 Feb 2020 00:59:46 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [NOTFORMERGE PATCH 1/2] hw/arm: Add the BCM2835 SoC Date: Mon, 3 Feb 2020 09:59:41 +0100 Message-Id: <20200203085942.19826-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200203085942.19826-1-f4bug@amsat.org> References: <20200203085942.19826-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add the BCM2835 SoC, which uses a ARM1176JZF-S core. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- TODO: better QOM modelling of core_count and intc include/hw/arm/bcm2836.h | 1 + hw/arm/bcm2836.c | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h index 92a6544816..5c3f8958ef 100644 --- a/include/hw/arm/bcm2836.h +++ b/include/hw/arm/bcm2836.h @@ -24,6 +24,7 @@ * them, code using these devices should always handle them via the * BCM283x base class, so they have no BCM2836(obj) etc macros. */ +#define TYPE_BCM2835 "bcm2835" #define TYPE_BCM2836 "bcm2836" #define TYPE_BCM2837 "bcm2837" =20 diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 38e2941bab..e4a89f0381 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -21,13 +21,21 @@ struct BCM283XInfo { const char *cpu_type; hwaddr peri_base; /* Peripheral base address seen by the CPU */ hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */ + int core_count; int clusterid; }; =20 static const BCM283XInfo bcm283x_socs[] =3D { + { + .name =3D TYPE_BCM2835, + .cpu_type =3D ARM_CPU_TYPE_NAME("arm1176"), + .core_count =3D 1, + .peri_base =3D 0x20000000, + }, { .name =3D TYPE_BCM2836, .cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a7"), + .core_count =3D 4, .peri_base =3D 0x3f000000, .ctrl_base =3D 0x40000000, .clusterid =3D 0xf, @@ -36,6 +44,7 @@ static const BCM283XInfo bcm283x_socs[] =3D { { .name =3D TYPE_BCM2837, .cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a53"), + .core_count =3D 4, .peri_base =3D 0x3f000000, .ctrl_base =3D 0x40000000, .clusterid =3D 0x0, @@ -50,14 +59,16 @@ static void bcm2836_init(Object *obj) const BCM283XInfo *info =3D bc->info; int n; =20 - for (n =3D 0; n < BCM283X_NCPUS; n++) { + for (n =3D 0; n < info->core_count; n++) { object_initialize_child(obj, "cpu[*]", &s->cpu[n].core, sizeof(s->cpu[n].core), info->cpu_type, &error_abort, NULL); } =20 - sysbus_init_child_obj(obj, "control", &s->control, sizeof(s->control), - TYPE_BCM2836_CONTROL); + if (info->ctrl_base) { + sysbus_init_child_obj(obj, "control", &s->control, sizeof(s->contr= ol), + TYPE_BCM2836_CONTROL); + } =20 sysbus_init_child_obj(obj, "peripherals", &s->peripherals, sizeof(s->peripherals), TYPE_BCM2835_PERIPHERALS= ); @@ -107,6 +118,7 @@ static void bcm2836_realize(DeviceState *dev, Error **e= rrp) sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, info->peri_base, 1); =20 + if (info->ctrl_base) { /* bcm2836 interrupt controller (and mailboxes, etc.) */ object_property_set_bool(OBJECT(&s->control), true, "realized", &err); if (err) { @@ -120,8 +132,22 @@ static void bcm2836_realize(DeviceState *dev, Error **= errp) qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); + } =20 - for (n =3D 0; n < BCM283X_NCPUS; n++) { + if (!info->ctrl_base) { + object_property_set_bool(OBJECT(&s->cpu[0].core), true, + "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + /* Connect irq/fiq outputs from the interrupt controller. */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, + qdev_get_gpio_in(DEVICE(&s->cpu[0].core), ARM_CPU_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, + qdev_get_gpio_in(DEVICE(&s->cpu[0].core), ARM_CPU_FIQ)); + } else { + for (n =3D 0; n < info->core_count; n++) { /* TODO: this should be converted to a property of ARM_CPU */ s->cpu[n].core.mp_affinity =3D (info->clusterid << 8) | n; =20 @@ -165,6 +191,7 @@ static void bcm2836_realize(DeviceState *dev, Error **e= rrp) qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_SEC, qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n)= ); } + } } =20 static Property bcm2836_props[] =3D { --=20 2.21.1 From nobody Thu Nov 13 13:36:11 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580720591708701.1889567812652; Mon, 3 Feb 2020 01:03:11 -0800 (PST) Received: from localhost ([::1]:36342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyXdO-0003bw-NR for importer@patchew.org; Mon, 03 Feb 2020 04:03:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyXaA-0008Ct-Df for qemu-devel@nongnu.org; Mon, 03 Feb 2020 03:59:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyXa9-0007bs-7e for qemu-devel@nongnu.org; Mon, 03 Feb 2020 03:59:50 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:33561) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyXa9-0007bF-1V; Mon, 03 Feb 2020 03:59:49 -0500 Received: by mail-wm1-x341.google.com with SMTP id m10so13809352wmc.0; Mon, 03 Feb 2020 00:59:48 -0800 (PST) Received: from localhost.localdomain (162.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.162]) by smtp.gmail.com with ESMTPSA id j5sm10029678wrw.24.2020.02.03.00.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 00:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=McmqHb8ZIQwdrf/h9Ux5lHwfQS28gH0LN86W4pPo+uk=; b=owdrG602dn0k3raB28tmGoosiKs3/9yKbmulinp149Si0LAYfR8QAnbenmLtbBdsuQ 7kJGCbO30+oCtRp+TFtig4qTGIYSGn+t8l8z775enqTIBNjy2XOCMsaI6vofXRN2vPBR j88tWK9miuMltDYiU7zzIOAE6d8IXIipt64acLrOHjrF1qI2x4tTB1HtNFY6hZpoMhaX QQGLBdIeSCqS80DEwuZfaVR+EQ+3bXgJ233D3CL56W4nG/IzSx7PNpj9dzpJE/BSh9VP sgeRbhOeWBc+3CSIPpalKJUN6i0cMGpSloB/leMx+6H81R5Z2CoxEwDKtxztguZmTFQT oM7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=McmqHb8ZIQwdrf/h9Ux5lHwfQS28gH0LN86W4pPo+uk=; b=LoaElKHOCXldh7XbQ+ElSD39Uck/5BLEI0kUSEZlrt2hcEsTdEBomSjOFpd+BUQ/Wm 8Ups8eocxIcoJvyxPnmDbLz9DMbZyVp6LbyYz7JhDRB3q1WJ6VovFM8xnu+hrB+OVRsD Kntiw6Kw70JMWqe7nF32rdBwF4Uq9XaNWCmvx+SMZaOm6+qVGPBTib5p/mC0CeS8cNJR 6zV6ID0cccU69i466Fo91eevefnJSo4BmLti8AzIZvittmVSyiEnSubDq1m0UAyy7PjM carg07//JKz+GbSObDq77oAxFXldcyva5QvXAZShiFVoylHITVXzzP7DmF4bP3m5cRtP vXxA== X-Gm-Message-State: APjAAAXJvoohfl9fPNkdvFK4GveHlLFrTqvCyCo5FLvhWQCF419WcT4Q DleIeGk2y1bSluBBJZfWnrCwRVky X-Google-Smtp-Source: APXvYqzu7Hf9I3Ah2KFvjHPb3c73acvX/Zxip0zFpuKHv5Mgc+dlduI3Lf+ulAUpbGh271qIvDKscw== X-Received: by 2002:a1c:f003:: with SMTP id a3mr28570948wmb.41.1580720387807; Mon, 03 Feb 2020 00:59:47 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [NOTFORMERGE PATCH 2/2] RFC: hw/arm/raspi: Add the Raspberry Pi Zero machine Date: Mon, 3 Feb 2020 09:59:42 +0100 Message-Id: <20200203085942.19826-3-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200203085942.19826-1-f4bug@amsat.org> References: <20200203085942.19826-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add a Raspberry Pi Zero machine. $ qemu-system-arm -M raspi0 -serial stdio \ -kernel raspberrypi/firmware/boot/kernel.img \ -dtb raspberrypi/firmware/boot/bcm2708-rpi-zero-w.dtb \ -append 'printk.time=3D0 earlycon=3Dpl011,0x20201000 console=3DttyAMA= 0' [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.19.69+ (dom@buildbot) (gcc version 4.9.3 (= crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1261 Tue Sep 3 20:21:01 BST= 2019 [ 0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARM= v7), cr=3D00c5387d [ 0.000000] CPU: VIPT aliasing data cache, unknown instruction cache [ 0.000000] OF: fdt: Machine model: Raspberry Pi Zero W [ 0.000000] earlycon: pl11 at MMIO 0x20201000 (options '') [ 0.000000] bootconsole [pl11] enabled [ 0.000000] Memory policy: Data cache writeback [ 0.000000] cma: Reserved 8 MiB at 0x1b800000 [ 0.000000] random: get_random_bytes called from start_kernel+0x8c/0x4= 9c with crng_init=3D0 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 113= 680 [ 0.000000] Kernel command line: printk.time=3D0 earlycon=3Dpl011,0x20= 201000 console=3DttyAMA0 root=3D/dev/mmcblk0 rootwait Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) Memory: 434380K/458752K available (6971K kernel code, 635K rwdata, 2080K = rodata, 464K init, 797K bss, 16180K reserved, 8192K cma-reserved) Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xffc00000 - 0xfff00000 (3072 kB) vmalloc : 0xdc800000 - 0xff800000 ( 560 MB) lowmem : 0xc0000000 - 0xdc000000 ( 448 MB) modules : 0xbf000000 - 0xc0000000 ( 16 MB) .text : 0x(ptrval) - 0x(ptrval) (6973 kB) .init : 0x(ptrval) - 0x(ptrval) ( 464 kB) .data : 0x(ptrval) - 0x(ptrval) ( 636 kB) .bss : 0x(ptrval) - 0x(ptrval) ( 798 kB) SLUB: HWalign=3D32, Order=3D0-3, MinObjects=3D0, CPUs=3D1, Nodes=3D1 ftrace: allocating 25193 entries in 74 pages NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 214748364= 7500ns clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns:= 1911260446275 ns bcm2835: system timer (irq =3D 27) Console: colour dummy device 80x30 ... Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- TODO: Add acceptance test hw/arm/raspi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index aff5d57261..f2496a5590 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -33,6 +33,7 @@ #define MACH_TYPE_BCM2708 3138 /* Linux board IDs */ =20 enum BoardIdChip { + C_BCM2835 =3D 0, C_BCM2836 =3D 1, C_BCM2837 =3D 2, }; @@ -41,6 +42,7 @@ static const struct { const char *soc_name; int cores_count; } soc_config[] =3D { + [C_BCM2835] =3D {TYPE_BCM2835, 1}, [C_BCM2836] =3D {TYPE_BCM2836, BCM283X_NCPUS}, [C_BCM2837] =3D {TYPE_BCM2837, BCM283X_NCPUS}, }; @@ -80,6 +82,11 @@ typedef struct RaspiMachineClass { OBJECT_GET_CLASS(RaspiMachineClass, (obj), TYPE_RASPI_MACHINE) =20 static const RaspiBoardInfo raspi_boards[] =3D { + { + .name =3D MACHINE_TYPE_NAME("raspi0"), + .desc =3D "Raspberry Pi Zero W", + .board_rev =3D 0x9000c1, + }, { .name =3D MACHINE_TYPE_NAME("raspi2"), .desc =3D "Raspberry Pi 2B", --=20 2.21.1