ec/google/chromeec: Add debug timestamp for host EC commands

Improve host EC command debugging with timestamps and duration for
better analysis, this feature can be enabled by selecting the config
EC_GOOGLE_CHROMEEC_HOST_CMD_DEBUG.

BUG=none
TEST=Brox/lotso device successfully built and booted. Debug messages
confirmed in device logs only when the specific configuration is
selected. Sample print: "EC HOST CMD Duration: 661 us, Command: 0x4b,
version: 0x0"

Change-Id: I8ab89830ede940d2237ad21187b137dca9689fb0
Signed-off-by: Jayvik Desai <jayvik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85326
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
This commit is contained in:
Jayvik Desai 2024-11-26 19:06:20 +05:30 committed by Subrata Banik
commit 759dd5379e
2 changed files with 28 additions and 3 deletions

View file

@ -98,6 +98,12 @@ config EC_GOOGLE_CHROMEEC_MEC
help
Microchip EC variant for LPC register access.
config EC_GOOGLE_CHROMEEC_EC_HOST_CMD_DEBUG
depends on EC_GOOGLE_CHROMEEC_LPC && HAVE_MONOTONIC_TIMER
def_bool n
help
Enables timestamp and duration logging for host EC commands.
config EC_GOOGLE_CHROMEEC_PD
def_bool n
help

View file

@ -401,17 +401,36 @@ void google_chromeec_ioport_range(uint16_t *out_base, size_t *out_size)
int google_chromeec_command(struct chromeec_command *cec_command)
{
static int command_version;
struct stopwatch sw;
uint16_t cmd_code;
int result = -1;
if (command_version <= 0)
command_version = google_chromeec_command_version();
if (CONFIG(EC_GOOGLE_CHROMEEC_EC_HOST_CMD_DEBUG)) {
cmd_code = cec_command->cmd_code;
stopwatch_init(&sw);
}
switch (command_version) {
case EC_HOST_CMD_FLAG_VERSION_3:
return google_chromeec_command_v3(cec_command);
result = google_chromeec_command_v3(cec_command);
break;
case EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED:
return google_chromeec_command_v1(cec_command);
result = google_chromeec_command_v1(cec_command);
break;
}
return -1;
if (CONFIG(EC_GOOGLE_CHROMEEC_EC_HOST_CMD_DEBUG)) {
stopwatch_tick(&sw);
printk(BIOS_DEBUG, "EC HOST CMD end Duration: %llu us, Command: 0x%x, Version: 0x%x\n",
stopwatch_duration_usecs(&sw),
cmd_code,
command_version);
}
return result;
}
static void lpc_ec_init(struct device *dev)