From 755a767c2bac52522595ceb9fec5e651244d0449 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Tue, 17 Apr 2012 16:11:51 +0800 Subject: [PATCH] Fixed the bug that reboot_ec resets the keyboard state to disabled. The reboot_ec command could warm boot the EC while the host is still running. However, this resets the internal state so that the keyboard module is disabled on the EC side. Check the reset cause during the keyboard init code. If it is wrm boot, enable the keyboard (assume the host is on). BUG=chrome-os-partner:9102 TEST=on link 1.0 % ectool version Firmware copy: RO % ectool reboot_ec RO the keyboard keeps working. Change-Id: I0009c561e2cd88789e50f9129b494538e50ee00e --- common/keyboard.c | 16 ++++++++++++++++ common/main.c | 3 +++ include/keyboard.h | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) 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),