From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web09.17547.1628737742856847181 for ; Wed, 11 Aug 2021 20:09:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=PlOfh+od; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: nathaniel.l.desimone@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10073"; a="195537130" X-IronPort-AV: E=Sophos;i="5.84,314,1620716400"; d="scan'208";a="195537130" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2021 20:09:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,314,1620716400"; d="scan'208";a="517274371" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by FMSMGA003.fm.intel.com with ESMTP; 11 Aug 2021 20:08:58 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 11 Aug 2021 20:08:57 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Wed, 11 Aug 2021 20:08:57 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10 via Frontend Transport; Wed, 11 Aug 2021 20:08:57 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.10; Wed, 11 Aug 2021 20:08:57 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aXq+Werd6b+W/uUyB8h5I4WaKCWIzRzDFsh4i8y5ZTL5Is8At4QQxFcykSqYMvxMZcrK/W9tLVyEWeuP+uOSInzUxrhx0jqj0lXloDVcDyDH3GhfwQDFzJEJz5A3t110vxDW1Lgyuk8FZEUMDpnJGbvHWGPO2DiE9ddh2R1DWIghGxltVytY5RMLYhD4FiqGbeGHx85vhxbEU1cGLIy5dVaTN57BIVZgqunxUDJ0fA2smm5Lu4N/X9BnuhFezvpY2SQhD0VhE18yTfGS1ZrB+UmKc5yTlLt1cn1Izp8QM0NBSjCZFJmnw2cC71aJNHA2Z0P47s9X/8lTuMIE0/wHvA== 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=6tbEbjab4SCmrhHqypP7O744ASYWa/9d/QilVneWP+U=; b=g+WzkSMJwJmf0XeexCMqes8+P7B2DUh+b7SJXtEVKUQfTyq9imH7OwuLBBFNCqwISwAqHLztcxhDSqcFnnu/Rjylywn14VGXplim3MTrpP5PtKMiAdqux/kFwHYonQ7Ez2WizSWWf4+u2cwo+39li1rMrtIwnhSLJRi4u7EPt40LxDY1FtR3mhO7vWjKe85FKyi2+zz7u9BsyB8Y+jp7gDM0x/s37n7ctLpiIEMpIFL7gCtkyRwOb9trU48rQTPeWVXf5dIho8KqHYqipJiSYIjQWUsJ7z4IpoHcuzMtiHUNGJoyknevEnWOkHQIDd7Kqqj86jRBNXb/pDWwbeIx3A== 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=6tbEbjab4SCmrhHqypP7O744ASYWa/9d/QilVneWP+U=; b=PlOfh+odQGjbp016ig0tzqU9HPVsfMaYxnFD2xT7PlRVDtgmI/XhVSwk5x4gZ741SpQiqZRANB37yDtLnEg4rsZiSkvblEaXR5zq1t3md4wdqdYvR2d6veNGQDM8gpG1h90n0kQ0H3LyHcHR5EOGXaWaK5U5lmInighNMF2ZMVo= Received: from MWHPR1101MB2160.namprd11.prod.outlook.com (2603:10b6:301:5b::12) by MWHPR11MB1357.namprd11.prod.outlook.com (2603:10b6:300:2b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Thu, 12 Aug 2021 03:08:56 +0000 Received: from MWHPR1101MB2160.namprd11.prod.outlook.com ([fe80::546c:f20e:35d2:65a7]) by MWHPR1101MB2160.namprd11.prod.outlook.com ([fe80::546c:f20e:35d2:65a7%5]) with mapi id 15.20.4415.016; Thu, 12 Aug 2021 03:08:55 +0000 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "Desimone, Nathaniel L" CC: Michael Kubacki , "Chiu, Chasel" , "Chaganty, Rangasai V" , Benjamin Doron Subject: Re: [edk2-devel] [edk2-platforms][PATCH v1] KabylakeSiliconPkg/PchPmcLib: Add GetSleepTypeAfterWakeup() Thread-Topic: [edk2-devel] [edk2-platforms][PATCH v1] KabylakeSiliconPkg/PchPmcLib: Add GetSleepTypeAfterWakeup() Thread-Index: AQHXjxiRV6c75XLABESMFloUH8CzcKtvMH/Q Date: Thu, 12 Aug 2021 03:08:55 +0000 Message-ID: References: <169A6A8AFE09D4DA.28384@groups.io> In-Reply-To: <169A6A8AFE09D4DA.28384@groups.io> 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: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: facd4c46-13da-4d17-7366-08d95d3e857e x-ms-traffictypediagnostic: MWHPR11MB1357: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1186; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MalhVnD7Grz4V2279XXxOvRVQnkyRZ/JL3r+pmdUmKuG0+bQ5salnw38mY3Ng79dcfvUqTlsMc34rZze3odEHPj0H+LmP79dTazFI/YeVBb5YEaOrOPcwy3THLJ6Nj+ncrzcGCb+43mnANwb7epBOC+yvRQwRioiZ1UvFDXDD+TL10AYl+gx8xGbwMeGZyJPeNRDkcSXlxzMTDHMnHmJNsovkDvrEVYrl6CaZ9vkTGb6fqSqouiAgBH0R5ohB702ECQr/Ul0G/DHgjSxpjT4M/ZXzueN8DXrXiGDD/RvAa+7nedNAwPcVAKn12Mt/fDEz44QEWrSpKw9g5VIXTvg3P0nMgriQsy+4ZuFsrXGuPOazcOIDfGbZ5xC3jUh5idOgBHUjl1erWHNRs2H8cKhEsKaGqbFmy4q1M18wzfjsFBjGuAQyepxkjifV+L6VOOOdCPrPhmqEc0B4ShLX0Fevmfe2IX+zsKGrQLSA+aFXDxy5qZnBUtoAhYu3+hYKzgSwfeVysfUYLP9f+//f7DC8M9AHqeUO4w1hiFDxtPgwq/xxodblkXQXe1zCg2dbw3VKzv4BVMkfj61qTXm65zeHYIbi02FQmZkShX728DFbctTHwZdw15hXWZVjNZUCrbbns0mkgiFj4mDohej8ntmkJy4h+QO4wQ9ZF0Z4hNNgt3bsvT+lpeQwv310ybmdUcV9Ju8R07HJh5t8MGQ/mO+LYbUNjywAGlITQi9knHkr/XqHdxaMtVgvw5lVULhzwg/WGIEtCx+0L/NnW4qAX7kc0Ppw3PPedD31BiqJIPIrxcv0Xd7fdLH2s98TN9nPnrIMKYXiB48EzvHiGucLGctO65toAEby2fP5xzkYp/fUKo= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1101MB2160.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(366004)(376002)(346002)(136003)(396003)(64756008)(9686003)(33656002)(66556008)(76116006)(66446008)(66476007)(66946007)(316002)(55016002)(86362001)(186003)(478600001)(966005)(83380400001)(5660300002)(38070700005)(52536014)(7696005)(6506007)(8936002)(4326008)(38100700002)(26005)(122000001)(8676002)(53546011)(54906003)(110136005)(2906002)(71200400001)(213903007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?hBEEfv7LWiq7Swig3hMKANbQJ4zEAXCUvpLnR5PIW+dgOdbVL4lFb5nVeHSU?= =?us-ascii?Q?HNSLSpeCWT0+cSTwO0gLwW7Ul07nPqyKBLFtMnTmed44zaDTYuyi/kfzSldw?= =?us-ascii?Q?CshGt2ctYdPRokdDZG9aeNlUjsuLg8UMQ3LrxXlh2S1/L2o/7wFeecChhy0c?= =?us-ascii?Q?eOTAxmQqtfA9rvXEwJMchotTjqasG2YhaHC61UZAHhbDJ2BnEKivBWqdMcjz?= =?us-ascii?Q?ARvLRkajEl80ELD+Anvu0MHlBKcRm/qLgyr3rlPDyICqjIdZBd3D3bBqOajr?= =?us-ascii?Q?SgtBSUHohRHWt4fRxLaHAVh+ZxNbzzuU5Y+cHZYh9+vxE3flEYjQeollvULd?= =?us-ascii?Q?HWsuOw5knDiXYowr7aCQfhSEg3IpGqpR6k7Z1CizpHj0cB0uYpF3BrKF0Qdc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CIzFN5WG24oSNLhtTQgffLrVa5n?= =?us-ascii?Q?kc/hnN3gsKusUthTjKQNMUip?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR1101MB2160.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: facd4c46-13da-4d17-7366-08d95d3e857e X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Aug 2021 03:08:55.6749 (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: FIV+7c8WalOmm2pteYLSLev1cQE4GiugcqEsmYAgIaaBPKo9TvySZ8r3HsdOFphY7dmYKeH7eWyFhWkFgUhWayPxvJty/oxLh6P8/Diyw6A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1357 Return-Path: nathaniel.l.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nate DeSimone -----Original Message----- From: devel@edk2.groups.io On Behalf Of Nate DeSimon= e 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-devel] [edk2-platforms][PATCH v1] KabylakeSiliconPkg/PchPmcL= ib: Add GetSleepTypeAfterWakeup() 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