diff mbox series

[14/22] cros_ec: Use standard calls for recovery-request checking

Message ID 20210705223300.2139971-13-sjg@chromium.org
State Accepted
Commit 56dae9ef3c56a7de6ed4af5efb82e661329d4738
Delegated to: Simon Glass
Headers show
Series Various fixes and enhancements | expand

Commit Message

Simon Glass July 5, 2021, 10:32 p.m. UTC
Rather than calling directly into the sandbox SDL code, we can use the
normal U-Boot console handling for this feature. Update the code, to make
it more generic.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_sandbox.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Simon Glass July 17, 2021, 8:39 p.m. UTC | #1
Rather than calling directly into the sandbox SDL code, we can use the
normal U-Boot console handling for this feature. Update the code, to make
it more generic.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_sandbox.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 6a95a9132a6..17fca0f9f00 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -622,15 +622,19 @@  void cros_ec_check_keyboard(struct udevice *dev)
 	struct ec_state *ec = dev_get_priv(dev);
 	ulong start;
 
-	printf("Press keys for EC to detect on reset (ESC=recovery)...");
+	printf("\nPress keys for EC to detect on reset (ESC=recovery)...");
 	start = get_timer(0);
-	while (get_timer(start) < 1000)
-		;
-	putc('\n');
-	if (!sandbox_sdl_key_pressed(KEY_ESC)) {
-		ec->recovery_req = true;
-		printf("   - EC requests recovery\n");
+	while (get_timer(start) < 2000) {
+		if (tstc()) {
+			int ch = getchar();
+
+			if (ch == 0x1b) {
+				ec->recovery_req = true;
+				printf("EC requests recovery");
+			}
+		}
 	}
+	putc('\n');
 }
 
 /* Return the byte of EC switch states */