From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web10.6492.1573747674773957432 for ; Thu, 14 Nov 2019 08:07:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=ToRAJBAA; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.67, mailfrom: pete@akeo.ie) Received: by mail-wr1-f67.google.com with SMTP id i10so7107606wrs.7 for ; Thu, 14 Nov 2019 08:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nXz7mrhJ3ZHvy6VCkmOdHsxNBB7ZM7l49J0TSzhbRAY=; b=ToRAJBAAue/HQ66jQxztrg9UtAUpQCHW89fxminyRPJFwqNmNfiVJ8SSXPOl8/+P1b PyeNkxKGjhGCrEG5qrqauMqoPTfAkKvy57iq6m4rxryXswk56q3TMKd9ijSCxJ5y6NI2 PsfA6JnuHBVO9qE2oHS1RJB4fktLluKQwfu2RFT4E5Y+3RpndY6EnabVWbamVIgmvYKX pM/S5SLRmZo6XdN/kw2CEuVMntiLce36yhwHt7JfR6/dCMYV/VcrlfSWcgDinj+3IHft v2zW4Ti2tqAwmbAu1CwP+yLIvtxjNo1BKZA42Qdmx4MxeH4MX/nWuzQnW2Y7PcFG4L4J 9/rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nXz7mrhJ3ZHvy6VCkmOdHsxNBB7ZM7l49J0TSzhbRAY=; b=rLQKNc6w8uigJyLAKmyADkdw6ADmY0yyQvbGtsstXj476C9akFXOwef8JgCZiNkwjy hZmk31X8m/7WCejVPJyahILuHwlLSq7eCACRIMQSNyhjAxulTorruyQ73YSvUKTB8lt2 y3QnezqCvwBX/Ryw6KVlEfYsT1NWJQXqby5eFrrnh5A3aedltPIcNelEq/dzYUHlS63b KEjfYop7lO18OYDcMrNriG8gzBU2HmWItPTQQX4a6foKnormhasmKu92tkKJfPedZCpy UyH8553H3YDFliOSI8lA7NDJYhgB5BF7toPEM05KRlSo2WMSTzCm/ed1+hABv4I6PfHv bBrA== X-Gm-Message-State: APjAAAX+0+2r24cRshkelk8I+kRiU6XNDmG+Dem9NmxOSHA/IXR39znz VveCZiCnAhI2W9z0yam4JLIiDqn+Qfk= X-Google-Smtp-Source: APXvYqw4g/8sNnMa8P9K4lw0g2hyfxjMzBZseONWYGbzmFqjumj5uDpLMry7mNLp3prdv/kVdvYBCw== X-Received: by 2002:a05:6000:1083:: with SMTP id y3mr8548900wrw.290.1573747673066; Thu, 14 Nov 2019 08:07:53 -0800 (PST) Return-Path: Received: from localhost.localdomain ([84.203.67.47]) by smtp.gmail.com with ESMTPSA id a16sm6793088wmd.11.2019.11.14.08.07.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2019 08:07:52 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-platforms][PATCH 1/8] Platform/RPi: Add model family detection Date: Thu, 14 Nov 2019 16:07:33 +0000 Message-Id: <20191114160740.10072-2-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20191114160740.10072-1-pete@akeo.ie> References: <20191114160740.10072-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Samer El-Haj-Mahmoud 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. Also add a missing entry for the "Raspberry Pi Compute Module 3+" in RpiFirmwareGetModelName (). Signed-off-by: Pete Batard --- Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 64 ++++++++++++++++++++ Platform/RaspberryPi/Include/Protocol/RpiFirmware.h | 8 +++ 2 files changed, 72 insertions(+) diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index 9b4aa068857c..dd61ef089ca7 100644 --- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c +++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c @@ -1,5 +1,6 @@ /** @file * + * Copyright (c) 2019, ARM Limited. All rights reserved. * Copyright (c) 2017-2018, Andrei Warkentin * Copyright (c) 2016, Linaro, Ltd. All rights reserved. * @@ -595,6 +596,8 @@ RpiFirmwareGetModelName ( return "Raspberry Pi 3 Model B+"; case 0x0E: return "Raspberry Pi 3 Model A+"; + case 0x10: + return "Raspberry Pi Compute Module 3+"; case 0x11: return "Raspberry Pi 4 Model B"; default: @@ -602,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 @@ -1168,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