coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pm_state.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <acpi/acpi_gnvs.h>
4 #include <acpi/acpi_pm.h>
5 #include <amdblocks/acpi.h>
6 #include <bootstate.h>
7 #include <soc/acpi.h>
8 #include <soc/nvs.h>
9 #include <soc/southbridge.h>
10 #include <types.h>
11 
13 {
14  uint16_t i;
15  uint32_t t;
16 
17  if (limit > TOTAL_BITS(uint32_t))
18  return -1;
19 
20  /* get a mask of valid bits. Ex limit = 3, set bits 0-2 */
21  t = (1ULL << limit) - 1;
22  if ((value & t) == 0)
23  return -1;
24  t = 1;
25  for (i = 0; i < limit; i++) {
26  if (value & t)
27  break;
28  t <<= 1;
29  }
30  return i;
31 }
32 
33 static void pm_fill_gnvs(struct global_nvs *gnvs, const struct acpi_pm_gpe_state *state)
34 {
35  int index;
36 
37  index = get_index_bit(state->pm1_sts & state->pm1_en, PM1_LIMIT);
38  if (index >= 0)
39  gnvs->pm1i = index;
40 
41  index = get_index_bit(state->gpe0_sts & state->gpe0_en, GPE0_LIMIT);
42  if (index >= 0)
43  gnvs->gpei = index;
44 }
45 
46 static void acpi_save_wake_source(void *unused)
47 {
48  const struct chipset_power_state *ps;
49  struct global_nvs *gnvs;
50 
52  return;
53  if (acpi_pm_state_for_wake(&ps) < 0)
54  return;
55 
57 }
58 
int acpi_reset_gnvs_for_wake(struct global_nvs **gnvs_)
Definition: gnvs.c:84
int acpi_pm_state_for_wake(const struct chipset_power_state **ps)
Definition: acpi_pm.c:61
pte_t value
Definition: mmu.c:91
@ BS_PRE_DEVICE
Definition: bootstate.h:78
@ BS_ON_ENTRY
Definition: bootstate.h:95
#define TOTAL_BITS(a)
Definition: southbridge.h:84
#define PM1_LIMIT
Definition: southbridge.h:82
#define GPE0_LIMIT
Definition: southbridge.h:83
state
Definition: raminit.c:1787
BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, acpi_save_wake_source, NULL)
static void acpi_save_wake_source(void *unused)
Definition: pm_state.c:46
static void pm_fill_gnvs(struct global_nvs *gnvs, const struct acpi_pm_gpe_state *state)
Definition: pm_state.c:33
static int get_index_bit(uint32_t value, uint16_t limit)
Definition: pm_state.c:12
struct global_nvs * gnvs
#define NULL
Definition: stddef.h:19
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
struct acpi_pm_gpe_state gpe_state
Definition: acpi.h:49
Definition: nvs.h:14
uint64_t gpei
Definition: nvs.h:21
uint64_t pm1i
Definition: nvs.h:20