From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=zXroi2g0; spf=pass (domain: linaro.org, ip: 209.85.166.196, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-it1-f196.google.com (mail-it1-f196.google.com [209.85.166.196]) by groups.io with SMTP; Fri, 26 Apr 2019 04:57:05 -0700 Received: by mail-it1-f196.google.com with SMTP id y10so5355128itc.1 for ; Fri, 26 Apr 2019 04:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=00PHlnOHkbOhkbMb1ejyc/XpqvaNJj8GmaQlXhlLTlY=; b=zXroi2g03QfP0ajP9iJ5JcqJNtJpDpAiWZqf9PtgGjU160ZcmF3PrsjVsqZGmEyzzN AP0Rjbtcg4UrVyaCfEFLQtkYCfjKy6N7d7WnAIb2k5wu36CZ5TXoaT8Oel/CN/jLY1jv PgChcwpoZPtGmI3Q4lflZ2dH4tHquXygxbKy8UTAN1P0I/sA0O/PInV95pifoFaKJGK+ WNu2jkGfMU1sC9IVw6RePagD6uXlguh5ilI+YidmEYTahS3aNsB7OMN3hmQfefpAiihs Q2x+ROsuG1BtGwZuU1cZAb0fAMWvWa9n++kdqq2BV78sAqvzQ0GpbeNct0Vkp+ULanbl gjXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=00PHlnOHkbOhkbMb1ejyc/XpqvaNJj8GmaQlXhlLTlY=; b=Cc+wCgJzu1ELDc+6waiU5lLR3A5nf3j7ghctlsHYuzTIeTFF+iYgyqj0x1E7o7hvY0 5gnO98Xtcanpborq4CRY2X5kPH0+XAtfzLM4aLuRYoe9yxeIrQQ1F9fFJijQDYjVzvqG mzeIZRyyeMgrVTnWjkj6IJUfH93v/rXczg5PRbYk+PwgYpwUwP66N487QvHkFIOF25Yv dsPOIkSznQViQPITbbkWGLo2V7v8aVJ0fDo/3uAqCQK4vh3yl3jKvIgrTcDeqNTIIK+i HhZqQmB9Bg/mNgaO2J2VMCPmym6O31Wx2miUm495PqH25sVziFv7MPxh6rBdccBCRnAt hn3Q== X-Gm-Message-State: APjAAAUxvEBblTBokfwOpAcsEhMM3EJW+x58J4J7+H33H2mWh/kufwFQ dBPbKXaZ9z9ggyj5fFIXv4jfJIyPOO+QUHQQVGhzxQ== X-Google-Smtp-Source: APXvYqx0M2wq0P1mdoV/NajEYg/KVPOQeQ/qAahxspC+hyUJ2RVkqyyEHFM1EpqD6w+R0mXpgySCiq31NZ+oYvuiASU= X-Received: by 2002:a05:660c:4c2:: with SMTP id v2mr8446492itk.71.1556279824919; Fri, 26 Apr 2019 04:57:04 -0700 (PDT) MIME-Version: 1.0 References: <20190425123254.16396-1-ard.biesheuvel@linaro.org> <20190425123254.16396-4-ard.biesheuvel@linaro.org> <20190426111610.w5cnegxjn66paavb@bivouac.eciton.net> In-Reply-To: <20190426111610.w5cnegxjn66paavb@bivouac.eciton.net> From: "Ard Biesheuvel" Date: Fri, 26 Apr 2019 13:56:54 +0200 Message-ID: Subject: Re: [PATCH edk2-platforms 3/3] Platform/Secure96Dxe: add ACPI description of the GPIO LEDs To: Leif Lindholm Cc: edk2-devel-groups-io , Graeme Gregory , Masahisa Kojima Content-Type: text/plain; charset="UTF-8" On Fri, 26 Apr 2019 at 13:16, Leif Lindholm wrote: > > On Thu, Apr 25, 2019 at 02:32:54PM +0200, Ard Biesheuvel wrote: > > Wire up the new 96boards mezzanine SSDT loading support, and use it > > to describe the four GPIO LEDs on the Secure96 mezzanine board. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Ard Biesheuvel > > --- > > Platform/96Boards/Secure96Dxe/Secure96.asl | 103 ++++++++++++++++++++ > > Platform/96Boards/Secure96Dxe/Secure96Dxe.c | 59 ++++++++++- > > Platform/96Boards/Secure96Dxe/Secure96Dxe.inf | 1 + > > 3 files changed, 158 insertions(+), 5 deletions(-) > > > > diff --git a/Platform/96Boards/Secure96Dxe/Secure96.asl b/Platform/96Boards/Secure96Dxe/Secure96.asl > > new file mode 100644 > > index 000000000000..bb9dac462a33 > > --- /dev/null > > +++ b/Platform/96Boards/Secure96Dxe/Secure96.asl > > @@ -0,0 +1,103 @@ > > +/** @file > > + * Copyright (c) 2019, Linaro Limited. All rights reserved. > > + * > > + * This program and the accompanying materials are licensed and made > > + * available under the terms and conditions of the BSD License which > > + * accompanies this distribution. The full text of the license may be > > + * found at http://opensource.org/licenses/bsd-license.php > > + * > > + * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > > + * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR > > + * IMPLIED. > > + */ > > + > > +#include "Secure96.h" > > + > > +DefinitionBlock ("Secure96.aml", "SSDT", 2, "LINARO", "SECURE96", 1) > > +{ > > + External (\_SB.LS96.GPIO) > > + > > + Scope (_SB) > > + { > > + Device (LD96) > > + { > > + Name (_HID, "PRP0001") // _HID: Hardware ID > > + Name (_UID, 0x00) // _UID: Unique ID > > + Name (_DSD, Package () { > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), > > Surely the above stanza is the most repeated bit of boiler plate in > the entire tree? I count 207 instances before this goes in. > Can we stick a #define in some common header for this and reuse? > ACPI_DSD_UUID? > > As I said, not required for this patch, but would be worth addressing. > We should add the GUID to MdePkg, given that it occurs in the ACPI spec. > > + Package () { > > + Package () { "compatible", "gpio-leds" }, > > + } > > + }) > > + > > + Method (_CRS) > > + { > > + Return (\_SB.LS96.GPIO) > > + } > > + > > + Device (LDU1) > > + { > > + Name (_ADR, 0x1) > > + Name (_DSD, Package () { > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), > > + Package () { > > + Package () { "label", "secure96-u1" }, > > + Package () { "gpios", > > + Package () { > > + ^^LD96, 0, 6, FixedPcdGet32 (PcdGpioPolarity) > > + }, > > + }, > > + } > > + }) > > + } > > + > > + Device (LDU2) > > + { > > + Name (_ADR, 0x2) > > + Name (_DSD, Package () { > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), > > + Package () { > > + Package () { "label", "secure96-u2" }, > > + Package () { "gpios", > > + Package () { > > + ^^LD96, 0, 5, FixedPcdGet32 (PcdGpioPolarity) > > + }, > > + }, > > + } > > + }) > > + } > > + > > + Device (LDU3) > > + { > > + Name (_ADR, 0x3) > > + Name (_DSD, Package () { > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), > > + Package () { > > + Package () { "label", "secure96-u3" }, > > + Package () { "gpios", > > + Package () { > > + ^^LD96, 0, 8, FixedPcdGet32 (PcdGpioPolarity) > > + }, > > + }, > > + } > > + }) > > + } > > + > > + Device (LDU4) > > + { > > + Name (_ADR, 0x4) > > + Name (_DSD, Package () { > > + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), > > + Package () { > > + Package () { "label", "secure96-u4" }, > > + Package () { "gpios", > > + Package () { > > + ^^LD96, 0, 7, FixedPcdGet32 (PcdGpioPolarity) > > + }, > > + }, > > + } > > + }) > > + } > > + } > > + } > > +} > > diff --git a/Platform/96Boards/Secure96Dxe/Secure96Dxe.c b/Platform/96Boards/Secure96Dxe/Secure96Dxe.c > > index 6c48d7c0b024..68f8ec812b52 100644 > > --- a/Platform/96Boards/Secure96Dxe/Secure96Dxe.c > > +++ b/Platform/96Boards/Secure96Dxe/Secure96Dxe.c > > @@ -24,6 +24,8 @@ > > > > #include "Secure96.h" > > > > +#define SECURE96_SSDT_OEM_TABLE_ID SIGNATURE_64('S','E','C','U','R','E','9','6') > > + > > STATIC CONST UINT32 mI2cAtmelSha204aSlaveAddress[] = { > > ATSHA204A_SLAVE_ADDRESS, > > > > @@ -148,15 +150,20 @@ ApplyDeviceTreeOverlay ( > > UINTN OverlaySize; > > EFI_STATUS Status; > > INT32 Err; > > + UINTN Index; > > > > // > > // Load the raw overlay DTB image from the raw section of this FFS file. > > // > > - Status = GetSectionFromFv (&gEfiCallerIdGuid, > > - EFI_SECTION_RAW, 0, &Overlay, &OverlaySize); > > - ASSERT_EFI_ERROR (Status); > > - if (EFI_ERROR (Status)) { > > - return EFI_NOT_FOUND; > > + for (Index = 0;; Index++) { > > + Status = GetSectionFromFv (&gEfiCallerIdGuid, > > + EFI_SECTION_RAW, Index, &Overlay, &OverlaySize); > > + if (EFI_ERROR (Status)) { > > + return EFI_NOT_FOUND; > > + } > > + if (!fdt_check_header (Overlay)) { > > + break; > > + } > > } > > > > // > > @@ -177,8 +184,50 @@ ApplyDeviceTreeOverlay ( > > return EFI_SUCCESS; > > } > > > > +/** > > + Install the mezzanine's SSDT table > > + > > + @param[in] This Pointer to the MEZZANINE_PROTOCOL instance. > > + @param[in] Dtb Pointer to the device tree blob > > + > > + @return EFI_SUCCESS Operation succeeded. > > + @return other An error has occurred. > > +**/ > > +STATIC > > +EFI_STATUS > > +EFIAPI > > +InstallSsdtTable ( > > + IN MEZZANINE_PROTOCOL *This, > > + IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol > > + ) > > +{ > > + EFI_ACPI_DESCRIPTION_HEADER *Ssdt; > > + UINTN SsdtSize; > > + EFI_STATUS Status; > > + UINTN Index; > > + UINTN TableKey; > > + > > + // > > + // Load SSDT table from the raw section of this FFS file. > > + // > > + for (Index = 0;; Index++) { > > + Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index, > > + (VOID **)&Ssdt, &SsdtSize); > > + if (EFI_ERROR (Status)) { > > + return EFI_NOT_FOUND; > > + } > > + if (SsdtSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER) && > > + Ssdt->OemTableId == SECURE96_SSDT_OEM_TABLE_ID) { > > + break; > > + } > > + } > > + return AcpiProtocol->InstallAcpiTable (AcpiProtocol, Ssdt, SsdtSize, > > + &TableKey); > > +} > > + > > STATIC MEZZANINE_PROTOCOL mMezzanine = { > > ApplyDeviceTreeOverlay, > > + InstallSsdtTable, > > ARRAY_SIZE (mI2c0Devices), > > 0, > > mI2c0Devices, > > diff --git a/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf b/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf > > index 72dbf1314c15..ce4c8b5f8fa5 100644 > > --- a/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf > > +++ b/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf > > @@ -21,6 +21,7 @@ [Defines] > > ENTRY_POINT = Secure96DxeEntryPoint > > > > [Sources] > > + Secure96.asl > > Secure96.dts > > Secure96.h > > Secure96Dxe.c > > -- > > 2.20.1 > >