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=DAtyfWK1; spf=pass (domain: linaro.org, ip: 209.85.221.65, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by groups.io with SMTP; Thu, 02 May 2019 02:59:02 -0700 Received: by mail-wr1-f65.google.com with SMTP id k16so2457429wrn.5 for ; Thu, 02 May 2019 02:59:02 -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=DAtyfWK1pmBJThbyv8dZWUXTg+Ba7eqL2JcrYv2z7kd8mXkfsr9ZGmblZcgKV+Gp2l OAT3coyg4H6e/bB1yFeFC/XE25rikfszdwXutex+5oRqb4LpsW76u4Sv7Gi24pWmJ5Uc a82Xk56QqR2kK1UmzXNJe4Jd2Yl8OjtbZF0nGR7pO/cNB4RPDXY+Hy1TPjBIfkMIgES3 pNusbNYBkz26Tjs773KexM/W6rDJTlV2Px10wd1slWi5hfpylGBOAmHKsBSgr0FL5XuE eZmFGpx4OOLc7PhSvtcQJLjuW+l4I3zdRRCPJoK/NnoiT4NFsN6Atp6pwPZs5q3lbUd2 yh2Q== 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=YG86LON3wHiKXtd+WfustargoBW6wVfgpG64B+IhKSUmXGUhctaBbkAmLwG1NKAW1Y H1LD8oidL0iptUhHhxXGgrJf04jG5Uhl1A6L/IejLz9/zX/DN6w4RLU2SP3O3ijox3nE 1GO5ijNor+ZjtodKDowCOa0Y3/2p3fzEr2eQ/Op5QH5/mDA2eTyV9UJh8/+5DMHcRpDa LwTgajf9H+KFUkxqVOrt10M0aVLt8QUqc5ezdqmqCsN6hfdzjtvwNrAb3MTbPP8XfJkr bLJXaNZQWXPjutmKz5Nc92PTEiBAjUT0UqzfFC7fGwKlK3v4InyVqcEICGmX3pkXGNT8 qSqQ== X-Gm-Message-State: APjAAAXxVnMVtmwRMfMT+0BVb1VfvALd5STt6rS/IHzxgWdKADXmOexw 4zDgRQ638LmNVlm2eJ/1SnOLBM7R24DLXQ== X-Google-Smtp-Source: APXvYqwONprPUvDO2Z65bvTUqOF4W7xq82vwpdf13K/ybVd96iv5rV21WvhnJh2UMDdKV662U9g1Pw== X-Received: by 2002:adf:ec0d:: with SMTP id x13mr2038263wrn.268.1556791140499; Thu, 02 May 2019 02:59:00 -0700 (PDT) Return-Path: Received: from sudo.home ([2a01:cb1d:112:6f00:2dc9:bac0:dc74:9979]) by smtp.gmail.com with ESMTPSA id j3sm10681740wrg.72.2019.05.02.02.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 02:58:59 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, graeme.gregory@linaro.org, Ard Biesheuvel Subject: [PATCH edk2-platforms v2 1/2] Platform/96Boards: add ACPI support to mezzanine/LS connector driver Date: Thu, 2 May 2019 11:58:53 +0200 Message-Id: <20190502095854.6989-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502095854.6989-1-ard.biesheuvel@linaro.org> References: <20190502095854.6989-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