diff options
author | Joel Kitching <kitching@chromium.org> | 2018-06-25 18:37:58 +0000 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-06-25 18:39:47 +0000 |
commit | 841981478425c9ccaba2aa952538ccc977595968 (patch) | |
tree | b9989cc8d696015c2b3f3c4234c691a7e048d0df | |
parent | d562212a94eaa757ee2ea44946012110b574601d (diff) | |
download | chrome-ec-841981478425c9ccaba2aa952538ccc977595968.tar.gz |
Revert "host_events: Bump up host events and masks to 64-bit"
This reverts commit d0decbf1d041cda667c08506fe045b75e2f343b9.
Reason for revert: Re-using 32-bit host events instead. See b/110292722
Original change's description:
> host_events: Bump up host events and masks to 64-bit
>
> With the upcoming change to add a new command to get/set/clear host
> events and masks, it seems to be the right time to bump up the host
> events and masks to 64-bit. We are already out of available host
> events. This change opens up at least 32 bits for new host events.
>
> Old EC commands to operate on host events/masks will still deal with
> lower 32-bits of the events/mask. On the other hand, the new command
> being added will take care of the entire 64-bit events/masks. This
> ensures that old BIOS and kernel versions can still work with the
> newer EC versions.
>
> BUG=b:69329196
> BRANCH=None
> TEST=make -j buildall. Verified:
> 1. hostevent set 0x4000 ==> Sets correct bit in host events
> 2. hostevent clear 0x4000 ==> Clears correct bit in host events
> 3. Kernel is able to query and read correct host event bits from
> EC. Verified using evtest.
> 4. Coreboot is able to read correct wake reason from EC. Verified
> using mosys eventlog list.
>
> Change-Id: I286aef0f35cec10754ef7d662f883e999c22d235
> Signed-off-by: Furquan Shaikh <furquan@chromium.org>
> Reviewed-on: https://chromium-review.googlesource.com/770925
> Reviewed-by: Randall Spangler <rspangler@chromium.org>
> (cherry picked from commit c9cd870600b12123dddc88814446327337557369)
> Leaving out change under CONFIG_HOSTCMD_RTC #ifdef in
> chip/stm32/clock-f.c.
> Reviewed-on: https://chromium-review.googlesource.com/989867
> Reviewed-by: Joel Kitching <kitching@chromium.org>
> Commit-Queue: Joel Kitching <kitching@chromium.org>
> Tested-by: Joel Kitching <kitching@chromium.org>
> Trybot-Ready: Joel Kitching <kitching@chromium.org>
Bug: b:69329196
Change-Id: If9d9bcf49e09c854211528f15ae0caef6ccf1ffe
Reviewed-on: https://chromium-review.googlesource.com/1113783
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Trybot-Ready: Joel Kitching <kitching@chromium.org>
-rw-r--r-- | board/kevin/board.h | 2 | ||||
-rw-r--r-- | chip/it83xx/lpc.c | 4 | ||||
-rw-r--r-- | chip/lm4/lpc.c | 12 | ||||
-rw-r--r-- | chip/mec1322/lpc.c | 4 | ||||
-rw-r--r-- | chip/npcx/gpio.c | 2 | ||||
-rw-r--r-- | chip/npcx/lpc.c | 12 | ||||
-rw-r--r-- | common/ec_features.c | 6 | ||||
-rw-r--r-- | common/host_command.c | 2 | ||||
-rw-r--r-- | common/host_event_commands.c | 184 | ||||
-rw-r--r-- | common/keyboard_mkbp.c | 14 | ||||
-rw-r--r-- | common/util.c | 39 | ||||
-rw-r--r-- | include/config.h | 4 | ||||
-rw-r--r-- | include/ec_commands.h | 14 | ||||
-rw-r--r-- | include/host_command.h | 31 | ||||
-rw-r--r-- | include/lpc.h | 11 | ||||
-rw-r--r-- | include/util.h | 1 | ||||
-rw-r--r-- | power/intel_x86.c | 4 |
17 files changed, 92 insertions, 254 deletions
diff --git a/board/kevin/board.h b/board/kevin/board.h index 40498a7826..ee8f6a1fca 100644 --- a/board/kevin/board.h +++ b/board/kevin/board.h @@ -8,8 +8,6 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H -#undef CONFIG_HOST_EVENT64 - /* Optional modules */ #define CONFIG_ADC #define CONFIG_CHIPSET_RK3399 diff --git a/chip/it83xx/lpc.c b/chip/it83xx/lpc.c index 94b00a0839..c860a372b9 100644 --- a/chip/it83xx/lpc.c +++ b/chip/it83xx/lpc.c @@ -153,7 +153,7 @@ static void lpc_generate_sci(void) * * @param wake_events Currently asserted wake events */ -static void lpc_update_wake(host_event_t wake_events) +static void lpc_update_wake(uint32_t wake_events) { /* * Mask off power button event, since the AP gets that through a @@ -238,7 +238,7 @@ void lpc_update_host_event_status(void) } /* Copy host events to mapped memory */ - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = lpc_get_host_events(); task_enable_irq(IT83XX_IRQ_PMC_IN); diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index 823efa2439..91c4959862 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -149,7 +149,7 @@ static inline void keyboard_irq_assert(void) */ static void lpc_generate_smi(void) { - host_event_t smi; + uint32_t smi; /* Enforce signal-high for long enough to debounce high */ gpio_set_level(GPIO_PCH_SMI_L, 1); @@ -162,7 +162,7 @@ static void lpc_generate_smi(void) smi = lpc_get_host_events_by_type(LPC_HOST_EVENT_SMI); if (smi) - HOST_EVENT_CPRINTS("smi", smi); + CPRINTS("smi 0x%08x", smi); } /** @@ -170,7 +170,7 @@ static void lpc_generate_smi(void) */ static void lpc_generate_sci(void) { - host_event_t sci; + uint32_t sci; #ifdef CONFIG_SCI_GPIO /* Enforce signal-high for long enough to debounce high */ @@ -187,7 +187,7 @@ static void lpc_generate_sci(void) sci = lpc_get_host_events_by_type(LPC_HOST_EVENT_SCI); if (sci) - HOST_EVENT_CPRINTS("sci", sci); + CPRINTS("sci 0x%08x", sci); } /** @@ -195,7 +195,7 @@ static void lpc_generate_sci(void) * * @param wake_events Currently asserted wake events */ -static void lpc_update_wake(uint64_t wake_events) +static void lpc_update_wake(uint32_t wake_events) { /* * Mask off power button event, since the AP gets that through a @@ -368,7 +368,7 @@ void lpc_update_host_event_status(void) LM4_LPC_ST(LPC_CH_ACPI) &= ~LM4_LPC_ST_SCI; /* Copy host events to mapped memory */ - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = lpc_get_host_events(); task_enable_irq(LM4_IRQ_LPC); diff --git a/chip/mec1322/lpc.c b/chip/mec1322/lpc.c index 93e306d276..52ed7d5a58 100644 --- a/chip/mec1322/lpc.c +++ b/chip/mec1322/lpc.c @@ -93,7 +93,7 @@ static void lpc_generate_sci(void) * * @param wake_events Currently asserted wake events */ -static void lpc_update_wake(host_event_t wake_events) +static void lpc_update_wake(uint32_t wake_events) { /* * Mask off power button event, since the AP gets that through a @@ -151,7 +151,7 @@ void lpc_update_host_event_status(void) } /* Copy host events to mapped memory */ - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = lpc_get_host_events(); task_enable_irq(MEC1322_IRQ_ACPIEC0_IBF); diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c index 2945dfd512..47bc6bc59a 100644 --- a/chip/npcx/gpio.c +++ b/chip/npcx/gpio.c @@ -542,7 +542,7 @@ void __gpio_rtc_interrupt(void) if (NPCX_WKPND(MIWU_TABLE_0, MIWU_GROUP_4) & 0x80) { /* Clear pending bit for WUI */ SET_BIT(NPCX_WKPCL(MIWU_TABLE_0, MIWU_GROUP_4), 7); - host_set_single_event(EC_HOST_EVENT_RTC); + host_set_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)); } else #endif { diff --git a/chip/npcx/lpc.c b/chip/npcx/lpc.c index e9f6471910..c6607b3472 100644 --- a/chip/npcx/lpc.c +++ b/chip/npcx/lpc.c @@ -139,7 +139,7 @@ static void lpc_task_disable_irq(void) */ static void lpc_generate_smi(void) { - host_event_t smi; + uint32_t smi; #ifdef CONFIG_SCI_GPIO /* Enforce signal-high for long enough to debounce high */ @@ -177,7 +177,7 @@ static void lpc_generate_smi(void) #endif smi = lpc_get_host_events_by_type(LPC_HOST_EVENT_SMI); if (smi) - HOST_EVENT_CPRINTS("smi", smi); + CPRINTS("smi 0x%08x", smi); } /** @@ -185,7 +185,7 @@ static void lpc_generate_smi(void) */ static void lpc_generate_sci(void) { - host_event_t sci; + uint32_t sci; #ifdef CONFIG_SCI_GPIO /* Enforce signal-high for long enough to debounce high */ @@ -224,7 +224,7 @@ static void lpc_generate_sci(void) sci = lpc_get_host_events_by_type(LPC_HOST_EVENT_SCI); if (sci) - HOST_EVENT_CPRINTS("sci", sci); + CPRINTS("sci 0x%08x", sci); } /** @@ -232,7 +232,7 @@ static void lpc_generate_sci(void) * * @param wake_events Currently asserted wake events */ -static void lpc_update_wake(host_event_t wake_events) +static void lpc_update_wake(uint32_t wake_events) { /* * Mask off power button event, since the AP gets that through a @@ -452,7 +452,7 @@ void lpc_update_host_event_status(void) CLEAR_BIT(NPCX_HIPMST(PMC_ACPI), NPCX_HIPMST_ST1); /* Copy host events to mapped memory */ - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = lpc_get_host_events(); lpc_task_enable_irq(); diff --git a/common/ec_features.c b/common/ec_features.c index b51588004b..8715fecd34 100644 --- a/common/ec_features.c +++ b/common/ec_features.c @@ -116,11 +116,7 @@ uint32_t get_feature_flags0(void) uint32_t get_feature_flags1(void) { - uint32_t result = EC_FEATURE_MASK_1(EC_FEATURE_UNIFIED_WAKE_MASKS) -#ifdef CONFIG_HOST_EVENT64 - | EC_FEATURE_MASK_1(EC_FEATURE_HOST_EVENT64) -#endif - ; + uint32_t result = EC_FEATURE_MASK_1(EC_FEATURE_UNIFIED_WAKE_MASKS); #ifdef CONFIG_EC_FEATURE_BOARD_OVERRIDE result = board_override_feature_flags1(result); #endif diff --git a/common/host_command.c b/common/host_command.c index 25a2e71428..812c930272 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -411,7 +411,7 @@ static void host_command_init(void) #ifdef CONFIG_HOSTCMD_EVENTS host_set_single_event(EC_HOST_EVENT_INTERFACE_READY); - HOST_EVENT_CPRINTS("hostcmd init", host_get_events()); + CPRINTS("hostcmd init 0x%x", host_get_events()); #endif } diff --git a/common/host_event_commands.c b/common/host_event_commands.c index 9da08c892c..8a67822bf7 100644 --- a/common/host_event_commands.c +++ b/common/host_event_commands.c @@ -5,6 +5,7 @@ /* Host event commands for Chrome EC */ +#include "atomic.h" #include "common.h" #include "console.h" #include "hooks.h" @@ -12,31 +13,12 @@ #include "lpc.h" #include "mkbp_event.h" #include "system.h" -#include "task.h" #include "util.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_EVENTS, outstr) #define CPRINTS(format, args...) cprints(CC_EVENTS, format, ## args) -/* - * This is used to avoid 64-bit shifts which might require a new library - * function. - */ -#define HOST_EVENT_32BIT_MASK(x) (1UL << ((x) - 1)) -static void host_event_set_bit(host_event_t *ev, uint8_t bit) -{ - uint32_t *ptr = (uint32_t *)ev; - - *ev = 0; -#ifdef CONFIG_HOST_EVENT64 - if (bit >= 32) - *(ptr + 1) = HOST_EVENT_32BIT_MASK(bit - 32); - else -#endif - *ptr = HOST_EVENT_32BIT_MASK(bit); -} - #ifdef CONFIG_LPC #define LPC_SYSJUMP_TAG 0x4c50 /* "LP" */ @@ -72,23 +54,23 @@ static void host_event_set_bit(host_event_t *ev, uint8_t bit) EC_HOST_EVENT_MASK(EC_HOST_EVENT_MKBP) | \ EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)) -static host_event_t lpc_host_events; -static host_event_t lpc_host_event_mask[LPC_HOST_EVENT_COUNT]; +static uint32_t lpc_host_events; +static uint32_t lpc_host_event_mask[LPC_HOST_EVENT_COUNT]; -void lpc_set_host_event_mask(enum lpc_host_event_type type, host_event_t mask) +void lpc_set_host_event_mask(enum lpc_host_event_type type, uint32_t mask) { lpc_host_event_mask[type] = mask; lpc_update_host_event_status(); } -host_event_t lpc_get_host_event_mask(enum lpc_host_event_type type) +uint32_t lpc_get_host_event_mask(enum lpc_host_event_type type) { return lpc_host_event_mask[type]; } -static host_event_t lpc_get_all_host_event_masks(void) +static uint32_t lpc_get_all_host_event_masks(void) { - host_event_t or_mask = 0; + uint32_t or_mask = 0; int i; for (i = 0; i < LPC_HOST_EVENT_COUNT; i++) @@ -97,7 +79,7 @@ static host_event_t lpc_get_all_host_event_masks(void) return or_mask; } -static void lpc_set_host_event_state(host_event_t events) +static void lpc_set_host_event_state(uint32_t events) { if (events == lpc_host_events) return; @@ -106,25 +88,22 @@ static void lpc_set_host_event_state(host_event_t events) lpc_update_host_event_status(); } -host_event_t lpc_get_host_events_by_type(enum lpc_host_event_type type) +uint32_t lpc_get_host_events_by_type(enum lpc_host_event_type type) { return lpc_host_events & lpc_get_host_event_mask(type); } -host_event_t lpc_get_host_events(void) +uint32_t lpc_get_host_events(void) { return lpc_host_events; } int lpc_get_next_host_event(void) { - host_event_t ev; int evt_idx = __builtin_ffs(lpc_host_events); - if (evt_idx) { - host_event_set_bit(&ev, evt_idx); - host_clear_events(ev); - } + if (evt_idx) + host_clear_events(1 << (evt_idx - 1)); return evt_idx; } @@ -145,10 +124,10 @@ DECLARE_HOOK(HOOK_SYSJUMP, lpc_sysjump_save_mask, HOOK_PRIO_DEFAULT); */ static int lpc_post_sysjump_restore_mask(void) { - const host_event_t *prev_mask; + const uint32_t *prev_mask; int size, version; - prev_mask = (const host_event_t *)system_get_jump_tag(LPC_SYSJUMP_TAG, + prev_mask = (const uint32_t *)system_get_jump_tag(LPC_SYSJUMP_TAG, &version, &size); if (!prev_mask || size != sizeof(lpc_host_event_mask) || (version != LPC_SYSJUMP_VERSION && @@ -160,7 +139,7 @@ static int lpc_post_sysjump_restore_mask(void) return version == LPC_SYSJUMP_VERSION; } -host_event_t __attribute__((weak)) lpc_override_always_report_mask(void) +uint32_t __attribute__((weak)) lpc_override_always_report_mask(void) { return LPC_HOST_EVENT_ALWAYS_REPORT_DEFAULT_MASK; } @@ -199,58 +178,18 @@ void lpc_s3_resume_clear_masks(void) * * Setting an event sets both copies. Copies are cleared separately. */ -static host_event_t events; -static host_event_t events_copy_b; - -static void host_events_atomic_or(host_event_t *e, host_event_t m) -{ - uint32_t *ptr = (uint32_t *)e; - - atomic_or(ptr, (uint32_t)m); -#ifdef CONFIG_HOST_EVENT64 - atomic_or(ptr + 1, (uint32_t)(m >> 32)); -#endif -} - -static void host_events_atomic_clear(host_event_t *e, host_event_t m) -{ - uint32_t *ptr = (uint32_t *)e; - - atomic_clear(ptr, (uint32_t)m); -#ifdef CONFIG_HOST_EVENT64 - atomic_clear(ptr + 1, (uint32_t)(m >> 32)); -#endif -} - -#if !defined(CONFIG_LPC) && defined(CONFIG_MKBP_EVENT) -static void host_events_send_mkbp_event(host_event_t e) -{ -#ifdef CONFIG_HOST_EVENT64 - /* - * If event bits in the upper 32-bit are set, indicate 64-bit host - * event. - */ - if (!(uint32_t)e) - mkbp_send_event(EC_MKBP_EVENT_HOST_EVENT64); - else -#endif - mkbp_send_event(EC_MKBP_EVENT_HOST_EVENT); -} -#endif +static uint32_t events; +static uint32_t events_copy_b; -host_event_t host_get_events(void) +uint32_t host_get_events(void) { return events; } -void host_set_events(host_event_t mask) +void host_set_events(uint32_t mask) { /* ignore host events the rest of board doesn't care about */ -#ifdef CONFIG_HOST_EVENT64 - mask &= CONFIG_HOST_EVENT64_REPORT_MASK; -#else mask &= CONFIG_HOST_EVENT_REPORT_MASK; -#endif #ifdef CONFIG_LPC /* @@ -268,63 +207,43 @@ void host_set_events(host_event_t mask) if (!((events & mask) != mask || (events_copy_b & mask) != mask)) return; - HOST_EVENT_CPRINTS("event set", mask); + CPRINTS("event set 0x%08x", mask); - host_events_atomic_or(&events, mask); - host_events_atomic_or(&events_copy_b, mask); + atomic_or(&events, mask); + atomic_or(&events_copy_b, mask); #ifdef CONFIG_LPC lpc_set_host_event_state(events); #else - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; #ifdef CONFIG_MKBP_EVENT #ifdef CONFIG_MKBP_USE_HOST_EVENT #error "Config error: MKBP must not be on top of host event" #endif - host_events_send_mkbp_event(events); + mkbp_send_event(EC_MKBP_EVENT_HOST_EVENT); #endif /* CONFIG_MKBP_EVENT */ #endif /* !CONFIG_LPC */ } -void host_set_single_event(enum host_event_code event) -{ - host_event_t ev = 0; - - host_event_set_bit(&ev, event); - host_set_events(ev); -} - -int host_is_event_set(enum host_event_code event) -{ - host_event_t ev = 0; - - host_event_set_bit(&ev, event); - return events & ev; -} - -void host_clear_events(host_event_t mask) +void host_clear_events(uint32_t mask) { /* ignore host events the rest of board doesn't care about */ -#ifdef CONFIG_HOST_EVENT64 - mask &= CONFIG_HOST_EVENT64_REPORT_MASK; -#else mask &= CONFIG_HOST_EVENT_REPORT_MASK; -#endif /* return early if nothing changed */ if (!(events & mask)) return; - HOST_EVENT_CPRINTS("event clear", mask); + CPRINTS("event clear 0x%08x", mask); - host_events_atomic_clear(&events, mask); + atomic_clear(&events, mask); #ifdef CONFIG_LPC lpc_set_host_event_state(events); #else - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; #ifdef CONFIG_MKBP_EVENT - host_events_send_mkbp_event(events); + mkbp_send_event(EC_MKBP_EVENT_HOST_EVENT); #endif #endif /* !CONFIG_LPC */ } @@ -332,26 +251,13 @@ void host_clear_events(host_event_t mask) #ifndef CONFIG_LPC static int host_get_next_event(uint8_t *out) { - uint32_t event_out = (uint32_t)events; + uint32_t event_out = events; memcpy(out, &event_out, sizeof(event_out)); - host_events_atomic_clear(&events, event_out); - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; + atomic_clear(&events, event_out); + *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; return sizeof(event_out); } DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_HOST_EVENT, host_get_next_event); - -#ifdef CONFIG_HOST_EVENT64 -static int host_get_next_event64(uint8_t *out) -{ - host_event_t event_out = events; - - memcpy(out, &event_out, sizeof(event_out)); - host_events_atomic_clear(&events, event_out); - *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = events; - return sizeof(event_out); -} -DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_HOST_EVENT64, host_get_next_event64); -#endif #endif /** @@ -360,13 +266,13 @@ DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_HOST_EVENT64, host_get_next_event64); * @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(host_event_t mask) +static void host_clear_events_b(uint32_t mask) { /* Only print if something's about to change */ if (events_copy_b & mask) - HOST_EVENT_CPRINTS("event clear B", mask); + CPRINTS("event clear B 0x%08x", mask); - host_events_atomic_clear(&events_copy_b, mask); + atomic_clear(&events_copy_b, mask); } /** @@ -389,7 +295,7 @@ static int command_host_event(int argc, char **argv) /* Handle sub-commands */ if (argc == 3) { char *e; - host_event_t i = strtoul(argv[2], &e, 0); + int i = strtoi(argv[2], &e, 0); if (*e) return EC_ERROR_PARAM2; @@ -415,16 +321,16 @@ static int command_host_event(int argc, char **argv) } /* Print current SMI/SCI status */ - HOST_EVENT_CCPRINTF("Events: ", host_get_events()); - HOST_EVENT_CCPRINTF("Events-B: ", events_copy_b); + ccprintf("Events: 0x%08x\n", host_get_events()); + ccprintf("Events-B: 0x%08x\n", events_copy_b); #ifdef CONFIG_LPC - HOST_EVENT_CCPRINTF("SMI mask: ", + ccprintf("SMI mask: 0x%08x\n", lpc_get_host_event_mask(LPC_HOST_EVENT_SMI)); - HOST_EVENT_CCPRINTF("SCI mask: ", + ccprintf("SCI mask: 0x%08x\n", lpc_get_host_event_mask(LPC_HOST_EVENT_SCI)); - HOST_EVENT_CCPRINTF("Wake mask: ", + ccprintf("Wake mask: 0x%08x\n", lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE)); - HOST_EVENT_CCPRINTF("Always report mask: ", + ccprintf("Always report mask: 0x%08x\n", lpc_get_host_event_mask(LPC_HOST_EVENT_ALWAYS_REPORT)); #endif return EC_SUCCESS; @@ -442,7 +348,7 @@ static int host_event_get_smi_mask(struct host_cmd_handler_args *args) { struct ec_response_host_event_mask *r = args->response; - r->mask = (uint32_t)lpc_get_host_event_mask(LPC_HOST_EVENT_SMI); + r->mask = lpc_get_host_event_mask(LPC_HOST_EVENT_SMI); args->response_size = sizeof(*r); return EC_RES_SUCCESS; @@ -455,7 +361,7 @@ static int host_event_get_sci_mask(struct host_cmd_handler_args *args) { struct ec_response_host_event_mask *r = args->response; - r->mask = (uint32_t)lpc_get_host_event_mask(LPC_HOST_EVENT_SCI); + r->mask = lpc_get_host_event_mask(LPC_HOST_EVENT_SCI); args->response_size = sizeof(*r); return EC_RES_SUCCESS; @@ -468,7 +374,7 @@ static int host_event_get_wake_mask(struct host_cmd_handler_args *args) { struct ec_response_host_event_mask *r = args->response; - r->mask = (uint32_t)lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE); + r->mask = lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE); args->response_size = sizeof(*r); return EC_RES_SUCCESS; diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c index ab5a83d322..e6d06c30fb 100644 --- a/common/keyboard_mkbp.c +++ b/common/keyboard_mkbp.c @@ -87,11 +87,6 @@ static int get_data_size(enum ec_mkbp_event e) case EC_MKBP_EVENT_KEY_MATRIX: return KEYBOARD_COLS; -#ifdef CONFIG_HOST_EVENT64 - case EC_MKBP_EVENT_HOST_EVENT64: - return sizeof(uint64_t); -#endif - case EC_MKBP_EVENT_HOST_EVENT: case EC_MKBP_EVENT_BUTTON: case EC_MKBP_EVENT_SWITCH: @@ -445,17 +440,10 @@ static int mkbp_get_info(struct host_cmd_handler_args *args) break; #endif case EC_MKBP_EVENT_HOST_EVENT: - r->host_event = (uint32_t)host_get_events(); + r->host_event = host_get_events(); args->response_size = sizeof(r->host_event); break; -#ifdef CONFIG_HOST_EVENT64 - case EC_MKBP_EVENT_HOST_EVENT64: - r->host_event64 = host_get_events(); - args->response_size = sizeof(r->host_event64); - break; -#endif - case EC_MKBP_EVENT_BUTTON: r->buttons = mkbp_button_state; args->response_size = sizeof(r->buttons); diff --git a/common/util.c b/common/util.c index a03b434a17..bc4001ee22 100644 --- a/common/util.c +++ b/common/util.c @@ -153,45 +153,6 @@ int strtoi(const char *nptr, char **endptr, int base) return neg ? -result : result; } -uint64_t strtoul(const char *nptr, char **endptr, int base) -{ - uint64_t result = 0; - int c = '\0'; - - if (endptr) - *endptr = (char *)nptr; - - while ((c = *nptr++) && isspace(c)) - ; - - if (c == '0' && *nptr == 'x') { - base = 16; - c = nptr[1]; - nptr += 2; - } else if (base == 0) { - base = 10; - if (c == '-') - return result; - } - - while (c) { - if (c >= '0' && c < '0' + MIN(base, 10)) - result = result * base + (c - '0'); - else if (c >= 'A' && c < 'A' + base - 10) - result = result * base + (c - 'A' + 10); - else if (c >= 'a' && c < 'a' + base - 10) - result = result * base + (c - 'a' + 10); - else - break; - - if (endptr) - *endptr = (char *)nptr; - c = *nptr++; - } - - return result; -} - int parse_bool(const char *s, int *dest) { /* off, disable, false, no */ diff --git a/include/config.h b/include/config.h index dac303fae2..0395eb3b34 100644 --- a/include/config.h +++ b/include/config.h @@ -1335,10 +1335,6 @@ /* clear bit(s) to mask reporting of an EC_HOST_EVENT_XXX event(s) */ #define CONFIG_HOST_EVENT_REPORT_MASK 0xffffffff -#define CONFIG_HOST_EVENT64_REPORT_MASK 0xffffffffffffffffULL - -/* Config option to support 64-bit hostevents and wake-masks. */ -#define CONFIG_HOST_EVENT64 /* * The host commands are sorted in the .rodata.hcmds section so use the binary diff --git a/include/ec_commands.h b/include/ec_commands.h index 54056caf33..24cd099fe1 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -83,7 +83,8 @@ /* Unused 0x28 - 0x2f */ #define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */ /* Unused 0x31 - 0x33 */ -#define EC_MEMMAP_HOST_EVENTS 0x34 /* 64 bits */ +#define EC_MEMMAP_HOST_EVENTS 0x34 /* 32 bits */ +/* Reserve 0x38 - 0x3f for additional host event-related stuff */ /* Battery values are all 32 bits */ #define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */ #define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */ @@ -573,7 +574,7 @@ enum host_event_code { EC_HOST_EVENT_INVALID = 32 }; /* Host event mask */ -#define EC_HOST_EVENT_MASK(event_code) (1ULL << ((event_code) - 1)) +#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1)) /* Arguments at EC_LPC_ADDR_HOST_ARGS */ struct __ec_align4 ec_lpc_host_args { @@ -1090,8 +1091,6 @@ enum ec_feature_code { EC_FEATURE_DEVICE_EVENT = 31, /* EC supports the unified wake masks for LPC/eSPI systems */ EC_FEATURE_UNIFIED_WAKE_MASKS = 32, - /* EC supports 64-bit host events */ - EC_FEATURE_HOST_EVENT64 = 33, }; #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32)) @@ -2922,12 +2921,6 @@ enum ec_mkbp_event { */ EC_MKBP_EVENT_SYSRQ = 6, - /* - * New 64-bit host event. - * The event data is 8 bytes of host event flags. - */ - EC_MKBP_EVENT_HOST_EVENT64 = 7, - /* Number of MKBP events */ EC_MKBP_EVENT_COUNT, }; @@ -2937,7 +2930,6 @@ union __ec_align_offset1 ec_response_get_next_data { /* Unaligned */ uint32_t host_event; - uint64_t host_event64; struct __ec_todo_unpacked { /* For aligning the fifo_info */ diff --git a/include/host_command.h b/include/host_command.h index 6fdbc639e9..78157231ca 100644 --- a/include/host_command.h +++ b/include/host_command.h @@ -122,16 +122,6 @@ struct host_command { int version_mask; }; -#ifdef CONFIG_HOST_EVENT64 -typedef uint64_t host_event_t; -#define HOST_EVENT_CPRINTS(str, e) CPRINTS("%s 0x%016lx", str, e) -#define HOST_EVENT_CCPRINTF(str, e) ccprintf("%s 0x%016lx\n", str, e) -#else -typedef uint32_t host_event_t; -#define HOST_EVENT_CPRINTS(str, e) CPRINTS("%s 0x%08x", str, e) -#define HOST_EVENT_CCPRINTF(str, e) ccprintf("%s 0x%08x\n", str, e) -#endif - /** * Return a pointer to the memory-mapped buffer. * @@ -156,11 +146,21 @@ uint16_t host_command_process(struct host_cmd_handler_args *args); #ifdef CONFIG_HOSTCMD_EVENTS /** + * Set one or more host event bits. + * + * @param mask Event bits to set (use EC_HOST_EVENT_MASK()). + */ +void host_set_events(uint32_t mask); + +/** * Set a single host event. * * @param event Event to set (EC_HOST_EVENT_*). */ -void host_set_single_event(enum host_event_code event); +static inline void host_set_single_event(int event) +{ + host_set_events(EC_HOST_EVENT_MASK(event)); +} /** * Clear one or more host event bits. @@ -168,12 +168,12 @@ void host_set_single_event(enum host_event_code event); * @param mask Event bits to clear (use EC_HOST_EVENT_MASK()). * Write 1 to a bit to clear it. */ -void host_clear_events(host_event_t mask); +void host_clear_events(uint32_t mask); /** * Return the raw event state. */ -host_event_t host_get_events(void); +uint32_t host_get_events(void); /** * Check a single host event. @@ -181,7 +181,10 @@ host_event_t host_get_events(void); * @param event Event to check * @return true if <event> is set or false otherwise */ -int host_is_event_set(enum host_event_code event); +static inline int host_is_event_set(enum host_event_code event) +{ + return host_get_events() & EC_HOST_EVENT_MASK(event); +} #endif /** diff --git a/include/lpc.h b/include/lpc.h index c95999a98e..7b9a7d7012 100644 --- a/include/lpc.h +++ b/include/lpc.h @@ -9,7 +9,6 @@ #define __CROS_EC_LPC_H #include "common.h" -#include "host_command.h" /** * Return a pointer to the memory-mapped buffer. @@ -79,14 +78,14 @@ enum lpc_host_event_type { /** * Get current state of host events. */ -host_event_t lpc_get_host_events(void); +uint32_t lpc_get_host_events(void); /** * Get host events that are set based on the type provided. * * @param type Event type */ -host_event_t lpc_get_host_events_by_type(enum lpc_host_event_type type); +uint32_t lpc_get_host_events_by_type(enum lpc_host_event_type type); /** * Set the event mask for the specified event type. @@ -94,14 +93,14 @@ host_event_t lpc_get_host_events_by_type(enum lpc_host_event_type type); * @param type Event type * @param mask New event mask */ -void lpc_set_host_event_mask(enum lpc_host_event_type type, host_event_t mask); +void lpc_set_host_event_mask(enum lpc_host_event_type type, uint32_t mask); /** * Get host event mask based on the type provided. * * @param type Event type */ -host_event_t lpc_get_host_event_mask(enum lpc_host_event_type type); +uint32_t lpc_get_host_event_mask(enum lpc_host_event_type type); /** * Clear and return the lowest host event. @@ -148,7 +147,7 @@ void lpc_update_host_event_status(void); * LPC_HOST_EVENT_ALWAYS_REPORT mask. It can be implemented by boards if there * is a need to use custom mask. */ -host_event_t lpc_override_always_report_mask(void); +uint32_t lpc_override_always_report_mask(void); /* Initialize LPC masks. */ void lpc_init_mask(void); diff --git a/include/util.h b/include/util.h index 5c5bb57ad1..a2395674e9 100644 --- a/include/util.h +++ b/include/util.h @@ -77,7 +77,6 @@ int strncmp(const char *s1, const char *s2, size_t n); /* Like strtol(), but for integers. */ int strtoi(const char *nptr, char **endptr, int base); -uint64_t strtoul(const char *nptr, char **endptr, int base); /* Like strncpy(), but guarantees null termination. */ char *strzcpy(char *dest, const char *src, int len); diff --git a/power/intel_x86.c b/power/intel_x86.c index 92972d2c73..e2b2e42303 100644 --- a/power/intel_x86.c +++ b/power/intel_x86.c @@ -141,7 +141,7 @@ static enum power_state power_wait_s5_rtc_reset(void) static void s0ix_lpc_enable_wake_mask(void) { if (chipset_in_state(CHIPSET_STATE_STANDBY | CHIPSET_STATE_ON)) { - host_event_t mask; + uint32_t mask; mask = lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE) | EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) | @@ -161,7 +161,7 @@ static void s0ix_lpc_enable_wake_mask(void) static void s0ix_lpc_disable_wake_mask(void) { if (chipset_in_state(CHIPSET_STATE_STANDBY | CHIPSET_STATE_ON)) { - host_event_t mask; + uint32_t mask; mask = lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE) & ~EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) & |