We already know the Chip ID, let's name it with the board_soc_name() helper.
Signed-off-by: Philippe Mathieu-Daudé <f4...@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