From nobody Mon Feb 9 18:43:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518764678686767.4591508090907; Thu, 15 Feb 2018 23:04:38 -0800 (PST) Received: from localhost ([::1]:45303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ema4T-0004qd-Lc for importer@patchew.org; Fri, 16 Feb 2018 02:04:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ema2E-0003QT-HY for qemu-devel@nongnu.org; Fri, 16 Feb 2018 02:02:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ema2B-0007kw-KJ for qemu-devel@nongnu.org; Fri, 16 Feb 2018 02:02:18 -0500 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:35596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ema2B-0007jn-9g for qemu-devel@nongnu.org; Fri, 16 Feb 2018 02:02:15 -0500 Received: by mail-lf0-x244.google.com with SMTP id a204so2767417lfa.2 for ; Thu, 15 Feb 2018 23:02:15 -0800 (PST) Received: from localhost.localdomain (81-175-247-183.bb.dnainternet.fi. [81.175.247.183]) by smtp.gmail.com with ESMTPSA id r9sm3365313ljc.18.2018.02.15.23.02.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Feb 2018 23:02:12 -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=gsI41yUflBN/sQ70WetF37+jFA+IW07JvL0bXId/0rQ=; b=uZX5oQmTOVQpegUz9QEyvp87+BKq/x3LIEcvW5Cj+wJm3PS5h77JNtj5BoFActlqCM a/Dl8edKv+q4BaSikSNbbs5ai12OFvn9j5AZSeUKbNKV+87eBhyYyE3PCzog3hiEQUYq 2B2pRYbGPAIC8oi0PqtKMV1Xxmeh5SqQR0oOy3mctXpXjqHWgfitqnIKf8UqSddJ1syf tP6+d/qmsC08I5naeLKaZ0HvlfzbJcK5YPueMGyMrPvH0Oy1FQicYnfbGC/e/045fln9 1BddeZTMSZdHQSZj34awWGvX2j137/DcVztojtpb9o8ib2g0/rdWlWlp6s7OHSxnDL7G O4nQ== 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=gsI41yUflBN/sQ70WetF37+jFA+IW07JvL0bXId/0rQ=; b=NULfcyGgGsp/O+3tkrKfN/Q6zGUYGjO/2lctRQFYzAFRu1kZSX6vgzj9ANcOGR6DtC TRrL0vgX+PwRjh64X+SAj8pDaQYWFr7d5nVJkefYj7OMLe8L949sWcxG0/dLtVe1fE/1 r6Dd3z1Tb1sroJwvenRjRSB4iWFPSfaiPMVp5s/tpMzNiJGqeHlPpX3z37ZemwM+sJ52 9n6JQcfFOUHUTbzLwdnK4CDK014kNRFhwWkNqWTSv1ckudMY0H2sm9TcRWYuAkYIsibp NQZW4TSJ4pyjBz/sDhwNphugKGigEsWJlsJqa0wIXcoIDFXnI+5c0KFKvJ4XB83mgaIr Jl7Q== X-Gm-Message-State: APf1xPC3K91AzxikkTz1KFqYhmeCPodXjzTZuVbn2YyQrwO1eVSUaF8S LeTdNdEYbRCrZkZ8cdzWExEYUxhO X-Google-Smtp-Source: AH8x226OOPcNsDfOXfUyKQu68aCjeC2x5Slk5xU+pAUPylvdryhuwIYJYLPE4JqgpWueTizMhKvv/g== X-Received: by 10.46.4.10 with SMTP id 10mr3577965lje.64.1518764533630; Thu, 15 Feb 2018 23:02:13 -0800 (PST) From: Pekka Enberg To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 09:02:00 +0200 Message-Id: <20180216070201.4271-3-penberg@iki.fi> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180216070201.4271-1-penberg@iki.fi> References: <20180216070201.4271-1-penberg@iki.fi> MIME-Version: 1.0 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:4010:c07::244 Subject: [Qemu-devel] [PATCH v2 2/3] raspi: Raspberry Pi 3 support 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: , Cc: peter.maydell@linaro.org, Pekka Enberg Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This patch adds Raspberry Pi 3 support to hw/arm/raspi.c. The differences to Pi 2 are: - Firmware address - Board ID - Board revision The CPU is different too, but that's going to be configured as part of the machine default CPU when we introduce a new machine type. The patch was written from scratch by me but the logic is similar to Zolt=C3=A1n Baldaszti's previous work, which I used as a reference (with permission from the author): https://github.com/bztsrc/qemu-raspi3 Signed-off-by: Pekka Enberg --- hw/arm/raspi.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index c24a4a1b14..66fe10e376 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -5,6 +5,9 @@ * Rasperry Pi 2 emulation Copyright (c) 2015, Microsoft * Written by Andrew Baumann * + * Raspberry Pi 3 emulation Copyright (c) 2018 Zolt=C3=A1n Baldaszti + * Upstream code cleanup (c) 2018 Pekka Enberg=20 + * * This code is licensed under the GNU GPLv2 and later. */ =20 @@ -22,10 +25,11 @@ #define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS = */ #define MVBAR_ADDR 0x400 /* secure vectors */ #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ -#define FIRMWARE_ADDR 0x8000 /* Pi loads kernel.img here by default */ +#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */ +#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ =20 /* Table of Linux board IDs for different Pi versions */ -static const int raspi_boardid[] =3D {[1] =3D 0xc42, [2] =3D 0xc43}; +static const int raspi_boardid[] =3D {[1] =3D 0xc42, [2] =3D 0xc43, [3] = =3D 0xc44}; =20 typedef struct RasPiState { BCM2836State soc; @@ -83,8 +87,8 @@ static void setup_boot(MachineState *machine, int version= , size_t ram_size) binfo.secure_board_setup =3D true; binfo.secure_boot =3D true; =20 - /* Pi2 requires SMP setup */ - if (version =3D=3D 2) { + /* Pi2 and Pi3 requires SMP setup */ + if (version >=3D 2) { binfo.smp_loader_start =3D SMPBOOT_ADDR; binfo.write_secondary_boot =3D write_smpboot; binfo.secondary_cpu_reset_hook =3D reset_secondary; @@ -94,15 +98,16 @@ static void setup_boot(MachineState *machine, int versi= on, size_t ram_size) * the normal Linux boot process */ if (machine->firmware) { + hwaddr firmware_addr =3D version =3D=3D 3 ? FIRMWARE_ADDR_3 : FIRM= WARE_ADDR_2; /* load the firmware image (typically kernel.img) */ - r =3D load_image_targphys(machine->firmware, FIRMWARE_ADDR, - ram_size - FIRMWARE_ADDR); + r =3D load_image_targphys(machine->firmware, firmware_addr, + ram_size - firmware_addr); if (r < 0) { error_report("Failed to load firmware from %s", machine->firmw= are); exit(1); } =20 - binfo.entry =3D FIRMWARE_ADDR; + binfo.entry =3D firmware_addr; binfo.firmware_loaded =3D true; } else { binfo.kernel_filename =3D machine->kernel_filename; @@ -113,7 +118,7 @@ static void setup_boot(MachineState *machine, int versi= on, size_t ram_size) arm_load_kernel(ARM_CPU(first_cpu), &binfo); } =20 -static void raspi2_init(MachineState *machine) +static void raspi_init(MachineState *machine, int version) { RasPiState *s =3D g_new0(RasPiState, 1); uint32_t vcram_size; @@ -139,7 +144,8 @@ static void raspi2_init(MachineState *machine) &error_abort); object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", &error_abort); - object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev", + int board_rev =3D version =3D=3D 3 ? 0xa02082 : 0xa21041; + object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev", &error_abort); object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abo= rt); =20 @@ -157,7 +163,12 @@ static void raspi2_init(MachineState *machine) =20 vcram_size =3D object_property_get_uint(OBJECT(&s->soc), "vcram-size", &error_abort); - setup_boot(machine, 2, machine->ram_size - vcram_size); + setup_boot(machine, version, machine->ram_size - vcram_size); +} + +static void raspi2_init(MachineState *machine) +{ + raspi_init(machine, 2); } =20 static void raspi2_machine_init(MachineClass *mc) --=20 2.14.3