[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] hw/arm/raspi: Get the SoC type name from the revision code
From: |
Philippe Mathieu-Daudé |
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 |
We already know the Chip ID, let's name it with the
board_soc_name() helper.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
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
- [PATCH 0/6] hw/arm/raspi: Dynamically create machines based on the board revision, Philippe Mathieu-Daudé, 2020/02/03
- [PATCH 1/6] hw/arm/raspi: Use BCM2708 machine type with pre Device Tree kernels, Philippe Mathieu-Daudé, 2020/02/03
- [PATCH 2/6] hw/arm/raspi: Get board version from board revision code, Philippe Mathieu-Daudé, 2020/02/03
- [PATCH 3/6] hw/arm/raspi: Get the SoC type name from the revision code,
Philippe Mathieu-Daudé <=
- [PATCH 4/6] hw/arm/raspi: Get board RAM size from board revision code, Philippe Mathieu-Daudé, 2020/02/03
- [PATCH 5/6] hw/arm/raspi: Dynamically create machines based on the board revision, Philippe Mathieu-Daudé, 2020/02/03
- [PATCH 6/6] hw/arm/raspi: Get the CPU core count from the revision code, Philippe Mathieu-Daudé, 2020/02/03
- Re: [PATCH 0/6] hw/arm/raspi: Dynamically create machines based on the board revision, no-reply, 2020/02/03