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 <acpi/acpi_pm.h>
4 #include <device/pci_type.h>
5 #include <elog.h>
6 #include <intelblocks/pmclib.h>
7 #include <intelblocks/xhci.h>
8 #include <soc/pm.h>
9 #include <soc/pci_devs.h>
10 #include <soc/smbus.h>
11 #include <stdint.h>
12 
13 static void pch_log_gpio_gpe(u32 gpe0_sts, u32 gpe0_en, int start)
14 {
15  int i;
16 
17  gpe0_sts &= gpe0_en;
18 
19  for (i = 0; i <= 31; i++) {
20  if (gpe0_sts & (1 << i))
22  }
23 }
24 
25 static void pch_log_wake_source(const struct chipset_power_state *ps)
26 {
27  const struct xhci_wake_info xhci_wake_info[] = {
29  };
30 
31  /* Power Button */
32  if (ps->pm1_sts & PWRBTN_STS)
34 
35  /* RTC */
36  if (ps->pm1_sts & RTC_STS)
38 
39  /* PCI Express (TODO: determine wake device) */
40  if (ps->pm1_sts & PCIEXPWAK_STS)
42 
43  /* PME */
44  if (ps->gpe0_sts[GPE0_A] & CSE_PME_STS)
46 
47  /* XHCI */
48  if (ps->gpe0_sts[GPE0_A] & XHCI_PME_STS)
51 
52  /* SMBUS Wake */
53  if (ps->gpe0_sts[GPE0_A] & SMB_WAK_STS)
55 
56  /* ACPI Wake Event - Log prev sleep state only if it was not S0. */
57  if (ps->prev_sleep_state != ACPI_S0)
59 
60  /* Log GPIO events in set A-D */
65 }
66 
67 static void pch_log_power_and_resets(const struct chipset_power_state *ps)
68 {
69  /* RTC Reset */
70  if (ps->gen_pmcon1 & RPS)
72 
73  /* System Reset */
74  if (ps->gen_pmcon1 & WARM_RESET_STS)
76 
77  /* TCO Timeout */
78  if (ps->prev_sleep_state != ACPI_S3 &&
79  ps->tco1_sts & TCO_TIMEOUT)
81 
82  /* Power Button Override */
83  if (ps->pm1_sts & PRBTNOR_STS)
85 
86 }
87 
88 void pch_log_state(void)
89 {
90  const struct chipset_power_state *ps;
91 
92  if (acpi_pm_state_for_elog(&ps) < 0)
93  return;
94 
95  /* Power and Reset */
97 
98  /* Wake Sources */
99  if (ps->prev_sleep_state > ACPI_S0)
101 }
102 
104 {
105  struct chipset_power_state ps;
106 
108  pch_log_wake_source(&ps);
109 }
int acpi_pm_state_for_elog(const struct chipset_power_state **ps)
Definition: acpi_pm.c:41
#define SMB_WAK_STS
Definition: pm.h:95
#define PRBTNOR_STS
Definition: pm.h:15
#define GPE0_C
Definition: pm.h:127
#define GPE0_D
Definition: pm.h:128
#define WARM_RESET_STS
Definition: pm.h:158
#define CSE_PME_STS
Definition: pm.h:136
#define GPE0_A
Definition: pm.h:125
#define XHCI_PME_STS
Definition: pm.h:134
#define GPE0_B
Definition: pm.h:126
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#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_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_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_PME_XHCI
Definition: elog.h:178
#define ELOG_WAKE_SOURCE_SMBUS
Definition: elog.h:156
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
#define RPS
Definition: i440bx.h:45
@ ACPI_S3
Definition: acpi.h:1383
@ ACPI_S0
Definition: acpi.h:1380
void elog_gsmi_cb_platform_log_wake_source(void)
Definition: elog.c:212
#define PCH_DEVFN_XHCI
Definition: pci_devs.h:124
static void pch_log_wake_source(const struct chipset_power_state *ps)
Definition: elog.c:25
static void pch_log_gpio_gpe(u32 gpe0_sts, u32 gpe0_en, int start)
Definition: elog.c:13
void pch_log_state(void)
Definition: elog.c:88
static void pch_log_power_and_resets(const struct chipset_power_state *ps)
Definition: elog.c:67
#define TCO_TIMEOUT
Definition: smbus.h:8
void pmc_fill_pm_reg_info(struct chipset_power_state *ps)
Definition: pmclib.c:413
bool xhci_update_wake_event(const struct xhci_wake_info *wake_info, size_t wake_info_count)
Definition: elog.c:98
uint32_t u32
Definition: stdint.h:51
uint16_t tco1_sts
Definition: pm.h:145
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_pmcon1
Definition: pm.h:231
uint16_t pm1_sts
Definition: pm.h:142