From 4dc92782fca59e797556f6278c247b88f91c09ec Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sun, 20 Dec 2020 20:04:30 +0100 Subject: libpayload/keyboard: Add a detention state Instead of ignoring keyboards indefinitely when they failed to initialize, we wait 5s and then start over with the hotplug detection. As we always assume a present keyboard at first, we'd otherwise never have a chance to hot plug a device after the initial 30s timer ran out. Change-Id: I8dec4921b2e932442d52b5118cdcf27090633498 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/48774 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- payloads/libpayload/drivers/i8042/keyboard.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'payloads/libpayload') diff --git a/payloads/libpayload/drivers/i8042/keyboard.c b/payloads/libpayload/drivers/i8042/keyboard.c index 6d0cdd1c7b..cc412ac6e0 100644 --- a/payloads/libpayload/drivers/i8042/keyboard.c +++ b/payloads/libpayload/drivers/i8042/keyboard.c @@ -259,7 +259,7 @@ static enum keyboard_state { STATE_ENABLE_SCAN, STATE_RUNNING, STATE_RUNNING_ECHO, - STATE_IGNORE, + STATE_DETENTION, } keyboard_state; #define STATE_NAMES_ENTRY(name) [STATE_##name] = #name @@ -279,7 +279,7 @@ static const char *const state_names[] = { STATE_NAMES_ENTRY(ENABLE_SCAN), STATE_NAMES_ENTRY(RUNNING), STATE_NAMES_ENTRY(RUNNING_ECHO), - STATE_NAMES_ENTRY(IGNORE), + STATE_NAMES_ENTRY(DETENTION), }; __attribute__((unused)) @@ -455,8 +455,9 @@ static void keyboard_poll(void) state_time = timer_us(0); break; - case STATE_IGNORE: - /* TODO: Try again after timeout if it ever seems useful. */ + case STATE_DETENTION: + if (timer_us(state_time) > 5*1000*1000) + next_state = STATE_HOTPLUG; break; } @@ -467,11 +468,11 @@ static void keyboard_poll(void) case STATE_HOTPLUG_ECHO: case STATE_RUNNING: case STATE_RUNNING_ECHO: - case STATE_IGNORE: + case STATE_DETENTION: break; default: if (timer_us(keyboard_time) > 30*1000*1000) - next_state = STATE_IGNORE; + next_state = STATE_DETENTION; break; } -- cgit v1.2.3