summaryrefslogtreecommitdiff
path: root/drivers/misc/cros_ec.c
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2020-10-30 20:25:20 +0300
committerSimon Glass <sjg@chromium.org>2020-11-05 09:11:31 -0700
commit690079767803c7406062dc074bbb1f8f0ff37fa0 (patch)
treee3fa347bde860b56c8939d8b6f95617899b10ad2 /drivers/misc/cros_ec.c
parent9485a80be1354e55fc712ba82817dbe8779284d8 (diff)
downloadu-boot-690079767803c7406062dc074bbb1f8f0ff37fa0.tar.gz
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>
Diffstat (limited to 'drivers/misc/cros_ec.c')
-rw-r--r--drivers/misc/cros_ec.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index a5534b1667..c3674908ee 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -415,6 +415,21 @@ int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan)
return 0;
}
+int cros_ec_get_next_event(struct udevice *dev,
+ struct ec_response_get_next_event *event)
+{
+ int ret;
+
+ ret = ec_command(dev, EC_CMD_GET_NEXT_EVENT, 0, NULL, 0,
+ event, sizeof(*event));
+ if (ret < 0)
+ return ret;
+ else if (ret != sizeof(*event))
+ return -EC_RES_INVALID_RESPONSE;
+
+ return 0;
+}
+
int cros_ec_read_id(struct udevice *dev, char *id, int maxlen)
{
struct ec_response_get_version *r;