summaryrefslogtreecommitdiff
path: root/chip/it83xx
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-10-09 22:02:22 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-17 23:14:19 -0700
commitb9e07ce1bfa42ea2a5e7564575b0072c13811c31 (patch)
tree16e69783b0b8e1825c88a2753912949dc9ef7ef8 /chip/it83xx
parent501fba17a93c5a08afd4bdaeb9c632712557c362 (diff)
downloadchrome-ec-b9e07ce1bfa42ea2a5e7564575b0072c13811c31.tar.gz
host_event: Move host events and mask handling into common code
Instead of duplicating the handling of host events and host event masks in chip lpc drivers, add routines in common code to provide basic functions like setting/getting of masks, setting/getting of events and handling of masks transitions across sysjump. BUG=None BRANCH=None TEST=make -j buildall. Verified following: 1. Event masks are correctly retained across sysjumps. 2. Wake from S3 works fine. 3. Wake from S0ix works fine. 4. SCI generated correctly. Change-Id: Ie409f91b12788e4b902b2627e31ba5ce40ff1d27 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/707771 Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'chip/it83xx')
-rw-r--r--chip/it83xx/lpc.c94
1 files changed, 7 insertions, 87 deletions
diff --git a/chip/it83xx/lpc.c b/chip/it83xx/lpc.c
index a7e1609419..71ce9fa16b 100644
--- a/chip/it83xx/lpc.c
+++ b/chip/it83xx/lpc.c
@@ -30,8 +30,6 @@
#define CPUTS(outstr) cputs(CC_LPC, outstr)
#define CPRINTS(format, args...) cprints(CC_LPC, format, ## args)
-#define LPC_SYSJUMP_TAG 0x4c50 /* "LP" */
-
/* LPC PM channels */
enum lpc_pm_ch {
LPC_PM1 = 0,
@@ -57,8 +55,6 @@ static uint8_t acpi_ec_memmap[EC_MEMMAP_SIZE]
static uint8_t host_cmd_memmap[256]
__attribute__((section(".h2ram.pool.hostcmd")));
-static uint32_t host_events; /* Currently pending SCI/SMI events */
-static uint32_t event_mask[3]; /* Event masks for each type */
static struct host_packet lpc_packet;
static struct host_cmd_handler_args host_cmd_args;
static uint8_t host_cmd_flags; /* Flags from host command */
@@ -213,7 +209,7 @@ static void lpc_send_response(struct host_cmd_handler_args *args)
pm_set_status(LPC_HOST_CMD, EC_LPC_STATUS_PROCESSING, 0);
}
-static void update_host_event_status(void)
+void lpc_update_host_event_status(void)
{
int need_sci = 0;
int need_smi = 0;
@@ -224,7 +220,7 @@ static void update_host_event_status(void)
/* Disable PMC1 interrupt while updating status register */
task_disable_irq(IT83XX_IRQ_PMC_IN);
- if (host_events & event_mask[LPC_HOST_EVENT_SMI]) {
+ if (lpc_get_host_events_by_type(LPC_HOST_EVENT_SMI)) {
/* Only generate SMI for first event */
if (!(pm_get_status(LPC_ACPI_CMD) & EC_LPC_STATUS_SMI_PENDING))
need_smi = 1;
@@ -233,7 +229,7 @@ static void update_host_event_status(void)
pm_set_status(LPC_ACPI_CMD, EC_LPC_STATUS_SMI_PENDING, 0);
}
- if (host_events & event_mask[LPC_HOST_EVENT_SCI]) {
+ if (lpc_get_host_events_by_type(LPC_HOST_EVENT_SCI)) {
/* Generate SCI for every event */
need_sci = 1;
pm_set_status(LPC_ACPI_CMD, EC_LPC_STATUS_SCI_PENDING, 1);
@@ -242,12 +238,13 @@ static void update_host_event_status(void)
}
/* Copy host events to mapped memory */
- *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) = host_events;
+ *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) =
+ lpc_get_host_events();
task_enable_irq(IT83XX_IRQ_PMC_IN);
/* Process the wake events. */
- lpc_update_wake(host_events & event_mask[LPC_HOST_EVENT_WAKE]);
+ lpc_update_wake(lpc_get_host_events_by_type(LPC_HOST_EVENT_WAKE));
/* Send pulse on SMI signal if needed */
if (need_smi)
@@ -358,54 +355,6 @@ void lpc_keyboard_resume_irq(void)
}
}
-void lpc_set_host_event_state(uint32_t mask)
-{
- if (mask != host_events) {
- host_events = mask;
- update_host_event_status();
- }
-}
-
-int lpc_query_host_event_state(void)
-{
- const uint32_t any_mask = event_mask[0] | event_mask[1] | event_mask[2];
- int evt_index = 0;
- int i;
-
- for (i = 0; i < 32; i++) {
- const uint32_t e = (1 << i);
-
- if (host_events & e) {
- host_clear_events(e);
-
- /*
- * If host hasn't unmasked this event, drop it. We do
- * this at query time rather than event generation time
- * so that the host has a chance to unmask events
- * before they're dropped by a query.
- */
- if (!(e & any_mask))
- continue;
-
- evt_index = i + 1; /* Events are 1-based */
- break;
- }
- }
-
- return evt_index;
-}
-
-void lpc_set_host_event_mask(enum lpc_host_event_type type, uint32_t mask)
-{
- event_mask[type] = mask;
- update_host_event_status();
-}
-
-uint32_t lpc_get_host_event_mask(enum lpc_host_event_type type)
-{
- return event_mask[type];
-}
-
void lpc_set_acpi_status_mask(uint8_t mask)
{
pm_set_status(LPC_ACPI_CMD, mask, 1);
@@ -600,32 +549,6 @@ void pm5_ibf_interrupt(void)
task_clear_pending_irq(IT83XX_IRQ_PMC5_IN);
}
-/**
- * Preserve event masks across a sysjump.
- */
-static void lpc_sysjump(void)
-{
- system_add_jump_tag(LPC_SYSJUMP_TAG, 1,
- sizeof(event_mask), event_mask);
-}
-DECLARE_HOOK(HOOK_SYSJUMP, lpc_sysjump, HOOK_PRIO_DEFAULT);
-
-/**
- * Restore event masks after a sysjump.
- */
-static void lpc_post_sysjump(void)
-{
- const uint32_t *prev_mask;
- int size, version;
-
- prev_mask = (const uint32_t *)system_get_jump_tag(LPC_SYSJUMP_TAG,
- &version, &size);
- if (!prev_mask || version != 1 || size != sizeof(event_mask))
- return;
-
- memcpy(event_mask, prev_mask, sizeof(event_mask));
-}
-
static void lpc_init(void)
{
enum ec2i_message ec2i_r;
@@ -761,14 +684,11 @@ static void lpc_init(void)
task_clear_pending_irq(IT83XX_IRQ_PMC3_IN);
task_enable_irq(IT83XX_IRQ_PMC3_IN);
- /* Restore event masks if needed */
- lpc_post_sysjump();
-
/* Sufficiently initialized */
init_done = 1;
/* Update host events now that we can copy them to memmap */
- update_host_event_status();
+ lpc_update_host_event_status();
}
/*
* Set prio to higher than default; this way LPC memory mapped data is ready