From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.25925.1629949777878542931 for ; Wed, 25 Aug 2021 20:49:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=CTDWDWMf; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: nathaniel.l.desimone@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10087"; a="204794802" X-IronPort-AV: E=Sophos;i="5.84,352,1620716400"; d="scan'208";a="204794802" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2021 20:49:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,352,1620716400"; d="scan'208";a="444408931" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga002.jf.intel.com with ESMTP; 25 Aug 2021 20:49:36 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) 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; Wed, 25 Aug 2021 20:49:36 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Wed, 25 Aug 2021 20:49:35 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Wed, 25 Aug 2021 20:49:35 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.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; Wed, 25 Aug 2021 20:49:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sk7xTZ9sCTD+POJVGAOffL4aFz1WHeI7fzQFQHr1Ve8ydo/WT3qOuQvwXkvDm29dirCrXLBAf6JVrmsCpL64iVxH6UQdJlgHB3o84DpxyjHvZ7nyOo5smx77skN6Og/E5nsC/9pWa0N9YzLI09EehP2udzzJj818tUuSI9JCLdqNOB9tcoEyZYdJdT3ejz+oUuMbJ7qz7DEVeKNo6MPRAU5rfot3AK/y8+q3JZCVnUT4Mj6XdgegHLfrPTxnuK2f1Q86q9mMFFz04iCRP6ioSE9ZKTlEYEE0+xoQi1OwqhEpzGWHPnpDUwWiKBiabrsyViz6zJTE7jRSCOhemFwveA== 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=2Z3k23U0Qp9f1ImbFxXHZb6MaR8fC6V3c7yeG265FHw=; b=EvV8x5nntt5dEovLLqsQAyd3HEYQslPugv35Yt5O4LwRLWWoud3IwkiQ39COPVbCRvgdOwod/KUv3jo57UfqwCIBZCsldcmFBj1Q90x6NnB8mhuOJi94Fdf5RJpvAskf4W57d6MWFvwvOiaSPccA+/QH04rjOSto/M8nm39Kh61fAKGLvrT25zRLCIJr6lyW3J0ZUB4xzgLxhR28H8oHAqPHkFCVYa5dJEaKzPS7EkUd/dsyMuUzg5VxSlFfRn45fEdEpiKmd3zwt0GEmrmEf8CgWiGy0eEZvwqp1FctnPCY82lHlhDlQRU/VFpGImGClsNUpUSHahuHiODAShv/Gw== 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=2Z3k23U0Qp9f1ImbFxXHZb6MaR8fC6V3c7yeG265FHw=; b=CTDWDWMf/B2KHpxTZk/DsLoUgNY2Mn3cVzxIXs7SgQROFBI2tzypEBVuz2GcLGmfIILQFmbFP8SHr6EvykYvKeWcasfnkt93WEeGDilYAx8OXTCokKXCHTyWWsmK+yPIVUlgb7Q7DKtECjDSTa0GHTfTK1GV75YTgEGcXPTG9RA= Received: from MWHPR1101MB2160.namprd11.prod.outlook.com (2603:10b6:301:5b::12) by MWHPR11MB1759.namprd11.prod.outlook.com (2603:10b6:300:111::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18; Thu, 26 Aug 2021 03:49:34 +0000 Received: from MWHPR1101MB2160.namprd11.prod.outlook.com ([fe80::4421:2284:94aa:8d3a]) by MWHPR1101MB2160.namprd11.prod.outlook.com ([fe80::4421:2284:94aa:8d3a%3]) with mapi id 15.20.4436.024; Thu, 26 Aug 2021 03:49:34 +0000 From: "Nate DeSimone" To: Benjamin Doron , "devel@edk2.groups.io" CC: "Chiu, Chasel" , "Oram, Isaac W" , Michael Kubacki Subject: Re: [edk2-platforms][PATCH v3 1/7] KabylakeOpenBoardPkg/BaseEcLib: Add some common EC commands Thread-Topic: [edk2-platforms][PATCH v3 1/7] KabylakeOpenBoardPkg/BaseEcLib: Add some common EC commands Thread-Index: AQHXlGG+kvFQVsuu/kGp2NxaKDQlnquFMekA Date: Thu, 26 Aug 2021 03:49:34 +0000 Message-ID: References: <20210818184903.7445-1-benjamin.doron00@gmail.com> <20210818184903.7445-2-benjamin.doron00@gmail.com> In-Reply-To: <20210818184903.7445-2-benjamin.doron00@gmail.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: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d3cb6c07-07dc-4756-81c7-08d9684484e5 x-ms-traffictypediagnostic: MWHPR11MB1759: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:989; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YbowirIH+XXWlxI1Jt5ZTWaBeVNkr8veGTkGH+IYE2sHvgZsYP15D1CkymaBIbEX3oaSNf9HGk6BJP1T7yOf8F16LJPDAJDmmdLuIpZ0hhbnxbOaqo4eZnUa9R6bsbs3vqHn5Y1ARZRXV89maI3KDocSnTLVYFN7d0hjlVZA8VnNp9/3I9sXVKDnZwmAo9y9FsT+gF1017cqAxiwRveP4Qrc5vtPTjrXeSMfxnhjyR7IvQyu+JnRvapxr18qOjGY8gVcFrxue91YAjgYbTIkHNLqRKiuvsq2vzyNbTKlfnfGJpbhuXfLCiRKkjMdPklgRSanMtYDIs38nfyCl8uAIFDLiZmHLTKEW5h1SMYXugnifEzwdvdIw4Gj/S/ZBLY+808IKSWpXNTjaBtIq5eP9cuaHUORp+6uqHrThNaWMKbxKGCXratXW4qKIaVum5TREKNSDm454RZqAdmajJh3WCUQbvmIqB/ULDhrFqRvHD8WXfDp/w7nqY5Fpx/Mf0jih6k/dOrgA7ADCOZuj6SmKMYAhTVhPU1lbZmqNNxN7FxxcMS2M9G3DvYwQr/ad6OaPQEbVJHOVfQbioZu6Q60IR9HOHPbFPYUyMhqgN9ZkkVhCkd2RE2R86VQAafYNTQawVQwJBLzvJr6cjVHmT8dU8dQYRxbjYtKNHq/xpH8caF1hQ0RlWAdfstZ1ZZlCir9ZJ4D7V0BhUVd05a9pPERTw== 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:(6029001)(4636009)(346002)(366004)(376002)(396003)(136003)(39860400002)(66556008)(76116006)(64756008)(66446008)(8936002)(86362001)(53546011)(6506007)(52536014)(38070700005)(110136005)(83380400001)(33656002)(71200400001)(2906002)(66476007)(4326008)(66946007)(55016002)(316002)(54906003)(7696005)(38100700002)(5660300002)(9686003)(26005)(8676002)(122000001)(186003)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?CxzCvT+pTjwmkHn9sjO2xxB3aIgQB7dblkmEe6DnUzoF9OVr0YHtPyjH15Mb?= =?us-ascii?Q?NA9w5DOrDOaB8lFdEasSjwT6XqFIwp0gNB3EGpUNsROR3MdTyIias0f3r87L?= =?us-ascii?Q?LZgDyr7jVb/5ozuPRuypsTg8YMOAuyOMBx6hZ8j7I254XGV3/5slt/tgId6y?= =?us-ascii?Q?WOBjenLNKfcn52q0sgesg3o8yn1kski05VYwvRxtZ/Q2SrysAHLg/4Db+6oz?= =?us-ascii?Q?8EN+lshPliuYpkEuFaRfBEPFChfYYla3n4aG1LXRZ/ypaOWjA8E72irTFq9K?= =?us-ascii?Q?T9q886hjv9S4y5jT0biQ2alMmbIdaza0X5dDAEsFeq9qQ8dbEmhLDcDLzt2Q?= =?us-ascii?Q?EtOFn3hSRM4teSVZY5sTzbzDh86djCEwKSZpwSxUFVMvQyH67fa8K74PSTpM?= =?us-ascii?Q?t3OuADH/s5gbDV7XcXWcaA82h46fG0V5NxhhjhvOz/jnpZr36vkP+nNxDVio?= =?us-ascii?Q?whRk+VPqEYUDZF0GnlhRs0d5GySkGak/XWMwhXNjF/aWUT2yyLvBJInLmkH3?= =?us-ascii?Q?MjcJE973o+P0RbIshFs+sz+b72TpAfhkTXalPgknkLDTwI+j+A+QH6aARUp1?= =?us-ascii?Q?1G+ite2rSeQTSKqB2MkKvJTTGQJ2BiSUuRkSYLa2zGUQaTIMuT1/XtDRH9+O?= =?us-ascii?Q?L9qCjaOV559LEsWjs+8A0ruC2cQOUXwfXNXu4KPdG1dAeQDKNd8j4EW6941s?= =?us-ascii?Q?ZJl+cREOUzkWMUcL0DZngJ8IbmhTKY4QF7TVQPm5mvemHpfTv9MfjACD4mXJ?= =?us-ascii?Q?47OP94O0YTkQnS0C4wSB+yamQW3pthn8rjQDxc3n1ASuH0DPDFo0y00t7t9L?= =?us-ascii?Q?yDr5DZFY/IlZoP0eAl2VbWjTJmTZu7VQ01XQkwfP73l5vM2Q7b1cPytXjSdn?= =?us-ascii?Q?/wCQGdMAvdgSTGmd9byssj/lLKV8KZ+8MiK6dlLYZZrIeEAwkHq2BnHOPhdk?= =?us-ascii?Q?66gFVt01e+1S7rZyBxKkgOID6dlmK9h98AYnWaRQ3qLqN01Zurd8GqOPqy1m?= =?us-ascii?Q?CT7E+TiheD0qri4X1/cBVre6eFNEFpVpqQDgR/rqcEs0q0jvP2z6L8JxPk/z?= =?us-ascii?Q?fwqpR3GWkoSMYtcx6xQ2Q/c12QkeJl5+HQPU1mAWRKA/8nzxbptAUS+H9oEr?= =?us-ascii?Q?E7smh9kFOzIhuKbR1tOGKlplRTSTSg9V9Lm4dL+zosMnHof2pzE82cQe33f7?= =?us-ascii?Q?uAPTfRfUQsvXUVAyqVvTbeJTdWfNOUMnDEVBLhSskRYeBMzvkhmU0kGANuRA?= =?us-ascii?Q?e49gqEih3R99T1mEZc/RbJ5on3QEgKDsrlXzZswe4mUEnIJVn6PksRxd+Unz?= =?us-ascii?Q?1ACdLBlZI3Uqh8FRH2YFGuep?= 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: d3cb6c07-07dc-4756-81c7-08d9684484e5 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Aug 2021 03:49:34.5354 (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: yz28ltwJzAMttN/ttKubbXbMz68rnHgVBS/UyR35BMdFDigG/t8LpVOikPuj00AMYVZwT1t8Oon3Z+kVDQg4XndTgDVrVL/9jDbA+iealh0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1759 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: Benjamin Doron =20 Sent: Wednesday, August 18, 2021 11:49 AM To: devel@edk2.groups.io Cc: Chiu, Chasel ; Desimone, Nathaniel L ; Oram, Isaac W ; Michael Kuba= cki Subject: [edk2-platforms][PATCH v3 1/7] KabylakeOpenBoardPkg/BaseEcLib: Add= some common EC commands Add EC read (0x80) and write (0x81) commands, as defined by ACPI. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Isaac Oram Cc: Michael Kubacki Signed-off-by: Benjamin Doron --- Platform/Intel/KabylakeOpenBoardPkg/Include/Library/EcLib.h | 32= +++++++++ Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Include/EcCommands.h | 2= + Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.c | 4= +- Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.inf | 1= + Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/EcCommands.c | 76= ++++++++++++++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/EcLib.h b/= Platform/Intel/KabylakeOpenBoardPkg/Include/Library/EcLib.h index 04ce076f91b7..7c58e592d965 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/EcLib.h +++ b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/EcLib.h @@ -103,4 +103,36 @@ LpcEcInterface ( IN OUT UINT8 *DataBuffer ); =20 +/** + Read a byte of EC RAM. + + @param[in] Address Address to read + @param[out] Data Data received + + @retval EFI_SUCCESS Command success + @retval EFI_DEVICE_ERROR Command error + @retval EFI_TIMEOUT Command timeout +**/ +EFI_STATUS +EcRead ( + IN UINT8 Address, + OUT UINT8 *Data + ); + +/** + Write a byte of EC RAM. + + @param[in] Address Address to write + @param[in] Data Data to write + + @retval EFI_SUCCESS Command success + @retval EFI_DEVICE_ERROR Command error + @retval EFI_TIMEOUT Command timeout +**/ +EFI_STATUS +EcWrite ( + IN UINT8 Address, + IN UINT8 Data + ); + #endif diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Include/EcCom= mands.h b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Include/EcComman= ds.h index be56d134edc7..a4ab192d8ce1 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Include/EcCommands.h +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Include/EcCommands.h @@ -40,5 +40,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Data read from the EC data port is valid only when OBF=3D1. // #define EC_C_FAB_ID 0x0D // Get the board fab ID in = the lower 3 bits +#define EC_C_ACPI_READ 0x80 // Read a byte of EC RAM +#define EC_C_ACPI_WRITE 0x81 // Write a byte of EC RAM =20 #endif // EC_COMMANDS_H_ diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLi= b.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.c index eda6f7d2e142..66bd478906fb 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.c @@ -32,7 +32,9 @@ typedef struct { } EC_COMMAND_TABLE; =20 EC_COMMAND_TABLE mEcCommand[] =3D { - {EC_C_FAB_ID , 0, 2, TRUE} // Get the board fab ID i= n the lower 3 bits + {EC_C_FAB_ID , 0, 2, TRUE}, // Get the board fab ID i= n the lower 3 bits + {EC_C_ACPI_READ , 1, 1, TRUE}, // Read a byte of EC RAM + {EC_C_ACPI_WRITE , 2, 0, TRUE} // Write a byte of EC RAM }; =20 // diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLi= b.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.inf index c7de77d80f3d..f0b4c67fffc2 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.inf @@ -27,3 +27,4 @@ =20 [Sources] BaseEcLib.c + EcCommands.c diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/EcComman= ds.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/EcCommands.c new file mode 100644 index 000000000000..d14edb75de36 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/EcCommands.c @@ -0,0 +1,76 @@ +/** @file + Common EC commands. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +/** + Read a byte of EC RAM. + + @param[in] Address Address to read + @param[out] Data Data received + + @retval EFI_SUCCESS Command success + @retval EFI_DEVICE_ERROR Command error + @retval EFI_TIMEOUT Command timeout +**/ +EFI_STATUS +EcRead ( + IN UINT8 Address, + OUT UINT8 *Data + ) +{ + UINT8 DataSize; + UINT8 DataBuffer[1]; + EFI_STATUS Status; + + if (Data =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // Prepare arguments for LpcEcInterface() + DataSize =3D 1; + DataBuffer[0] =3D Address; + + Status =3D LpcEcInterface (EC_C_ACPI_READ, &DataSize, DataBuffer); + if (EFI_ERROR(Status)) { + return Status; + } + + // Write caller's pointer from returned data and return success + *Data =3D DataBuffer[0]; + return EFI_SUCCESS; +} + +/** + Write a byte of EC RAM. + + @param[in] Address Address to write + @param[in] Data Data to write + + @retval EFI_SUCCESS Command success + @retval EFI_DEVICE_ERROR Command error + @retval EFI_TIMEOUT Command timeout +**/ +EFI_STATUS +EcWrite ( + IN UINT8 Address, + IN UINT8 Data + ) +{ + UINT8 DataSize; + UINT8 DataBuffer[2]; + + // Prepare arguments for LpcEcInterface() + DataSize =3D 2; + DataBuffer[0] =3D Address; + DataBuffer[1] =3D Data; + + return LpcEcInterface (EC_C_ACPI_WRITE, &DataSize, DataBuffer); +} --=20 2.31.1