From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web10.1733.1571046964680141117 for ; Mon, 14 Oct 2019 02:56:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GQF5vaZs; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571046963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Me3TtOuRdtkHEUw91XPCAc5x/bjGpMlQy1ogFiIv/V0=; b=GQF5vaZsSIYGOZdt2W032FpJ2ePkFUpbYn/1jJ5027BbxIt6riS4gNNURC19M6R56W9Wst R+oZhn1COMPfgYcZC5AmG2f4yE7o42GnA/8DGZa/lgERbdYvJCeUt6QaSWAi1bFMGelqvX QBrkP4tjNWFt/kurv7M1FSjMlqLM36U= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-aFCI9m6mOlu8C6FP0n1NiQ-1; Mon, 14 Oct 2019 05:56:00 -0400 Received: by mail-wr1-f69.google.com with SMTP id n18so8256844wro.11 for ; Mon, 14 Oct 2019 02:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=V3sCQEW+jBdUlD++TmWgAEaqI96+MQHiBzrcvp3V+RA=; b=fy8LYvh8Cf+v7TrElbj4uBIQdrZJNub607rAMoIv140DQXJ1iOljI+EApmlYu3CgQE owNHywkHjsT/d1yksR7VRQo0bROmK/zlDTrLQqB9XtWGZ129R33DsTXZ6i43BIqm2moy I8cwInBQJ6ITjM4QMMecCH6T53hY6IENXsM7+nWmULplBMufqlg6YYrvCmJs9RChII4F 8jsAiq3H5AoFq3hoGNsxbPhgHmf6OtUIc0UhTDFzJh3kS9wZPXP6FUEPg/QpuOogy6e0 rHWPdpumJdwwyvFCvBK2KUevfmbqshjsFeLl8Yic4zq5k+MVftObGyFPBIORXRHOpwH7 YGAw== X-Gm-Message-State: APjAAAWsxUy9pv7Ypu80id2go57aazkXMWw+kqvDOqXAa/Z93KC9TIUv 27xZ+Kot8uwLGQGcm7FvyjwSyEn1dDKn3gY+pJATEbTMcM1fGTtZ1qBuFbj7+axN4FmbgURJGi7 vq0ZMs2DrCUdMJg== X-Received: by 2002:a1c:5946:: with SMTP id n67mr14911458wmb.93.1571046959196; Mon, 14 Oct 2019 02:55:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0QVfOXhgneRRvMxyTzsLFI+XF6VAH2wuvhMb5sVQGbmkkzGBMm9wqopHsqhjm99tWhttbEw== X-Received: by 2002:a1c:5946:: with SMTP id n67mr14911438wmb.93.1571046958918; Mon, 14 Oct 2019 02:55:58 -0700 (PDT) Return-Path: Received: from [192.168.50.32] (243.red-88-26-246.staticip.rima-tde.net. [88.26.246.243]) by smtp.gmail.com with ESMTPSA id b5sm13878151wmj.18.2019.10.14.02.55.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Oct 2019 02:55:58 -0700 (PDT) Subject: Re: [edk2-devel] [edk2-platforms][PATCH v3 1/5] Platform/RPi3/RpiFirmwareDxe: Add more query functions To: devel@edk2.groups.io, pete@akeo.ie Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org References: <20191011110746.1952-1-pete@akeo.ie> <20191011110746.1952-2-pete@akeo.ie> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: <7bd11200-fafc-fdbf-c014-2ac2af61240f@redhat.com> Date: Mon, 14 Oct 2019 11:55:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20191011110746.1952-2-pete@akeo.ie> X-MC-Unique: aFCI9m6mOlu8C6FP0n1NiQ-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 10/11/19 1:07 PM, Pete Batard wrote: > This patch introduces the capability to also query the Model Name/ > Manufacturer Name/CPU Name/Firmware Revision using the RpiFirmware > protocol. This is aims at making the driver more suitable to cater > for platforms other than the Raspberry Pi 3 as well as simplifying > the population of entries in PlatformSmbiosDxe. >=20 > Signed-off-by: Pete Batard > --- > Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 158= +++++++++++++++++++- > Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h | 58= +++++-- > 2 files changed, 199 insertions(+), 17 deletions(-) >=20 > diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmware= Dxe.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c > index 9b5ee1946279..25d7fa3974c0 100644 > --- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c > +++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c > @@ -461,7 +461,7 @@ typedef struct { > RPI_FW_TAG_HEAD TagHead; > RPI_FW_MODEL_REVISION_TAG TagBody; > UINT32 EndTag; > -} RPI_FW_GET_MODEL_REVISION_CMD; > +} RPI_FW_GET_REVISION_CMD; > #pragma pack() > =20 > STATIC > @@ -471,7 +471,7 @@ RpiFirmwareGetModelRevision ( > OUT UINT32 *Revision > ) > { > - RPI_FW_GET_MODEL_REVISION_CMD *Cmd; > + RPI_FW_GET_REVISION_CMD *Cmd; > EFI_STATUS Status; > UINT32 Result; > =20 > @@ -506,6 +506,156 @@ RpiFirmwareGetModelRevision ( > return EFI_SUCCESS; > } > =20 > +STATIC > +EFI_STATUS > +EFIAPI > +RpiFirmwareGetFirmwareRevision ( > + OUT UINT32 *Revision > + ) > +{ > + RPI_FW_GET_REVISION_CMD *Cmd; > + EFI_STATUS Status; > + UINT32 Result; > + > + if (!AcquireSpinLockOrFail (&mMailboxLock)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION_= _)); > + return EFI_DEVICE_ERROR; > + } > + > + Cmd =3D mDmaBuffer; > + ZeroMem (Cmd, sizeof (*Cmd)); > + > + Cmd->BufferHead.BufferSize =3D sizeof (*Cmd); > + Cmd->BufferHead.Response =3D 0; > + Cmd->TagHead.TagId =3D RPI_MBOX_GET_REVISION; > + Cmd->TagHead.TagSize =3D sizeof (Cmd->TagBody); > + Cmd->TagHead.TagValueSize =3D 0; > + Cmd->EndTag =3D 0; > + > + Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC= _CHANNEL, &Result); > + > + ReleaseSpinLock (&mMailboxLock); > + > + if (EFI_ERROR (Status) || > + Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { > + DEBUG ((DEBUG_ERROR, > + "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D = 0x%x\n", > + __FUNCTION__, Status, Cmd->BufferHead.Response)); > + return EFI_DEVICE_ERROR; > + } > + > + *Revision =3D Cmd->TagBody.Revision; > + return EFI_SUCCESS; > +} > + > +STATIC > +CHAR8* > +EFIAPI > +RpiFirmwareGetModelName ( > + IN INTN ModelId > + ) > +{ > + UINT32 Revision; > + > + // If a negative ModelId is passed, detect it. > + if ((ModelId < 0) && (RpiFirmwareGetModelRevision (&Revision) =3D=3D E= FI_SUCCESS)) { > + ModelId =3D (Revision >> 4) & 0xFF; > + } > + > + switch (ModelId) { > + // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-cod= es/README.md > + case 0x00: > + return "Raspberry Pi Model A"; > + case 0x01: > + return "Raspberry Pi Model B"; > + case 0x02: > + return "Raspberry Pi Model A+"; > + case 0x03: > + return "Raspberry Pi Model B+"; > + case 0x04: > + return "Raspberry Pi 2 Model B"; > + case 0x06: > + return "Raspberry Pi Compute Module 1"; > + case 0x08: > + return "Raspberry Pi 3 Model B"; > + case 0x09: > + return "Raspberry Pi Zero"; > + case 0x0A: > + return "Raspberry Pi Compute Module 3"; > + case 0x0C: > + return "Raspberry Pi Zero W"; > + case 0x0D: > + return "Raspberry Pi 3 Model B+"; > + case 0x0E: > + return "Raspberry Pi 3 Model A+"; > + case 0x11: > + return "Raspberry Pi 4 Model B"; > + default: > + return "Unknown Raspberry Pi Model"; > + } > +} > + > +STATIC > +CHAR8* > +EFIAPI > +RpiFirmwareGetManufacturerName ( > + IN INTN ManufacturerId > + ) > +{ > + UINT32 Revision; > + > + // If a negative ModelId is passed, detect it. > + if ((ManufacturerId < 0) && (RpiFirmwareGetModelRevision (&Revision) = =3D=3D EFI_SUCCESS)) { > + ManufacturerId =3D (Revision >> 16) & 0x0F; > + } > + > + switch (ManufacturerId) { > + // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-cod= es/README.md > + case 0x00: > + return "Sony UK"; > + case 0x01: > + return "Egoman"; > + case 0x02: > + case 0x04: > + return "Embest"; > + case 0x03: > + return "Sony Japan"; > + case 0x05: > + return "Stadium"; > + default: > + return "Unknown Manufacturer"; > + } > +} > + > +STATIC > +CHAR8* > +EFIAPI > +RpiFirmwareGetCpuName ( > + IN INTN CpuId > + ) > +{ > + UINT32 Revision; > + > + // If a negative CpuId is passed, detect it. > + if ((CpuId < 0) && (RpiFirmwareGetModelRevision (&Revision) =3D=3D EFI= _SUCCESS)) { > + CpuId =3D (Revision >> 12) & 0x0F; > + } > + > + switch (CpuId) { > + // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-cod= es/README.md > + case 0x00: > + return "BCM2835 (ARM11)"; > + case 0x01: > + return "BCM2836 (ARM Cortex-A7)"; > + case 0x02: > + return "BCM2837 (ARM Cortex-A53)"; > + case 0x03: > + return "BCM2711 (ARM Cortex-A72)"; > + default: > + return "Unknown CPU Model"; > + } > +} > + > #pragma pack() > typedef struct { > UINT32 Width; > @@ -1009,6 +1159,10 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmware= Protocol =3D { > RpiFirmwareGetSerial, > RpiFirmwareGetModel, > RpiFirmwareGetModelRevision, > + RpiFirmwareGetModelName, > + RpiFirmwareGetFirmwareRevision, > + RpiFirmwareGetManufacturerName, > + RpiFirmwareGetCpuName, > RpiFirmwareGetArmMemory > }; > =20 > diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h b/P= latform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h > index ec70f28efe1a..e49d6e6132d9 100644 > --- a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h > +++ b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h > @@ -96,6 +96,30 @@ EFI_STATUS > UINT32 *Revision > ); > =20 > +typedef > +CHAR8* > +(EFIAPI *GET_MODEL_NAME) ( > + INTN ModelId > + ); > + > +typedef > +EFI_STATUS > +(EFIAPI *GET_FIRMWARE_REVISION) ( > + UINT32 *Revision > + ); > + > +typedef > +CHAR8* > +(EFIAPI *GET_MANUFACTURER_NAME) ( > + INTN ManufacturerId > + ); > + > +typedef > +CHAR8* > +(EFIAPI *GET_CPU_NAME) ( > + INTN CpuId > + ); > + > typedef > EFI_STATUS > (EFIAPI *GET_ARM_MEM) ( > @@ -104,21 +128,25 @@ EFI_STATUS > ); > =20 > typedef struct { > - SET_POWER_STATE SetPowerState; > - GET_MAC_ADDRESS GetMacAddress; > - GET_COMMAND_LINE GetCommandLine; > - GET_CLOCK_RATE GetClockRate; > - GET_CLOCK_RATE GetMaxClockRate; > - GET_CLOCK_RATE GetMinClockRate; > - SET_CLOCK_RATE SetClockRate; > - GET_FB GetFB; > - FREE_FB FreeFB; > - GET_FB_SIZE GetFBSize; > - SET_LED SetLed; > - GET_SERIAL GetSerial; > - GET_MODEL GetModel; > - GET_MODEL_REVISION GetModelRevision; > - GET_ARM_MEM GetArmMem; > + SET_POWER_STATE SetPowerState; > + GET_MAC_ADDRESS GetMacAddress; > + GET_COMMAND_LINE GetCommandLine; > + GET_CLOCK_RATE GetClockRate; > + GET_CLOCK_RATE GetMaxClockRate; > + GET_CLOCK_RATE GetMinClockRate; > + SET_CLOCK_RATE SetClockRate; > + GET_FB GetFB; > + FREE_FB FreeFB; > + GET_FB_SIZE GetFBSize; > + SET_LED SetLed; > + GET_SERIAL GetSerial; > + GET_MODEL GetModel; > + GET_MODEL_REVISION GetModelRevision; > + GET_MODEL_NAME GetModelName; > + GET_FIRMWARE_REVISION GetFirmwareRevision; > + GET_MANUFACTURER_NAME GetManufacturerName; > + GET_CPU_NAME GetCpuName; > + GET_ARM_MEM GetArmMem; > } RASPBERRY_PI_FIRMWARE_PROTOCOL; > =20 > extern EFI_GUID gRaspberryPiFirmwareProtocolGuid; >=20 Reviewed-by: Philippe Mathieu-Daude