diff options
author | Tom Rini <trini@konsulko.com> | 2020-11-06 11:27:14 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-11-06 11:27:14 -0500 |
commit | 22ad69b7987eb4b10221330661db4427e40174fb (patch) | |
tree | b13bc4ba708907cd76a0ec09c4599b55cb586953 /drivers | |
parent | 896cc5aa4a8fc0c28036b9615a37f0034addad44 (diff) | |
parent | dc4b2a9770b5b932cd6d98c33ebff6dc46de6849 (diff) | |
download | u-boot-22ad69b7987eb4b10221330661db4427e40174fb.tar.gz |
Merge tag 'dm-pull5nov20' of git://git.denx.de/u-boot-dmWIP/06Nov2020
patman status subcommand to collect tags from Patchwork
patman showing email replies from Patchwork
sandbox poweroff command
minor fixes in binman, tests
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/cros_ec_keyb.c | 32 | ||||
-rw-r--r-- | drivers/misc/cros_ec.c | 15 | ||||
-rw-r--r-- | drivers/sysreset/sysreset_sandbox.c | 3 |
3 files changed, 44 insertions, 6 deletions
diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c index 00bf58f2b5..0c0f52205b 100644 --- a/drivers/input/cros_ec_keyb.c +++ b/drivers/input/cros_ec_keyb.c @@ -47,15 +47,35 @@ static int check_for_keys(struct udevice *dev, struct key_matrix_key *keys, struct key_matrix_key *key; static struct mbkp_keyscan last_scan; static bool last_scan_valid; - struct mbkp_keyscan scan; + struct ec_response_get_next_event event; + struct mbkp_keyscan *scan = (struct mbkp_keyscan *) + &event.data.key_matrix; unsigned int row, col, bit, data; int num_keys; + int ret; - if (cros_ec_scan_keyboard(dev->parent, &scan)) { - debug("%s: keyboard scan failed\n", __func__); + /* Get pending MKBP event. It may not be a key matrix event. */ + do { + ret = cros_ec_get_next_event(dev->parent, &event); + /* The EC has no events for us at this time. */ + if (ret == -EC_RES_UNAVAILABLE) + return -EIO; + else if (ret) + break; + } while (event.event_type != EC_MKBP_EVENT_KEY_MATRIX); + + /* Try the old command if the EC doesn't support the above. */ + if (ret == -EC_RES_INVALID_COMMAND) { + if (cros_ec_scan_keyboard(dev->parent, scan)) { + debug("%s: keyboard scan failed\n", __func__); + return -EIO; + } + } else if (ret) { + debug("%s: Error getting next MKBP event. (%d)\n", + __func__, ret); return -EIO; } - *samep = last_scan_valid && !memcmp(&last_scan, &scan, sizeof(scan)); + *samep = last_scan_valid && !memcmp(&last_scan, scan, sizeof(*scan)); /* * This is a bit odd. The EC has no way to tell us that it has run @@ -64,14 +84,14 @@ static int check_for_keys(struct udevice *dev, struct key_matrix_key *keys, * that this scan is the same as the last. */ last_scan_valid = true; - memcpy(&last_scan, &scan, sizeof(last_scan)); + memcpy(&last_scan, scan, sizeof(last_scan)); for (col = num_keys = bit = 0; col < priv->matrix.num_cols; col++) { for (row = 0; row < priv->matrix.num_rows; row++) { unsigned int mask = 1 << (bit & 7); - data = scan.data[bit / 8]; + data = scan->data[bit / 8]; if ((data & mask) && num_keys < max_count) { key = keys + num_keys++; key->row = row; 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; diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 71cabd1956..7026a48c4b 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -56,6 +56,9 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) switch (type) { case SYSRESET_COLD: state->last_sysreset = type; + if (!state->sysreset_allowed[type]) + return -EACCES; + sandbox_reset(); break; case SYSRESET_POWER_OFF: state->last_sysreset = type; |