summaryrefslogtreecommitdiff
path: root/include/cros_ec.h
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 /include/cros_ec.h
parent9485a80be1354e55fc712ba82817dbe8779284d8 (diff)
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 'include/cros_ec.h')
-rw-r--r--include/cros_ec.h11
1 files changed, 11 insertions, 0 deletions
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
@@ -83,6 +83,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.
*
* @param dev CROS-EC device