From nobody Thu Nov 13 18:08:16 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 1581940289668176.48656811756564; Mon, 17 Feb 2020 03:51:29 -0800 (PST) Received: from localhost ([::1]:44178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3evw-00067k-Gi for importer@patchew.org; Mon, 17 Feb 2020 06:51:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40644) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3eqP-0006Ys-4y for qemu-devel@nongnu.org; Mon, 17 Feb 2020 06:45:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3eqN-0002Qi-LJ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 06:45:45 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3eqN-0002Q7-Em; Mon, 17 Feb 2020 06:45:43 -0500 Received: by mail-wr1-x444.google.com with SMTP id n10so17385980wrm.1; Mon, 17 Feb 2020 03:45:43 -0800 (PST) Received: from x1w.redhat.com (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id i2sm268149wmb.28.2020.02.17.03.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 03:45:41 -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=3UiEjEXttuM7t0xfD+phHvJNwF4QMG2Y+xuMq2THqy8=; b=nfBTBu4k1ml1skKW92aonJI6EY7SGTutu+amIEpRNTWBW//lrsFj6chx1hinP7lqF0 /GoTEjoFWL6oxduseO7xScOUdgmId/IT+3+w7BBlYKJq0R2X6xoxDkctXDaXAOjVrpD3 RV7dBXOgF5w26vN/U49JEctKqpDOscxw0jqLiRUbSqgsEcm2CqSRsaiZXtztIS69W8OK Agf58/JmUseO3wiagTFFC/GCiOhyDFpkyTDrxH2MdUaDlk0Jbl49n2ZaJTQ5T2OZdMoh 0ZutvSapnWRqhgPBHhBIWmXxjE+5s6zGxSXNsMb/gC8iFD1+kr3P83ng3V8KtDNk9itx CurA== 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=3UiEjEXttuM7t0xfD+phHvJNwF4QMG2Y+xuMq2THqy8=; b=G2k5Tscb7vGd0obc1MnL3/q47ZQFtOhJMp0BVtveHq4sxIPB+YJcZL9n6pJ5RxJUwk qpust/pUVfk245ic02pJclvKpFNYbnhQCxdrr8DZA5B/wmk6mKMPFvS8J2+VOQHwUjrk u2d0QLZKPmAc2YAITRJxT7yC4aQIgy+/t0H+S3JyY46t5J8E3e6f7jVgE51p59QzTsjH ucmuinicGTWyBApVUmPdD5CP9p+9OxZoMl2YIktZnEQkUa6KCK33TE3E/j0gz1rFRb+e qsYBgTfgxGTecFw2XqgTWIb7Mw82eRYCWtGNBIWdf9FDc5JTpb71sGVp0um3kNZXu4wQ jWOA== X-Gm-Message-State: APjAAAX75CTcjARpVo4/v8E59Ce9fjfIS88Hc2MHy2pWOVJmj+ZLhWjM LOzDm0es1gpbRAZq1htPsRiQ1g71L1s= X-Google-Smtp-Source: APXvYqyFMIrWOCv1C8DrCglln7p6Nn242A1A3D5jYBLPffCQphODihEENkETGoWIwbOKA0F5QOVhgA== X-Received: by 2002:a5d:6a88:: with SMTP id s8mr21712664wru.173.1581939942103; Mon, 17 Feb 2020 03:45:42 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/13] hw/arm/raspi: Remove use of the 'version' value in the board code Date: Mon, 17 Feb 2020 12:45:25 +0100 Message-Id: <20200217114533.17779-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200217114533.17779-1-f4bug@amsat.org> References: <20200217114533.17779-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::444 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We expected the 'version' ID to match the board processor ID, but this is not always true (for example boards with revision id 0xa02042/0xa22042 are Raspberry Pi 2 with a BCM2837 SoC). This was not important because we were not modelling them, but since the recent refactor now allow to model these boards, it is safer to check the processor id directly. Remove the version check. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Luc Michel --- hw/arm/raspi.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index b628dadf34..fff501affb 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -98,11 +98,6 @@ static RaspiProcessorId board_processor_id(uint32_t boar= d_rev) return proc_id; } =20 -static int board_version(uint32_t board_rev) -{ - return board_processor_id(board_rev) + 1; -} - static const char *board_soc_type(uint32_t board_rev) { return soc_property[board_processor_id(board_rev)].type; @@ -201,7 +196,8 @@ static void reset_secondary(ARMCPU *cpu, const struct a= rm_boot_info *info) cpu_set_pc(cs, info->smp_loader_start); } =20 -static void setup_boot(MachineState *machine, int version, size_t ram_size) +static void setup_boot(MachineState *machine, RaspiProcessorId processor_i= d, + size_t ram_size) { static struct arm_boot_info binfo; int r; @@ -210,12 +206,13 @@ static void setup_boot(MachineState *machine, int ver= sion, size_t ram_size) binfo.ram_size =3D ram_size; binfo.nb_cpus =3D machine->smp.cpus; =20 - if (version <=3D 2) { - /* The rpi1 and 2 require some custom setup code to run in Secure - * mode before booting a kernel (to set up the SMC vectors so - * that we get a no-op SMC; this is used by Linux to call the + if (processor_id <=3D PROCESSOR_ID_BCM2836) { + /* + * The BCM2835 and BCM2836 require some custom setup code to run + * in Secure mode before booting a kernel (to set up the SMC vecto= rs + * so that we get a no-op SMC; this is used by Linux to call the * firmware for some cache maintenance operations. - * The rpi3 doesn't need this. + * The BCM2837 doesn't need this. */ binfo.board_setup_addr =3D BOARDSETUP_ADDR; binfo.write_board_setup =3D write_board_setup; @@ -223,10 +220,10 @@ static void setup_boot(MachineState *machine, int ver= sion, size_t ram_size) binfo.secure_boot =3D true; } =20 - /* Pi2 and Pi3 requires SMP setup */ - if (version >=3D 2) { + /* BCM2836 and BCM2837 requires SMP setup */ + if (processor_id >=3D PROCESSOR_ID_BCM2836) { binfo.smp_loader_start =3D SMPBOOT_ADDR; - if (version =3D=3D 2) { + if (processor_id =3D=3D PROCESSOR_ID_BCM2836) { binfo.write_secondary_boot =3D write_smpboot; } else { binfo.write_secondary_boot =3D write_smpboot64; @@ -238,7 +235,13 @@ static void setup_boot(MachineState *machine, int vers= ion, 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; + hwaddr firmware_addr; + + if (processor_id =3D=3D PROCESSOR_ID_BCM2837) { + firmware_addr =3D FIRMWARE_ADDR_3; + } else { + firmware_addr =3D FIRMWARE_ADDR_2; + } /* load the firmware image (typically kernel.img) */ r =3D load_image_targphys(machine->firmware, firmware_addr, ram_size - firmware_addr); @@ -259,7 +262,6 @@ static void raspi_machine_init(MachineState *machine) RaspiMachineClass *mc =3D RASPI_MACHINE_GET_CLASS(machine); RaspiMachineState *s =3D RASPI_MACHINE(machine); uint32_t board_rev =3D mc->board_rev; - int version =3D board_version(board_rev); uint64_t ram_size =3D board_ram_size(board_rev); uint32_t vcram_size; DriveInfo *di; @@ -303,7 +305,8 @@ static void raspi_machine_init(MachineState *machine) =20 vcram_size =3D object_property_get_uint(OBJECT(&s->soc), "vcram-size", &error_abort); - setup_boot(machine, version, machine->ram_size - vcram_size); + setup_boot(machine, board_processor_id(mc->board_rev), + machine->ram_size - vcram_size); } =20 static void raspi_machine_class_common_init(MachineClass *mc, --=20 2.21.1