[PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array

Philippe Mathieu-Daudé posted 12 patches 2 months ago
[PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array
Posted by Philippe Mathieu-Daudé 2 months ago
Expand the current type2model array to include the processor id.

Since the BCM2838 is indistinctly used as BCM2711 (within the
Linux community), add it as alias in RaspiProcessorId.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/raspi.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 571b50bef7e..1a6a1f8ff22 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -70,6 +70,7 @@ typedef enum RaspiProcessorId {
     PROCESSOR_ID_BCM2836 = 1,
     PROCESSOR_ID_BCM2837 = 2,
     PROCESSOR_ID_BCM2838 = 3,
+    PROCESSOR_ID_BCM2711 = 3,
 } RaspiProcessorId;
 
 static const struct {
@@ -82,6 +83,30 @@ static const struct {
     [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
 };
 
+static const struct {
+    RaspiProcessorId proc_id;
+    const char *model;
+} types[] = {
+    {PROCESSOR_ID_BCM2835, "A"},
+    {PROCESSOR_ID_BCM2835, "B"},
+    {PROCESSOR_ID_BCM2835, "A+"},
+    {PROCESSOR_ID_BCM2835, "B+"},
+    {PROCESSOR_ID_BCM2836, "2B"},
+    { },
+    {PROCESSOR_ID_BCM2835, "CM1"},
+    { },
+    {PROCESSOR_ID_BCM2837, "3B"},
+    {PROCESSOR_ID_BCM2835, "Zero"},
+    {PROCESSOR_ID_BCM2837, "CM3"},
+    { },
+    {PROCESSOR_ID_BCM2835, "ZeroW"},
+    {PROCESSOR_ID_BCM2837, "3B+"},
+    {PROCESSOR_ID_BCM2837, "3A+"},
+    { },
+    {PROCESSOR_ID_BCM2837, "CM3+"},
+    {PROCESSOR_ID_BCM2711, "4B"},
+};
+
 uint64_t board_ram_size(uint32_t board_rev)
 {
     assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
@@ -110,16 +135,12 @@ static int cores_count(uint32_t board_rev)
 
 static const char *board_type(uint32_t board_rev)
 {
-    static const char *types[] = {
-        "A", "B", "A+", "B+", "2B", "Alpha", "CM1", NULL, "3B", "Zero",
-        "CM3", NULL, "Zero W", "3B+", "3A+", NULL, "CM3+", "4B",
-    };
     assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
     int bt = FIELD_EX32(board_rev, REV_CODE, TYPE);
-    if (bt >= ARRAY_SIZE(types) || !types[bt]) {
+    if (bt >= ARRAY_SIZE(types) || !types[bt].model) {
         return "Unknown";
     }
-    return types[bt];
+    return types[bt].model;
 }
 
 static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
-- 
2.47.1


Re: [PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array
Posted by Peter Maydell 2 months ago
On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Expand the current type2model array to include the processor id.
>
> Since the BCM2838 is indistinctly used as BCM2711 (within the
> Linux community), add it as alias in RaspiProcessorId.

Can you explain this in more detail? Presumably the hardware
itself has whatever ID it has...

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

-- PMM