diff --git a/common/keyboard.c b/common/keyboard.c index 65e9b45d40..84d1a64d81 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -13,6 +13,7 @@ #include "lpc.h" #include "lpc_commands.h" #include "registers.h" +#include "system.h" #include "task.h" #include "timer.h" #include "uart.h" @@ -799,3 +800,18 @@ static int command_keyboard_press(int argc, char **argv) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(kbpress, command_keyboard_press); + + +int keyboard_init(void) +{ + /* If the host is still alive during the EC resets (ex. reboot_ec), + * we should enable keyboard so that the user can type. */ + enum system_reset_cause_t reset_cause = system_get_reset_cause(); + if (reset_cause == SYSTEM_RESET_SOFT_WARM || + reset_cause == SYSTEM_RESET_WATCHDOG || + reset_cause == SYSTEM_RESET_SOFT_COLD ) { + i8042_enable_keyboard_irq(); + } + + return 0; +} diff --git a/common/main.c b/common/main.c index 05ce0e5096..1b72d9f9ab 100644 --- a/common/main.c +++ b/common/main.c @@ -99,6 +99,9 @@ int main(void) #ifdef CONFIG_EOPTION eoption_init(); #endif +#ifdef CONFIG_TASK_I8042CMD + keyboard_init(); +#endif #ifdef CONFIG_TASK_KEYSCAN keyboard_scan_init(); #endif diff --git a/include/keyboard.h b/include/keyboard.h index f715ab2bba..bc5aaadfe9 100644 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -26,7 +26,7 @@ enum scancode_set_list { /* The initialize code of keyboard lib. Called by core main. */ -enum ec_error_list keyboard_init(void); +int keyboard_init(void); /* Called by keyboard scan code once any key state change (after de-bounce),