[edk2-devel] [edk2-platforms][PATCH v2 1/5] KabylakeOpenBoardPkg/BaseEcLib: Add some common EC commands
Michael Kubacki
mikuback at linux.microsoft.com
Mon Aug 16 15:50:20 UTC 2021
Reviewed-by: Michael Kubacki <michael.kubacki at microsoft.com>
On 8/13/2021 8:24 PM, Benjamin Doron wrote:
> Add EC read (0x80) and write (0x81) commands, as defined by ACPI.
>
> Cc: Chasel Chiu <chasel.chiu at intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
> Cc: Michael Kubacki <michael.kubacki at microsoft.com>
> Signed-off-by: Benjamin Doron <benjamin.doron00 at gmail.com>
> ---
> 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
>
> );
>
>
>
> +/**
>
> + 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/EcCommands.h b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Include/EcCommands.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=1.
>
> //
>
> #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
>
>
>
> #endif // EC_COMMANDS_H_
>
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.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;
>
>
>
> EC_COMMAND_TABLE mEcCommand[] = {
>
> - {EC_C_FAB_ID , 0, 2, TRUE} // Get the board fab ID in the lower 3 bits
>
> + {EC_C_FAB_ID , 0, 2, TRUE}, // Get the board fab ID in 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
>
> };
>
>
>
> //
>
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/BaseEcLib.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 @@
>
>
> [Sources]
>
> BaseEcLib.c
>
> + EcCommands.c
>
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/BaseEcLib/EcCommands.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.<BR>
>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
>
> +**/
>
> +
>
> +#include <Base.h>
>
> +#include <Uefi.h>
>
> +#include <Library/EcLib.h>
>
> +
>
> +/**
>
> + 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 == NULL) {
>
> + return EFI_INVALID_PARAMETER;
>
> + }
>
> +
>
> + // Prepare arguments for LpcEcInterface()
>
> + DataSize = 1;
>
> + DataBuffer[0] = Address;
>
> +
>
> + Status = LpcEcInterface (EC_C_ACPI_READ, &DataSize, DataBuffer);
>
> + if (EFI_ERROR(Status)) {
>
> + return Status;
>
> + }
>
> +
>
> + // Write caller's pointer from returned data and return success
>
> + *Data = 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 = 2;
>
> + DataBuffer[0] = Address;
>
> + DataBuffer[1] = Data;
>
> +
>
> + return LpcEcInterface (EC_C_ACPI_WRITE, &DataSize, DataBuffer);
>
> +}
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79366): https://edk2.groups.io/g/devel/message/79366
Mute This Topic: https://groups.io/mt/84876363/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list