Furquan Shaikh has uploaded this change for review. ( https://review.coreboot.org/21877
Change subject: ec/google/chromeec: Add library function google_chromeec_events_init ......................................................................
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 --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/auron/ec.c M src/mainboard/google/chell/ec.c M src/mainboard/google/cyan/ec.c M src/mainboard/google/eve/ec.c M src/mainboard/google/fizz/ec.c M src/mainboard/google/glados/ec.c M src/mainboard/google/kahlee/ec.c M src/mainboard/google/lars/ec.c M src/mainboard/google/link/ec.c M src/mainboard/google/poppy/ec.c M src/mainboard/google/rambi/ec.c M src/mainboard/google/reef/ec.c M src/mainboard/google/slippy/ec.c M src/mainboard/google/zoombini/ec.c M src/mainboard/intel/glkrvp/ec.c M src/mainboard/intel/kblrvp/ec.c M src/mainboard/intel/kunimitsu/ec.c M src/mainboard/intel/strago/ec.c 20 files changed, 204 insertions(+), 382 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/21877/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index ab879c5..639719a 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -222,12 +222,12 @@ return 0; }
-void google_chromeec_log_device_events(uint32_t mask) +static void google_chromeec_log_device_events(uint32_t mask) { uint32_t events; int i;
- if (!IS_ENABLED(CONFIG_ELOG)) + if (!IS_ENABLED(CONFIG_ELOG) || !mask) return;
if (google_chromeec_check_feature(EC_FEATURE_DEVICE_EVENT) != 1) @@ -240,6 +240,53 @@ if (EC_DEVICE_EVENT_MASK(i) & events) elog_add_event_byte(ELOG_TYPE_EC_DEVICE_EVENT, i); } +} + +static void google_chromeec_log_events(u32 mask) +{ + u8 event; + u32 wake_mask; + + if (!IS_ENABLED(CONFIG_ELOG)) + return; + + /* Set wake mask so events will be read from ACPI interface */ + wake_mask = google_chromeec_get_wake_mask(); + google_chromeec_set_wake_mask(mask); + + while ((event = google_chromeec_get_event()) != 0) { + if (EC_HOST_EVENT_MASK(event) & mask) + elog_add_event_byte(ELOG_TYPE_EC_EVENT, event); + } + + google_chromeec_set_wake_mask(wake_mask); +} + +void google_chromeec_events_init(const struct google_chromeec_event_info *info, + bool is_s3_wakeup) +{ + if (is_s3_wakeup) { + google_chromeec_log_events(info->log_events | + info->s3_wake_events); + + /* Log and clear device events that may wake the system. */ + google_chromeec_log_device_events(info->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(info->sci_events); + } else + google_chromeec_log_events(info->log_events | + info->s5_wake_events); + + /* Clear wake event mask. */ + google_chromeec_set_wake_mask(0); }
int google_chromeec_check_feature(int feature) @@ -518,25 +565,6 @@ { return google_chromeec_get_mask( EC_CMD_HOST_EVENT_GET_WAKE_MASK); -} - -void google_chromeec_log_events(u32 mask) -{ -#if IS_ENABLED(CONFIG_ELOG) - u8 event; - u32 wake_mask; - - /* Set wake mask so events will be read from ACPI interface */ - wake_mask = google_chromeec_get_wake_mask(); - google_chromeec_set_wake_mask(mask); - - while ((event = google_chromeec_get_event()) != 0) { - if (EC_HOST_EVENT_MASK(event) & mask) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, event); - } - - google_chromeec_set_wake_mask(wake_mask); -#endif }
int google_chromeec_set_usb_charge_mode(u8 port_id, enum usb_charge_mode mode) diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 81bc933..95d7443 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -38,7 +38,6 @@ uint32_t google_chromeec_get_device_enabled_events(void); int google_chromeec_set_device_enabled_events(uint32_t mask); uint32_t google_chromeec_get_device_current_events(void); -void google_chromeec_log_device_events(uint32_t mask);
int google_chromeec_check_feature(int feature); uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size); @@ -49,7 +48,6 @@ int google_chromeec_clear_events_b(u32 mask); int google_chromeec_kbbacklight(int percent); void google_chromeec_post(u8 postcode); -void google_chromeec_log_events(u32 mask); int google_chromeec_vbnv_context(int is_read, uint8_t *data, int len); uint8_t google_chromeec_get_switches(void);
@@ -118,4 +116,14 @@
int google_chromeec_command(struct chromeec_command *cec_command);
+struct google_chromeec_event_info { + uint32_t log_events; + uint32_t sci_events; + uint32_t s3_wake_events; + uint32_t s3_device_events; + uint32_t s5_wake_events; +}; +void google_chromeec_events_init(const struct google_chromeec_event_info *info, + bool is_s3_wakeup); + #endif /* _EC_GOOGLE_CHROMEEC_EC_H */ diff --git a/src/mainboard/google/auron/ec.c b/src/mainboard/google/auron/ec.c index 5feafb8..3fc5373 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 36cd10a..3722378 100644 --- a/src/mainboard/google/chell/ec.c +++ b/src/mainboard/google/chell/ec.c @@ -21,26 +21,14 @@
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");
- 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) - ; - - /* 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/cyan/ec.c b/src/mainboard/google/cyan/ec.c index cce7d70..efd20a5 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); + if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)) + google_chromeec_events_init(&info, acpi_is_wakeup_s3());
- /* 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); - } - - /* 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 d5710f3..893255a 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 0f2dccf..6b3ec9e 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 36cd10a..3722378 100644 --- a/src/mainboard/google/glados/ec.c +++ b/src/mainboard/google/glados/ec.c @@ -21,26 +21,14 @@
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");
- 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) - ; - - /* 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/kahlee/ec.c b/src/mainboard/google/kahlee/ec.c index 75ed1fa..0d1dae2 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 36cd10a..3722378 100644 --- a/src/mainboard/google/lars/ec.c +++ b/src/mainboard/google/lars/ec.c @@ -21,26 +21,14 @@
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");
- 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) - ; - - /* 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/link/ec.c b/src/mainboard/google/link/ec.c index acf1185..37949f6 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 f0559ca..ef1d55c 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 27fcb0f..307aedf 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); + google_chromeec_events_init(&info, s3_wakeup);
- /* 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); + 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 59fa442..54e9c36 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) { + 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_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); - - /* 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 bootblock_ec_init(void) diff --git a/src/mainboard/google/slippy/ec.c b/src/mainboard/google/slippy/ec.c index c011f33..f8ab6b8 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 2ce1abf..d756444 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 ff891a9..c170338 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) { + 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_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); - - /* 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 bootblock_ec_init(void) diff --git a/src/mainboard/intel/kblrvp/ec.c b/src/mainboard/intel/kblrvp/ec.c index 235ecab..b40aabf 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 36cd10a..32ae8ba 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 dabe274..efd20a5 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); + if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)) + google_chromeec_events_init(&info, acpi_is_wakeup_s3());
- /* 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); - } - - /* Clear wake event mask */ - google_chromeec_set_wake_mask(0); -#endif post_code(0xf1); }