coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pm.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _SOC_PM_H_
4 #define _SOC_PM_H_
5 
6 #include <acpi/acpi.h>
7 
8 #define IOCOM1 0x3f8
9 
10 /* Memory mapped IO registers behind PMC_BASE_ADDRESS */
11 #define PRSTS 0x00
12 # define PMC_WDT_STS (1 << 15)
13 # define SEC_GBLRST_STS (1 << 7)
14 # define SEC_WDT_STS (1 << 6)
15 # define WOL_OVR_WK_STS (1 << 5)
16 # define PMC_WAKE_STS (1 << 4)
17 #define PMC_CFG 0x08
18 # define SPS (1 << 5)
19 # define NO_REBOOT (1 << 4)
20 # define SX_ENT_TO_EN (1 << 3)
21 # define TIMING_T581_SHIFT (0)
22 # define TIMING_T581_MASK (3 << TIMING_T581_SHIFT)
23 # define TIMING_T581_10uS (0 << TIMING_T581_SHIFT)
24 # define TIMING_T581_100uS (1 << TIMING_T581_SHIFT)
25 # define TIMING_T581_1mS (2 << TIMING_T581_SHIFT)
26 # define TIMING_T581_10mS (3 << TIMING_T581_SHIFT)
27 #define VLV_PM_STS 0x0c
28 # define PMC_MSG_FULL_STS (1 << 24)
29 # define PMC_MSG_4_FULL_STS (1 << 23)
30 # define PMC_MSG_3_FULL_STS (1 << 22)
31 # define PMC_MSG_2_FULL_STS (1 << 21)
32 # define PMC_MSG_1_FULL_STS (1 << 20)
33 # define CODE_REQ (1 << 8)
34 # define HPR_ENT_TO (1 << 2)
35 # define SX_ENT_TO (1 << 1)
36 #define GEN_PMCON1 0x20
37 # define UART_EN (1 << 24)
38 # define DISB (1 << 23)
39 # define MEM_SR (1 << 21)
40 # define SRS (1 << 20)
41 # define CTS (1 << 19)
42 # define MS4V (1 << 18)
43 # define PWR_FLR (1 << 16)
44 # define PME_B0_S5_DIS (1 << 15)
45 # define SUS_PWR_FLR (1 << 14)
46 # define WOL_EN_OVRD (1 << 13)
47 # define DIS_SLP_X_STRCH_SUS_UP (1 << 12)
48 # define GEN_RST_STS (1 << 9)
49 # define RPS (1 << 2)
50 # define AFTERG3_EN (1 << 0)
51 #define GEN_PMCON2 0x24
52 # define SLPSX_STR_POL_LOCK (1 << 18)
53 # define BIOS_PCI_EXP_EN (1 << 10)
54 # define PWRBTN_LVL (1 << 9)
55 # define SMI_LOCK (1 << 4)
56 #define ETR 0x48
57 # define CF9LOCK (1 << 31)
58 # define LTR_DEF (1 << 22)
59 # define IGNORE_HPET (1 << 21)
60 # define CF9GR (1 << 20)
61 # define CWORWRE (1 << 18)
62 #define FUNC_DIS 0x34
63 # define SIO_DMA2_DIS (1 << 0)
64 # define PWM1_DIS (1 << 1)
65 # define PWM2_DIS (1 << 2)
66 # define HSUART1_DIS (1 << 3)
67 # define HSUART2_DIS (1 << 4)
68 # define SPI_DIS (1 << 5)
69 # define SDIO_DIS (1 << 9)
70 # define SD_DIS (1 << 10)
71 # define MMC_DIS (1 << 11)
72 # define HDA_DIS (1 << 12)
73 # define LPE_DIS (1 << 13)
74 # define OTG_DIS (1 << 14)
75 # define XHCI_DIS (1 << 15)
76 # define SATA_DIS (1 << 17)
77 # define EHCI_DIS (1 << 18)
78 # define TXE_DIS (1 << 19)
79 # define PCIE_PORT1_DIS (1 << 20)
80 # define PCIE_PORT2_DIS (1 << 21)
81 # define PCIE_PORT3_DIS (1 << 22)
82 # define PCIE_PORT4_DIS (1 << 23)
83 # define SIO_DMA1_DIS (1 << 24)
84 # define I2C1_DIS (1 << 25)
85 # define I2C2_DIS (1 << 26)
86 # define I2C3_DIS (1 << 27)
87 # define I2C4_DIS (1 << 28)
88 # define I2C5_DIS (1 << 29)
89 # define I2C6_DIS (1 << 30)
90 # define I2C7_DIS (1 << 31)
91 #define FUNC_DIS2 0x38
92 # define USH_SS_PHY_DIS (1 << 2)
93 # define OTG_SS_PHY_DIS (1 << 1)
94 # define SMBUS_DIS (1 << 0)
95 #define GPIO_ROUT 0x58
96 # define ROUTE_MASK 3
97 # define ROUTE_NONE 0
98 # define ROUTE_SMI 1
99 # define ROUTE_SCI 2
100 #define PLT_CLK_CTL_0 0x60
101 #define PLT_CLK_CTL_1 0x64
102 #define PLT_CLK_CTL_2 0x68
103 #define PLT_CLK_CTL_3 0x6c
104 #define PLT_CLK_CTL_4 0x70
105 #define PLT_CLK_CTL_5 0x74
106 # define CLK_SRC_XTAL (0x0 << 2)
107 # define CLK_SRC_PLL (0x1 << 2)
108 # define CLK_CTL_D3_LPE (0x0 << 0)
109 # define CLK_CTL_ON (0x1 << 0)
110 # define CLK_CTL_OFF (0x2 << 0)
111 #define PME_STS 0xc0
112 #define GPE_LEVEL_EDGE 0xc4
113 # define GPE_EDGE 0
114 # define GPE_LEVEL 1
115 #define GPE_POLARITY 0xc8
116 # define GPE_ACTIVE_HIGH 1
117 # define GPE_ACTIVE_LOW 0
118 #define LOCK 0xcc
119 
120 /* IO Mapped registers behind ACPI_BASE_ADDRESS */
121 #define PM1_STS 0x00
122 #define WAK_STS (1 << 15)
123 #define PCIEXPWAK_STS (1 << 14)
124 #define USB_STS (1 << 13)
125 #define PRBTNOR_STS (1 << 11)
126 #define RTC_STS (1 << 10)
127 #define PWRBTN_STS (1 << 8)
128 #define GBL_STS (1 << 5)
129 #define TMROF_STS (1 << 0)
130 #define PM1_EN 0x02
131 #define PCIEXPWAK_DIS (1 << 14)
132 #define USB_WAKE_EN (1 << 13)
133 #define RTC_EN (1 << 10)
134 #define PWRBTN_EN (1 << 8)
135 #define GBL_EN (1 << 5)
136 #define TMROF_EN (1 << 0)
137 #define PM1_CNT 0x04
138 #define GBL_RLS (1 << 2)
139 #define BM_RLD (1 << 1)
140 #define SCI_EN (1 << 0)
141 #define PM1_TMR 0x08
142 #define GPE0_STS 0x20
143 #define GPE0_EN 0x28
144 #define SUS_GPIO_EN7_BIT 23
145 #define SUS_GPIO_EN7 (1 << SUS_GPIO_EN7_BIT)
146 #define SUS_GPIO_EN6_BIT 22
147 #define SUS_GPIO_EN6 (1 << SUS_GPIO_EN6_BIT)
148 #define SUS_GPIO_EN5_BIT 21
149 #define SUS_GPIO_EN5 (1 << SUS_GPIO_EN5_BIT)
150 #define SUS_GPIO_EN4_BIT 20
151 #define SUS_GPIO_EN4 (1 << SUS_GPIO_EN4_BIT)
152 #define SUS_GPIO_EN3_BIT 19
153 #define SUS_GPIO_EN3 (1 << SUS_GPIO_EN3_BIT)
154 #define SUS_GPIO_EN2_BIT 18
155 #define SUS_GPIO_EN2 (1 << SUS_GPIO_EN2_BIT)
156 #define SUS_GPIO_EN1_BIT 17
157 #define SUS_GPIO_EN1 (1 << SUS_GPIO_EN1_BIT)
158 #define SUS_GPIO_EN0_BIT 16
159 #define SUS_GPIO_EN0 (1 << SUS_GPIO_EN0_BIT)
160 #define SUS_GPIO_STS0 (1 << 16)
161 #define PCIE_WAKE3_STS (1 << 8)
162 #define PCIE_WAKE2_STS (1 << 7)
163 #define PCIE_WAKE1_STS (1 << 6)
164 #define PCIE_WAKE0_STS (1 << 3)
165 #define PCI_EXP_STS (1 << 9)
166 #define PME_B0_EN (1 << 13)
167 #define _ACPI_ENABLE_WAKE_SUS_GPIO(x) SUS_GPIO_EN##x##_BIT
168 #define ACPI_ENABLE_WAKE_SUS_GPIO(x) _ACPI_ENABLE_WAKE_SUS_GPIO(x)
169 #define SMI_EN 0x30
170 #define INTEL_USB2_EN (1 << 18) /* Intel-Specific USB2 SMI logic */
171 #define USB_EN (1 << 17) /* Legacy USB2 SMI logic */
172 #define PERIODIC_EN (1 << 14) /* SMI on PERIODIC_STS in SMI_STS */
173 #define TCO_EN (1 << 13) /* Enable TCO Logic (BIOSWE et al) */
174 #define BIOS_RLS (1 << 7) /* asserts SCI on bit set */
175 #define SWSMI_TMR_EN (1 << 6) /* start software smi timer on bit set */
176 #define APMC_EN (1 << 5) /* Writes to APM_CNT cause SMI# */
177 #define SLP_SMI_EN (1 << 4) /* Write to SLP_EN in PM1_CNT asserts SMI# */
178 #define BIOS_EN (1 << 2) /* Assert SMI# on setting GBL_RLS bit */
179 #define EOS (1 << 1) /* End of SMI (deassert SMI#) */
180 #define GBL_SMI_EN (1 << 0) /* SMI# generation at all? */
181 #define SMI_STS 0x34
182 #define ALT_GPIO_SMI 0x38
183 #define UPRWC 0x3c
184 # define UPRWC_WR_EN (1 << 1) /* USB Per-Port Registers Write Enable */
185 #define GPE_CTRL 0x40
186 #define PM2A_CNT_BLK 0x50
187 #define TCO_RLD 0x60
188 #define TCO_STS 0x64
189 # define SECOND_TO_STS (1 << 17)
190 # define TCO_TIMEOUT (1 << 3)
191 #define TCO1_CNT 0x68
192 # define TCO_LOCK (1 << 12)
193 # define TCO_TMR_HALT (1 << 11)
194 #define TCO_TMR 0x70
195 
196 #if !defined(__ASSEMBLER__) && !defined(__ACPI__)
197 
198 /* Track power state from reset to log events. */
199 struct chipset_power_state {
206  uint32_t prsts;
211 
213 
214 /* Power Management Utility Functions. */
215 uint16_t get_pmbase(void);
221 void clear_pmc_status(void);
222 void enable_smi(uint32_t mask);
224 void enable_pm1(uint16_t events);
227 void enable_gpe(uint32_t mask);
229 void disable_all_gpe(void);
230 
231 void southcluster_log_state(void);
232 
233 /* Return non-zero when RTC failure happened. */
234 int rtc_failure(void);
235 
236 #endif /* !defined(__ASSEMBLER__) && !defined(__ACPI__) */
237 
238 #endif /* _SOC_PM_H_ */
uint16_t get_pmbase(void)
Definition: pmutil.c:254
struct chipset_power_state __packed
void enable_pm1(uint16_t events)
Definition: pmutil.c:157
uint16_t clear_pm1_status(void)
Definition: pmutil.c:152
void enable_pm1_control(uint32_t mask)
Definition: pmutil.c:105
void southcluster_log_state(void)
Definition: elog.c:76
uint32_t clear_alt_status(void)
Definition: pmutil.c:312
void disable_smi(uint32_t mask)
Definition: pmutil.c:97
void enable_smi(uint32_t mask)
Definition: pmutil.c:89
void enable_gpe(uint32_t mask)
Definition: pmutil.c:194
void clear_pmc_status(void)
Definition: pmutil.c:317
uint32_t clear_gpe_status(void)
Definition: pmutil.c:265
void disable_pm1_control(uint32_t mask)
Definition: pmutil.c:113
void disable_all_gpe(void)
Definition: pmutil.c:210
uint32_t clear_tco_status(void)
Definition: pmutil.c:189
uint32_t clear_smi_status(void)
Definition: pmutil.c:84
int rtc_failure(void)
Definition: pmutil.c:330
void disable_gpe(uint32_t mask)
Definition: pmutil.c:202
struct chipset_power_state * fill_power_state(void)
Definition: romstage.c:31
static const int mask[4]
Definition: gpio.c:308
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
uint32_t tco_sts
Definition: pm.h:249
uint32_t gen_pmcon2
Definition: pm.h:232
uint32_t gpe0_en[4]
Definition: pm.h:148
uint32_t gpe0_sts[4]
Definition: pm.h:147
uint32_t gen_pmcon1
Definition: pm.h:231
uint16_t pm1_en
Definition: pm.h:143
int prev_sleep_state
Definition: pm.h:209
uint16_t pm1_sts
Definition: pm.h:142
uint32_t prsts
Definition: pm.h:230
uint32_t pm1_cnt
Definition: pm.h:144