From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by mx.groups.io with SMTP id smtpd.web10.59400.1629312540120519781 for ; Wed, 18 Aug 2021 11:49:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N2Z+X9X1; spf=pass (domain: gmail.com, ip: 209.85.160.178, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qt1-f178.google.com with SMTP id b1so2407390qtx.0 for ; Wed, 18 Aug 2021 11:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ag5SngYTTYnV1njmkC6Pz69ffZnuy+PlA8PlWOyLNXQ=; b=N2Z+X9X1Jpv8zODTOizHrT0tjgrh9jkx0dd815SK4T55rxFRW1sa/6Yt/mAx4Uwd3W MJfqg9Dkehzt8lSnr9m7lf+HsCj+smnyN5g2fRWMJgc3ritIe0vG066h4sySdfJ3E5j3 GfOzCnQD82ICNKF/aAOhyawCX45TglKlXlkavMh+IhQk9URVMVzp3lYciegjqj+kzoOq 7+Im+ZJaNFBGJOBCbAzSqoeX/YWSxX5efvBuMes1PpPVcFkIPzs0IaYHaDjS/C7pIiYg j6Ll2cGD4CuAClRbbjRdgTj20Ry9K2q4hyNaJw1NCSGqLrLb4LbQ/arXzD3ZLKW+nZPZ sTgw== 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=ag5SngYTTYnV1njmkC6Pz69ffZnuy+PlA8PlWOyLNXQ=; b=SwWWuITZthwTHe21DduFfdN0japGTtZvXEBm3lX5A2IGfnbxKKgWERpX5C6u71qU3y +vqntFjzGwijjoL949G/nyNYz/LqoYXo00lPa5sOdvynt5qYgFkK1fAI2q1rpLPDDB7c jcE6KEmexT1/SAdzPxnu+/Ft0rCymXMFGupSI6aBKt1grqHZyIzc1MXhzRCYxh1ifJbC 0baHqvjLMCj5sM4wLDKTIy76fJdfTsq7FayUQOT5MH+e9Uxi3rZqKqiBOOhXsqyKNZju Vjt/RZP/pRwUgZm47DCqMh0NEDW4GGjYt7NGHQNqsaS5vNXTxWHvrCli/4Qy8BPdhbad SqlA== X-Gm-Message-State: AOAM530yWLLV3K9rHD37b/xbLZGai5qXHRIDnOtlHi7XiRcM56U5zHDf iTX/zMCzcNSy28Wvjc0ZkXl81Sb0HKs= X-Google-Smtp-Source: ABdhPJwHUdWqwlE27C865xSHkLj6bzjN3t49h7kLqBBSEJxbTljNoybOmBzUtRNQDHV6z1bUQmthRg== X-Received: by 2002:ac8:7154:: with SMTP id h20mr9151125qtp.251.1629312539170; Wed, 18 Aug 2021 11:48:59 -0700 (PDT) Return-Path: Received: from benjamind-benjamindomain.. ([2607:f2c0:e98c:24:6c37:ffa5:42b4:be78]) by smtp.gmail.com with ESMTPSA id z186sm329739qke.59.2021.08.18.11.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 11:48:58 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Isaac Oram , Michael Kubacki Subject: [edk2-platforms][PATCH v3 1/7] KabylakeOpenBoardPkg/BaseEcLib: Add some common EC commands Date: Wed, 18 Aug 2021 14:48:56 -0400 Message-Id: <20210818184903.7445-2-benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210818184903.7445-1-benjamin.doron00@gmail.com> References: <20210818184903.7445-1-benjamin.doron00@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=0D );=0D =0D +/**=0D + Read a byte of EC RAM.=0D +=0D + @param[in] Address Address to read=0D + @param[out] Data Data received=0D +=0D + @retval EFI_SUCCESS Command success=0D + @retval EFI_DEVICE_ERROR Command error=0D + @retval EFI_TIMEOUT Command timeout=0D +**/=0D +EFI_STATUS=0D +EcRead (=0D + IN UINT8 Address,=0D + OUT UINT8 *Data=0D + );=0D +=0D +/**=0D + Write a byte of EC RAM.=0D +=0D + @param[in] Address Address to write=0D + @param[in] Data Data to write=0D +=0D + @retval EFI_SUCCESS Command success=0D + @retval EFI_DEVICE_ERROR Command error=0D + @retval EFI_TIMEOUT Command timeout=0D +**/=0D +EFI_STATUS=0D +EcWrite (=0D + IN UINT8 Address,=0D + IN UINT8 Data=0D + );=0D +=0D #endif=0D 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.=0D //=0D #define EC_C_FAB_ID 0x0D // Get the board fab ID in = the lower 3 bits=0D +#define EC_C_ACPI_READ 0x80 // Read a byte of EC RAM=0D +#define EC_C_ACPI_WRITE 0x81 // Write a byte of EC RAM=0D =0D #endif // EC_COMMANDS_H_=0D 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;=0D =0D EC_COMMAND_TABLE mEcCommand[] =3D {=0D - {EC_C_FAB_ID , 0, 2, TRUE} // Get the board fab ID i= n the lower 3 bits=0D + {EC_C_FAB_ID , 0, 2, TRUE}, // Get the board fab ID i= n the lower 3 bits=0D + {EC_C_ACPI_READ , 1, 1, TRUE}, // Read a byte of EC RAM= =0D + {EC_C_ACPI_WRITE , 2, 0, TRUE} // Write a byte of EC RAM= =0D };=0D =0D //=0D 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 @@ =0D [Sources]=0D BaseEcLib.c=0D + EcCommands.c=0D 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=0D + Common EC commands.=0D +=0D +Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Read a byte of EC RAM.=0D +=0D + @param[in] Address Address to read=0D + @param[out] Data Data received=0D +=0D + @retval EFI_SUCCESS Command success=0D + @retval EFI_DEVICE_ERROR Command error=0D + @retval EFI_TIMEOUT Command timeout=0D +**/=0D +EFI_STATUS=0D +EcRead (=0D + IN UINT8 Address,=0D + OUT UINT8 *Data=0D + )=0D +{=0D + UINT8 DataSize;=0D + UINT8 DataBuffer[1];=0D + EFI_STATUS Status;=0D +=0D + if (Data =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + // Prepare arguments for LpcEcInterface()=0D + DataSize =3D 1;=0D + DataBuffer[0] =3D Address;=0D +=0D + Status =3D LpcEcInterface (EC_C_ACPI_READ, &DataSize, DataBuffer);=0D + if (EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D +=0D + // Write caller's pointer from returned data and return success=0D + *Data =3D DataBuffer[0];=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Write a byte of EC RAM.=0D +=0D + @param[in] Address Address to write=0D + @param[in] Data Data to write=0D +=0D + @retval EFI_SUCCESS Command success=0D + @retval EFI_DEVICE_ERROR Command error=0D + @retval EFI_TIMEOUT Command timeout=0D +**/=0D +EFI_STATUS=0D +EcWrite (=0D + IN UINT8 Address,=0D + IN UINT8 Data=0D + )=0D +{=0D + UINT8 DataSize;=0D + UINT8 DataBuffer[2];=0D +=0D + // Prepare arguments for LpcEcInterface()=0D + DataSize =3D 2;=0D + DataBuffer[0] =3D Address;=0D + DataBuffer[1] =3D Data;=0D +=0D + return LpcEcInterface (EC_C_ACPI_WRITE, &DataSize, DataBuffer);=0D +}=0D --=20 2.31.1