[PATCH] cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT

Simon Glass sjg at chromium.org
Tue Nov 3 16:12:09 CET 2020


On Fri, 30 Oct 2020 at 11:25, Alper Nebi Yasak <alpernebiyasak at gmail.com> wrote:
>
> 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 at gmail.com>
> ---
>
>  drivers/input/cros_ec_keyb.c | 32 ++++++++++++++++++++++++++------
>  drivers/misc/cros_ec.c       | 15 +++++++++++++++
>  include/cros_ec.h            | 11 +++++++++++
>  3 files changed, 52 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list