From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.19244.1628752941266198993 for ; Thu, 12 Aug 2021 00:22:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ct6YMB1W; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: rangasai.v.chaganty@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10073"; a="202484424" X-IronPort-AV: E=Sophos;i="5.84,315,1620716400"; d="scan'208";a="202484424" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2021 00:22:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,315,1620716400"; d="scan'208";a="421820311" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP; 12 Aug 2021 00:22:15 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Thu, 12 Aug 2021 00:22:15 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Thu, 12 Aug 2021 00:22:14 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10 via Frontend Transport; Thu, 12 Aug 2021 00:22:14 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.172) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.10; Thu, 12 Aug 2021 00:22:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GJnvQOcRlQz5PiXWcnnlqWPb8X5LHYcLyJekgkpedb+oUwxZ42codkPBfxNCqREwo+eebTuWQ1UkXCjfyJLOTKMFBL2qGOwaXNC2nMSRKlyN+Rb6JyTIbumFsEMawOgKri26lk3gz2bGnHxUqTzb5tc18BUCEo3I/b1hQFVzyHn41jGKJGtZzrYhi7/nJQX3kpCzFfnkH72FIbQkpMzIXgMFgM0Kzw8d6l/8TOuMenmDUlpgONddxe8kkVjo8uFP8/coKrZBYfo7lRVOSTD5Weyw0GagfIUt+z7JazxlWX77O9F7X31uHKUjFQk4//joo7eAB0bLjKrDXxSX2NYxuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tBVW5TBI1+nMy0IWJnGhaFBLNK6zhXLIxZQ9166VT4Y=; b=JzCTd0ECw+K8DvCFH6lMh/iG7dJXSJquWEqF4V59eqbojPRTlJFYALxLvklyAngVnvjVn1OE1f8KGTyAWo7HUazthm0SFDo0IKwdLRnTW8VYBO0/adpCXm8qOfes2KhadnxJGXpfSWFDWqm75PgxAcWZEVx1tkVJlOncoEo6Yo6XqmYUPLu/LH6pASCbvONzxd8YeJy9rgdJWKP8CP6hA9oJWgzXep8whfVRX49SXCsg80fI+2STDCSke14dCXbWj5Q/NMSiHZ5fCj3SkeWtzjOlzJ6FrfKFn4B/FSUhoaoDAUMFp0yn/w9L1+/kFZ0TkHYkG0fET8/SmL480UQq+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tBVW5TBI1+nMy0IWJnGhaFBLNK6zhXLIxZQ9166VT4Y=; b=ct6YMB1Wsc/liU//COwSsty3xbzJj3p1PNIG62hTIslRPVwBffLrgVyzpNwGI2EZnkDGlVc/vzo8nv8wxweYj0Jyx+d4aTM/elRvd7pe3uDAiY+CFvp+1L6kE8pl5naUS0JOcTDpnQA6ivG7tu0JOrdIo7gDOpfICut7LQ/rZuM= Received: from MW3PR11MB4602.namprd11.prod.outlook.com (2603:10b6:303:52::19) by MWHPR11MB1439.namprd11.prod.outlook.com (2603:10b6:301:9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.20; Thu, 12 Aug 2021 07:22:12 +0000 Received: from MW3PR11MB4602.namprd11.prod.outlook.com ([fe80::f015:1569:4279:35e5]) by MW3PR11MB4602.namprd11.prod.outlook.com ([fe80::f015:1569:4279:35e5%3]) with mapi id 15.20.4415.017; Thu, 12 Aug 2021 07:22:12 +0000 From: "Chaganty, Rangasai V" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" CC: Michael Kubacki , "Chiu, Chasel" , Benjamin Doron Subject: Re: [edk2-platforms][PATCH v1] KabylakeSiliconPkg/PchPmcLib: Add GetSleepTypeAfterWakeup() Thread-Topic: [edk2-platforms][PATCH v1] KabylakeSiliconPkg/PchPmcLib: Add GetSleepTypeAfterWakeup() Thread-Index: AQHXjxiP2ICBlhFd90ekl3u7ewEZ0Ktvd02A Date: Thu, 12 Aug 2021 07:22:11 +0000 Message-ID: References: <20210812012225.28357-1-nathaniel.l.desimone@intel.com> In-Reply-To: <20210812012225.28357-1-nathaniel.l.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4e8e6328-cec8-40af-cb07-08d95d61e725 x-ms-traffictypediagnostic: MWHPR11MB1439: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: s3/m95PXD/q9HZmYOHpluDFrLuIsDZLKwDMhEjCTtR4UE6/NzJHsMt/zgFL1eXgg6TR5nyMcsSDWPS9Q1JzWLsrYq1zBntMCbkILMYvO1nBjXqKdbTcQojyXU4PF+ewTY2NZ93efQlGd5JWWKtBVl8OvlfEqXFL0Gvm4hg6pZQRVVumFYFTg+qT8i0ANQNwvX1bFa+2pe4rwhIZUBfllfDKxrZf52AOsDmika07TtXuGHG8lCcfgMUKJIZBy3zH4zhb3EUmXtkiwa3VwvYPGz+7H0eIN7SwqPSeyE1KX1Q3KHCdb74QsGLIL7x5JrjWogw8jHmVIjPdd0cEvY9NLHtB1g8W4aPGaqXn4LkG/KrUk3zjXi+YZA9KdmYe/2OgIGwTmej/1CGPUisP8duzp5H5QGBrJG/TNyL7Z1FFHYPeY7RhndZMWJrLKd0GqPzM2otxhRGXS7Pf6Fc7PxSTRdf1QPt4STeXEmKG/TAIcpmhjUB8dDhk8kPZw5zhtqcz3eDRjLFAE+qEPlYlpp8wyyVarsWs31L5Cxcx2qeK3/Z08vKzZEGAPvUeRwHo6h+YpwSKnrehq2+rfdtenY0qzanhXKLk4684GxAIflhyvcPMd7rKeoCZ4sdZhQuCmfbAyi1jOj5YnC7BrdU/6PeyyQNS90mhihnY0GoaOoccPqTeRLqXGlgDq6yNit5wfvfdIqL+bYUD9E84XBth/7hSONaVR/CCUdBdslI6l9KJ5KJQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4602.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(346002)(136003)(376002)(366004)(396003)(186003)(86362001)(478600001)(26005)(38100700002)(122000001)(38070700005)(4326008)(54906003)(7696005)(316002)(33656002)(83380400001)(53546011)(6506007)(110136005)(2906002)(5660300002)(8676002)(71200400001)(66946007)(64756008)(66556008)(66446008)(9686003)(66476007)(8936002)(52536014)(55016002)(76116006)(213903007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?nqtEXbfd8qL24C0cZqfXXf0y/zVertdVsXvaF8kd4YGSFnPd98Q1H8N5+KRe?= =?us-ascii?Q?NT9DmdUP0Zb3WajaaOm8DTfh1a5oV9eQH8guKtV4Vm0CsoIdi9DLEmu37Yxa?= =?us-ascii?Q?w7zZ4U3sIyf8MNu/+1CotQqI01d6aurb0JT6gQFXkpJv/FI+ylo/hqsPRKVl?= =?us-ascii?Q?hPsktcJ3ANKIl77WlhI8UPYnUVXRH4ynrmHhBs2/VcE8TbyzWpgYnpgGvYsF?= =?us-ascii?Q?rZls/r4EXkBqsVMlXeATOC29+c9+SLAWd9yGs5KqNyO/cjTpViiQBm8Ml1Vl?= =?us-ascii?Q?iSvQBun+3RofHZZcmkMiy8zXYwoI39i0vFpTK+vvQdB5rHgA3Dae01bZNFwM?= =?us-ascii?Q?9wU0Yb0qAK44IDP6DJ0AFp7Ld4V3wb9gupTiiiXvX+ROJ6xkufVaMQVtJA7w?= =?us-ascii?Q?ObkVqRBqCv5bwDoTMQTcH1GDKCTEQBjb8lcvIAb9TlSFZCe1azb0ty/APSfz?= =?us-ascii?Q?fU+jlPq/2qJw4uko53OOgiWPihTBPXPvPEC87j9ZK1jeJxU5jjJ8kQaiBxUR?= =?us-ascii?Q?6n1gqqGLMv465sIi524DZcPi9+oA29ccsbdCB9qx+4YwAlCdjL7dwrkOMoNX?= =?us-ascii?Q?tss/JnrgQimF5VLkbGAQuNcUKmHZm+vrBAA0JkSJGmGK+ZEHzOwt/lqBeNJz?= =?us-ascii?Q?Fx3MKym4YFTUdV7RY6mlfzBz4VOZz9jdGsboDG26zd5zMAfQfKvmr45vgXzj?= =?us-ascii?Q?jFvmME16AS4xjUH1tLWydnkLTTF4cjjTRyW5SeITamwo8WA21jJNigQwHL+N?= =?us-ascii?Q?8IjWB/yO3bT3Y1l78QWs133xAXI3SU/TLZ9jEM7GuwyQ7YcNWg4FrlPfmMgQ?= =?us-ascii?Q?fgaNDFEUdNrHZgoKYPLxcvBdZPCMyqzkY41uPX1sz0K7arVwZ8R4Ub0OZRAv?= =?us-ascii?Q?yxKDHGl8LsT8x85JRnP+XYMra6d54fjpoI+ZoTG0RMtyYueQ6pSVJnL62O7R?= =?us-ascii?Q?9RcfSKKMGP0G0oxlqgO+drM97kPe0cfQRlhW2mn43itz6zByI1HZ+yrLWDZ5?= =?us-ascii?Q?60NDNWxjexsQRld/Tf2sLV7au2evNmHTpuri12Q99XnvGMfmLF+MVWjxHqki?= =?us-ascii?Q?+TALC4IPY8lGBnwVI2yhqm4qEsjLqCp/2+iBRdzTTUgb2E2CQ0b98PqDn7e1?= =?us-ascii?Q?BNdvTjIkcq0nbQvAhWgjS+nr9gtx4GV+YPR3qlQ4SFJiZTR80aiXmxJ68/jY?= =?us-ascii?Q?UWRy7W+ulwduacK3aA07GHwqjG9W6BO7XL0HRtjDWCddDp97JZHQF4JczlRG?= =?us-ascii?Q?ndXNxs/EDsKFmJI894Dx6pqAKm+z7CJWBlaFSRdTCQDbJ/+nlv/poc8avBO7?= =?us-ascii?Q?xsvMVRjpFMrKYXf62OPeQuGk?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4602.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e8e6328-cec8-40af-cb07-08d95d61e725 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Aug 2021 07:22:11.9595 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: q+8b2DF8Zx3889H1rCOLgIqXKr6x060Hfy6PM3+VKBQzSKNuShhPiMhf3BsvKnebjhoPsghtlq4cmZFJdnFnxNz1OJiN//sNePd8GUYfTHs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1439 Return-Path: rangasai.v.chaganty@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Sai Chaganty =20 -----Original Message----- From: Desimone, Nathaniel L =20 Sent: Wednesday, August 11, 2021 6:22 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L ; Michael Kubacki= ; Chiu, Chasel ; Cha= ganty, Rangasai V ; Benjamin Doron Subject: [edk2-platforms][PATCH v1] KabylakeSiliconPkg/PchPmcLib: Add GetSl= eepTypeAfterWakeup() 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 --- 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/Pc +++ hPmcLib.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) +=20 + R_PCH_ACPI_PM1_STS); Pm1Cnt =3D IoRead32 (PcdGet16=20 + (PcdAcpiBaseAddress) + R_PCH_ACPI_PM1_CNT); + + /// + /// Get sleep type if a wake event occurred and there is no power=20 + failure 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,=20 + Pm1Cnt); + + 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/Pe +++ iDxeSmmPchPmcLib.inf @@ -33,5 +33,9 @@ MdePkg/MdePkg.dec KabylakeSiliconPkg/SiPkg.dec =20 =20 +[Pcd] +gSiPkgTokenSpaceGuid.PcdAcpiBaseAddress + + [Sources] PchPmcLib.c -- 2.29.2.windows.2