coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
elog.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <bootstate.h>
4 #include <console/console.h>
5 #include <stdint.h>
6 #include <elog.h>
7 #include <intelblocks/pmclib.h>
8 #include <soc/pci_devs.h>
9 #include <soc/pm.h>
10 
11 static void pch_log_gpio_gpe(u32 gpe0_sts, u32 gpe0_en, int start)
12 {
13  int i;
14 
15  gpe0_sts &= gpe0_en;
16 
17  for (i = 0; i <= 31; i++) {
18  if (gpe0_sts & (1 << i))
20  }
21 }
22 
23 static void pch_log_wake_source(const struct chipset_power_state *ps)
24 {
25  /* Power Button */
26  if (ps->pm1_sts & PWRBTN_STS)
28 
29  /* RTC */
30  if (ps->pm1_sts & RTC_STS)
32 
33  /* PCI Express (TODO: determine wake device) */
34  if (ps->pm1_sts & PCIEXPWAK_STS)
36 
37  /* PME (TODO: determine wake device) */
38  if (ps->gpe0_sts[GPE_STD] & PME_STS)
40 
41  /* Internal PME (TODO: determine wake device) */
42  if (ps->gpe0_sts[GPE_STD] & PME_B0_STS)
44 
45  /* SMBUS Wake */
46  if (ps->gpe0_sts[GPE_STD] & SMB_WAK_STS)
48 
49  /* Log GPIO events in set 1-3 */
53  /* Treat the STD as an extension of GPIO to obtain visibility. */
55 }
56 
57 static void pch_log_power_and_resets(const struct chipset_power_state *ps)
58 {
59  /* Thermal Trip */
62 
63  /* PWR_FLR Power Failure */
64  if (ps->gen_pmcon_a & PWR_FLR)
66 
67  /* SUS Well Power Failure */
68  if (ps->gen_pmcon_a & SUS_PWR_FLR)
70 
71  /* TCO Timeout */
72  if (ps->prev_sleep_state != ACPI_S3 &&
75 
76  /* Power Button Override */
77  if (ps->pm1_sts & PRBTNOR_STS)
79 
80  /* RTC reset */
81  if (ps->gen_pmcon_b & RTC_BATTERY_DEAD)
83 
84  /* Host Reset Status */
85  if (ps->gen_pmcon_a & HOST_RST_STS)
87 
88  /* ACPI Wake Event */
89  if (ps->prev_sleep_state != ACPI_S0)
91 }
92 
93 static void pch_log_state(void *unused)
94 {
96 
97  if (!ps) {
98  printk(BIOS_ERR, "chipset_power_state not found!\n");
99  return;
100  }
101 
102  /* Power and Reset */
104 
105  /* Wake Sources */
106  if (ps->prev_sleep_state > ACPI_S0)
108 }
109 
111 
113 {
114  struct chipset_power_state ps;
116  pch_log_wake_source(&ps);
117 }
#define GPE_63_32
Definition: pm.h:83
#define GPE_31_0
Definition: pm.h:82
#define GPE_STD
Definition: pm.h:85
#define SMB_WAK_STS
Definition: pm.h:95
#define GPE_95_64
Definition: pm.h:84
#define PME_STS
Definition: pm.h:92
#define PRBTNOR_STS
Definition: pm.h:15
#define PME_B0_STS
Definition: pm.h:90
@ BS_DEV_INIT
Definition: bootstate.h:83
@ BS_ON_EXIT
Definition: bootstate.h:96
#define PWRBTN_STS
Definition: southbridge.h:30
#define PCIEXPWAK_STS
Definition: southbridge.h:28
#define RTC_STS
Definition: southbridge.h:29
#define ELOG_WAKE_SOURCE_RTC
Definition: elog.h:154
#define ELOG_WAKE_SOURCE_PCIE
Definition: elog.h:151
#define ELOG_TYPE_SUS_POWER_FAIL
Definition: elog.h:129
#define ELOG_TYPE_THERM_TRIP
Definition: elog.h:277
#define ELOG_TYPE_POWER_FAIL
Definition: elog.h:128
#define ELOG_TYPE_ACPI_WAKE
Definition: elog.h:149
#define ELOG_WAKE_SOURCE_PME
Definition: elog.h:152
#define ELOG_WAKE_SOURCE_GPE
Definition: elog.h:155
#define ELOG_WAKE_SOURCE_PWRBTN
Definition: elog.h:157
#define ELOG_WAKE_SOURCE_PME_INTERNAL
Definition: elog.h:153
#define ELOG_TYPE_POWER_BUTTON_OVERRIDE
Definition: elog.h:134
#define ELOG_TYPE_SYSTEM_RESET
Definition: elog.h:138
#define ELOG_TYPE_RTC_RESET
Definition: elog.h:139
#define ELOG_TYPE_TCO_RESET
Definition: elog.h:140
#define ELOG_WAKE_SOURCE_SMBUS
Definition: elog.h:156
#define printk(level,...)
Definition: stdlib.h:16
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, elog_bs_init, NULL)
int elog_add_event_byte(u8 event_type, u8 data)
Definition: elog.c:868
int elog_add_event_wake(u8 source, u32 instance)
Definition: elog.c:883
int elog_add_event(u8 event_type)
Definition: elog.c:863
@ ACPI_S3
Definition: acpi.h:1383
@ ACPI_S0
Definition: acpi.h:1380
#define PWR_FLR
Definition: pmc.h:30
#define HOST_RST_STS
Definition: pmc.h:38
#define GBLRST_CAUSE0_THERMTRIP
Definition: pmc.h:132
#define RTC_BATTERY_DEAD
Definition: pmc.h:61
#define SUS_PWR_FLR
Definition: pmc.h:28
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
void elog_gsmi_cb_platform_log_wake_source(void)
Definition: elog.c:212
void pch_log_state(void)
Definition: elog.c:88
#define TCO_STS_SECOND_TO
Definition: smbus.h:10
void pmc_fill_pm_reg_info(struct chipset_power_state *ps)
Definition: pmclib.c:413
struct chipset_power_state * pmc_get_power_state(void)
Definition: pmclib.c:58
static void pch_log_wake_source(const struct chipset_power_state *ps)
Definition: elog.c:23
static void pch_log_gpio_gpe(u32 gpe0_sts, u32 gpe0_en, int start)
Definition: elog.c:11
static void pch_log_power_and_resets(const struct chipset_power_state *ps)
Definition: elog.c:57
#define NULL
Definition: stddef.h:19
uint32_t u32
Definition: stdint.h:51
uint16_t tco2_sts
Definition: pm.h:146
uint32_t gpe0_en[4]
Definition: pm.h:148
uint32_t prev_sleep_state
Definition: pm.h:153
uint32_t gpe0_sts[4]
Definition: pm.h:147
uint32_t gen_pmcon_b
Definition: pm.h:150
uint16_t pm1_sts
Definition: pm.h:142
uint32_t gblrst_cause[2]
Definition: pm.h:151
uint32_t gen_pmcon_a
Definition: pm.h:149