From patchwork Thu Feb 13 14:41:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 183386 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp638506ile; Thu, 13 Feb 2020 07:09:29 -0800 (PST) X-Google-Smtp-Source: APXvYqy+YK+YRVwNsN137MPiVOaip5+Le5EPa1VZm8H6xwHaDZ8qBQoOSLa+bGMDaO5b5TkgYjAB X-Received: by 2002:a05:620a:12a8:: with SMTP id x8mr16320384qki.93.1581606569272; Thu, 13 Feb 2020 07:09:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581606569; cv=none; d=google.com; s=arc-20160816; b=IHTFD/zBDjMQrpswyAnvuSEDB67RZ2BCugVT20F3eJ3Ync9z3ml8AWKKwSrcHT0zDv wF4oULG6qtORX5WdErZR/I8hFP1UBoL/mKIzxoVTFf2Gv7Fr6rVvy+RFYJ5KeibPsI7q 7tcURBT07pZEcsOb9/cJpaUqb+ee16CvhpLw96nd65XmbJ+Qdz0m4uXud97yodnLpTLN 9B3ENLGqvl8rmsKb/nQ9xeWf4r279SgecuOgZM/sj1z4TrLeX4KH6pK5RGwpTrjeL6mi 5jQf+H/a8L6c87M0psoe+gpiGOKntiQoeSBYMLLqDDZyv9/NCEerdc3lJfm1Uy0nHPhG 1Y2Q== 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=GWz1pjVoz6EtEwxuWeaelwOEmy5EO8eEws/ey/K03f8=; b=LjqPLxLURC/4wOzuD5ZS0y8GnW32AxazFSHggQTPOE/Z3Z5QoDR9bIhJPq2bD5kwNp bRH0WF6lTwWCcrU6fp5dSG2rRnJZa5BxiaHW6xQaySvRFfpqW6S9PlCSB58RAT0VvSb/ ngoj7uP7L5RCTO4KA52fC9fCINOhdmwlL4Ve7DUzeDsvuaf51fYLrBOkOmJOIod7OEzf IfIiOhCh5Om3aUG/s1ntUOYlGLdTSK3CFW/JH0Jmd3XSPkG9iHo5U1uDC2BOzoHQZdPx NISJK+rEq8lcLHN5e63Bm+SZahCrHiHIo+SaeHukk3DVGXx7iW3RIlhyVZhcCghLdLXm WqQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BhmP95Ex; 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 j19si1297158qkk.246.2020.02.13.07.09.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2020 07:09:29 -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=BhmP95Ex; 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]:54310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2G7M-0005gN-PG for patch@linaro.org; Thu, 13 Feb 2020 10:09:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60535) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2FhO-0004mm-74 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-0002Oi-1N for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:38 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51731) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2FhM-0002Jr-Qo for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:36 -0500 Received: by mail-wm1-x344.google.com with SMTP id t23so6545453wmi.1 for ; Thu, 13 Feb 2020 06:42:35 -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=GWz1pjVoz6EtEwxuWeaelwOEmy5EO8eEws/ey/K03f8=; b=BhmP95Exm/gK6DIhdwZvHR2w/qXWOLQX6K1tO4UzwadBpAEOX6iZjrIr4We4QPyzav XeiOY7BCkxyr00YSJilvGDmnE25aX5KN5kq5ezQ5n+kcz0ivD2hk5/26w5hyOAX8g+3s Nu1kCvHqIHD5GY3VTqObTGf/A6gXZurBxxwXjAJBgjOPTx9Lr5qGgdRQBHpUCf76dRhn k6NtpmPwTezQjIlFhfMyDn+DDj4OAAu2cTkWz+DifJm8T+DAbMDcuWbdKwqdGU3lSMx0 9XqClUUONZjdi+nSGBl0Kd0viV/G3sK4rOC3GNn6ziqy/aL0b7ZRkANt3e5pLLLP1D8v 4D/A== 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=GWz1pjVoz6EtEwxuWeaelwOEmy5EO8eEws/ey/K03f8=; b=eomcmT/0j+jy8mfej+g/2sHexm/gckMZiP5atyp4zPJeCbKHKi9MQy1KkEWZI0PcWi ymmN+8mD/ESGSWx1q9Fu3eHLEU0lH4h/8++6tUwDL35xY+bxtwZbiRx5zec2x0mzdzrE PeHgL3rsPbOeIp+jDQu6Mt3TyylIvjiHhyNMEBv4bEoozTpbpMN+xTPUDvMmLm/pOZBZ 78URAzJjpdqAx2iMej35Hg7tuolbBD9cxAx5JAm6Daki6fbVnvCgT9/4A4ss0hMR9P5W 5ifLXCHlfzrAICgj8QMu9zml3s6teblaqPsB3CT5GRP5vUj+RvQZeM7h1o0wBAFJ83jA yo2g== X-Gm-Message-State: APjAAAXbtGY5hxbXQVbLXYUAFoc/zPqY2F+AkwNM9vnqr/o0ApNTspVx OmNc16JsBQtLxcevqKsL6f5yFX6s1zM= X-Received: by 2002:a05:600c:22d3:: with SMTP id 19mr6111153wmg.20.1581604949515; Thu, 13 Feb 2020 06:42:29 -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.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 06:42:28 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/46] hw/arm/raspi: Extract the processor type from the board revision Date: Thu, 13 Feb 2020 14:41:36 +0000 Message-Id: <20200213144145.818-38-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::344 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 processor type. Add a helper to extract the type, and use it. Signed-off-by: Philippe Mathieu-Daudé Message-id: 20200208165645.15657-6-f4bug@amsat.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/raspi.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index dcd8d2d6d38..7a2ca97347e 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -67,6 +67,21 @@ 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) +{ + static const char *soc_types[] = { + NULL, TYPE_BCM2836, TYPE_BCM2837, + }; + int proc_id = board_processor_id(board_rev); + + if (proc_id >= ARRAY_SIZE(soc_types) || !soc_types[proc_id]) { + error_report("Unsupported processor id '%d' (board revision: 0x%x)", + proc_id, board_rev); + exit(1); + } + return soc_types[proc_id]; +} + static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) { static const uint32_t smpboot[] = { @@ -213,8 +228,7 @@ static void raspi_init(MachineState *machine, uint32_t board_rev) } object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), - version == 3 ? TYPE_BCM2837 : TYPE_BCM2836, - &error_abort, NULL); + board_soc_type(board_rev), &error_abort, NULL); /* Allocate and map RAM */ memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram",