From nobody Sat Apr 27 15:32:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+79132+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79132+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1628731361; cv=none; d=zohomail.com; s=zohoarc; b=BvJuEt8IlzlmN7PPuOY6GW4nZhG2riXiQln2x3JaPzpkZhwd06siUwwCtj0tvlaq91HWt0nhzZaTxAIQ1gmsimEwdcqQj13qWHKxbGOQ7x0HuhvhU806oIZJvoYMg01sYnV634ueiijBmQHO3X8rYWO8HXBsBL84Gc7jGFlxjNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628731361; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=uhVfKy2sPlR8nq9XaKdlojxj7fAV6x0dZg7Ap4Uu5Bw=; b=luuU37O9OXaMynYvbW7qtXL1wirV+UfwGe6w+2AJuwwbaOyLyg7tljtkQVSEzNBeKwwLEIY4bBXUTY3LKOFNCuGoXiCGS94nymOSrjInK5N10J4nkZs3jIC2LU1WQi5QeLipTCLSnAEh3pWm9emD8g3rAKufD68fKDfNbCHNGuI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79132+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1628731361352439.42219213405053; Wed, 11 Aug 2021 18:22:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jAhOYY1788612xT64ev2Ds75; Wed, 11 Aug 2021 18:22:41 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web09.16640.1628731360062511526 for ; Wed, 11 Aug 2021 18:22:40 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10073"; a="202441805" X-IronPort-AV: E=Sophos;i="5.84,314,1620716400"; d="scan'208";a="202441805" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2021 18:22:39 -0700 X-IronPort-AV: E=Sophos;i="5.84,314,1620716400"; d="scan'208";a="507310892" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.212.189.134]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2021 18:22:38 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: nathaniel.l.desimone@intel.com, Michael Kubacki , Chasel Chiu , Sai Chaganty , Benjamin Doron Subject: [edk2-devel] [edk2-platforms][PATCH v1] KabylakeSiliconPkg/PchPmcLib: Add GetSleepTypeAfterWakeup() Date: Wed, 11 Aug 2021 18:22:25 -0700 Message-Id: <20210812012225.28357-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: v2Wi1DfFZlJCEO0nRS87M8IQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1628731361; bh=rqH3oyAzaKkD/rlCQ3D7gS5BbZQWzRE6CuV3nlEyHQI=; h=Cc:Date:From:Reply-To:Subject:To; b=ch4vrYQlKNgrInHpd6y0UWQpo7DkcZg2DRC6X61MR/vMu+Ad43lXyeOXx6IEymaPzG5 1YKwJ9gZrDE8iRDMUSdcg0rh9PB3rScFVlrjWypc25dr60ZBTl3sPBfAYR7PELLgb6xjL BKR+8kSQdrgXOeXz0t6SXlck4bMN5fe/zpY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1628731361697100001 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Adds the capability to get the system sleep type after wakeup to PchPmcLib in KabylakeSiliconPkg. This is needed by platforms to determine the Sx resume state. Cc: Chasel Chiu Cc: Sai Chaganty Cc: Nate DeSimone Cc: Benjamin Doron Signed-off-by: Michael Kubacki Reviewed-by: Chasel Chiu Reviewed-by: Sai Chaganty =20 --- Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PchPmcLib.= c | 54 ++++++++++++++++++++ Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/PchPmcLib.h = | 15 ++++++ Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PeiDxeSmmP= chPmcLib.inf | 4 ++ 3 files changed, 73 insertions(+) diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLi= b/PchPmcLib.c b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPm= cLib/PchPmcLib.c index 790af0a7a1..3c9c4c2a2d 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PchPm= cLib.c +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PchPm= cLib.c @@ -128,3 +128,57 @@ PchIsRtcBatteryGood ( } return FALSE; } + +/** + Returns the sleep type after system wakeup. + + @param[out] SleepType Sleep type to be returned. + + @retval TRUE A wake event occurred without power failure. + @retval FALSE Power failure occurred or not a wakeup. + +**/ +BOOLEAN +EFIAPI +GetSleepTypeAfterWakeup ( + OUT UINT32 *SleepType + ) +{ + UINT16 Pm1Sts; + UINT32 Pm1Cnt; + UINTN PmcBaseAddress; + + PmcBaseAddress =3D MmPciBase ( + DEFAULT_PCI_BUS_NUMBER_PCH, + PCI_DEVICE_NUMBER_PCH_PMC, + PCI_FUNCTION_NUMBER_PCH_PMC + ); + + /// + /// Read the ACPI registers + /// + Pm1Sts =3D IoRead16 (PcdGet16 (PcdAcpiBaseAddress) + R_PCH_ACPI_PM1_STS= ); + Pm1Cnt =3D IoRead32 (PcdGet16 (PcdAcpiBaseAddress) + R_PCH_ACPI_PM1_CNT= ); + + /// + /// Get sleep type if a wake event occurred and there is no power failur= e and reset + /// + if ((Pm1Sts & B_PCH_ACPI_PM1_STS_WAK) !=3D 0) { + if ((MmioRead16 (PmcBaseAddress + R_PCH_PMC_GEN_PMCON_B) & (B_PCH_PMC_= GEN_PMCON_B_RTC_PWR_STS | B_PCH_PMC_GEN_PMCON_B_PWR_FLR)) =3D=3D 0) { + *SleepType =3D Pm1Cnt & B_PCH_ACPI_PM1_CNT_SLP_TYP; + + return TRUE; + } else { + /// + /// Clear Wake Status (WAK_STS) and Sleep Type (SLP_TYP) + /// + IoWrite16 (PcdGet16 (PcdAcpiBaseAddress) + R_PCH_ACPI_PM1_STS, B_PCH= _ACPI_PM1_STS_WAK); + Pm1Cnt &=3D ~B_PCH_ACPI_PM1_CNT_SLP_TYP; + IoWrite32 (PcdGet16 (PcdAcpiBaseAddress) + R_PCH_ACPI_PM1_CNT, Pm1Cn= t); + + return FALSE; + } + } + + return FALSE; +} diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/PchPmcLib= .h b/Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/PchPmcLib.h index ec98e07100..f84606d31c 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/PchPmcLib.h +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/PchPmcLib.h @@ -41,4 +41,19 @@ PchIsRtcBatteryGood ( VOID ); =20 +/** + Returns the sleep type after system wakeup. + + @param[out] SleepType Sleep type to be returned. + + @retval TRUE A wake event occurred without power failure. + @retval FALSE Power failure occurred or not a wakeup. + +**/ +BOOLEAN +EFIAPI +GetSleepTypeAfterWakeup ( + OUT UINT32 *SleepType + ); + #endif // _PCH_PMC_LIB_H_ diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLi= b/PeiDxeSmmPchPmcLib.inf b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/Pei= DxeSmmPchPmcLib/PeiDxeSmmPchPmcLib.inf index 8b46a59b67..1e6103f4ca 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PeiDx= eSmmPchPmcLib.inf +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchPmcLib/PeiDx= eSmmPchPmcLib.inf @@ -33,5 +33,9 @@ MdePkg/MdePkg.dec KabylakeSiliconPkg/SiPkg.dec =20 =20 +[Pcd] +gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress + + [Sources] PchPmcLib.c --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#79132): https://edk2.groups.io/g/devel/message/79132 Mute This Topic: https://groups.io/mt/84831387/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-