From patchwork Thu Feb 13 14:41:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 183387 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp641139ile; Thu, 13 Feb 2020 07:11:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzcuGZjE3+8CTK7w4lb/zB9k34O+nu6u631yJCVBq8dWGVzZvXeMftiKPkZDUOwOeDoqMC+ X-Received: by 2002:ad4:5144:: with SMTP id g4mr11957418qvq.179.1581606693473; Thu, 13 Feb 2020 07:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581606693; cv=none; d=google.com; s=arc-20160816; b=xQ+eLnjDaiRfi/BwX7LE9GF4G2PTKvjJ2hdi2UqorF5qPLVII9r5nTkDCy75m2BGt/ Llklnj/9tu36UTorQJJlG5zValPuC9eyv1LxlvD/5Ac5iHChlOX6BqZeJ3JflHxsoru6 gRtN0bcsBmWoI3G1VJ5HyPrEPXMUgdjZ+EmfeEZvU1eYQnUZ9H9S5ZCYi/8b/GMdzYQi Uw7PmXep88OF8dFflcd4tbIFqfK/8EBLf7vFSTx05l8humEHyozwJdVPSMIbGrzE1UCU Rg+f9ORciNlH5BtBxCJ/+Ryozf/Gs9bVLSX4aiU9PbrsFzM8oKiMSL1NzIdi2KbRz/SC 0fGg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=2ouywPz5Xm2vWfWs0doQqLT+siGfCg7eInrXlduofqk=; b=iGSO2L5XCTcHjWoMIXUtjxAYZi8g8arAT9dSJnzYcZAFqbyWk7wd7NEgzHefw7UXFp 0Utphij54eVtcM4zOdvH7uIDZY2wPcJozGOz3SoiTwUk8lsB6HGWTSURs+Da/LPianl7 Dd5KIKs8rlNWSNA0J8IVh5g8crZQQZENutIMjp9UdDW2NFzKdi6aOTVyxTv+pCVgNBOh Q88pQ5GBQ6LmuApy6UOWZ+rYpA4al3OeGzHkkdPoNAoLwvEtM5NaE0DM7rN0SiksrXvj WKPC1Elup58f5RBA3Ggv3yqVkYUx23rJ2mWs95SSaxrPlChVNZ085H9Se4lCeSSSG9Wa HXLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e6phfntS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i22si1347320qka.346.2020.02.13.07.11.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2020 07:11:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e6phfntS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2G9M-00008A-RU for patch@linaro.org; Thu, 13 Feb 2020 10:11:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60546) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2FhO-0004nn-GY for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2FhN-0002Od-13 for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:38 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:36560) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2FhM-0002Iq-QV for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:36 -0500 Received: by mail-wm1-x32e.google.com with SMTP id p17so7027136wma.1 for ; Thu, 13 Feb 2020 06:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2ouywPz5Xm2vWfWs0doQqLT+siGfCg7eInrXlduofqk=; b=e6phfntSqSlqeOfzxvNxo12Ke3kPc5u34git/3hWQvhuLF97rzSAUTKJrIsHovXefa lO7LB/H3H/YqLkQwbsqNUQ4m3vuAwynTpqZxkcvFd/DWrK0zXFBeGu14c2CAU6U2ZUJj 4FcWCTKiZrGcmKmVQ1YsxnGMSv7ulpU76eY9Yuk8hdCEP2raZo86dUmZZj7MVLyhAnEA ik6JDFd6V5FarRMgBHpALcLhLLn6mYN6KlRZmIQxl4gYdUFQYiLCO4W+d1GYVMqG5NUH 9hpWKiKZq1IZgCvpQCrbz1R+0dHXPoIQH4zSo2juVckMG3IgH66i+062r/gghfrwHZaV /9JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2ouywPz5Xm2vWfWs0doQqLT+siGfCg7eInrXlduofqk=; b=L+jtYEG4e1Nmsa606SxhsPGtRWAZXawATerevMtxPthDO3KMkjBIPapdPn6jx73ype 0i0/H5ZaKonS9+22tPO8sv9QVOwTKGGcBO42Oj54Hl2KuE4mWaZkcqQwwv2wZlUs/DB5 EFQet++GPYM5iEsAidIspdSys/NOkb+vMJHCKujExXaLWG+ectff9azarh1Q2UhmFIoN XBGBtjoieY3tHyOlyZ+JQzu7/yO4bt1l+i3i9YfwPiYl7xHAWL0H+BBRphJLsnH8nAaN 8qZoCaXM69tMY+PzVTNDiHgbT/JsOPY4QwRdHL3vCkZ1tX6jXGVzzKKwivctmOEVzEGH IIjA== X-Gm-Message-State: APjAAAV2gctg1qwsx35MeLAAyLNKbPRmMDT6SUAaTTD1aeAXh3wtJaAa 1XIoCylqGXKSl/HLXcC3cTR+rEiFCqI= X-Received: by 2002:a1c:1fc5:: with SMTP id f188mr6484394wmf.55.1581604947513; Thu, 13 Feb 2020 06:42:27 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id e22sm3362454wme.45.2020.02.13.06.42.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 06:42:26 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 35/46] hw/arm/raspi: Extract the version from the board revision Date: Thu, 13 Feb 2020 14:41:34 +0000 Message-Id: <20200213144145.818-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200213144145.818-1-peter.maydell@linaro.org> References: <20200213144145.818-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: 2a00:1450:4864:20::32e 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé The board revision encode the board version. Add a helper to extract the version, and use it. Signed-off-by: Philippe Mathieu-Daudé Message-id: 20200208165645.15657-4-f4bug@amsat.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/raspi.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 818146fdbb2..f285e2988fc 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -16,6 +16,7 @@ #include "qapi/error.h" #include "cpu.h" #include "hw/arm/bcm2836.h" +#include "hw/registerfields.h" #include "qemu/error-report.h" #include "hw/boards.h" #include "hw/loader.h" @@ -37,6 +38,28 @@ typedef struct RasPiState { MemoryRegion ram; } RasPiState; +/* + * Board revision codes: + * www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/ + */ +FIELD(REV_CODE, REVISION, 0, 4); +FIELD(REV_CODE, TYPE, 4, 8); +FIELD(REV_CODE, PROCESSOR, 12, 4); +FIELD(REV_CODE, MANUFACTURER, 16, 4); +FIELD(REV_CODE, MEMORY_SIZE, 20, 3); +FIELD(REV_CODE, STYLE, 23, 1); + +static int board_processor_id(uint32_t board_rev) +{ + assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ + return FIELD_EX32(board_rev, REV_CODE, PROCESSOR); +} + +static int board_version(uint32_t board_rev) +{ + return board_processor_id(board_rev) + 1; +} + static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) { static const uint32_t smpboot[] = { @@ -164,9 +187,10 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo); } -static void raspi_init(MachineState *machine, int version) +static void raspi_init(MachineState *machine, uint32_t board_rev) { RasPiState *s = g_new0(RasPiState, 1); + int version = board_version(board_rev); uint32_t vcram_size; DriveInfo *di; BlockBackend *blk; @@ -192,7 +216,6 @@ static void raspi_init(MachineState *machine, int version) /* Setup the SOC */ object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), &error_abort); - int board_rev = version == 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_abort); @@ -216,7 +239,7 @@ static void raspi_init(MachineState *machine, int version) static void raspi2_init(MachineState *machine) { - raspi_init(machine, 2); + raspi_init(machine, 0xa21041); } static void raspi2_machine_init(MachineClass *mc) @@ -238,7 +261,7 @@ DEFINE_MACHINE("raspi2", raspi2_machine_init) #ifdef TARGET_AARCH64 static void raspi3_init(MachineState *machine) { - raspi_init(machine, 3); + raspi_init(machine, 0xa02082); } static void raspi3_machine_init(MachineClass *mc)