libpayload: keyboard: Add option to ignore failures during init

If keys are pressed at boot some keyboard controllers will not
properly respond with an ACK to commands, which results in the
keyboard_init function aborting before it adds the keyboard to the
input device list.

This same keyboard controller will manage to properly return keyboard
data when keys are pressed later, so it is possible for it to be
functional in the payload even if it does not respond properly to
every command during initialization.

In order to allow payloads to use the keyboard when this happens a
new Kconfig option is added to ignore the keyboard ACK response and
always add the keyboard to the input device list.  This option is
disabled by default and must be enabled by the specific boards that
need it.

BUG=b:126633269
TEST=boot on device with this controller and press keys during boot
and see that the keyboard is still functional in the payload.

Change-Id: Icc6053f99804f1b57d785cb04235b5c4b8d5426f
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/c/31657
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Duncan Laurie 2019-02-28 16:35:21 +08:00 committed by Duncan Laurie
parent f1b58b7835
commit 5aa0e925bc
2 changed files with 7 additions and 3 deletions

View File

@ -344,6 +344,10 @@ config PC_KEYBOARD
default y if ARCH_X86 # uses IO default y if ARCH_X86 # uses IO
default n default n
config PC_KEYBOARD_IGNORE_INIT_FAILURE
bool "Ignore keyboard failures during init and always add input device"
default n
config PC_KEYBOARD_LAYOUT_US config PC_KEYBOARD_LAYOUT_US
bool "English (US) keyboard layout" bool "English (US) keyboard layout"
depends on PC_KEYBOARD depends on PC_KEYBOARD

View File

@ -309,16 +309,16 @@ void keyboard_init(void)
/* Set scancode set 1 */ /* Set scancode set 1 */
ret = keyboard_cmd(I8042_KBCMD_SET_SCANCODE); ret = keyboard_cmd(I8042_KBCMD_SET_SCANCODE);
if (!ret) if (!ret && !IS_ENABLED(CONFIG_LP_PC_KEYBOARD_IGNORE_INIT_FAILURE))
return; return;
ret = keyboard_cmd(I8042_SCANCODE_SET_1); ret = keyboard_cmd(I8042_SCANCODE_SET_1);
if (!ret) if (!ret && !IS_ENABLED(CONFIG_LP_PC_KEYBOARD_IGNORE_INIT_FAILURE))
return; return;
/* Enable scanning */ /* Enable scanning */
ret = keyboard_cmd(I8042_KBCMD_EN); ret = keyboard_cmd(I8042_KBCMD_EN);
if (!ret) if (!ret && !IS_ENABLED(CONFIG_LP_PC_KEYBOARD_IGNORE_INIT_FAILURE))
return; return;
console_add_input_driver(&cons); console_add_input_driver(&cons);