diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-07-12 13:41:01 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-07-12 18:21:32 -0700 |
commit | 89049421a6f2681f517373338a0f601beae7c737 (patch) | |
tree | 84e58710d77d00c1a72680a15e5cda860f2ccc95 /common/host_event_commands.c | |
parent | 02d820786c2fda890411494ddbc9e6d2ddf90f32 (diff) | |
download | chrome-ec-89049421a6f2681f517373338a0f601beae7c737.tar.gz |
Add second copy of event state
U-boot and ectool need this to see what events have occurred, in a way
which doesn't conflict with ACPI/SCI/SMI.
BUG=chrome-os-partner:11172
TEST=manual
- boot EC
- look at event set / event clear debug output; that's for copy A
- from ec console,
hostevent -> events=0, events-B = 0x2088
hostevent clearb 0x2000 -> events-B = 0x88
Change-Id: If842b157914426df593d82af2bfb08a923caa34b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27317
Diffstat (limited to 'common/host_event_commands.c')
-rw-r--r-- | common/host_event_commands.c | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/common/host_event_commands.c b/common/host_event_commands.c index 3242a6de83..b4a161068a 100644 --- a/common/host_event_commands.c +++ b/common/host_event_commands.c @@ -5,12 +5,20 @@ /* Host event commands for Chrome EC */ +#include "atomic.h" #include "common.h" #include "console.h" #include "host_command.h" #include "lpc.h" #include "util.h" +/* Copy B of current events mask. + * + * This is separate from the main copy, which affects ACPI/SCI/SMI/wake. + * + * Setting an event sets both copies. Copies are cleared separately. */ +static uint32_t events_copy_b; + uint32_t host_get_events(void) { #ifdef CONFIG_LPC @@ -24,12 +32,12 @@ uint32_t host_get_events(void) void host_set_events(uint32_t mask) { + atomic_or(&events_copy_b, mask); + #ifdef CONFIG_LPC lpc_set_host_events(mask); #else - uint32_t *mapped_raw_events = - (uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS); - *mapped_raw_events |= mask; + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) |= mask; #endif } @@ -38,12 +46,21 @@ void host_clear_events(uint32_t mask) #ifdef CONFIG_LPC lpc_clear_host_events(mask); #else - uint32_t *mapped_raw_events = - (uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS); - *mapped_raw_events &= ~mask; + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) &= ~mask; #endif } +/** + * Clear one or more host event bits from copy B. + * + * @param mask Event bits to clear (use EC_HOST_EVENT_MASK()). + * Write 1 to a bit to clear it. + */ +static void host_clear_events_b(uint32_t mask) +{ + atomic_clear(&events_copy_b, mask); +} + /*****************************************************************************/ /* Console commands */ @@ -60,6 +77,8 @@ static int command_host_event(int argc, char **argv) host_set_events(i); else if (!strcasecmp(argv[1], "clear")) host_clear_events(i); + else if (!strcasecmp(argv[1], "clearb")) + host_clear_events_b(i); #ifdef CONFIG_LPC else if (!strcasecmp(argv[1], "smi")) lpc_set_host_event_mask(LPC_HOST_EVENT_SMI, i); @@ -74,6 +93,7 @@ static int command_host_event(int argc, char **argv) /* Print current SMI/SCI status */ ccprintf("Events: 0x%08x\n", host_get_events()); + ccprintf("Events-B: 0x%08x\n", events_copy_b); #ifdef CONFIG_LPC ccprintf("SMI mask: 0x%08x\n", lpc_get_host_event_mask(LPC_HOST_EVENT_SMI)); @@ -85,7 +105,7 @@ static int command_host_event(int argc, char **argv) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(hostevent, command_host_event, - "[set | clear | smi | sci | wake] [mask]", + "[set | clear | clearb | smi | sci | wake] [mask]", "Print / set host event state", NULL); @@ -174,6 +194,20 @@ DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_SET_WAKE_MASK, #endif /* CONFIG_LPC */ +static int host_event_get_b(struct host_cmd_handler_args *args) +{ + struct ec_response_host_event_mask *r = + (struct ec_response_host_event_mask *)args->response; + + r->mask = events_copy_b; + args->response_size = sizeof(*r); + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_B, + host_event_get_b, + EC_VER_MASK(0)); + static int host_event_clear(struct host_cmd_handler_args *args) { const struct ec_params_host_event_mask *p = @@ -185,3 +219,15 @@ static int host_event_clear(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_CLEAR, host_event_clear, EC_VER_MASK(0)); + +static int host_event_clear_b(struct host_cmd_handler_args *args) +{ + const struct ec_params_host_event_mask *p = + (const struct ec_params_host_event_mask *)args->params; + + host_clear_events_b(p->mask); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_CLEAR_B, + host_event_clear_b, + EC_VER_MASK(0)); |