summaryrefslogtreecommitdiff
path: root/src/mainboard
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-10-04 14:01:41 -0700
committerFurquan Shaikh <furquan@google.com>2017-10-08 19:38:28 +0000
commit2749c52080bbaba9e6ce54fb327b7157a7e392c2 (patch)
tree91e05dd62841fe1d1f0f63bba017d1fd11550613 /src/mainboard
parent687b023d970327e2d4994e5fb170edf9a1e7180f (diff)
downloadcoreboot-2749c52080bbaba9e6ce54fb327b7157a7e392c2.tar.xz
ec/google/chromeec: Add library function google_chromeec_events_init
mainboard_ec_init implemented by all x86-based mainboards using chromeec performed similar tasks for initializing and recording ec events. Instead of duplicating this code across multiple boards, provide a library function google_chromeec_events_init that can be called by mainboard with appropriate inputs to perform the required actions. This change also adds a new structure google_chromeec_event_info to allow mainboards to provide information required by the library function to handle different event masks. Also, google_chromeec_log_device_events and google_chromeec_log_events no longer need to be exported. Change-Id: I1cbc24e3e1a31aed35d8527f90ed16ed15ccaa86 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/21877 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'src/mainboard')
-rw-r--r--src/mainboard/google/auron/ec.c27
-rw-r--r--src/mainboard/google/chell/ec.c28
-rw-r--r--src/mainboard/google/cyan/ec.c33
-rw-r--r--src/mainboard/google/eve/ec.c31
-rw-r--r--src/mainboard/google/fizz/ec.c26
-rw-r--r--src/mainboard/google/glados/ec.c28
-rw-r--r--src/mainboard/google/kahlee/ec.c28
-rw-r--r--src/mainboard/google/lars/ec.c28
-rw-r--r--src/mainboard/google/link/ec.c26
-rw-r--r--src/mainboard/google/poppy/ec.c25
-rw-r--r--src/mainboard/google/rambi/ec.c27
-rw-r--r--src/mainboard/google/reef/ec.c28
-rw-r--r--src/mainboard/google/slippy/ec.c26
-rw-r--r--src/mainboard/google/zoombini/ec.c26
-rw-r--r--src/mainboard/intel/glkrvp/ec.c28
-rw-r--r--src/mainboard/intel/kblrvp/ec.c28
-rw-r--r--src/mainboard/intel/kunimitsu/ec.c28
-rw-r--r--src/mainboard/intel/strago/ec.c33
18 files changed, 145 insertions, 359 deletions
diff --git a/src/mainboard/google/auron/ec.c b/src/mainboard/google/auron/ec.c
index 5feafb8d08..3fc5373096 100644
--- a/src/mainboard/google/auron/ec.c
+++ b/src/mainboard/google/auron/ec.c
@@ -22,28 +22,17 @@
void mainboard_ec_init(void)
{
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
+
printk(BIOS_DEBUG, "mainboard_ec_init\n");
post_code(0xf0);
- /* Restore SCI event mask on resume. */
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake events, these are enabled on entry to sleep */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
post_code(0xf1);
}
diff --git a/src/mainboard/google/chell/ec.c b/src/mainboard/google/chell/ec.c
index 36cd10acd1..372237800e 100644
--- a/src/mainboard/google/chell/ec.c
+++ b/src/mainboard/google/chell/ec.c
@@ -21,26 +21,14 @@
void mainboard_ec_init(void)
{
- printk(BIOS_DEBUG, "mainboard: EC init\n");
-
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
+ printk(BIOS_DEBUG, "mainboard: EC init\n");
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/google/cyan/ec.c b/src/mainboard/google/cyan/ec.c
index cce7d705e1..efd20a597f 100644
--- a/src/mainboard/google/cyan/ec.c
+++ b/src/mainboard/google/cyan/ec.c
@@ -23,33 +23,18 @@
void mainboard_ec_init(void)
{
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
+
printk(BIOS_DEBUG, "mainboard_ec_init\n");
post_code(0xf0);
-#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)
- /* Restore SCI event mask on resume. */
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
- /*
- * Set SCI mask.OS may not generate SMI event to set
- * this on S3 resume.
- */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
+ if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
-#endif
post_code(0xf1);
}
diff --git a/src/mainboard/google/eve/ec.c b/src/mainboard/google/eve/ec.c
index d5710f326d..893255ad47 100644
--- a/src/mainboard/google/eve/ec.c
+++ b/src/mainboard/google/eve/ec.c
@@ -20,28 +20,13 @@
void mainboard_ec_init(void)
{
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s3_device_events = MAINBOARD_EC_S3_DEVICE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Log and clear device events that may wake the system */
- google_chromeec_log_device_events(
- MAINBOARD_EC_S3_DEVICE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/google/fizz/ec.c b/src/mainboard/google/fizz/ec.c
index 0f2dccfaaf..6b3ec9e35f 100644
--- a/src/mainboard/google/fizz/ec.c
+++ b/src/mainboard/google/fizz/ec.c
@@ -20,24 +20,12 @@
void mainboard_ec_init(void)
{
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/google/glados/ec.c b/src/mainboard/google/glados/ec.c
index 36cd10acd1..372237800e 100644
--- a/src/mainboard/google/glados/ec.c
+++ b/src/mainboard/google/glados/ec.c
@@ -21,26 +21,14 @@
void mainboard_ec_init(void)
{
- printk(BIOS_DEBUG, "mainboard: EC init\n");
-
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
+ printk(BIOS_DEBUG, "mainboard: EC init\n");
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/google/kahlee/ec.c b/src/mainboard/google/kahlee/ec.c
index 75ed1fa8eb..0d1dae2bde 100644
--- a/src/mainboard/google/kahlee/ec.c
+++ b/src/mainboard/google/kahlee/ec.c
@@ -22,28 +22,16 @@
static void ramstage_ec_init(void)
{
- printk(BIOS_ERR, "mainboard: EC init\n");
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
+ printk(BIOS_DEBUG, "mainboard: EC init\n");
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
static void early_ec_init(void)
diff --git a/src/mainboard/google/lars/ec.c b/src/mainboard/google/lars/ec.c
index 36cd10acd1..372237800e 100644
--- a/src/mainboard/google/lars/ec.c
+++ b/src/mainboard/google/lars/ec.c
@@ -21,26 +21,14 @@
void mainboard_ec_init(void)
{
- printk(BIOS_DEBUG, "mainboard: EC init\n");
-
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
+ printk(BIOS_DEBUG, "mainboard: EC init\n");
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/google/link/ec.c b/src/mainboard/google/link/ec.c
index acf118553e..37949f6855 100644
--- a/src/mainboard/google/link/ec.c
+++ b/src/mainboard/google/link/ec.c
@@ -21,27 +21,17 @@
void link_ec_init(void)
{
+ const struct google_chromeec_event_info info = {
+ .log_events = LINK_EC_LOG_EVENTS,
+ .sci_events = LINK_EC_SCI_EVENTS,
+ .s3_wake_events = LINK_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = LINK_EC_S5_WAKE_EVENTS,
+ };
+
printk(BIOS_DEBUG, "link_ec_init\n");
post_code(0xf0);
- /* Restore SCI event mask on resume. */
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(LINK_EC_LOG_EVENTS |
- LINK_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0);
- google_chromeec_set_sci_mask(LINK_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(LINK_EC_LOG_EVENTS |
- LINK_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake events, these are enabled on entry to sleep */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
post_code(0xf1);
}
diff --git a/src/mainboard/google/poppy/ec.c b/src/mainboard/google/poppy/ec.c
index f0559ca6f7..ef1d55c2c7 100644
--- a/src/mainboard/google/poppy/ec.c
+++ b/src/mainboard/google/poppy/ec.c
@@ -20,24 +20,13 @@
void mainboard_ec_init(void)
{
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
}
diff --git a/src/mainboard/google/rambi/ec.c b/src/mainboard/google/rambi/ec.c
index 27fcb0f066..307aedf28f 100644
--- a/src/mainboard/google/rambi/ec.c
+++ b/src/mainboard/google/rambi/ec.c
@@ -21,28 +21,21 @@
void mainboard_ec_init(void)
{
+ bool s3_wakeup = acpi_is_wakeup_s3();
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
+
printk(BIOS_DEBUG, "mainboard_ec_init\n");
post_code(0xf0);
- /* Restore SCI event mask on resume. */
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
+ google_chromeec_events_init(&info, s3_wakeup);
- /* Clear pending events */
- while (google_chromeec_get_event() != 0);
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
+ if (!s3_wakeup)
google_chromeec_set_smi_mask(MAINBOARD_EC_SMI_EVENTS);
- }
-
- /* Clear wake events, these are enabled on entry to sleep */
- google_chromeec_set_wake_mask(0);
post_code(0xf1);
}
diff --git a/src/mainboard/google/reef/ec.c b/src/mainboard/google/reef/ec.c
index 59fa442414..54e9c361a6 100644
--- a/src/mainboard/google/reef/ec.c
+++ b/src/mainboard/google/reef/ec.c
@@ -23,28 +23,16 @@
static void ramstage_ec_init(void)
{
- printk(BIOS_ERR, "mainboard: EC init\n");
-
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
+ printk(BIOS_ERR, "mainboard: EC init\n");
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
static void bootblock_ec_init(void)
diff --git a/src/mainboard/google/slippy/ec.c b/src/mainboard/google/slippy/ec.c
index c011f33d60..f8ab6b81d5 100644
--- a/src/mainboard/google/slippy/ec.c
+++ b/src/mainboard/google/slippy/ec.c
@@ -21,27 +21,17 @@
void mainboard_ec_init(void)
{
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
+
printk(BIOS_DEBUG, "mainboard_ec_init\n");
post_code(0xf0);
- /* Restore SCI event mask on resume. */
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0);
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake events, these are enabled on entry to sleep */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
post_code(0xf1);
}
diff --git a/src/mainboard/google/zoombini/ec.c b/src/mainboard/google/zoombini/ec.c
index 2ce1abfe48..d756444e15 100644
--- a/src/mainboard/google/zoombini/ec.c
+++ b/src/mainboard/google/zoombini/ec.c
@@ -19,24 +19,12 @@
void mainboard_ec_init(void)
{
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/intel/glkrvp/ec.c b/src/mainboard/intel/glkrvp/ec.c
index ff891a99a9..c17033832e 100644
--- a/src/mainboard/intel/glkrvp/ec.c
+++ b/src/mainboard/intel/glkrvp/ec.c
@@ -24,28 +24,16 @@
static void ramstage_ec_init(void)
{
- printk(BIOS_ERR, "mainboard: EC init\n");
-
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
+ printk(BIOS_ERR, "mainboard: EC init\n");
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
static void bootblock_ec_init(void)
diff --git a/src/mainboard/intel/kblrvp/ec.c b/src/mainboard/intel/kblrvp/ec.c
index 235ecab9ef..b40aabf73c 100644
--- a/src/mainboard/intel/kblrvp/ec.c
+++ b/src/mainboard/intel/kblrvp/ec.c
@@ -21,26 +21,14 @@
void mainboard_ec_init(void)
{
- printk(BIOS_DEBUG, "mainboard: EC init\n");
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
+ printk(BIOS_ERR, "mainboard: EC init\n");
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/intel/kunimitsu/ec.c b/src/mainboard/intel/kunimitsu/ec.c
index 36cd10acd1..32ae8ba22f 100644
--- a/src/mainboard/intel/kunimitsu/ec.c
+++ b/src/mainboard/intel/kunimitsu/ec.c
@@ -21,26 +21,14 @@
void mainboard_ec_init(void)
{
- printk(BIOS_DEBUG, "mainboard: EC init\n");
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
+ printk(BIOS_ERR, "mainboard: EC init\n");
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
-
- /* Restore SCI event mask */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
-
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
}
diff --git a/src/mainboard/intel/strago/ec.c b/src/mainboard/intel/strago/ec.c
index dabe274fbf..efd20a597f 100644
--- a/src/mainboard/intel/strago/ec.c
+++ b/src/mainboard/intel/strago/ec.c
@@ -23,33 +23,18 @@
void mainboard_ec_init(void)
{
+ const struct google_chromeec_event_info info = {
+ .log_events = MAINBOARD_EC_LOG_EVENTS,
+ .sci_events = MAINBOARD_EC_SCI_EVENTS,
+ .s3_wake_events = MAINBOARD_EC_S3_WAKE_EVENTS,
+ .s5_wake_events = MAINBOARD_EC_S5_WAKE_EVENTS,
+ };
+
printk(BIOS_DEBUG, "mainboard_ec_init\n");
post_code(0xf0);
-#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)
- /* Restore SCI event mask on resume. */
- if (acpi_is_wakeup_s3()) {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S3_WAKE_EVENTS);
-
- /* Disable SMI and wake events */
- google_chromeec_set_smi_mask(0);
-
- /* Clear pending events */
- while (google_chromeec_get_event() != 0)
- ;
- /*
- * Set SCI mask.OS may not generate the SMI event to
- * set this on S3 resume
- */
- google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
- } else {
- google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
- MAINBOARD_EC_S5_WAKE_EVENTS);
- }
+ if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
+ google_chromeec_events_init(&info, acpi_is_wakeup_s3());
- /* Clear wake event mask */
- google_chromeec_set_wake_mask(0);
-#endif
post_code(0xf1);
}