libpayload: configs: Add new config.featuretest to broaden CI
[coreboot.git] / src / soc / intel / broadwell / pch / elog.c
blobe3e8c0cab16fca334c3abbdd6bdea89043b58bde
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi_pm.h>
4 #include <bootstate.h>
5 #include <stdint.h>
6 #include <elog.h>
7 #include <soc/lpc.h>
8 #include <soc/pm.h>
10 static void pch_log_gpio_gpe(u32 gpe0_sts, u32 gpe0_en, int start)
12 int i;
14 gpe0_sts &= gpe0_en;
16 for (i = 0; i <= 31; i++) {
17 if (gpe0_sts & (1 << i))
18 elog_add_event_wake(ELOG_WAKE_SOURCE_GPE, i + start);
22 static void pch_log_wake_source(const struct chipset_power_state *ps)
24 /* Power Button */
25 if (ps->pm1_sts & PWRBTN_STS)
26 elog_add_event_wake(ELOG_WAKE_SOURCE_PWRBTN, 0);
28 /* RTC */
29 if (ps->pm1_sts & RTC_STS)
30 elog_add_event_wake(ELOG_WAKE_SOURCE_RTC, 0);
32 /* PCI Express (TODO: determine wake device) */
33 if (ps->pm1_sts & PCIEXPWAK_STS)
34 elog_add_event_wake(ELOG_WAKE_SOURCE_PCIE, 0);
36 /* PME (TODO: determine wake device) */
37 if (ps->gpe0_sts[GPE_STD] & PME_STS)
38 elog_add_event_wake(ELOG_WAKE_SOURCE_PME, 0);
40 /* Internal PME (TODO: determine wake device) */
41 if (ps->gpe0_sts[GPE_STD] & PME_B0_STS)
42 elog_add_event_wake(ELOG_WAKE_SOURCE_PME_INTERNAL, 0);
44 /* SMBUS Wake */
45 if (ps->gpe0_sts[GPE_STD] & SMB_WAK_STS)
46 elog_add_event_wake(ELOG_WAKE_SOURCE_SMBUS, 0);
48 /* GPIO27 */
49 if (ps->gpe0_sts[GPE_STD] & GP27_STS)
50 elog_add_event_wake(ELOG_WAKE_SOURCE_GPE, 27);
52 /* Log GPIO events in set 1-3 */
53 pch_log_gpio_gpe(ps->gpe0_sts[GPE_31_0], ps->gpe0_en[GPE_31_0], 0);
54 pch_log_gpio_gpe(ps->gpe0_sts[GPE_63_32], ps->gpe0_en[GPE_63_32], 32);
55 pch_log_gpio_gpe(ps->gpe0_sts[GPE_94_64], ps->gpe0_en[GPE_94_64], 64);
58 static void pch_log_power_and_resets(const struct chipset_power_state *ps)
60 /* Thermal Trip Status */
61 if (ps->gen_pmcon2 & THERMTRIP_STS)
62 elog_add_event(ELOG_TYPE_THERM_TRIP);
64 /* PWR_FLR Power Failure */
65 if (ps->gen_pmcon2 & PWROK_FLR)
66 elog_add_event(ELOG_TYPE_POWER_FAIL);
68 /* SUS Well Power Failure */
69 if (ps->gen_pmcon3 & SUS_PWR_FLR)
70 elog_add_event(ELOG_TYPE_SUS_POWER_FAIL);
72 /* SYS_PWROK Failure */
73 if (ps->gen_pmcon2 & SYSPWR_FLR)
74 elog_add_event(ELOG_TYPE_SYS_PWROK_FAIL);
76 /* PWROK Failure */
77 if (ps->gen_pmcon2 & PWROK_FLR)
78 elog_add_event(ELOG_TYPE_PWROK_FAIL);
80 /* TCO Timeout */
81 if (ps->prev_sleep_state != ACPI_S3 &&
82 ps->tco2_sts & TCO2_STS_SECOND_TO)
83 elog_add_event(ELOG_TYPE_TCO_RESET);
85 /* Power Button Override */
86 if (ps->pm1_sts & PRBTNOR_STS)
87 elog_add_event(ELOG_TYPE_POWER_BUTTON_OVERRIDE);
89 /* RTC reset */
90 if (ps->gen_pmcon3 & RTC_BATTERY_DEAD)
91 elog_add_event(ELOG_TYPE_RTC_RESET);
93 /* System Reset Status (reset button pushed) */
94 if (ps->gen_pmcon2 & SYSTEM_RESET_STS)
95 elog_add_event(ELOG_TYPE_RESET_BUTTON);
97 /* General Reset Status */
98 if (ps->gen_pmcon3 & GEN_RST_STS)
99 elog_add_event(ELOG_TYPE_SYSTEM_RESET);
101 /* ACPI Wake Event */
102 if (ps->prev_sleep_state != ACPI_S0)
103 elog_add_event_byte(ELOG_TYPE_ACPI_WAKE, ps->prev_sleep_state);
106 static void pch_log_state(void *unused)
108 const struct chipset_power_state *ps;
110 if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0)
111 return;
113 /* Power and Reset */
114 pch_log_power_and_resets(ps);
116 /* Wake Sources */
117 pch_log_wake_source(ps);
120 BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, pch_log_state, NULL);