summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-11-14 18:51:42 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-11-21 18:53:35 -0800
commitc9cd870600b12123dddc88814446327337557369 (patch)
treee1e24ad901e91e98831b38c1ccd315cb272b9a6a /include
parent0da531fae0099080b7dd472ade0788c18162cc19 (diff)
downloadchrome-ec-c9cd870600b12123dddc88814446327337557369.tar.gz
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: Idcb24ea364ac6c491efc2f8dd9e29a9df6149e07 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/770925 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/config.h4
-rw-r--r--include/ec_commands.h14
-rw-r--r--include/host_command.h31
-rw-r--r--include/lpc.h11
-rw-r--r--include/util.h1
5 files changed, 36 insertions, 25 deletions
diff --git a/include/config.h b/include/config.h
index 083f81258d..dba87924db 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1436,6 +1436,10 @@
/* 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 09ebc75319..fb39644e19 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -83,8 +83,7 @@
/* Unused 0x28 - 0x2f */
#define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */
/* Unused 0x31 - 0x33 */
-#define EC_MEMMAP_HOST_EVENTS 0x34 /* 32 bits */
-/* Reserve 0x38 - 0x3f for additional host event-related stuff */
+#define EC_MEMMAP_HOST_EVENTS 0x34 /* 64 bits */
/* Battery values are all 32 bits */
#define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */
#define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */
@@ -595,7 +594,7 @@ enum host_event_code {
EC_HOST_EVENT_INVALID = 32
};
/* Host event mask */
-#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
+#define EC_HOST_EVENT_MASK(event_code) (1ULL << ((event_code) - 1))
/* Arguments at EC_LPC_ADDR_HOST_ARGS */
struct __ec_align4 ec_lpc_host_args {
@@ -1112,6 +1111,8 @@ 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))
@@ -3016,6 +3017,12 @@ 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,
};
@@ -3025,6 +3032,7 @@ 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 78157231ca..6fdbc639e9 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -122,6 +122,16 @@ 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.
*
@@ -146,21 +156,11 @@ 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_*).
*/
-static inline void host_set_single_event(int event)
-{
- host_set_events(EC_HOST_EVENT_MASK(event));
-}
+void host_set_single_event(enum host_event_code event);
/**
* Clear one or more host event bits.
@@ -168,12 +168,12 @@ static inline void host_set_single_event(int event)
* @param mask Event bits to clear (use EC_HOST_EVENT_MASK()).
* Write 1 to a bit to clear it.
*/
-void host_clear_events(uint32_t mask);
+void host_clear_events(host_event_t mask);
/**
* Return the raw event state.
*/
-uint32_t host_get_events(void);
+host_event_t host_get_events(void);
/**
* Check a single host event.
@@ -181,10 +181,7 @@ uint32_t host_get_events(void);
* @param event Event to check
* @return true if <event> is set or false otherwise
*/
-static inline int host_is_event_set(enum host_event_code event)
-{
- return host_get_events() & EC_HOST_EVENT_MASK(event);
-}
+int host_is_event_set(enum host_event_code event);
#endif
/**
diff --git a/include/lpc.h b/include/lpc.h
index 7b9a7d7012..c95999a98e 100644
--- a/include/lpc.h
+++ b/include/lpc.h
@@ -9,6 +9,7 @@
#define __CROS_EC_LPC_H
#include "common.h"
+#include "host_command.h"
/**
* Return a pointer to the memory-mapped buffer.
@@ -78,14 +79,14 @@ enum lpc_host_event_type {
/**
* Get current state of host events.
*/
-uint32_t lpc_get_host_events(void);
+host_event_t lpc_get_host_events(void);
/**
* Get host events that are set based on the type provided.
*
* @param type Event type
*/
-uint32_t lpc_get_host_events_by_type(enum lpc_host_event_type type);
+host_event_t lpc_get_host_events_by_type(enum lpc_host_event_type type);
/**
* Set the event mask for the specified event type.
@@ -93,14 +94,14 @@ uint32_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, uint32_t mask);
+void lpc_set_host_event_mask(enum lpc_host_event_type type, host_event_t mask);
/**
* Get host event mask based on the type provided.
*
* @param type Event type
*/
-uint32_t lpc_get_host_event_mask(enum lpc_host_event_type type);
+host_event_t lpc_get_host_event_mask(enum lpc_host_event_type type);
/**
* Clear and return the lowest host event.
@@ -147,7 +148,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.
*/
-uint32_t lpc_override_always_report_mask(void);
+host_event_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 bf3405728a..453ff8c739 100644
--- a/include/util.h
+++ b/include/util.h
@@ -77,6 +77,7 @@ 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);