From: "Pete Batard" <pete@akeo.ie>
To: devel@edk2.groups.io
Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org,
philmd@redhat.com, samer.el-haj-mahmoud@arm.com
Subject: [edk2-platforms][PATCH v2 2/7] Platform/RPi: Add model family detection
Date: Tue, 19 Nov 2019 11:38:04 +0000 [thread overview]
Message-ID: <20191119113809.2472-3-pete@akeo.ie> (raw)
In-Reply-To: <20191119113809.2472-1-pete@akeo.ie>
From: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
Add GetModelFamily to RASPBERRY_PI_FIRMWARE_PROTOCOL.
This uses the board revision to return a numeric value representing
the RPi family (1=RPi, 2=RPi2, 3=RPi3 and 4=RPi4).
Knowing the Pi family will help us set the SD card routing when we
introduce support for the Pi 4 and should also be easier to maintain
than if using individual model detection.
Signed-off-by: Pete Batard <pete@akeo.ie>
---
Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 61 ++++++++++++++++++++
Platform/RaspberryPi/Include/Protocol/RpiFirmware.h | 8 +++
2 files changed, 69 insertions(+)
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index dcb434fabefe..dd61ef089ca7 100644
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -605,6 +605,66 @@ RpiFirmwareGetModelName (
}
}
+STATIC
+EFI_STATUS
+EFIAPI
+RPiFirmwareGetModelFamily (
+ OUT UINT32 *ModelFamily
+ )
+{
+ EFI_STATUS Status;
+ UINT32 Revision;
+ UINT32 ModelId;
+
+ Status = RpiFirmwareGetModelRevision(&Revision);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR,
+ "%a: Could not get the board revision: Status == %r\n",
+ __FUNCTION__, Status));
+ return EFI_DEVICE_ERROR;
+ } else {
+ ModelId = (Revision >> 4) & 0xFF;
+ }
+
+ switch (ModelId) {
+ // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+ case 0x00: // Raspberry Pi Model A
+ case 0x01: // Raspberry Pi Model B
+ case 0x02: // Raspberry Pi Model A+
+ case 0x03: // Raspberry Pi Model B+
+ case 0x06: // Raspberry Pi Compute Module 1
+ case 0x09: // Raspberry Pi Zero
+ case 0x0C: // Raspberry Pi Zero W
+ *ModelFamily = 1;
+ break;
+ case 0x04: // Raspberry Pi 2 Model B
+ *ModelFamily = 2;
+ break;
+ case 0x08: // Raspberry Pi 3 Model B
+ case 0x0A: // Raspberry Pi Compute Module 3
+ case 0x0D: // Raspberry Pi 3 Model B+
+ case 0x0E: // Raspberry Pi 3 Model A+
+ case 0x10: // Raspberry Pi Compute Module 3+
+ *ModelFamily = 3;
+ break;
+ case 0x11: // Raspberry Pi 4 Model B
+ *ModelFamily = 4;
+ break;
+ default:
+ *ModelFamily = 0;
+ break;
+ }
+
+ if (*ModelFamily == 0) {
+ DEBUG ((DEBUG_ERROR,
+ "%a: Unknown Raspberry Pi model family : ModelId == 0x%x\n",
+ __FUNCTION__, ModelId));
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
STATIC
CHAR8*
EFIAPI
@@ -1171,6 +1231,7 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
RpiFirmwareGetModel,
RpiFirmwareGetModelRevision,
RpiFirmwareGetModelName,
+ RPiFirmwareGetModelFamily,
RpiFirmwareGetFirmwareRevision,
RpiFirmwareGetManufacturerName,
RpiFirmwareGetCpuName,
diff --git a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
index e49d6e6132d9..e3287e3c040f 100644
--- a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
+++ b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
@@ -1,5 +1,6 @@
/** @file
*
+ * Copyright (c) 2019, ARM Limited. All rights reserved.
* Copyright (c) 2016, Linaro Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -102,6 +103,12 @@ CHAR8*
INTN ModelId
);
+typedef
+EFI_STATUS
+(EFIAPI *GET_MODEL_FAMILY) (
+ UINT32 *ModelFamily
+ );
+
typedef
EFI_STATUS
(EFIAPI *GET_FIRMWARE_REVISION) (
@@ -143,6 +150,7 @@ typedef struct {
GET_MODEL GetModel;
GET_MODEL_REVISION GetModelRevision;
GET_MODEL_NAME GetModelName;
+ GET_MODEL_FAMILY GetModelFamily;
GET_FIRMWARE_REVISION GetFirmwareRevision;
GET_MANUFACTURER_NAME GetManufacturerName;
GET_CPU_NAME GetCpuName;
--
2.21.0.windows.1
next prev parent reply other threads:[~2019-11-19 11:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 11:38 [edk2-platforms][PATCH v2 0/7] Platform/RPi: Early Raspberry Pi 4 groundwork Pete Batard
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 1/7] Platform/RPi: Add missing model name Pete Batard
2019-11-19 12:02 ` Philippe Mathieu-Daudé
2019-11-19 12:14 ` [edk2-devel] " Leif Lindholm
2019-11-19 12:25 ` Philippe Mathieu-Daudé
2019-11-19 12:50 ` Leif Lindholm
2019-11-19 12:25 ` Pete Batard
2019-11-19 11:38 ` Pete Batard [this message]
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 3/7] Platform/RPi: Replace Bcm283x SoC base register address with a PCD Pete Batard
2019-11-19 11:43 ` Philippe Mathieu-Daudé
2019-11-19 11:57 ` Pete Batard
2019-11-19 12:16 ` Philippe Mathieu-Daudé
2019-11-19 12:44 ` Leif Lindholm
2019-11-19 12:51 ` Ard Biesheuvel
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 4/7] Platform/RPi: Use offsets for Bcm238x SoC register addresses Pete Batard
2019-11-19 11:46 ` Philippe Mathieu-Daudé
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 5/7] Silicon/Broadcom: Add Bcm2711 header Pete Batard
2019-11-19 11:51 ` Philippe Mathieu-Daudé
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 6/7] Platform/RPi: Read more variables from VideoCore during early init Pete Batard
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 7/7] Platform/RPi: Clean up and improve early memory init Pete Batard
2019-11-19 18:20 ` [edk2-platforms][PATCH v2 0/7] Platform/RPi: Early Raspberry Pi 4 groundwork Leif Lindholm
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-list 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=20191119113809.2472-3-pete@akeo.ie \
--to=devel@edk2.groups.io \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox