summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-03 17:02:20 -0700
committerGerrit <chrome-bot@google.com>2012-07-07 23:05:50 -0700
commit1e8e8cd6aac846ab88aa1597f3cb21604eef207d (patch)
tree71ef5ae49103b447712d5e48b87c8c7e03f21d92
parent1c287d0486de1821b77ecdfcd321d7f98c17c57d (diff)
downloadchrome-ec-1e8e8cd6aac846ab88aa1597f3cb21604eef207d.tar.gz
Add new event for host interface ready
Also add new 'invalid' host event bit; if the host reads this, it knows the memory-mapped data for current events is invalid. BUG=chrome-os-partner:11146 TEST=manual On host, ectool eventget -> should print events = 0 On EC, hostevent set 0x80000000 On host, ectool eventget -> should print events = invalid Reboot EC; should see debug output where event mask 0x2000 is set during the boot process. Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: I8d3f161eec25db50ac06e3642a1a1fb8edb9590e Reviewed-on: https://gerrit.chromium.org/gerrit/26876
-rw-r--r--chip/lm4/lpc.c2
-rw-r--r--common/host_command.c8
-rw-r--r--include/ec_commands.h16
-rw-r--r--util/ectool.c10
4 files changed, 30 insertions, 6 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c
index 26fcb39931..6db8d1c096 100644
--- a/chip/lm4/lpc.c
+++ b/chip/lm4/lpc.c
@@ -284,6 +284,7 @@ void lpc_set_host_events(uint32_t mask)
return;
host_events |= mask;
+ CPRINTF("[%T event set 0x%08x -> %08x]\n", mask, host_events);
update_host_event_status();
}
@@ -294,6 +295,7 @@ void lpc_clear_host_events(uint32_t mask)
return;
host_events &= ~mask;
+ CPRINTF("[%T event clear 0x%08x -> %08x]\n", mask, host_events);
update_host_event_status();
}
diff --git a/common/host_command.c b/common/host_command.c
index 3647e50cda..99de6e057b 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -176,7 +176,7 @@ enum ec_status host_command_process(int slot, int command, uint8_t *data,
const struct host_command *cmd = find_host_command(command);
enum ec_status res = EC_RES_INVALID_COMMAND;
- CPRINTF("[hostcmd%d 0x%02x]\n", slot, command);
+ CPRINTF("[%T hostcmd%d 0x%02x]\n", slot, command);
*response_size = 0;
if (cmd)
@@ -191,24 +191,26 @@ static void command_process(int slot)
int size;
int res;
- CPRINTF("[hostcmd%d 0x%02x]\n", slot, host_command[slot]);
+ CPRINTF("[%T hostcmd%d 0x%02x]\n", slot, host_command[slot]);
res = host_command_process(slot, host_command[slot],
host_get_buffer(slot), &size);
host_send_response(slot, res, host_get_buffer(slot), size);
}
+
/*****************************************************************************/
/* Initialization / task */
static int host_command_init(void)
{
host_command[0] = host_command[1] = -1;
+ host_set_single_event(EC_HOST_EVENT_INTERFACE_READY);
+ CPRINTF("[%T hostcmd init 0x%x]\n", host_get_events());
return EC_SUCCESS;
}
-
void host_command_task(void)
{
host_command_init();
diff --git a/include/ec_commands.h b/include/ec_commands.h
index e4499302d9..baa770d5e3 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -161,9 +161,23 @@ enum host_event_code {
EC_HOST_EVENT_THERMAL = 11,
EC_HOST_EVENT_USB_CHARGER = 12,
EC_HOST_EVENT_KEY_PRESSED = 13,
+ /*
+ * EC has finished initializing the host interface. The host can check
+ * for this event following sending a EC_CMD_REBOOT_EC command to
+ * determine when the EC is ready to accept subsequent commands.
+ */
+ EC_HOST_EVENT_INTERFACE_READY = 14,
+ /*
+ * The high bit of the event mask is not used as a host event code. If
+ * it reads back as set, then the entire event mask should be
+ * considered invalid by the host. This can happen when reading the
+ * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is
+ * not initialized on the EC, or improperly configured on the host.
+ */
+ EC_HOST_EVENT_INVALID = 32
};
/* Host event mask */
-#define EC_HOST_EVENT_MASK(event_code) (1 << ((event_code) - 1))
+#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
/*
* Notes on commands:
diff --git a/util/ectool.c b/util/ectool.c
index 2b1078323b..c04ff39d9a 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1251,8 +1251,14 @@ int cmd_acpi_query_ec(int argc, char *argv[])
int cmd_host_event_get_raw(int argc, char *argv[])
{
- printf("Current host events: 0x%08x\n",
- read_mapped_mem32(EC_MEMMAP_HOST_EVENTS));
+ uint32_t events = read_mapped_mem32(EC_MEMMAP_HOST_EVENTS);
+
+ if (events & EC_HOST_EVENT_MASK(EC_HOST_EVENT_INVALID)) {
+ printf("Current host events: invalid\n");
+ return -1;
+ }
+
+ printf("Current host events: 0x%08x\n", events);
return 0;
}