summaryrefslogtreecommitdiff
path: root/common/port80.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/port80.c')
-rw-r--r--common/port80.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/common/port80.c b/common/port80.c
index f8a6c8395d..72b8ccde11 100644
--- a/common/port80.c
+++ b/common/port80.c
@@ -7,6 +7,7 @@
#include "board.h"
#include "console.h"
+#include "host_command.h"
#include "port80.h"
#include "util.h"
@@ -16,6 +17,7 @@
static uint16_t history[HISTORY_LEN];
static int writes; /* Number of port 80 writes so far */
+static int last_boot; /* Last code from previous boot */
static int scroll;
static int print_in_int = 1;
@@ -30,6 +32,15 @@ void port_80_write(int data)
if (print_in_int)
CPRINTF("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data);
+ /* Save current port80 code if system is resetting */
+ if (data == PORT_80_EVENT_RESET && writes) {
+ int prev = history[(writes-1) % ARRAY_SIZE(history)];
+
+ /* Ignore special event codes */
+ if (prev < 0x100)
+ last_boot = prev;
+ }
+
history[writes % ARRAY_SIZE(history)] = data;
writes++;
}
@@ -82,10 +93,16 @@ static int command_port80(int argc, char **argv)
ccputs("Port 80 writes:");
for (i = tail; i < head; i++) {
int e = history[i % ARRAY_SIZE(history)];
- if (e == PORT_80_EVENT_RESUME) {
+ switch (e) {
+ case PORT_80_EVENT_RESUME:
ccprintf("\n(S3->S0)");
printed = 0;
- } else {
+ break;
+ case PORT_80_EVENT_RESET:
+ ccprintf("\n(RESET)");
+ printed = 0;
+ break;
+ default:
if (!(printed++ % 20)) {
ccputs("\n ");
cflush();
@@ -100,3 +117,15 @@ DECLARE_CONSOLE_COMMAND(port80, command_port80,
"[scroll | intprint | flush]",
"Print port80 writes or toggle port80 scrolling",
NULL);
+
+int port80_last_boot(struct host_cmd_handler_args *args)
+{
+ struct ec_response_port80_last_boot *r = args->response;
+
+ args->response_size = sizeof(*r);
+ r->code = last_boot;
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_PORT80_LAST_BOOT,
+ port80_last_boot, EC_VER_MASK(0));