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=T7WWT8r5; spf=pass (domain: linaro.org, ip: 209.85.128.65, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by groups.io with SMTP; Thu, 25 Apr 2019 05:33:02 -0700 Received: by mail-wm1-f65.google.com with SMTP id o25so9039691wmf.5 for ; Thu, 25 Apr 2019 05:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o/+3GyZCWy7NG+NLw6UVrYAf4RfiWKb0DDzufffoZ/s=; b=T7WWT8r5wVU3fPORFFbE3JvD01wf4xdkmnhJA97LdaLipREfGyeqytNYJ4K9kythSN 38g1YcTFOD4AjI5dZ8psTNl93IkghLE53y9z8ia3RTBSspc4I75bYMzsGEQeuXXipkWA Ajd/PBKOS0sbIU/6zpu/yL6aCzfKCfJvRF2SHgs3GbLKe1UBdvdszZ2mX82DAhtkNBbP jFBKbIeTKdB8QTqasACROTvVdSSRalx7QXb92Ij4uMhrOm4nzYfJUCsFjZ9EY4X98PVZ Fg6SgzOKCU0kuCc1DOmCvg1McMpDDQnnl88awhYhnenKTl74aM7Bd3mmK2tHQv3RVcLL wAfA== 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=o/+3GyZCWy7NG+NLw6UVrYAf4RfiWKb0DDzufffoZ/s=; b=COvhMICGecFTnyEY+VxaYxaAnTNhxrjzxIpGOThSTdoBOpe87Ro6AXVear+o2dDeb2 wnk0pEwnPp/Q+wZKF2XzA2YFxoOwz6zx2OGa35TrFxEDO6395Fhb0f3g+WxPFXCD+nS2 DJhmmMH031k7qwPuMD4Q9q1paV/IvWOBpjAEsBnPICyU3GwTYXjxKDsIDuCsFcKlm67/ wuvr4XiA4n73id5iCH+6vLKoWQWr83QsH42b7hQMLJN2//H0BqnBTH6zTMLpFoE7zu5+ bK6T/2jYyshc70hICe3jRk42W0ZIQJLnmYN4gRFIxl0aMMp5nOOgXdWHuzhCXsLG5xVp IKPQ== X-Gm-Message-State: APjAAAU6SkOg6S9ZCZ0a36fpOD9V5rvcqaOJm3l10WgIAbDJEKhQFUH3 nbjfbDkFMwhulGIhP/4hOk8bcaQIYQ3BMw== X-Google-Smtp-Source: APXvYqwRFVMt49bMG4rDTduOh6Qlw15uMtfdggQewb25qD97xkBeg378GiRpQC2YWa+gztuMiDLitw== X-Received: by 2002:a1c:2087:: with SMTP id g129mr3606176wmg.114.1556195579767; Thu, 25 Apr 2019 05:32:59 -0700 (PDT) Return-Path: Received: from sudo.home ([2a01:cb1d:112:6f00:95f:9014:5be9:5288]) by smtp.gmail.com with ESMTPSA id o6sm43753488wre.60.2019.04.25.05.32.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 05:32:58 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, graeme.gregory@linaro.org, masahisa.kojima@linaro.org, Ard Biesheuvel Subject: [PATCH edk2-platforms 2/3] Platform/96Boards: add ACPI support to mezzanine/LS connector driver Date: Thu, 25 Apr 2019 14:32:53 +0200 Message-Id: <20190425123254.16396-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190425123254.16396-1-ard.biesheuvel@linaro.org> References: <20190425123254.16396-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Make the LS connector mezzanine support code ACPI aware, and invoke the appropriate hook in the driver code to install a SSDT instead of a DT overlay when running on a system that is booting in ACPI mode. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Platform/96Boards/Include/Protocol/Mezzanine.h | 21 ++++++++++++ Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c | 35 ++++++++++++++------ Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf | 1 + 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Platform/96Boards/Include/Protocol/Mezzanine.h b/Platform/96Boards/Include/Protocol/Mezzanine.h index 9847649d2ac3..97f43e9a920f 100644 --- a/Platform/96Boards/Include/Protocol/Mezzanine.h +++ b/Platform/96Boards/Include/Protocol/Mezzanine.h @@ -16,6 +16,7 @@ #define _96BOARDS_MEZZANINE_H_ #include +#include #include #define MEZZANINE_PROTOCOL_GUID \ @@ -39,12 +40,32 @@ EFI_STATUS IN OUT VOID *Dtb ); +/** + 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. +**/ +typedef +EFI_STATUS +(EFIAPI *INSTALL_SSDT_TABLE) ( + IN MEZZANINE_PROTOCOL *This, + IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol + ); + struct _MEZZANINE_PROTOCOL { // // Get the device tree overlay for this mezzanine board // APPLY_DEVICE_TREE_OVERLAY ApplyDeviceTreeOverlay; // + // Install the mezzanine's SSDT table + // + INSTALL_SSDT_TABLE InstallSsdtTable; + // // The number of devices on LS connector I2C bus #0 // UINT32 I2c0NumDevices; diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c index f19d95635056..27044c5da699 100644 --- a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -97,7 +98,7 @@ InstallHiiPages ( STATIC VOID EFIAPI -ApplyDeviceTreeOverlay ( +PublishOsDescription ( EFI_EVENT Event, VOID *Context ) @@ -105,11 +106,30 @@ ApplyDeviceTreeOverlay ( VOID *Dtb; MEZZANINE_PROTOCOL *Mezzanine; EFI_STATUS Status; + EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol; + + Status = gBS->LocateProtocol (&g96BoardsMezzanineProtocolGuid, NULL, + (VOID **)&Mezzanine); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: no mezzanine driver active\n", __FUNCTION__)); + return; + } + + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, + (VOID **)&AcpiProtocol); + if (!EFI_ERROR (Status)) { + Status = Mezzanine->InstallSsdtTable (Mezzanine, AcpiProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table - %r\n", + __FUNCTION__, Status)); + } + return; + } // // Find the DTB in the configuration table array. If it isn't there, just - // bail without an error: we may be running on an ACPI platform even if - // this driver does not support it [yet]. + // bail without an error: the system may be able to proceed even without + // ACPI or DT description, so it isn't up to us to complain about this. // Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb); if (Status == EFI_NOT_FOUND) { @@ -117,13 +137,6 @@ ApplyDeviceTreeOverlay ( } ASSERT_EFI_ERROR (Status); - Status = gBS->LocateProtocol (&g96BoardsMezzanineProtocolGuid, NULL, - (VOID **)&Mezzanine); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a: no mezzanine driver active\n", __FUNCTION__)); - return; - } - Status = Mezzanine->ApplyDeviceTreeOverlay (Mezzanine, Dtb); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_WARN, "%a: failed to apply DT overlay - %r\n", __FUNCTION__, @@ -211,7 +224,7 @@ EntryPoint ( Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, - ApplyDeviceTreeOverlay, + PublishOsDescription, NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent); diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf index 1bf528ceaa84..20b9637c1923 100644 --- a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf @@ -46,6 +46,7 @@ [LibraryClasses] [Protocols] g96BoardsLsConnectorProtocolGuid ## PRODUCES g96BoardsMezzanineProtocolGuid ## CONSUMES + gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES [Guids] gEfiEndOfDxeEventGroupGuid -- 2.20.1