Kyösti Mälkki has submitted this change. ( https://review.coreboot.org/c/coreboot/+/36647 )
Change subject: ELOG: Introduce elog_gsmi variants ......................................................................
ELOG: Introduce elog_gsmi variants
This avoids a lot of if (CONFIG(ELOG_GSMI)) boilerplate.
Change-Id: I87d25c820daedeb33b3b474a6632a89ea80b0867 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/36647 Reviewed-by: Aaron Durbin adurbin@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/ec/google/chromeec/smihandler.c M src/include/elog.h M src/mainboard/google/auron/smihandler.c M src/mainboard/google/cyan/smihandler.c M src/mainboard/google/link/mainboard_smi.c M src/mainboard/google/rambi/mainboard_smi.c M src/mainboard/google/slippy/smihandler.c M src/mainboard/intel/strago/smihandler.c M src/soc/amd/picasso/smihandler.c M src/soc/amd/stoneyridge/smihandler.c M src/soc/intel/baytrail/smihandler.c M src/soc/intel/braswell/smihandler.c M src/soc/intel/broadwell/smihandler.c M src/soc/intel/common/block/smm/smihandler.c M src/soc/intel/fsp_baytrail/smihandler.c M src/southbridge/intel/common/smihandler.c M src/southbridge/intel/lynxpoint/smihandler.c 17 files changed, 49 insertions(+), 94 deletions(-)
Approvals: build bot (Jenkins): Verified Aaron Durbin: Looks good to me, approved
diff --git a/src/ec/google/chromeec/smihandler.c b/src/ec/google/chromeec/smihandler.c index eec888e..add0db3 100644 --- a/src/ec/google/chromeec/smihandler.c +++ b/src/ec/google/chromeec/smihandler.c @@ -26,8 +26,8 @@ uint8_t event = google_chromeec_get_event();
/* Log this event */ - if (CONFIG(ELOG_GSMI) && event) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, event); + if (event) + elog_gsmi_add_event_byte(ELOG_TYPE_EC_EVENT, event);
switch (event) { case EC_HOST_EVENT_LID_CLOSED: diff --git a/src/include/elog.h b/src/include/elog.h index 1692a80..8d1b3ba 100644 --- a/src/include/elog.h +++ b/src/include/elog.h @@ -243,6 +243,16 @@ static inline int elog_add_extended_event(u8 type, u32 complement) { return 0; } #endif
+#if CONFIG(ELOG_GSMI) +#define elog_gsmi_add_event elog_add_event +#define elog_gsmi_add_event_byte elog_add_event_byte +#define elog_gsmi_add_event_word elog_add_event_word +#else +static inline int elog_gsmi_add_event(u8 event_type) { return 0; } +static inline int elog_gsmi_add_event_byte(u8 event_type, u8 data) { return 0; } +static inline int elog_gsmi_add_event_word(u8 event_type, u16 data) { return 0; } +#endif + extern u32 gsmi_exec(u8 command, u32 *param);
#if CONFIG(ELOG_BOOT_COUNT) diff --git a/src/mainboard/google/auron/smihandler.c b/src/mainboard/google/auron/smihandler.c index 790eeff..4cc0aa8 100644 --- a/src/mainboard/google/auron/smihandler.c +++ b/src/mainboard/google/auron/smihandler.c @@ -33,11 +33,9 @@ u8 cmd = google_chromeec_get_event(); u32 pm1_cnt;
-#if CONFIG(ELOG_GSMI) /* Log this event */ if (cmd) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, cmd); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_EC_EVENT, cmd);
switch (cmd) { case EC_HOST_EVENT_LID_CLOSED: diff --git a/src/mainboard/google/cyan/smihandler.c b/src/mainboard/google/cyan/smihandler.c index 852d9c9..4db6384 100644 --- a/src/mainboard/google/cyan/smihandler.c +++ b/src/mainboard/google/cyan/smihandler.c @@ -62,11 +62,9 @@ uint16_t pmbase = get_pmbase(); uint32_t pm1_cnt;
-#if CONFIG(ELOG_GSMI) /* Log this event */ if (cmd) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, cmd); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_EC_EVENT, cmd);
switch (cmd) { case EC_HOST_EVENT_LID_CLOSED: diff --git a/src/mainboard/google/link/mainboard_smi.c b/src/mainboard/google/link/mainboard_smi.c index 96ae1cc..cd8fb09 100644 --- a/src/mainboard/google/link/mainboard_smi.c +++ b/src/mainboard/google/link/mainboard_smi.c @@ -32,11 +32,9 @@ { u8 cmd = google_chromeec_get_event();
-#if CONFIG(ELOG_GSMI) /* Log this event */ if (cmd) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, cmd); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_EC_EVENT, cmd);
switch (cmd) { case EC_HOST_EVENT_LID_CLOSED: diff --git a/src/mainboard/google/rambi/mainboard_smi.c b/src/mainboard/google/rambi/mainboard_smi.c index 94f7b2b..250e636 100644 --- a/src/mainboard/google/rambi/mainboard_smi.c +++ b/src/mainboard/google/rambi/mainboard_smi.c @@ -34,11 +34,9 @@ uint16_t pmbase = get_pmbase(); uint32_t pm1_cnt;
-#if CONFIG(ELOG_GSMI) /* Log this event */ if (cmd) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, cmd); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_EC_EVENT, cmd);
switch (cmd) { case EC_HOST_EVENT_LID_CLOSED: diff --git a/src/mainboard/google/slippy/smihandler.c b/src/mainboard/google/slippy/smihandler.c index 81a772c..4817588 100644 --- a/src/mainboard/google/slippy/smihandler.c +++ b/src/mainboard/google/slippy/smihandler.c @@ -41,11 +41,9 @@ u8 cmd = google_chromeec_get_event(); u32 pm1_cnt;
-#if CONFIG(ELOG_GSMI) /* Log this event */ if (cmd) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, cmd); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_EC_EVENT, cmd);
switch (cmd) { case EC_HOST_EVENT_LID_CLOSED: diff --git a/src/mainboard/intel/strago/smihandler.c b/src/mainboard/intel/strago/smihandler.c index 052e830..a52c4ca 100644 --- a/src/mainboard/intel/strago/smihandler.c +++ b/src/mainboard/intel/strago/smihandler.c @@ -61,11 +61,9 @@ uint16_t pmbase = get_pmbase(); uint32_t pm1_cnt;
-#if CONFIG(ELOG_GSMI) /* Log this event */ if (cmd) - elog_add_event_byte(ELOG_TYPE_EC_EVENT, cmd); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_EC_EVENT, cmd);
switch (cmd) { case EC_HOST_EVENT_LID_CLOSED: diff --git a/src/soc/amd/picasso/smihandler.c b/src/soc/amd/picasso/smihandler.c index 4995acb..39c2dfd 100644 --- a/src/soc/amd/picasso/smihandler.c +++ b/src/soc/amd/picasso/smihandler.c @@ -153,8 +153,7 @@
if (slp_typ >= ACPI_S3) { /* Sleep Type Elog S3, S4, and S5 entry */ - if (CONFIG(ELOG_GSMI)) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
wbinvd();
diff --git a/src/soc/amd/stoneyridge/smihandler.c b/src/soc/amd/stoneyridge/smihandler.c index 9eddf85..2b88397 100644 --- a/src/soc/amd/stoneyridge/smihandler.c +++ b/src/soc/amd/stoneyridge/smihandler.c @@ -153,8 +153,7 @@
if (slp_typ >= ACPI_S3) { /* Sleep Type Elog S3, S4, and S5 entry */ - if (CONFIG(ELOG_GSMI)) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
wbinvd();
diff --git a/src/soc/intel/baytrail/smihandler.c b/src/soc/intel/baytrail/smihandler.c index 7de9d96..16e2d95 100644 --- a/src/soc/intel/baytrail/smihandler.c +++ b/src/soc/intel/baytrail/smihandler.c @@ -114,11 +114,9 @@ /* Do any mainboard sleep handling */ mainboard_smi_sleep(slp_typ);
-#if CONFIG(ELOG_GSMI) /* Log S3, S4, and S5 entry */ if (slp_typ >= ACPI_S3) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
/* Next, do the deed. */ @@ -210,7 +208,6 @@ return NULL; }
-#if CONFIG(ELOG_GSMI) static void southbridge_smi_gsmi(void) { u32 *ret, *param; @@ -231,7 +228,6 @@ /* drivers/elog/gsmi.c */ *ret = gsmi_exec(sub_command, param); } -#endif
static void finalize(void) { @@ -348,11 +344,10 @@ printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs); } break; -#if CONFIG(ELOG_GSMI) case APM_CNT_ELOG_GSMI: - southbridge_smi_gsmi(); + if (CONFIG(ELOG_GSMI)) + southbridge_smi_gsmi(); break; -#endif case APM_CNT_FINALIZE: finalize(); break; @@ -374,9 +369,7 @@ */ if (pm1_sts & PWRBTN_STS) { // power button pressed -#if CONFIG(ELOG_GSMI) - elog_add_event(ELOG_TYPE_POWER_BUTTON); -#endif + elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON); disable_pm1_control(-1UL); enable_pm1_control(SLP_EN | (SLP_TYP_S5 << SLP_TYP_SHIFT)); } diff --git a/src/soc/intel/braswell/smihandler.c b/src/soc/intel/braswell/smihandler.c index 174cd5d..b94fe65 100644 --- a/src/soc/intel/braswell/smihandler.c +++ b/src/soc/intel/braswell/smihandler.c @@ -154,11 +154,10 @@ /* Do any mainboard sleep handling */ mainboard_smi_sleep(slp_typ);
-#if CONFIG(ELOG_GSMI) /* Log S3, S4, and S5 entry */ if (slp_typ >= ACPI_S3) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); + /* Clear pending GPE events */ clear_gpe_status();
@@ -260,7 +259,6 @@ return NULL; }
-#if CONFIG(ELOG_GSMI) static void southbridge_smi_gsmi(void) { u32 *ret, *param; @@ -281,7 +279,6 @@ /* drivers/elog/gsmi.c */ *ret = gsmi_exec(sub_command, param); } -#endif
static void finalize(void) { @@ -346,11 +343,10 @@ printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs); } break; -#if CONFIG(ELOG_GSMI) case APM_CNT_ELOG_GSMI: - southbridge_smi_gsmi(); + if (CONFIG(ELOG_GSMI)) + southbridge_smi_gsmi(); break; -#endif case APM_CNT_FINALIZE: finalize(); break; @@ -369,9 +365,7 @@ */ if (pm1_sts & PWRBTN_STS) { /* power button pressed */ -#if CONFIG(ELOG_GSMI) - elog_add_event(ELOG_TYPE_POWER_BUTTON); -#endif + elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON); disable_pm1_control(-1UL); enable_pm1_control(SLP_EN | (SLP_TYP_S5 << SLP_TYP_SHIFT)); } diff --git a/src/soc/intel/broadwell/smihandler.c b/src/soc/intel/broadwell/smihandler.c index bad1587..d37f65a 100644 --- a/src/soc/intel/broadwell/smihandler.c +++ b/src/soc/intel/broadwell/smihandler.c @@ -179,11 +179,9 @@ /* USB sleep preparations */ usb_xhci_sleep_prepare(PCH_DEV_XHCI, slp_typ);
-#if CONFIG(ELOG_GSMI) /* Log S3, S4, and S5 entry */ if (slp_typ >= ACPI_S3) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
/* Clear pending GPE events */ clear_gpe_status(); @@ -293,7 +291,6 @@ return NULL; }
-#if CONFIG(ELOG_GSMI) static void southbridge_smi_gsmi(void) { u32 *ret, *param; @@ -314,7 +311,6 @@ /* drivers/elog/gsmi.c */ *ret = gsmi_exec(sub_command, param); } -#endif
static void finalize(void) { @@ -372,11 +368,10 @@ printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs); } break; -#if CONFIG(ELOG_GSMI) case APM_CNT_ELOG_GSMI: - southbridge_smi_gsmi(); + if (CONFIG(ELOG_GSMI)) + southbridge_smi_gsmi(); break; -#endif }
mainboard_smi_apmc(reg8); @@ -391,9 +386,7 @@ */ if (pm1_sts & PWRBTN_STS) { /* power button pressed */ -#if CONFIG(ELOG_GSMI) - elog_add_event(ELOG_TYPE_POWER_BUTTON); -#endif + elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON); disable_pm1_control(-1UL); enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10)); } diff --git a/src/soc/intel/common/block/smm/smihandler.c b/src/soc/intel/common/block/smm/smihandler.c index 9e98aae..0581d23 100644 --- a/src/soc/intel/common/block/smm/smihandler.c +++ b/src/soc/intel/common/block/smm/smihandler.c @@ -195,8 +195,8 @@ mainboard_smi_sleep(slp_typ);
/* Log S3, S4, and S5 entry */ - if (slp_typ >= ACPI_S3 && CONFIG(ELOG_GSMI)) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); + if (slp_typ >= ACPI_S3) + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
/* Clear pending GPE events */ pmc_clear_all_gpe_status(); @@ -413,8 +413,7 @@ */ if ((pm1_sts & PWRBTN_STS) && (pm1_en & PWRBTN_EN)) { /* power button pressed */ - if (CONFIG(ELOG_GSMI)) - elog_add_event(ELOG_TYPE_POWER_BUTTON); + elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON); pmc_disable_pm1_control(-1UL); pmc_enable_pm1_control(SLP_EN | (SLP_TYP_S5 << SLP_TYP_SHIFT)); } diff --git a/src/soc/intel/fsp_baytrail/smihandler.c b/src/soc/intel/fsp_baytrail/smihandler.c index 2a7376a..1a8fb4b 100644 --- a/src/soc/intel/fsp_baytrail/smihandler.c +++ b/src/soc/intel/fsp_baytrail/smihandler.c @@ -112,11 +112,9 @@ /* Do any mainboard sleep handling */ mainboard_smi_sleep(slp_typ);
-#if CONFIG(ELOG_GSMI) /* Log S3, S4, and S5 entry */ if (slp_typ >= ACPI_S3) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
/* Next, do the deed. */ @@ -208,7 +206,6 @@ return NULL; }
-#if CONFIG(ELOG_GSMI) static void southbridge_smi_gsmi(void) { u32 *ret, *param; @@ -229,7 +226,7 @@ /* drivers/elog/gsmi.c */ *ret = gsmi_exec(sub_command, param); } -#endif + static void southbridge_smi_apmc(void) { uint8_t reg8; @@ -275,11 +272,10 @@ printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs); } break; -#if CONFIG(ELOG_GSMI) case APM_CNT_ELOG_GSMI: - southbridge_smi_gsmi(); + if (CONFIG(ELOG_GSMI)) + southbridge_smi_gsmi(); break; -#endif }
mainboard_smi_apmc(reg8); @@ -294,9 +290,7 @@ */ if (pm1_sts & PWRBTN_STS) { // power button pressed -#if CONFIG(ELOG_GSMI) - elog_add_event(ELOG_TYPE_POWER_BUTTON); -#endif + elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON); disable_pm1_control(-1UL); enable_pm1_control(SLP_EN | (SLP_TYP_S5 << SLP_TYP_SHIFT)); } diff --git a/src/southbridge/intel/common/smihandler.c b/src/southbridge/intel/common/smihandler.c index 5582051..7f376fd 100644 --- a/src/southbridge/intel/common/smihandler.c +++ b/src/southbridge/intel/common/smihandler.c @@ -138,11 +138,9 @@ /* Do any mainboard sleep handling */ mainboard_smi_sleep(slp_typ);
-#if CONFIG(ELOG_GSMI) /* Log S3, S4, and S5 entry */ if (slp_typ >= ACPI_S3) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
/* Next, do the deed. */ @@ -246,7 +244,6 @@ return NULL; }
-#if CONFIG(ELOG_GSMI) static void southbridge_smi_gsmi(void) { u32 *ret, *param; @@ -267,7 +264,6 @@ /* drivers/elog/gsmi.c */ *ret = gsmi_exec(sub_command, param); } -#endif
static void southbridge_smi_store(void) { @@ -338,11 +334,10 @@ southbridge_finalize_all(); mainboard_finalized = 1; break; -#if CONFIG(ELOG_GSMI) case APM_CNT_ELOG_GSMI: - southbridge_smi_gsmi(); + if (CONFIG(ELOG_GSMI)) + southbridge_smi_gsmi(); break; -#endif case APM_CNT_SMMSTORE: if (CONFIG(SMMSTORE)) southbridge_smi_store(); @@ -366,9 +361,7 @@ // power button pressed u32 reg32; reg32 = (7 << 10) | (1 << 13); -#if CONFIG(ELOG_GSMI) - elog_add_event(ELOG_TYPE_POWER_BUTTON); -#endif + elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON); write_pmbase32(PM1_CNT, reg32); } } diff --git a/src/southbridge/intel/lynxpoint/smihandler.c b/src/southbridge/intel/lynxpoint/smihandler.c index de2866e..61f86fb 100644 --- a/src/southbridge/intel/lynxpoint/smihandler.c +++ b/src/southbridge/intel/lynxpoint/smihandler.c @@ -140,11 +140,9 @@ #endif usb_xhci_sleep_prepare(PCH_XHCI_DEV, slp_typ);
-#if CONFIG(ELOG_GSMI) /* Log S3, S4, and S5 entry */ if (slp_typ >= ACPI_S3) - elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ); -#endif + elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
/* Next, do the deed. */ @@ -247,7 +245,6 @@ return NULL; }
-#if CONFIG(ELOG_GSMI) static void southbridge_smi_gsmi(void) { u32 *ret, *param; @@ -268,7 +265,6 @@ /* drivers/elog/gsmi.c */ *ret = gsmi_exec(sub_command, param); } -#endif
static void southbridge_smi_apmc(void) { @@ -332,11 +328,10 @@ case 0xca: usb_xhci_route_all(); break; -#if CONFIG(ELOG_GSMI) case APM_CNT_ELOG_GSMI: - southbridge_smi_gsmi(); + if (CONFIG(ELOG_GSMI)) + southbridge_smi_gsmi(); break; -#endif }
mainboard_smi_apmc(reg8); @@ -351,9 +346,7 @@ */ if (pm1_sts & PWRBTN_STS) { // power button pressed -#if CONFIG(ELOG_GSMI) - elog_add_event(ELOG_TYPE_POWER_BUTTON); -#endif + elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON); disable_pm1_control(-1UL); enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10)); }