u-boot-brain/drivers/input
Alper Nebi Yasak 6900797678 cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT
The cros_ec_keyb driver currently uses EC_CMD_MKBP_STATE to scan the
keyboard, but this host command was superseded by EC_CMD_GET_NEXT_EVENT
and unavailable on more recent devices (including gru-kevin), as it was
removed in cros-ec commit 87a071941b89 ("mkbp: Add support for buttons
and switches.") dated 2016-07-06.

The EC_CMD_GET_NEXT_EVENT has been available since cros-ec commit
d1ed75815efe ("MKBP event signalling implementation") dated 2014-10-20,
but it looks like it isn't included in firmware-* branches for at least
link, nyan-big, samus, snow, spring, panther and peach-pit which have
defconfigs in U-Boot. So this patch falls back to the old method if the
EC doesn't recognize the newer command.

The implementation is mostly adapted from Depthcharge commit
f88af26b44fc ("cros_ec: Change keyboard scanning method.").

On a gru-kevin, the current driver before this patch fails to read the
pressed keys with:

    out: cmd=0x60: 03 9d 60 00 00 00 00 00
    in-header: 03 fc 01 00 00 00 00 00
    in-data:
    ec_command_inptr: len=-1, din=0000000000000000
    check_for_keys: keyboard scan failed

However the keyboard works fine with the newer command:

    out: cmd=0x67: 03 96 67 00 00 00 00 00
    in-header: 03 ef 00 00 0e 00 00 00
    in-data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    ec_command_inptr: len=14, din=00000000f412df30
    key_matrix_decode: num_keys = 0
      0 valid keycodes found
    out: cmd=0x67: 03 96 67 00 00 00 00 00
    in-header: 03 df 00 00 0e 00 00 00
    in-data: 00 00 00 00 00 00 00 00 00 00 00 00 10 00
    ec_command_inptr: len=14, din=00000000f412df30
    key_matrix_decode: num_keys = 1
      valid=1, row=4, col=11
        keycode=28
      1 valid keycodes found
     {0d}

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2020-11-05 09:11:31 -07:00
..
cros_ec_keyb.c cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT 2020-11-05 09:11:31 -07:00
i8042.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
input.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
Kconfig kconfig: mark SPL/TPL options for DM_KEYBOARD 2020-06-02 17:27:04 -04:00
key_matrix.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
keyboard-uclass.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
Makefile input: Move input.o to be built only in some cases 2019-11-19 17:43:04 -05:00
tegra-kbc.c treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr() 2020-07-25 14:46:57 -06:00
twl4030.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
twl6030.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00