Debian Codegraph @

src/soc/intel/meteorlake/acpi/tcss_pcierp.asl

raw
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /*
4 * TCSS PCIE RP Channel Configuration (CCFG) Config Space register offsets
5 * MPC - Miscellaneous Port Configuration Register
6 * RPPGEN - Root Port Power Gating Enable Register
7 * SMSCS - SMI/SCI Status Register
8 */
9 #if CONFIG(SOC_INTEL_METEORLAKE_PRE_PRODUCTION_SILICON)
10 #define PXCS_OPREGION_SIZE 0x800
11 #define TCSS_CFG_MPC_FROM_CCFG 0xD8
12 #define TCSS_CFG_SMSCS_FROM_CCFG 0xDC
13 #define TCSS_CFG_RPPGEN_FROM_CCFG 0xE2
14 #else
15 #define PXCS_OPREGION_SIZE 0xC00
16 #define TCSS_CFG_MPC_FROM_CCFG 0xBA8
17 #define TCSS_CFG_SMSCS_FROM_CCFG 0xBAC
18 #define TCSS_CFG_RPPGEN_FROM_CCFG 0xBB2
19 #endif
20
21 OperationRegion (PXCS, SystemMemory, BASE(_ADR), PXCS_OPREGION_SIZE)
22 Field (PXCS, AnyAcc, NoLock, Preserve)
23 {
24 VDID, 32,
25 Offset(0x50), /* LCTL - Link Control Register */
26 L0SE, 1, /* 0, L0s Entry Enabled */
27 , 3,
28 LDIS, 1, /* 1, Link Disable */
29 , 3,
30 Offset(0x52), /* LSTS - Link Status Register */
31 , 13,
32 LASX, 1, /* 0, Link Active Status */
33 Offset(0x5A), /* SLSTS[7:0] - Slot Status Register */
34 ABPX, 1, /* 0, Attention Button Pressed */
35 , 2,
36 PDCX, 1, /* 3, Presence Detect Changed */
37 , 2,
38 PDSX, 1, /* 6, Presence Detect State */
39 , 1,
40 DLSC, 1, /* 8, Data Link Layer State Changed */
41 Offset(0x60), /* RSTS - Root Status Register */
42 , 16,
43 PSPX, 1, /* 16, PME Status */
44 Offset(0xA4),
45 D3HT, 2, /* Power State */
46 #if CONFIG(SOC_INTEL_METEORLAKE_PRE_PRODUCTION_SILICON)
47 Offset(TCSS_CFG_MPC_FROM_CCFG),
48 , 30,
49 HPEX, 1, /* 30, Hot Plug SCI Enable */
50 PMEX, 1, /* 31, Power Management SCI Enable */
51 Offset(TCSS_CFG_RPPGEN_FROM_CCFG),
52 , 2,
53 L23E, 1, /* 2, L23_Rdy Entry Request (L23ER) */
54 L23R, 1, /* 3, L23_Rdy to Detect Transition (L23R2DT) */
55 Offset(0x420), /* 0x420, PCIEPMECTL (PCIe PM Extension Control) */
56 , 30,
57 DPGE, 1, /* PCIEPMECTL[30]: Disabled, Detect and L23_Rdy State PHY Lane */
58 /* Power Gating Enable (DLSULPPGE) */
59 Offset(0x5BC), /* 0x5BC, PCIE ADVMCTRL */
60 , 3,
61 RPER, 1, /* RTD3PERST[3] */
62 RPFE, 1, /* RTD3PFETDIS[4] */
63 #else
64 Offset(0x420), /* 0x420, PCIEPMECTL (PCIe PM Extension Control) */
65 , 30,
66 DPGE, 1, /* PCIEPMECTL[30]: Disabled, Detect and L23_Rdy State PHY Lane */
67 /* Power Gating Enable (DLSULPPGE) */
68 Offset(0x5BC), /* 0x5BC, PCIE ADVMCTRL */
69 , 3,
70 RPER, 1, /* RTD3PERST[3] */
71 RPFE, 1, /* RTD3PFETDIS[4] */
72 Offset(TCSS_CFG_MPC_FROM_CCFG),
73 , 30,
74 HPEX, 1, /* 30, Hot Plug SCI Enable */
75 PMEX, 1, /* 31, Power Management SCI Enable */
76 Offset(TCSS_CFG_RPPGEN_FROM_CCFG),
77 , 2,
78 L23E, 1, /* 2, L23_Rdy Entry Request (L23ER) */
79 L23R, 1, /* 3, L23_Rdy to Detect Transition (L23R2DT) */
80 #endif
81 }
82
83 Field (PXCS, AnyAcc, NoLock, WriteAsZeros)
84 {
85 Offset(TCSS_CFG_SMSCS_FROM_CCFG),
86 , 30,
87 HPSX, 1, /* 30, Hot Plug SCI Status */
88 PMSX, 1 /* 31, Power Management SCI Status */
89 }
90
91 /*
92 * _DSM Device Specific Method
93 *
94 * Arg0: UUID Unique function identifier
95 * Arg1: Integer Revision Level
96 * Arg2: Integer Function Index (0 = Return Supported Functions)
97 * Arg3: Package Parameters
98 */
99 Method (_DSM, 4, Serialized)
100 {
101 Return (Buffer() { 0x00 })
102 }
103
104 /*
105 * A bitmask of functions support
106 */
107 Name(OPTS, Buffer(2) {0, 0})
108
109 Device (PXSX)
110 {
111 Name (_ADR, 0x00000000)
112
113 /*
114 * _DSM Device Specific Method
115 *
116 * Arg0: UUID: E5C937D0-3553-4d7a-9117-EA4D19C3434D
117 * Arg1: Revision ID: 3
118 * Arg2: Function index: 0, 9
119 * Arg3: Empty package
120 */
121 Method (_DSM, 4, Serialized)
122 {
123 If (Arg0 == ToUUID("E5C937D0-3553-4d7a-9117-EA4D19C3434D")) {
124 If (Arg1 >= 3) {
125 If (Arg2 == 0) {
126 /*
127 * Function index: 0
128 * Standard query - A bitmask of functions supported
129 */
130 CreateBitField(OPTS, 9, FUN9)
131 FUN9 = 1
132 Return (OPTS)
133 } ElseIf (Arg2 == 9) {
134 /*
135 * Function index: 9
136 * Specifying device readiness durations
137 */
138 Return (Package() { FW_RESET_TIME, FW_DL_UP_TIME,
139 FW_FLR_RESET_TIME, FW_D3HOT_TO_D0_TIME,
140 FW_VF_ENABLE_TIME })
141 }
142 }
143 }
144 Return (Buffer() { 0x0 })
145 }
146
147 Method (_PRW, 0)
148 {
149 Return (Package() { 0x69, 4 })
150 }
151 }
152
153 Method (_DSW, 3)
154 {
155 /* If entering Sx (Arg1 > 1), need to skip TCSS D3Cold & TBT RTD3/D3Cold. */
156 If ((TUID == 0) || (TUID == 1)) {
157 \_SB.PCI0.TDM0.SD3C = Arg1
158 } Else {
159 \_SB.PCI0.TDM1.SD3C = Arg1
160 }
161
162 C2PM (Arg0, Arg1, Arg2, DCPM)
163 }
164
165 Method (_PRW, 0)
166 {
167 Return (Package() { 0x69, 4 })
168 }
169
170 /*
171 * Sub-Method of _L61 Hot-Plug event
172 * _L61 event handler should invoke this method to support HotPlug wake event from TBT RP.
173 */
174 Method (HPEV, 0, Serialized)
175 {
176 If ((VDID != 0xFFFFFFFF) && HPSX) {
177 If ((PDCX == 1) && (DLSC == 1)) {
178 /* Clear all status bits first. */
179 PDCX = 1
180 HPSX = 1
181
182 /* Perform proper notification to the OS. */
183 Notify (^, 0)
184 } Else {
185 /* False event. Clear Hot-Plug Status, then exit. */
186 HPSX = 1
187 }
188 }
189 }
190
191 /*
192 * Power Management routine for D3
193 */
194 Name (STAT, 0x1) /* Variable to save power state 1 - D0, 0 - D3C */
195
196 /*
197 * RTD3 Exit Method to bring TBT controller out of RTD3 mode.
198 */
199 Method (D3CX, 0, Serialized)
200 {
201 If (STAT == 0x1) {
202 Return
203 }
204
205 RPFE = 0 /* Set RTD3PFETDIS = 0 */
206 RPER = 0 /* Set RTD3PERST = 0 */
207 L23R = 1 /* Set L23r2dt = 1 */
208
209 /*
210 * Poll for L23r2dt == 0. Wait for transition to Detect.
211 */
212 Local0 = 0
213 Local1 = L23R
214 While (Local1) {
215 If (Local0 > 20) {
216 Break
217 }
218 Sleep(5)
219 Local0++
220 Local1 = L23R
221 }
222 STAT = 0x1
223 }
224
225 /*
226 * RTD3 Entry method to enable TBT controller RTD3 mode.
227 */
228 Method (D3CE, 0, Serialized)
229 {
230 If (STAT == 0x0) {
231 Return
232 }
233
234 L23E = 1 /* Set L23er = 1 */
235
236 /* Poll until L23er == 0 */
237 Local0 = 0
238 Local1 = L23E
239 While (Local1) {
240 If (Local0 > 20) {
241 Break
242 }
243 Sleep(5)
244 Local0++
245 Local1 = L23E
246 }
247
248 STAT = 0 /* D3Cold */
249 RPFE = 1 /* Set RTD3PFETDIS = 1 */
250 RPER = 1 /* Set RTD3PERST = 1 */
251 }
252
253 Method (_PS0, 0, Serialized)
254 {
255 HPEV () /* Check and handle Hot Plug SCI status. */
256 If (HPEX == 1) {
257 HPEX = 0 /* Disable Hot Plug SCI */
258 }
259 HPME () /* Check and handle PME SCI status */
260 If (PMEX == 1) {
261 PMEX = 0 /* Disable Power Management SCI */
262 }
263 }
264
265 Method (_PS3, 0, Serialized)
266 {
267 /* Check it is hotplug SCI or not, then clear PDC accordingly */
268 If (PDCX == 1) {
269 If (DLSC == 0) {
270 /* Clear PDC since it is not a hotplug. */
271 PDCX = 1
272 }
273 }
274
275 If (HPEX == 0) {
276 HPEX = 1 /* Enable Hot Plug SCI. */
277 HPEV () /* Check and handle Hot Plug SCI status. */
278 }
279 If (PMEX == 0) {
280 PMEX = 1 /* Enable Power Management SCI. */
281 HPME () /* Check and handle PME SCI status. */
282 }
283 }
284
285 Method (_S0W, 0x0, NotSerialized)
286 {
287 #if CONFIG(D3COLD_SUPPORT)
288 Return (0x4)
289 #else
290 Return (0x3)
291 #endif // D3COLD_SUPPORT
292 }
293
294 Method (_PR0)
295 {
296 #if CONFIG(D3COLD_SUPPORT)
297 If ((TUID == 0) || (TUID == 1)) {
298 Return (Package() { \_SB.PCI0.D3C, \_SB.PCI0.TBT0 })
299 } Else {
300 Return (Package() { \_SB.PCI0.D3C, \_SB.PCI0.TBT1 })
301 }
302 #else
303 If ((TUID == 0) || (TUID == 1)) {
304 Return (Package() { \_SB.PCI0.TBT0 })
305 } Else {
306 Return (Package() { \_SB.PCI0.TBT1 })
307 }
308 #endif // D3COLD_SUPPORT
309 }
310
311 Method (_PR3)
312 {
313 #if CONFIG(D3COLD_SUPPORT)
314 If ((TUID == 0) || (TUID == 1)) {
315 Return (Package() { \_SB.PCI0.D3C, \_SB.PCI0.TBT0 })
316 } Else {
317 Return (Package() { \_SB.PCI0.D3C, \_SB.PCI0.TBT1 })
318 }
319 #else
320 If ((TUID == 0) || (TUID == 1)) {
321 Return (Package() { \_SB.PCI0.TBT0 })
322 } Else {
323 Return (Package() { \_SB.PCI0.TBT1 })
324 }
325 #endif // D3COLD_SUPPORT
326 }
327
328 /*
329 * PCI_EXP_STS Handler for PCIE Root Port
330 */
331 Method (HPME, 0, Serialized)
332 {
333 If ((VDID != 0xFFFFFFFF) && (PMSX == 1)) { /* if port exists and PME SCI Status set */
334 /*
335 * Notify child device; this will cause its driver to clear PME_Status from
336 * device.
337 */
338 Notify (PXSX, 0x2)
339 PMSX = 1 /* clear rootport's PME SCI status */
340 /*
341 * Consume one pending PME notification to prevent it from blocking the queue.
342 */
343 PSPX = 1
344 Return (0x01)
345 }
346 Return (0x00)
347 }