All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
	qemu-arm@nongnu.org, "Igor Mammedov" <imammedo@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 3/6] hw/arm/raspi: Get the SoC type name from the revision code
Date: Mon,  3 Feb 2020 09:26:16 +0100	[thread overview]
Message-ID: <20200203082619.7426-4-f4bug@amsat.org> (raw)
In-Reply-To: <20200203082619.7426-1-f4bug@amsat.org>

We already know the Chip ID, let's name it with the
board_soc_name() helper.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/raspi.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index eaa8c49009..f5e54fe876 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -31,6 +31,18 @@
 
 #define MACH_TYPE_BCM2708   3138 /* Linux board IDs */
 
+enum BoardIdChip {
+    C_BCM2836 = 1,
+    C_BCM2837 = 2,
+};
+
+static const struct {
+    const char *soc_name;
+} soc_config[] = {
+    [C_BCM2836] = {TYPE_BCM2836},
+    [C_BCM2837] = {TYPE_BCM2837},
+};
+
 typedef struct RasPiState {
     BCM283XState soc;
     MemoryRegion ram;
@@ -69,6 +81,11 @@ static int board_version(const RaspiBoardInfo *config)
     return board_chip_id(config) + 1;
 }
 
+static const char *board_soc_name(const RaspiBoardInfo *config)
+{
+    return soc_config[board_chip_id(config)].soc_name;
+}
+
 static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
 {
     static const uint32_t smpboot[] = {
@@ -213,8 +230,7 @@ static void raspi_init(MachineState *machine, const RaspiBoardInfo *config)
     }
 
     object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc),
-                            version == 3 ? TYPE_BCM2837 : TYPE_BCM2836,
-                            &error_abort, NULL);
+                            board_soc_name(config), &error_abort, NULL);
 
     /* Allocate and map RAM */
     memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram",
-- 
2.21.1



  parent reply	other threads:[~2020-02-03  8:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-03  8:26 [PATCH 0/6] hw/arm/raspi: Dynamically create machines based on the board revision Philippe Mathieu-Daudé
2020-02-03  8:26 ` [PATCH 1/6] hw/arm/raspi: Use BCM2708 machine type with pre Device Tree kernels Philippe Mathieu-Daudé
2020-02-03 18:38   ` Alistair Francis
2020-02-03  8:26 ` [PATCH 2/6] hw/arm/raspi: Get board version from board revision code Philippe Mathieu-Daudé
2020-02-03  9:57   ` Igor Mammedov
2020-02-03  8:26 ` Philippe Mathieu-Daudé [this message]
2020-02-03  8:26 ` [PATCH 4/6] hw/arm/raspi: Get board RAM size " Philippe Mathieu-Daudé
2020-02-03  9:58   ` Igor Mammedov
2020-02-03  8:26 ` [PATCH 5/6] hw/arm/raspi: Dynamically create machines based on the board revision Philippe Mathieu-Daudé
2020-02-03 10:10   ` Igor Mammedov
2020-02-03  8:26 ` [PATCH 6/6] hw/arm/raspi: Get the CPU core count from the revision code Philippe Mathieu-Daudé
2020-02-03 16:48 ` [PATCH 0/6] hw/arm/raspi: Dynamically create machines based on the board revision no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200203082619.7426-4-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=Andrew.Baumann@microsoft.com \
    --cc=alistair@alistair23.me \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.