From nobody Tue Oct 7 14:46:45 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 1580718446541955.2766391509737; Mon, 3 Feb 2020 00:27:26 -0800 (PST) Received: from localhost ([::1]:36022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyX4n-0003Ir-BO for importer@patchew.org; Mon, 03 Feb 2020 03:27:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34750) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyX3s-0002CO-TT for qemu-devel@nongnu.org; Mon, 03 Feb 2020 03:26:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyX3q-0000zj-Kb for qemu-devel@nongnu.org; Mon, 03 Feb 2020 03:26:28 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:33228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyX3q-0000ye-E2; Mon, 03 Feb 2020 03:26:26 -0500 Received: by mail-wm1-x342.google.com with SMTP id m10so13745357wmc.0; Mon, 03 Feb 2020 00:26:26 -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 w20sm22396778wmk.34.2020.02.03.00.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 00:26:24 -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=fH7Pr46rmz5zfbrhebu4o/OiNogYj/7gAgBrUxWpkLo=; b=tZU2e6MQrFAdoCSswO188XhNoZnhzsdTfMcXFl5qLNMbckVT4KJ7mMxkyNI5uMZLXB o+bcTC5CUmyqslqESlHRacNGD/vXBOuQZodvy69AAzOTttHqOd5LvntEHC8XwudG+TKk AOpP6N6hbjBhRFRSYiX4OsqOGybK8Y2KL8yBYEZTuAfatgCCpo1QokI5yur20O3aiC2o wz5NQ/dHiu2Q02ASpu3WxKLlTxAnFBnwh2hPYXQETBz5TulwdWbURjITdoF/bPuw2Vs/ FVeRSPlHADDDVejdHoCyw6wLGtP6+LuU7LZzrSkdOwefw/FcsW9gAxejKNF9MdqOyxjW 68Sg== 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=fH7Pr46rmz5zfbrhebu4o/OiNogYj/7gAgBrUxWpkLo=; b=JrLDAcnU2eubOE8DhYUPXGzSbbYDuBS4id41v68FocAoTG72zoxurw25dompfQF3KM Kujis2vvSr7I6qJMOF373A7Y4UojRZv5dZ5y1kCbEynlM91UAiJyyb5B30H1jbXk3Fvl Pcpts+fvYfaXbvMlS/gSQv+aP6jTW5WskGWsIOqQ7rwQdHsNVRh//g+7Xajcrtp9AYQg U6a5z+Rf+rlTkpb95rDSRo3hs6u3uLaZcmZDbgtUoleQlRNNxeW2/S4XMzpQ7J1N1uce yJ1ToP0viXwrPF4c9hmh8W1Je2azzwuacALTv1AeIF9P+y9tZ/Da05rVIX+xoMDjl5dP 2ZCg== X-Gm-Message-State: APjAAAW8IW1YmzlbpTXs9ThYQPP89LLOlmcc+k1fm8nPMduih2HvbGlD AabH5uv9gnqt1ogpQTBhY879Nu43 X-Google-Smtp-Source: APXvYqwM5YhbYRWsW7fFCiDkDhq6m6Eksj9GE04oNvw9Ovg/s/COQ+W0c77BcnEYAxfKkh9TLkB7IQ== X-Received: by 2002:a1c:3b87:: with SMTP id i129mr27019922wma.142.1580718385052; Mon, 03 Feb 2020 00:26:25 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/6] hw/arm/raspi: Get board version from board revision code Date: Mon, 3 Feb 2020 09:26:15 +0100 Message-Id: <20200203082619.7426-3-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200203082619.7426-1-f4bug@amsat.org> References: <20200203082619.7426-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::342 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 , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The chip ID is encoded in the board revision, and the board version is simply 'chip_id + 1'. We want to support more boards which follow the same scheme. Introduce a new RaspiBoardInfo structure which we'll extend in the following commits. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/raspi.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index ef76a27f33..eaa8c49009 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -36,6 +36,39 @@ typedef struct RasPiState { MemoryRegion ram; } RasPiState; =20 +typedef struct RaspiBoardInfo { + /* + * Board revision codes: + * www.raspberrypi.org/documentation/hardware/raspberrypi/revision-cod= es/ + */ + uint32_t board_rev; +} RaspiBoardInfo; + +enum { BOARD_PI2, BOARD_PI3 }; + +static const RaspiBoardInfo raspi_boards[] =3D { + [BOARD_PI2] =3D + { + .board_rev =3D 0xa21041, + }, +#ifdef TARGET_AARCH64 + [BOARD_PI3] =3D + { + .board_rev =3D 0xa02082, + }, +#endif +}; + +static int board_chip_id(const RaspiBoardInfo *config) +{ + return extract32(config->board_rev, 12, 4); +} + +static int board_version(const RaspiBoardInfo *config) +{ + return board_chip_id(config) + 1; +} + static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) { static const uint32_t smpboot[] =3D { @@ -163,9 +196,10 @@ static void setup_boot(MachineState *machine, int vers= ion, size_t ram_size) arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo); } =20 -static void raspi_init(MachineState *machine, int version) +static void raspi_init(MachineState *machine, const RaspiBoardInfo *config) { RasPiState *s =3D g_new0(RasPiState, 1); + int version =3D board_version(config); uint32_t vcram_size; DriveInfo *di; BlockBackend *blk; @@ -191,9 +225,8 @@ static void raspi_init(MachineState *machine, int versi= on) /* Setup the SOC */ object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), &error_abort); - 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_int(OBJECT(&s->soc), config->board_rev, + "board-rev", &error_abort); object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abo= rt); =20 /* Create and plug in the SD cards */ @@ -215,7 +248,7 @@ static void raspi_init(MachineState *machine, int versi= on) =20 static void raspi2_init(MachineState *machine) { - raspi_init(machine, 2); + raspi_init(machine, &raspi_boards[BOARD_PI2]); } =20 static void raspi2_machine_init(MachineClass *mc) @@ -237,7 +270,7 @@ DEFINE_MACHINE("raspi2", raspi2_machine_init) #ifdef TARGET_AARCH64 static void raspi3_init(MachineState *machine) { - raspi_init(machine, 3); + raspi_init(machine, &raspi_boards[BOARD_PI3]); } =20 static void raspi3_machine_init(MachineClass *mc) --=20 2.21.1