summaryrefslogtreecommitdiff
path: root/chip/mec1322
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/mec1322
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/mec1322')
-rw-r--r--chip/mec1322/lpc.c98
1 files changed, 7 insertions, 91 deletions
diff --git a/chip/mec1322/lpc.c b/chip/mec1322/lpc.c
index e5eae508ae..5f4d1f43a6 100644
--- a/chip/mec1322/lpc.c
+++ b/chip/mec1322/lpc.c
@@ -24,12 +24,8 @@
#define CPUTS(outstr) cputs(CC_LPC, outstr)
#define CPRINTS(format, args...) cprints(CC_LPC, format, ## args)
-#define LPC_SYSJUMP_TAG 0x4c50 /* "LP" */
-
static uint8_t mem_mapped[0x200] __attribute__((section(".bss.big_align")));
-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 */
@@ -126,7 +122,7 @@ static uint8_t *lpc_get_hostcmd_data_range(void)
* - SMI pulse via PCH_SMI_L GPIO
* - SCI pulse via PCH_SCI_L GPIO
*/
-static void update_host_event_status(void)
+void lpc_update_host_event_status(void)
{
int need_sci = 0;
int need_smi = 0;
@@ -137,7 +133,7 @@ static void update_host_event_status(void)
/* Disable LPC interrupt while updating status register */
task_disable_irq(MEC1322_IRQ_ACPIEC0_IBF);
- 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 (!(MEC1322_ACPI_EC_STATUS(0) & EC_LPC_STATUS_SMI_PENDING))
need_smi = 1;
@@ -146,7 +142,7 @@ static void update_host_event_status(void)
MEC1322_ACPI_EC_STATUS(0) &= ~EC_LPC_STATUS_SMI_PENDING;
}
- 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;
MEC1322_ACPI_EC_STATUS(0) |= EC_LPC_STATUS_SCI_PENDING;
@@ -155,12 +151,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(MEC1322_IRQ_ACPIEC0_IBF);
/* 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)
@@ -184,34 +181,6 @@ static void lpc_send_response_packet(struct host_packet *pkt)
MEC1322_ACPI_EC_STATUS(1) &= ~EC_LPC_STATUS_PROCESSING;
}
-/**
- * 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));
-}
-
-
-
/*
* Most registers in LPC module are reset when the host is off. We need to
* set up LPC again when the host is starting up.
@@ -288,7 +257,7 @@ static void setup_lpc(void)
init_done = 1;
/* Update host events now that we can copy them to memmap */
- update_host_event_status();
+ lpc_update_host_event_status();
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, setup_lpc, HOOK_PRIO_FIRST);
@@ -308,8 +277,6 @@ static void lpc_resume(void)
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, lpc_resume, HOOK_PRIO_DEFAULT);
-
-
static void lpc_init(void)
{
/* Activate LPC interface */
@@ -326,9 +293,6 @@ static void lpc_init(void)
memset(lpc_get_memmap_range(), 0, EC_MEMMAP_SIZE);
setup_lpc();
-
- /* Restore event masks if needed */
- lpc_post_sysjump();
}
/*
* Set prio to higher than default; this way LPC memory mapped data is ready
@@ -517,54 +481,6 @@ void lpc_keyboard_resume_irq(void)
keyboard_irq_assert();
}
-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)
{
MEC1322_ACPI_EC_STATUS(0) |= mask;