coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
acpi.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <acpi/acpi.h>
4 #include <acpi/acpi_gnvs.h>
5 #include <acpi/acpigen.h>
6 #include <device/mmio.h>
7 #include <arch/smp/mpspec.h>
8 #include <intelblocks/cpulib.h>
9 #include <intelblocks/pmclib.h>
10 #include <intelblocks/acpi.h>
11 #include <soc/cpu.h>
12 #include <soc/iomap.h>
13 #include <soc/nvs.h>
14 #include <soc/pci_devs.h>
15 #include <soc/pm.h>
16 #include <soc/soc_chip.h>
17 #include <soc/systemagent.h>
18 
19 /*
20  * List of supported C-states in this processor.
21  */
22 enum {
23  C_STATE_C0, /* 0 */
24  C_STATE_C1, /* 1 */
25  C_STATE_C1E, /* 2 */
32  C_STATE_C8, /* 9 */
33  C_STATE_C9, /* 10 */
34  C_STATE_C10, /* 11 */
36 };
37 
39  [C_STATE_C0] = {},
40  [C_STATE_C1] = {
41  .latency = 0,
42  .power = C1_POWER,
43  .resource = MWAIT_RES(0, 0),
44  },
45  [C_STATE_C1E] = {
46  .latency = 0,
47  .power = C1_POWER,
48  .resource = MWAIT_RES(0, 1),
49  },
51  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
52  .power = C6_POWER,
53  .resource = MWAIT_RES(2, 0),
54  },
56  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
57  .power = C6_POWER,
58  .resource = MWAIT_RES(2, 1),
59  },
61  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
62  .power = C7_POWER,
63  .resource = MWAIT_RES(3, 0),
64  },
66  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
67  .power = C7_POWER,
68  .resource = MWAIT_RES(3, 1),
69  },
71  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
72  .power = C7_POWER,
73  .resource = MWAIT_RES(3, 2),
74  },
76  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
77  .power = C7_POWER,
78  .resource = MWAIT_RES(3, 3),
79  },
80  [C_STATE_C8] = {
81  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
82  .power = C8_POWER,
83  .resource = MWAIT_RES(4, 0),
84  },
85  [C_STATE_C9] = {
86  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
87  .power = C9_POWER,
88  .resource = MWAIT_RES(5, 0),
89  },
90  [C_STATE_C10] = {
91  .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
92  .power = C10_POWER,
93  .resource = MWAIT_RES(6, 0),
94  },
95 };
96 
97 static int cstate_set_non_s0ix[] = {
101 };
102 
103 static int cstate_set_s0ix[] = {
104  C_STATE_C1E,
107 };
108 
109 const acpi_cstate_t *soc_get_cstate_map(size_t *entries)
110 {
113  int *set;
114  int i;
115 
117 
118  int is_s0ix_enable = config->s0ix_enable;
119 
120  if (is_s0ix_enable) {
121  *entries = ARRAY_SIZE(cstate_set_s0ix);
122  set = cstate_set_s0ix;
123  } else {
124  *entries = ARRAY_SIZE(cstate_set_non_s0ix);
125  set = cstate_set_non_s0ix;
126  }
127 
128  for (i = 0; i < *entries; i++) {
129  map[i] = cstate_map[set[i]];
130  map[i].ctype = i + 1;
131  }
132  return map;
133 }
134 
135 void soc_power_states_generation(int core_id, int cores_per_package)
136 {
138 
139  if (config->eist_enable)
140  /* Generate P-state tables */
141  generate_p_state_entries(core_id, cores_per_package);
142 }
143 
145 {
147 
149 
150  fadt->pm_tmr_blk = pmbase + PM1_TMR;
151  fadt->pm_tmr_len = 4;
153  fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
154  fadt->x_pm_tmr_blk.bit_offset = 0;
156  fadt->x_pm_tmr_blk.addrl = pmbase + PM1_TMR;
157  fadt->x_pm_tmr_blk.addrh = 0x0;
158 
159  if (config->s0ix_enable)
161 }
163 {
164  return read32p(soc_read_pmc_base() + IRQ_REG);
165 }
166 
168 {
170 
171  /* Enable DPTF based on mainboard configuration */
172  gnvs->dpte = config->dptf_enable;
173 
174  /* Set USB2/USB3 wake enable bitmaps. */
175  gnvs->u2we = config->usb2_wake_enable_bitmap;
176  gnvs->u3we = config->usb3_wake_enable_bitmap;
177 
178  /* Fill in Above 4GB MMIO resource */
180 }
181 
183 {
184  return MP_IRQ_POLARITY_HIGH;
185 }
__weak void soc_fill_fadt(acpi_fadt_t *fadt)
Definition: acpi.c:1483
#define PM1_TMR
Definition: pm.h:31
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define MAX(a, b)
Definition: helpers.h:40
void sa_fill_gnvs(struct global_nvs *gnvs)
Definition: systemagent.c:140
#define MWAIT_RES(state, sub_state)
Definition: acpi.c:17
#define C_STATE_LATENCY_FROM_LAT_REG(reg)
Definition: haswell.h:119
#define ACPI_ACCESS_SIZE_DWORD_ACCESS
Definition: acpi.h:129
#define ACPI_FADT_LOW_PWR_IDLE_S0
Definition: acpi.h:814
#define ACPI_ADDRESS_SPACE_IO
Definition: acpi.h:105
#define config_of_soc()
Definition: device.h:394
static __always_inline uint32_t read32p(const uintptr_t addr)
Definition: mmio.h:220
#define ACPI_BASE_ADDRESS
Definition: iomap.h:99
#define IRQ_REG
Definition: pmc.h:142
enum board_config config
Definition: memory.c:448
#define MP_IRQ_POLARITY_HIGH
Definition: mpspec.h:124
struct global_nvs * gnvs
const acpi_cstate_t * soc_get_cstate_map(size_t *entries)
Definition: acpi.c:113
@ C_STATE_C0
Definition: acpi.c:27
@ C_STATE_C7S_LONG_LAT
Definition: acpi.c:35
@ C_STATE_C1E
Definition: acpi.c:29
@ C_STATE_C7S_SHORT_LAT
Definition: acpi.c:34
@ C_STATE_C7_LONG_LAT
Definition: acpi.c:33
@ C_STATE_C6_LONG_LAT
Definition: acpi.c:31
@ C_STATE_C9
Definition: acpi.c:37
@ C_STATE_C10
Definition: acpi.c:38
@ C_STATE_C7_SHORT_LAT
Definition: acpi.c:32
@ C_STATE_C1
Definition: acpi.c:28
@ C_STATE_C8
Definition: acpi.c:36
@ NUM_C_STATES
Definition: acpi.c:39
@ C_STATE_C6_SHORT_LAT
Definition: acpi.c:30
int soc_madt_sci_irq_polarity(int sci)
Definition: acpi.c:282
void soc_power_states_generation(int core_id, int cores_per_package)
Definition: acpi.c:139
void soc_fill_gnvs(struct global_nvs *gnvs)
Definition: acpi.c:267
uint32_t soc_read_sci_irq_select(void)
Definition: acpi.c:167
#define C7_POWER
Definition: cpu.h:17
#define C1_POWER
Definition: cpu.h:15
#define C6_POWER
Definition: cpu.h:16
#define C9_POWER
Definition: cpu.h:19
#define C10_POWER
Definition: cpu.h:20
#define C8_POWER
Definition: cpu.h:18
uintptr_t soc_read_pmc_base(void)
Definition: pmutil.c:147
void generate_p_state_entries(int core, int cores_per_package)
Definition: acpi.c:259
static int cstate_set_non_s0ix[]
Definition: acpi.c:97
static int cstate_set_s0ix[]
Definition: acpi.c:103
static const acpi_cstate_t cstate_map[NUM_C_STATES]
Definition: acpi.c:38
static u16 pmbase
Definition: smi.c:27
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
u8 ctype
Definition: acpi.h:984
u16 latency
Definition: acpi.h:985
u32 pm_tmr_blk
Definition: acpi.h:724
u8 pm_tmr_len
Definition: acpi.h:730
u32 flags
Definition: acpi.h:746
acpi_addr_t x_pm_tmr_blk
Definition: acpi.h:760
u8 bit_offset
Definition: acpi.h:98
u8 bit_width
Definition: acpi.h:97
u8 access_size
Definition: acpi.h:99
Definition: nvs.h:14
u16 u2we
Definition: nvs.h:24
u16 u3we
Definition: nvs.h:25
uint8_t dpte
Definition: nvs.h:20