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-or-later */
2 
3 #ifndef _SOC_APOLLOLAKE_PM_H_
4 #define _SOC_APOLLOLAKE_PM_H_
5 
6 #include <stdint.h>
7 #include <acpi/acpi.h>
8 #include <soc/gpe.h>
9 #include <soc/iomap.h>
10 
11 /* ACPI_BASE_ADDRESS */
12 
13 #define PM1_STS 0x00
14 #define WAK_STS (1 << 15)
15 #define PCIEXPWAK_STS (1 << 14)
16 #define PRBTNOR_STS (1 << 11)
17 #define RTC_STS (1 << 10)
18 #define PWRBTN_STS (1 << 8)
19 #define GBL_STS (1 << 5)
20 
21 #define PM1_EN 0x02
22 #define PCIEXPWAK_DIS (1 << 14)
23 #define RTC_EN (1 << 10)
24 #define PWRBTN_EN (1 << 8)
25 #define GBL_EN (1 << 5)
26 
27 #define PM1_CNT 0x04
28 #define SCI_EN (1 << 0)
29 
30 #define PM1_TMR 0x08
31 
32 #define SMI_EN 0x40
33 
34 #define SMI_ESPI 28 /* This bit is present in GLK*/
35 #define SMI_OCP_CSE 27
36 #define SMI_SPI 26
37 #define SMI_SPI_SSMI 25
38 #define SMI_SCC2 21
39 #define SMI_PCIE 20
40 #define SMI_SCS 19
41 #define SMI_HOST_SMBUS 18
42 #define SMI_XHCI 17
43 #define SMI_SMBUS 16
44 #define SMI_SERIRQ 15
45 #define SMI_PERIODIC 14
46 #define SMI_TCO 13
47 #define SMI_MCSMI 12
48 #define SMI_GPIO_UNLOCK_SSMI 11
49 #define SMI_GPIO 10
50 #define SMI_BIOS_RLS 7
51 #define SMI_SWSMI_TMR 6
52 #define SMI_APMC 5
53 #define SMI_SLP 4
54 #define SMI_LEGACY_USB 3
55 #define SMI_BIOS 2
56 #define SMI_EOS 1
57 #define SMI_GBL 0
58 
59 #if CONFIG(SOC_ESPI)
60 #define ESPI_SMI_EN (1 << SMI_ESPI) /* Valid for GLK with ESPI */
61 #else
62 #define ESPI_SMI_EN 0
63 #endif
64 #define USB_EN (1 << SMI_XHCI) /* Legacy USB2 SMI logic */
65 #define PERIODIC_EN (1 << SMI_PERIODIC) /* SMI on PERIODIC_STS in SMI_STS */
66 #define TCO_SMI_EN (1 << SMI_TCO) /* Enable TCO Logic (BIOSWE et al) */
67 #define GPIO_EN (1 << SMI_GPIO) /* Enable GPIO SMI */
68 #define BIOS_RLS (1 << SMI_BIOS_RLS) /* asserts SCI on bit set */
69 /* start software smi timer on bit set */
70 #define SWSMI_TMR_EN (1 << SMI_SWSMI_TMR)
71 #define APMC_EN (1 << SMI_APMC) /* Writes to APM_CNT cause SMI# */
72 /* Write to SLP_EN in PM1_CNT asserts SMI# */
73 #define SLP_SMI_EN (1 << SMI_SLP)
74 #define BIOS_EN (1 << SMI_BIOS) /* Assert SMI# on GBL_RLS bit */
75 #define EOS (1 << SMI_EOS) /* End of SMI (deassert SMI#) */
76 #define GBL_SMI_EN (1 << SMI_GBL) /* Global SMI Enable */
77 
78 /* SMI_EN Params for this platform to pass to enable_smi
79  *
80  * Enable SMI generation:
81  * - on APMC writes (io 0xb2)
82  * - on writes to SLP_EN (sleep states)
83  * - on writes to GBL_RLS (bios commands)
84  * - on eSPI events (does nothing on LPC systems)
85  * No SMIs:
86  * - on microcontroller writes (io 0x62/0x66)
87  * - on TCO events, unless enabled in common code
88  */
89 #define ENABLE_SMI_PARAMS \
90  (ESPI_SMI_EN | APMC_EN | SLP_SMI_EN | GBL_SMI_EN | EOS | GPIO_EN)
91 
92 #define SMI_STS 0x44
93 #define SMI_STS_BITS 32
94 /* Bits for SMI status */
95 #define ESPI_SMI_STS_BIT 28
96 #define PMC_OCP_SMI_STS_BIT 27
97 #define SPI_SMI_STS_BIT 26
98 #define SPI_SSMI_STS_BIT 25
99 #define SCC2_SMI_STS_BIT 21
100 #define PCI_EXP_SMI_STS_BIT 20
101 #define SCS_SMI_STS_BIT 19
102 #define HSMBUS_SMI_STS_BIT 18
103 #define XHCI_SMI_STS_BIT 17
104 #define SMBUS_SMI_STS_BIT 16
105 #define SERIRQ_SMI_STS_BIT 15
106 #define PERIODIC_STS_BIT 14
107 #define TCO_STS_BIT 13
108 #define MC_SMI_STS_BIT 12
109 #define GPIO_UNLOCK_SMI_STS_BIT 11
110 #define GPIO_STS_BIT 10
111 #define GPE0_STS_BIT 9 /* Datasheet says this is reserved */
112 #define PM1_STS_BIT 8
113 #define SWSMI_TMR_STS_BIT 6
114 #define APM_STS_BIT 5
115 #define SMI_ON_SLP_EN_STS_BIT 4
116 #define LEGACY_USB_STS_BIT 3
117 #define BIOS_STS_BIT 2
118 
119 #define GPE_CNTL 0x50
120 #define DEVACT_STS 0x4c
121 
122 #define GPE0_REG_MAX 4
123 #define GPE0_REG_SIZE 32
124 #define GPE0_STS(x) (0x20 + ((x) * 4))
125 #define GPE0_A 0
126 #define GPE0_B 1
127 #define GPE0_C 2
128 #define GPE0_D 3
129 #define GPE_STD GPE0_A
130 #define ESPI_STS (1 << 20) /* This bit is present in GLK */
131 #define SATA_PME_STS (1 << 17)
132 #define SMB_WAK_STS (1 << 16)
133 #define AVS_PME_STS (1 << 14)
134 #define XHCI_PME_STS (1 << 13)
135 #define XDCI_PME_STS (1 << 12)
136 #define CSE_PME_STS (1 << 11)
137 #define BATLOW_STS (1 << 10)
138 #define PCIE_GPE_STS (1 << 9)
139 #define SWGPE_STS (1 << 2)
140 #define GPE0_EN(x) (0x30 + ((x) * 4))
141 #define ESPI_EN (1 << 20) /* This bit is present in GLK */
142 #define SATA_PME_EN (1 << 17)
143 #define SMB_WAK_EN (1 << 16)
144 #define AVS_PME_EN (1 << 14)
145 #define PME_B0_EN (1 << 13)
146 #define XDCI_PME_EN (1 << 12)
147 #define CSE_PME_EN (1 << 11)
148 #define BATLOW_EN (1 << 10)
149 #define PCIE_GPE_EN (1 << 9)
150 #define SWGPE_EN (1 << 2)
151 
152 /* Memory mapped IO registers behind PMC_BASE_ADDRESS */
153 #define PRSTS 0x1000
154 #define GEN_PMCON1 0x1020
155 #define GEN_PMCON_A GEN_PMCON1
156 #define COLD_BOOT_STS (1 << 27)
157 #define COLD_RESET_STS (1 << 26)
158 #define WARM_RESET_STS (1 << 25)
159 #define GLOBAL_RESET_STS (1 << 24)
160 #define SRS (1 << 20)
161 #define MS4V (1 << 18)
162 #define RPS (1 << 2)
163 #define SLEEP_AFTER_POWER_FAIL (1 << 0)
164 #define GEN_PMCON1_CLR1_BITS (COLD_BOOT_STS | COLD_RESET_STS | \
165  WARM_RESET_STS | GLOBAL_RESET_STS | \
166  SRS | MS4V)
167 #define GEN_PMCON2 0x1024
168 #define GEN_PMCON3 0x1028
169 # define SLP_S3_ASSERT_WIDTH_SHIFT 10
170 # define SLP_S3_ASSERT_MASK (0x3 << SLP_S3_ASSERT_WIDTH_SHIFT)
171 # define SLP_S3_ASSERT_60_USEC 0x0
172 # define SLP_S3_ASSERT_1_MSEC 0x1
173 # define SLP_S3_ASSERT_50_MSEC 0x2
174 # define SLP_S3_ASSERT_2_SEC 0x3
175 #define ETR 0x1048
176 # define CF9_LOCK (1 << 31)
177 # define CF9_GLB_RST (1 << 20)
178 #define GPIO_GPE_CFG 0x1050
179 #define GPE0_DWX_MASK 0xf
180 #define GPE0_DW_SHIFT(x) (4 + 4*(x))
181 
182 #if CONFIG(SOC_INTEL_GEMINILAKE)
183 #define PMC_GPE_AUDIO_31_0 9
184 #define PMC_GPE_N_95_64 8
185 #define PMC_GPE_N_63_32 7
186 #define PMC_GPE_N_31_0 6
187 #define PMC_GPE_NW_127_96 5
188 #define PMC_GPE_NW_95_64 4
189 #define PMC_GPE_NW_63_32 3
190 #define PMC_GPE_NW_31_0 2
191 #define PMC_GPE_SCC_63_32 1
192 #define PMC_GPE_SCC_31_0 0
193 #else /*For APL*/
194 #define PMC_GPE_SW_31_0 0
195 #define PMC_GPE_SW_63_32 1
196 #define PMC_GPE_NW_31_0 3
197 #define PMC_GPE_NW_63_32 4
198 #define PMC_GPE_NW_95_64 5
199 #define PMC_GPE_N_31_0 6
200 #define PMC_GPE_N_63_32 7
201 #define PMC_GPE_W_31_0 9
202 #endif
203 
204 #define IRQ_REG 0x106C
205 #define SCI_IRQ_ADJUST 24
206 #define SCI_IRQ_SEL (255 << SCI_IRQ_ADJUST)
207 #define SCIS_IRQ9 9
208 #define SCIS_IRQ10 10
209 #define SCIS_IRQ11 11
210 #define SCIS_IRQ20 20
211 #define SCIS_IRQ21 21
212 #define SCIS_IRQ22 22
213 #define SCIS_IRQ23 23
214 
215 /* P-state configuration */
216 #define PSS_MAX_ENTRIES 8
217 #define PSS_RATIO_STEP 2
218 #define PSS_LATENCY_TRANSITION 10
219 #define PSS_LATENCY_BUSMASTER 10
220 
221 /* Track power state from reset to log events. */
222 struct chipset_power_state {
236 
237 void pch_log_state(void);
238 
239 /* Get base address PMC memory mapped registers. */
240 uint8_t *pmc_mmio_regs(void);
241 
242 /* STM Support */
243 uint16_t get_pmbase(void);
244 
245 #endif
uint16_t get_pmbase(void)
Definition: pmutil.c:254
struct chipset_power_state __packed
uint8_t * pmc_mmio_regs(void)
Definition: pmutil.c:142
#define GPE0_REG_MAX
Definition: pm.h:122
void pch_log_state(void)
Definition: elog.c:88
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
uint16_t tco2_sts
Definition: pm.h:146
uint32_t gen_pmcon3
Definition: pm.h:233
uint16_t tco1_sts
Definition: pm.h:145
uint32_t gen_pmcon2
Definition: pm.h:232
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_en
Definition: pm.h:143
uint16_t pm1_sts
Definition: pm.h:142
uint32_t prsts
Definition: pm.h:230
uint32_t pm1_cnt
Definition: pm.h:144