Debian Codegraph @

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