From 690079767803c7406062dc074bbb1f8f0ff37fa0 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Fri, 30 Oct 2020 20:25:20 +0300 Subject: 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 Reviewed-by: Simon Glass --- include/cros_ec.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/cros_ec.h b/include/cros_ec.h index f4b9b7a5c2..f187bd0d4b 100644 --- a/include/cros_ec.h +++ b/include/cros_ec.h @@ -82,6 +82,17 @@ int cros_ec_read_id(struct udevice *dev, char *id, int maxlen); */ int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan); +/** + * Get the next pending MKBP event from the ChromeOS EC device. + * + * Send a message requesting the next event and return the result. + * + * @param event Place to put the event. + * @return 0 if ok, <0 on error. + */ +int cros_ec_get_next_event(struct udevice *dev, + struct ec_response_get_next_event *event); + /** * Read which image is currently running on the CROS-EC device. * -- cgit v1.2.1