diff options
author | Abel Briggs <abelbriggs1@hotmail.com> | 2022-04-14 22:08:41 -0500 |
---|---|---|
committer | Paul Fagerburg <pfagerburg@chromium.org> | 2022-06-03 15:28:00 +0000 |
commit | c3bfbafda5c3241ff74ec1de3fbdc469af0e4ce0 (patch) | |
tree | 9699e3a19c106170050cab626c798b5d2ec7c43b /src/ec/acpi/ec.h | |
parent | 1f52edb093aef9b70ce10172bc8c759cdaa1c2ba (diff) |
ec/acpi: Rework to reduce code duplication
- Move EC send/receive polling code to their own functions
- Add named constants for poll timeouts and delay interval
- Use human-readable timeout values
- Add `send`/`recv` functions which support custom timeouts
- Remove extra 10us delays between polling and performing a given
transaction
- Use constants from `ec.h` for standard EC command opcodes
Tested on a Lenovo Edge E530, which takes similar code paths to
the Lenovo Twist S230u.
Change-Id: Ifda5c030ff81f1046be58aa1fcafdcf71a27cd41
Signed-off-by: Abel Briggs <abelbriggs1@hotmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64012
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Diffstat (limited to 'src/ec/acpi/ec.h')
-rw-r--r-- | src/ec/acpi/ec.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ec/acpi/ec.h b/src/ec/acpi/ec.h index f176d7be03..665c62f559 100644 --- a/src/ec/acpi/ec.h +++ b/src/ec/acpi/ec.h @@ -3,7 +3,7 @@ #ifndef _EC_ACPI_H #define _EC_ACPI_H -#include <stdint.h> +#include <types.h> #define EC_DATA 0x62 #define EC_SC 0x66 @@ -11,7 +11,7 @@ /* EC_SC input */ #define EC_SMI_EVT (1 << 6) // 1: SMI event pending #define EC_SCI_EVT (1 << 5) // 1: SCI event pending -#define EC_BURST (1 << 4) // controller is in burst mode +#define EC_BURST (1 << 4) // 1: controller is in burst mode #define EC_CMD (1 << 3) // 1: byte in data register is command // 0: byte in data register is data #define EC_IBF (1 << 1) // 1: input buffer full (data ready for ec) @@ -23,10 +23,14 @@ #define BD_EC 0x83 // Burst Disable Embedded Controller #define QR_EC 0x84 // Query Embedded Controller +bool ec_ready_send(int timeout_us); +bool ec_ready_recv(int timeout_us); int send_ec_command(u8 command); +int send_ec_command_timeout(u8 command, int timeout); int send_ec_data(u8 data); -int send_ec_data_nowait(u8 data); +int send_ec_data_timeout(u8 data, int timeout); u8 recv_ec_data(void); +u8 recv_ec_data_timeout(int timeout); void ec_clear_out_queue(void); u8 ec_status(void); u8 ec_query(void); |