blob: 5af78edb8ae0a7f16bcbf3386b9a9f9f38e5ce44 [file] [log] [blame]
Elyes HAOUASf50b6622020-07-19 14:00:43 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
John Zhaoca584082020-03-16 15:33:06 -07002
Subrata Banikff433b72022-12-08 16:05:40 +05303#include <intelblocks/tcss.h>
John Zhaoca584082020-03-16 15:33:06 -07004#include <soc/iomap.h>
5
6/*
7 * Type C Subsystem(TCSS) topology provides Runtime D3 support for USB host controller(xHCI),
8 * USB device controller(xDCI), Thunderbolt DMA devices and Thunderbolt PCIe controllers.
9 * PCIe RP0/RP1 is grouped with DMA0 and PCIe RP2/RP3 is grouped with DMA1.
10 */
11#define TCSS_TBT_PCIE0_RP0 0
12#define TCSS_TBT_PCIE0_RP1 1
13#define TCSS_TBT_PCIE0_RP2 2
14#define TCSS_TBT_PCIE0_RP3 3
15#define TCSS_XHCI 4
16#define TCSS_XDCI 5
17#define TCSS_DMA0 6
18#define TCSS_DMA1 7
19
20/*
21 * MAILBOX_BIOS_CMD_TCSS_DEVEN_INTERFACE
22 * Command code 0x15
23 * Description: Gateway command for handling TCSS DEVEN clear/restore.
24 * Field PARAM1[15:8] of the _INTERFACE register is used in this command to select from
25 * a pre-defined set of subcommands.
26 */
27#define MAILBOX_BIOS_CMD_TCSS_DEVEN_INTERFACE 0x00000015
28#define TCSS_DEVEN_MAILBOX_SUBCMD_GET_STATUS 0 /* Sub-command 0 */
29#define TCSS_DEVEN_MAILBOX_SUBCMD_TCSS_CHANGE_REQ 1 /* Sub-command 1 */
John Zhaoca584082020-03-16 15:33:06 -070030#define TCSS_IOM_ACK_TIMEOUT_IN_MS 100
31
John Zhaob8febf42020-06-11 18:05:23 -070032#define MCHBAR_TCSS_DEVEN_OFFSET 0x7090
33
34#define REVISION_ID 1
35#define UNRECOGNIZED_UUID 0x4
36#define UNRECOGNIZED_REVISION 0x8
37
38#define USB_TUNNELING 0x1
39#define DISPLAY_PORT_TUNNELING 0x2
40#define PCIE_TUNNELING 0x4
41#define INTER_DOMAIN_USB4_INTERNET_PROTOCOL 0x8
42
John Zhaoca584082020-03-16 15:33:06 -070043Scope (\_SB)
44{
45 /* Device base address */
46 Method (BASE, 1)
47 {
48 Local0 = Arg0 & 0x7 /* Function number */
John Zhaof74aa6492020-06-07 09:20:01 -070049 Local1 = (Arg0 >> 16) & 0x1F /* Device number */
John Zhaoca584082020-03-16 15:33:06 -070050 Local2 = (Local0 << 12) + (Local1 << 15)
51 Local3 = \_SB.PCI0.GPCB() + Local2
52 Return (Local3)
53 }
54
55 /*
John Zhao7d054bd2020-05-19 11:10:21 -070056 * Define PCH ACPIBASE IO as an ACPI operating region. The base address can be
John Zhaoca584082020-03-16 15:33:06 -070057 * found in Device 31, Function 2, Offset 40h.
58 */
John Zhao7d054bd2020-05-19 11:10:21 -070059 OperationRegion (PMIO, SystemIO, ACPI_BASE_ADDRESS, 0x80)
John Zhaoca584082020-03-16 15:33:06 -070060 Field (PMIO, ByteAcc, NoLock, Preserve) {
61 Offset(0x6C), /* 0x6C, General Purpose Event 0 Status [127:96] */
62 , 19,
63 CPWS, 1, /* CPU WAKE STATUS */
64 Offset(0x7C), /* 0x7C, General Purpose Event 0 Enable [127:96] */
65 , 19,
66 CPWE, 1 /* CPU WAKE EN */
67 }
68
69 Name (C2PW, 0) /* Set default value to 0. */
70
71 /*
72 * C2PM (CPU to PCH Method)
73 *
74 * This object is Enable/Disable GPE_CPU_WAKE_EN.
75 * Arguments: (4)
76 * Arg0 - An Integer containing the device wake capability
77 * Arg1 - An Integer containing the target system state
78 * Arg2 - An Integer containing the target device state
79 * Arg3 - An Integer containing the request device type
80 * Return Value:
81 * return 0
82 */
83 Method (C2PM, 4, NotSerialized)
84 {
John Zhao9e9f3012020-05-13 09:53:24 -070085 Local0 = 1 << Arg3
John Zhaoca584082020-03-16 15:33:06 -070086 /* This method is used to enable/disable wake from Tcss Device (WKEN). */
87 If (Arg0 && Arg1)
88 { /* If entering Sx and enabling wake, need to enable WAKE capability. */
89 If (CPWE == 0) { /* If CPU WAKE EN is not set, Set it. */
90 If (CPWS) { /* If CPU WAKE STATUS is set, Clear it. */
91 /* Clear CPU WAKE STATUS by writing 1. */
92 CPWS = 1
93 }
94 CPWE = 1 /* Set CPU WAKE EN by writing 1. */
95 }
96 If ((C2PW & Local0) == 0) {
97 /* Set Corresponding Device En BIT in C2PW. */
98 C2PW |= Local0
99 }
100 } Else { /* If Staying in S0 or Disabling Wake. */
101 If (Arg0 || Arg2) { /* Check if Exiting D0 and arming for wake. */
102 /* If CPU WAKE EN is not set, Set it. */
103 If (CPWE == 0) {
104 /* If CPU WAKE STATUS is set, Clear it. */
105 If (CPWS) {
106 /* Clear CPU WAKE STATUS by writing 1. */
107 CPWS = 1
108 }
109 CPWE = 1 /* Set CPU WAKE EN by writing 1. */
110 }
111 If ((C2PW & Local0) == 0) {
112 /* Set Corresponding Device En BIT in C2PW. */
113 C2PW |= Local0
114 }
115 } Else {
116 /*
117 * Disable runtime PME, either because staying in D0 or
118 * disabling wake.
119 */
120 If ((C2PW & Local0) != 0) {
121 /*
122 * Clear Corresponding Device En BIT in C2PW.
123 */
124 C2PW &= ~Local0
125 }
126 If ((CPWE != 0) && (C2PW == 0)) {
127 /*
128 * If CPU WAKE EN is set, Clear it. Clear CPU WAKE EN
129 * by writing 0.
130 */
131 CPWE = 0
132 }
133 }
134 }
135 Return (0)
136 }
John Zhaob8febf42020-06-11 18:05:23 -0700137
138 Method (_OSC, 4, Serialized)
139 {
John Zhao85288672020-06-22 09:30:47 -0700140 CreateDWordField (Arg3, 0, CDW1)
John Zhaoc47e3142020-06-24 23:08:01 -0700141 If (Arg0 == ToUUID("0811B06E-4A27-44F9-8D60-3CBBC22E7B48")) {
142 /* Platform-Wide _OSC Capabilities
143 * Arg0: UUID = {0811B06E-4A27-44F9-8D60-3CBBC22E7B48}
144 * Arg1: Revision ID = 1
145 * Arg2: Count of entries (DWORD) in Arge3 (Integer): 3
146 * Arg3: DWORD capabilities buffer:
147 * First DWORD: The standard definition bits are used to return errors.
148 * Second DWORD: See ACPI specification Platform-Wide _OSC Capabilities
149 * DWORD2 table for Bits 0-17. Bit 18 is newly defined as native USB4
150 * support. The OS sets this bit to indicate support for an OSPM-native
151 * USB4 Connection Manager which handles USB4 connection events and
152 * link management.
153 */
154 If (Arg1 != REVISION_ID) {
155 CDW1 |= UNRECOGNIZED_REVISION
156 }
157 Return (Arg3)
Sean Rhodes060df172022-05-21 10:39:27 +0100158#if CONFIG(SOFTWARE_CONNECTION_MANAGER)
Sean Rhodese72e8572021-11-01 21:33:37 +0000159 /*
160 * Software Connection Manager doesn't work with Linux 5.13 or later and
161 * results in TBT ports timing out. Not advertising this results in
162 * Firmware Connection Manager being used and TBT works correctly.
163 */
John Zhaoc47e3142020-06-24 23:08:01 -0700164 } ElseIf (Arg0 == ToUUID("23A0D13A-26AB-486C-9C5F-0FFA525A575A")) {
165 /*
166 * Operating System Capabilities for USB4
167 * Arg0: UUID = {23A0D13A-26AB-486C-9C5F-0FFA525A575A}
168 * Arg1: Revision ID = 1
169 * Arg2: Count of entries (DWORD) in Arg3 (Integer): 3
170 * Arg3: DWORD capabilities buffer:
171 * First DWORD: The standard definition bits are used to return errors.
172 * Second DWORD: OSPM support field for USB4, bits [31:0] reserved.
173 * Third DWORD: OSPM control field for USB4.
174 * bit 0: USB tunneling
175 * bit 1: DisplayPort tunneling
176 * bit 2: PCIe tunneling
177 * bit 3: Inter-domain USB4 internet protocol
178 * bit 31:4: reserved
179 * Return: The platform acknowledges the capabilities buffer by
180 * returning a buffer of DWORD of the same length. Masked/Cleared bits
181 * in the control field indicate that the platform does not permit OSPM
182 * control of the respectively capabilities or features.
183 */
184 CreateDWordField (Arg3, 8, CDW3)
185 Local0 = CDW3
John Zhaob8febf42020-06-11 18:05:23 -0700186
187 If (Arg1 != REVISION_ID) {
188 CDW1 |= UNRECOGNIZED_REVISION
John Zhao85288672020-06-22 09:30:47 -0700189 Return (Arg3)
John Zhaob8febf42020-06-11 18:05:23 -0700190 }
John Zhaoc47e3142020-06-24 23:08:01 -0700191 Local0 |= USB_TUNNELING | DISPLAY_PORT_TUNNELING | PCIE_TUNNELING |
John Zhaob8febf42020-06-11 18:05:23 -0700192 INTER_DOMAIN_USB4_INTERNET_PROTOCOL
John Zhaoc47e3142020-06-24 23:08:01 -0700193 CDW3 = Local0
John Zhaob8febf42020-06-11 18:05:23 -0700194 Return (Arg3)
Sean Rhodese72e8572021-11-01 21:33:37 +0000195#endif
John Zhaob8febf42020-06-11 18:05:23 -0700196 } Else {
197 CDW1 |= UNRECOGNIZED_UUID
198 Return (Arg3)
199 }
200 }
John Zhaoca584082020-03-16 15:33:06 -0700201}
202
John Zhaof74aa6492020-06-07 09:20:01 -0700203Scope (_GPE)
204{
205 /* PCI Express Hot-Plug wake event */
206 Method (_L61, 0, NotSerialized)
207 {
208 /*
209 * Delay for 100ms to meet the timing requirements of the PCI Express Base
210 * Specification, Revision 1.0A, Section 6.6 ("...software must wait at least
211 * 100ms from the end of reset of one or more device before it is permitted
212 * to issue Configuration Requests to those devices").
213 */
214 Sleep (100)
215
216 If (CondRefOf (\_SB.PCI0.TXHC)) {
217 /* Invoke PCIe root ports wake event handler */
218 \_SB.PCI0.TRP0.HPEV()
219 \_SB.PCI0.TRP1.HPEV()
220 \_SB.PCI0.TRP2.HPEV()
221 \_SB.PCI0.TRP3.HPEV()
222 }
223
224 /* Check Root Port 0 for a Hot Plug Event if the port is enabled */
225 If (((\_SB.PCI0.TRP0.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP0.HPSX)) {
226 If (\_SB.PCI0.TRP0.PDCX) {
227 /* Clear all status bits */
228 \_SB.PCI0.TRP0.PDCX = 1
229 \_SB.PCI0.TRP0.HPSX = 1
230 /*
231 * Intercept Presence Detect Changed interrupt and make sure
232 * the L0s is disabled on empty slots.
233 */
234 If (!\_SB.PCI0.TRP0.PDSX) {
235 /*
236 * The PCIe slot is empty, so disable L0s on hot unplug.
237 */
238 \_SB.PCI0.TRP0.L0SE = 0
239 }
240 /* Performs proper notification to the OS. */
241 Notify (\_SB.PCI0.TRP0, 0)
242 } Else {
243 /* False event. Clear Hot-Plug status, then exit. */
244 \_SB.PCI0.TRP0.HPSX = 1
245 }
246 }
247
248 /* Check Root Port 1 for a Hot Plug Event if the port is enabled */
249 If (((\_SB.PCI0.TRP1.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP1.HPSX)) {
250 If (\_SB.PCI0.TRP1.PDCX) {
251 \_SB.PCI0.TRP1.PDCX = 1
252 \_SB.PCI0.TRP1.HPSX = 1
253 If (!\_SB.PCI0.TRP1.PDSX) {
254 \_SB.PCI0.TRP1.L0SE = 0
255 }
256 Notify (\_SB.PCI0.TRP1, 0)
257 } Else {
258 \_SB.PCI0.TRP1.HPSX = 1
259 }
260 }
261
262 /* Check Root Port 2 for a Hot Plug Event if the port is enabled */
263 If (((\_SB.PCI0.TRP2.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP2.HPSX)) {
264 If (\_SB.PCI0.TRP2.PDCX) {
265 \_SB.PCI0.TRP2.PDCX = 1
266 \_SB.PCI0.TRP2.HPSX = 1
267 If (!\_SB.PCI0.TRP2.PDSX) {
268 \_SB.PCI0.TRP2.L0SE = 0
269 }
270 Notify (\_SB.PCI0.TRP2, 0)
271 } Else {
272 \_SB.PCI0.TRP2.HPSX = 1
273 }
274 }
275
276 /* Check Root Port 3 for a Hot Plug Event if the port is enabled */
277 If (((\_SB.PCI0.TRP3.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP3.HPSX)) {
278 If (\_SB.PCI0.TRP3.PDCX) {
279 \_SB.PCI0.TRP3.PDCX = 1
280 \_SB.PCI0.TRP3.HPSX = 1
281 If (!\_SB.PCI0.TRP3.PDSX) {
282 \_SB.PCI0.TRP3.L0SE = 0
283 }
284 Notify (\_SB.PCI0.TRP3, 0)
285 } Else {
286 \_SB.PCI0.TRP3.HPSX = 1
287 }
288 }
289 }
290
291 /* PCI Express power management event */
292 Method (_L69, 0, Serialized)
293 {
294 If (CondRefOf (\_SB.PCI0.TXHC)) {
295 If (\_SB.PCI0.TRP0.HPME() == 1) {
296 Notify (\_SB.PCI0.TDM0, 0x2)
297 Notify (\_SB.PCI0.TRP0, 0x2)
298 }
299
300 If (\_SB.PCI0.TRP1.HPME() == 1) {
301 Notify (\_SB.PCI0.TDM0, 0x2)
302 Notify (\_SB.PCI0.TRP1, 0x2)
303 }
304
305 If (\_SB.PCI0.TRP2.HPME() == 1) {
306 Notify (\_SB.PCI0.TDM1, 0x2)
307 Notify (\_SB.PCI0.TRP2, 0x2)
308 }
309
310 If (\_SB.PCI0.TRP3.HPME() == 1) {
311 Notify (\_SB.PCI0.TDM1, 0x2)
312 Notify (\_SB.PCI0.TRP3, 0x2)
313 }
314 }
315
316 /* Invoke PCIe root ports power management status handler */
317 \_SB.PCI0.TRP0.HPME()
318 \_SB.PCI0.TRP1.HPME()
319 \_SB.PCI0.TRP2.HPME()
320 \_SB.PCI0.TRP3.HPME()
321 }
322}
323
John Zhaoca584082020-03-16 15:33:06 -0700324Scope (\_SB.PCI0)
325{
John Zhao6aedba22020-05-26 21:19:19 -0700326 Device (IOM)
327 {
328 Name (_HID, "INTC1072")
329 Name (_DDN, "Intel(R) Tiger Lake Input Output Manager(IOM) driver")
330 /* IOM preserved MMIO range from 0xFBC10000 to 0xFBC11600. */
331 Name (_CRS, ResourceTemplate () {
332 Memory32Fixed (ReadWrite, IOM_BASE_ADDRESS, IOM_BASE_SIZE)
333 })
Matt DeVillier3d85d6b2022-11-29 13:00:31 -0600334 Name (_STA, 0xF)
John Zhao6aedba22020-05-26 21:19:19 -0700335 }
336
John Zhaoca584082020-03-16 15:33:06 -0700337 /*
John Zhaob8febf42020-06-11 18:05:23 -0700338 * Operation region defined to access the TCSS_DEVEN. Get the MCHBAR in offset
339 * 0x48 in B0:D0:F0. TCSS device enable base address is in offset 0x7090 of MCHBAR.
340 */
341 OperationRegion (TDEN, SystemMemory, (GMHB() + MCHBAR_TCSS_DEVEN_OFFSET), 0x4)
342 Field (TDEN, ByteAcc, NoLock, Preserve)
343 {
344 TRE0, 1, /* PCIE0_EN */
345 TRE1, 1, /* PCIE1_EN */
346 TRE2, 1, /* PCIE2_EN */
347 TRE3, 1, /* PCIE3_EN */
348 , 4,
349 THCE, 1, /* XHCI_EN */
350 TDCE, 1, /* XDCI_EN */
351 DME0, 1, /* TBT_DMA0_EN */
352 DME1, 1, /* TBT_DMA1_EN */
353 , 20
354 }
355
356 /*
John Zhaoca584082020-03-16 15:33:06 -0700357 * Operation region defined to access the IOM REGBAR. Get the MCHBAR in offset
358 * 0x48 in B0:D0:F0. REGBAR Base address is in offset 0x7110 of MCHBAR.
359 */
360 OperationRegion (MBAR, SystemMemory, (GMHB() + 0x7100), 0x1000)
361 Field (MBAR, ByteAcc, NoLock, Preserve)
362 {
363 Offset(0x10),
364 RBAR, 64 /* RegBar, offset 0x7110 in MCHBAR */
365 }
366 Field (MBAR, DWordAcc, NoLock, Preserve)
367 {
368 Offset(0x304), /* PRIMDN_MASK1_0_0_0_MCHBAR_IMPH, offset 0x7404 */
369 , 31,
370 TCD3, 1 /* [31:31] TCSS IN D3 bit */
371 }
372
373 /*
374 * Operation region defined to access the pCode mailbox interface. Get the MCHBAR
375 * in offset 0x48 in B0:D0:F0. MMIO address is in offset 0x5DA0 of MCHBAR.
376 */
377 OperationRegion (PBAR, SystemMemory, (GMHB() + 0x5DA0), 0x08)
378 Field (PBAR, DWordAcc, NoLock, Preserve)
379 {
380 PMBD, 32, /* pCode MailBox Data, offset 0x5DA0 in MCHBAR */
381 PMBC, 8, /* pCode MailBox Command, [7:0] of offset 0x5DA4 in MCHBAR */
382 PSCM, 8, /* pCode MailBox Sub-Command, [15:8] of offset 0x5DA4 in MCHBAR */
383 , 15, /* Reserved */
384 PMBR, 1 /* pCode MailBox RunBit, [31:31] of offset 0x5DA4 in MCHBAR */
385 }
386
387 /*
388 * Poll pCode MailBox Ready
389 *
390 * Return 0xFF - Timeout
Elyes HAOUASe912e3e2020-08-13 14:54:21 +0200391 * 0x00 - Ready
John Zhaoca584082020-03-16 15:33:06 -0700392 */
393 Method (PMBY, 0)
394 {
395 Local0 = 0
396 While (PMBR && (Local0 < 1000)) {
397 Local0++
398 Stall (1)
399 }
400 If (Local0 == 1000) {
401 Printf("Timeout occurred.")
402 Return (0xFF)
403 }
404 Return (0)
405 }
406
407 /*
408 * Method to send pCode MailBox command TCSS_DEVEN_MAILBOX_SUBCMD_GET_STATUS
409 *
410 * Result will be updated in DATA[1:0]
411 * DATA[0:0] TCSS_DEVEN_CURRENT_STATE:
412 * 0 - TCSS Deven in normal state.
413 * 1 - TCSS Deven is cleared by BIOS Mailbox request.
414 * DATA[1:1] TCSS_DEVEN_REQUEST_STATUS:
415 * 0 - IDLE. TCSS DEVEN has reached its final requested state.
416 * 1 - In Progress. TCSS DEVEN is currently in progress of switching state
Elyes HAOUASe912e3e2020-08-13 14:54:21 +0200417 * according to given request (bit 0 reflects source state).
John Zhaoca584082020-03-16 15:33:06 -0700418 *
419 * Return 0x00 - TCSS Deven in normal state
Elyes HAOUASe912e3e2020-08-13 14:54:21 +0200420 * 0x01 - TCSS Deven is cleared by BIOS Mailbox request
421 * 0x1x - TCSS Deven is in progress of switching state according to given request
422 * 0xFE - Command timeout
423 * 0xFF - Command corrupt
John Zhaoca584082020-03-16 15:33:06 -0700424 */
425 Method (DSGS, 0)
426 {
427 If ((PMBY () == 0)) {
428 PMBC = MAILBOX_BIOS_CMD_TCSS_DEVEN_INTERFACE
429 PSCM = TCSS_DEVEN_MAILBOX_SUBCMD_GET_STATUS
430 PMBR = 1
431 If (PMBY () == 0) {
432 Local0 = PMBD
433 Local1 = PMBC
434 Stall (10)
435 If ((Local0 != PMBD) || (Local1 != PMBC)) {
436 Printf("pCode MailBox is corrupt.")
437 Return (0xFF)
438 }
439 Return (Local0)
440 } Else {
441 Printf("pCode MailBox is not ready.")
442 Return (0xFE)
443 }
444 } Else {
445 Printf("pCode MailBox is not ready.")
446 Return (0xFE)
447 }
448 }
449
450 /*
451 * Method to send pCode MailBox command TCSS_DEVEN_MAILBOX_SUBCMD_TCSS_CHANGE_REQ
452 *
453 * Arg0 : 0 - Restore to previously saved value of TCSS DEVEN
454 * 1 - Save current TCSS DEVEN value and clear it
455 *
456 * Return 0x00 - MAILBOX_BIOS_CMD_CLEAR_TCSS_DEVEN command completed
457 * 0xFD - Input argument is invalid
458 * 0xFE - Command timeout
459 * 0xFF - Command corrupt
460 */
461 Method (DSCR, 1)
462 {
463 If (Arg0 > 1) {
464 Printf("pCode MailBox is corrupt.")
465 Return (0xFD)
466 }
467 If ((PMBY () == 0)) {
468 PMBC = MAILBOX_BIOS_CMD_TCSS_DEVEN_INTERFACE
469 PSCM = TCSS_DEVEN_MAILBOX_SUBCMD_TCSS_CHANGE_REQ
470 PMBD = Arg0
471 PMBR = 1
472 If ((PMBY () == 0)) {
473 Local0 = PMBD
474 Local1 = PMBC
475 Stall (10)
476 If ((Local0 != PMBD) || (Local1 != PMBC)) {
477 Printf("pCode MailBox is corrupt.")
478 Return (0xFF)
479 }
480 /* Poll TCSS_DEVEN_REQUEST_STATUS, timeout value is 10ms. */
481 Local0 = 0
482 While ((DSGS () & 0x10) && (Local0 < 100)) {
483 Stall (100)
484 Local0++
485 }
486 If (Local0 == 100) {
487 Printf("pCode MailBox is not ready.")
488 Return (0xFE)
489 } Else {
490 Return (0x00)
491 }
492 } Else {
493 Printf("pCode MailBox is not ready.")
494 Return (0xFE)
495 }
496 } Else {
497 Printf("pCode MailBox is not ready.")
498 Return (0xFE)
499 }
500 }
501
502 /*
503 * IOM REG BAR Base address is in offset 0x7110 in MCHBAR.
504 */
505 Method (IOMA, 0)
506 {
507 Return (^RBAR & ~0x1)
508 }
509
510 /*
511 * From RegBar Base, IOM_TypeC_SW_configuration_1 is in offset 0xC10040, where
512 * 0x40 is the register offset.
513 */
514 OperationRegion (IOMR, SystemMemory, (IOMA() + 0xC10000), 0x100)
515 Field (IOMR, DWordAcc, NoLock, Preserve)
516 {
517 Offset(0x40),
518 , 15,
519 TD3C, 1, /* [15:15] Type C D3 cold bit */
520 TACK, 1, /* [16:16] IOM Acknowledge bit */
521 DPOF, 1, /* [17:17] Set 1 to indicate IOM, all the */
522 /* display is OFF, clear otherwise */
Martin Roth26f97f92021-10-01 14:53:22 -0600523 Offset(0x70), /* Physical addr is offset 0x70. */
John Zhaoca584082020-03-16 15:33:06 -0700524 IMCD, 32, /* R_SA_IOM_BIOS_MAIL_BOX_CMD */
525 IMDA, 32 /* R_SA_IOM_BIOS_MAIL_BOX_DATA */
526 }
527
528 /*
John Zhaoca584082020-03-16 15:33:06 -0700529 * TBT Group0 ON method
530 */
531 Method (TG0N, 0)
532 {
533 If (\_SB.PCI0.TDM0.VDID == 0xFFFFFFFF) {
534 Printf("TDM0 does not exist.")
John Zhaoca584082020-03-16 15:33:06 -0700535 } Else {
John Zhaof74aa6492020-06-07 09:20:01 -0700536 If (\_SB.PCI0.TDM0.STAT == 0) {
537 /* DMA0 is in D3Cold early. */
538 \_SB.PCI0.TDM0.D3CX() /* RTD3 Exit */
539
540 Printf("Bring TBT RPs out of D3Code.")
541 If (\_SB.PCI0.TRP0.VDID != 0xFFFFFFFF) {
542 /* RP0 D3 cold exit. */
543 \_SB.PCI0.TRP0.D3CX()
544 }
545 If (\_SB.PCI0.TRP1.VDID != 0xFFFFFFFF) {
546 /* RP1 D3 cold exit. */
547 \_SB.PCI0.TRP1.D3CX()
548 }
John Zhaof74aa6492020-06-07 09:20:01 -0700549 } Else {
550 Printf("Drop TG0N due to it is already exit D3 cold.")
551 }
552
553 /* TBT RTD3 exit 10ms delay. */
554 Sleep (10)
John Zhaoca584082020-03-16 15:33:06 -0700555 }
John Zhaoca584082020-03-16 15:33:06 -0700556 }
557
558 /*
559 * TBT Group0 OFF method
560 */
561 Method (TG0F, 0)
562 {
563 If (\_SB.PCI0.TDM0.VDID == 0xFFFFFFFF) {
564 Printf("TDM0 does not exist.")
John Zhaof74aa6492020-06-07 09:20:01 -0700565 } Else {
566 If (\_SB.PCI0.TDM0.STAT == 1) {
567 /* DMA0 is not in D3Cold now. */
568 \_SB.PCI0.TDM0.D3CE() /* Enable DMA RTD3 */
John Zhaoca584082020-03-16 15:33:06 -0700569
John Zhaof74aa6492020-06-07 09:20:01 -0700570 Printf("Push TBT RPs to D3Cold together")
571 If (\_SB.PCI0.TRP0.VDID != 0xFFFFFFFF) {
John Zhaof74aa6492020-06-07 09:20:01 -0700572 /* Put RP0 to D3 cold. */
573 \_SB.PCI0.TRP0.D3CE()
John Zhaoca584082020-03-16 15:33:06 -0700574 }
John Zhaof74aa6492020-06-07 09:20:01 -0700575 If (\_SB.PCI0.TRP1.VDID != 0xFFFFFFFF) {
John Zhaof74aa6492020-06-07 09:20:01 -0700576 /* Put RP1 to D3 cold. */
577 \_SB.PCI0.TRP1.D3CE()
John Zhaoca584082020-03-16 15:33:06 -0700578 }
John Zhaoca584082020-03-16 15:33:06 -0700579 }
580 }
581 }
582
583 /*
584 * TBT Group1 ON method
585 */
586 Method (TG1N, 0)
587 {
588 If (\_SB.PCI0.TDM1.VDID == 0xFFFFFFFF) {
589 Printf("TDM1 does not exist.")
John Zhaoca584082020-03-16 15:33:06 -0700590 } Else {
John Zhaof74aa6492020-06-07 09:20:01 -0700591 If (\_SB.PCI0.TDM1.STAT == 0) {
592 /* DMA1 is in D3Cold early. */
593 \_SB.PCI0.TDM1.D3CX() /* RTD3 Exit */
594
595 Printf("Bring TBT RPs out of D3Code.")
596 If (\_SB.PCI0.TRP2.VDID != 0xFFFFFFFF) {
597 /* RP2 D3 cold exit. */
598 \_SB.PCI0.TRP2.D3CX()
599 }
600 If (\_SB.PCI0.TRP3.VDID != 0xFFFFFFFF) {
601 /* RP3 D3 cold exit. */
602 \_SB.PCI0.TRP3.D3CX()
603 }
John Zhaof74aa6492020-06-07 09:20:01 -0700604 } Else {
605 Printf("Drop TG1N due to it is already exit D3 cold.")
606 }
607
608 /* TBT RTD3 exit 10ms delay. */
609 Sleep (10)
John Zhaoca584082020-03-16 15:33:06 -0700610 }
John Zhaoca584082020-03-16 15:33:06 -0700611 }
612
613 /*
614 * TBT Group1 OFF method
615 */
616 Method (TG1F, 0)
617 {
618 If (\_SB.PCI0.TDM1.VDID == 0xFFFFFFFF) {
619 Printf("TDM1 does not exist.")
John Zhaof74aa6492020-06-07 09:20:01 -0700620 } Else {
621 If (\_SB.PCI0.TDM1.STAT == 1) {
622 /* DMA1 is not in D3Cold now */
623 \_SB.PCI0.TDM1.D3CE() /* Enable DMA RTD3. */
John Zhaoca584082020-03-16 15:33:06 -0700624
John Zhaof74aa6492020-06-07 09:20:01 -0700625 Printf("Push TBT RPs to D3Cold together")
626 If (\_SB.PCI0.TRP2.VDID != 0xFFFFFFFF) {
John Zhaof74aa6492020-06-07 09:20:01 -0700627 /* Put RP2 to D3 cold. */
628 \_SB.PCI0.TRP2.D3CE()
John Zhaoca584082020-03-16 15:33:06 -0700629 }
John Zhaof74aa6492020-06-07 09:20:01 -0700630 If (\_SB.PCI0.TRP3.VDID != 0xFFFFFFFF) {
John Zhaof74aa6492020-06-07 09:20:01 -0700631 /* Put RP3 to D3 cold */
632 \_SB.PCI0.TRP3.D3CE()
John Zhaoca584082020-03-16 15:33:06 -0700633 }
John Zhaoca584082020-03-16 15:33:06 -0700634 }
635 }
636 }
637
638 PowerResource (TBT0, 5, 1)
639 {
640 Method (_STA, 0)
641 {
642 Return (\_SB.PCI0.TDM0.STAT)
643 }
644
645 Method (_ON, 0)
646 {
647 TG0N()
648 }
649
650 Method (_OFF, 0)
651 {
652 If (\_SB.PCI0.TDM0.SD3C == 0) {
653 TG0F()
654 }
655 }
656 }
657
658 PowerResource (TBT1, 5, 1)
659 {
660 Method (_STA, 0)
661 {
662 Return (\_SB.PCI0.TDM1.STAT)
663 }
664
665 Method (_ON, 0)
666 {
667 TG1N()
668 }
669
670 Method (_OFF, 0)
671 {
672 If (\_SB.PCI0.TDM1.SD3C == 0) {
673 TG1F()
674 }
675 }
676 }
677
Sean Rhodes5f0cda72023-04-13 12:17:38 +0100678#if CONFIG(D3COLD_SUPPORT)
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000679 Method (TCON, 0)
680 {
681 /* Reset IOM D3 cold bit if it is in D3 cold now. */
682 If (TD3C == 1) /* It was in D3 cold before. */
John Zhaoca584082020-03-16 15:33:06 -0700683 {
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000684 /* Reset IOM D3 cold bit. */
685 TD3C = 0 /* Request IOM for D3 cold exit sequence. */
686 Local0 = 0 /* Time check counter variable */
687 /* Wait for ack, the maximum wait time for the ack is 100 msec. */
688 While ((TACK != 0) && (Local0 < TCSS_IOM_ACK_TIMEOUT_IN_MS)) {
689 /*
690 * Wait in this loop until TACK becomes 0 with timeout
691 * TCSS_IOM_ACK_TIMEOUT_IN_MS by default.
692 */
693 Sleep (1) /* Delay of 1ms. */
694 Local0++
695 }
Sean Rhodes56226662021-11-08 21:34:34 +0000696
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000697 If (Local0 == TCSS_IOM_ACK_TIMEOUT_IN_MS) {
698 Printf("Error: Timeout occurred.")
699 }
700 Else
701 {
702 /*
703 * Program IOP MCTP Drop (TCSS_IN_D3) after D3 cold exit and
704 * acknowledgement by IOM.
705 */
706 TCD3 = 0
707 /*
708 * If the TCSS Deven is cleared by BIOS Mailbox request, then
709 * restore to previously saved value of TCSS DEVNE.
710 */
711 Local0 = 0
712 While (\_SB.PCI0.TXHC.VDID == 0xFFFFFFFF) {
713 If (DSGS () == 1) {
714 DSCR (0)
715 }
716 Local0++
717 If (Local0 == 5) {
718 Printf("pCode mailbox command failed.")
719 Break
John Zhaoca584082020-03-16 15:33:06 -0700720 }
721 }
722 }
John Zhaoca584082020-03-16 15:33:06 -0700723 }
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000724 Else {
725 Printf("Drop TCON due to it is already exit D3 cold.")
726 }
727 }
John Zhaoca584082020-03-16 15:33:06 -0700728
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000729 Method (TCOF, 0)
730 {
731 If ((\_SB.PCI0.TXHC.SD3C != 0) || (\_SB.PCI0.TDM0.SD3C != 0)
732 || (\_SB.PCI0.TDM1.SD3C != 0))
John Zhaoca584082020-03-16 15:33:06 -0700733 {
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000734 Printf("Skip D3C entry.")
735 Return
John Zhaoca584082020-03-16 15:33:06 -0700736 }
737
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000738 /*
739 * If the TCSS Deven in normal state, then Save current TCSS DEVEN value and
740 * clear it.
741 */
742 Local0 = 0
743 While (\_SB.PCI0.TXHC.VDID != 0xFFFFFFFF) {
744 If (DSGS () == 0) {
745 DSCR (1)
746 }
747 Local0++
748 If (Local0 == 5) {
749 Printf("pCode mailbox command failed.")
750 Break
751 }
752 }
753
754 /*
755 * Program IOM MCTP Drop (TCSS_IN_D3) in D3Cold entry before entering D3 cold.
756 */
757 TCD3 = 1
758
759 /* Request IOM for D3 cold entry sequence. */
760 TD3C = 1
761 }
762
763 PowerResource (D3C, 5, 0)
764 {
765 /*
766 * Variable to save power state
767 * 1 - TC Cold request cleared.
768 * 0 - TC Cold request sent.
769 */
770 Name (STAT, 0x1)
771
772 Method (_STA, 0)
John Zhaoca584082020-03-16 15:33:06 -0700773 {
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000774 Return (STAT)
John Zhaoca584082020-03-16 15:33:06 -0700775 }
Sean Rhodes6b5b7e02023-02-06 09:09:16 +0000776
777 Method (_ON, 0)
778 {
779 \_SB.PCI0.TCON()
780 STAT = 1
781 }
782
783 Method (_OFF, 0)
784 {
785 \_SB.PCI0.TCOF()
786 STAT = 0
787 }
788 }
Sean Rhodes5f0cda72023-04-13 12:17:38 +0100789#endif // D3COLD_SUPPORT
John Zhaoca584082020-03-16 15:33:06 -0700790
791 /*
792 * TCSS xHCI device
793 */
794 Device (TXHC)
795 {
796 Name (_ADR, 0x000D0000)
797 Name (_DDN, "North XHCI controller")
798 Name (_STR, Unicode ("North XHCI controller"))
799 Name (DCPM, TCSS_XHCI)
800
801 Method (_STA, 0x0, NotSerialized)
802 {
John Zhaob8febf42020-06-11 18:05:23 -0700803 If (THCE == 1) {
804 Return (0x0F)
805 } Else {
806 Return (0x0)
807 }
John Zhaoca584082020-03-16 15:33:06 -0700808 }
809 #include "tcss_xhci.asl"
810 }
811
812 /*
813 * TCSS DMA0 device
814 */
815 Device (TDM0)
816 {
817 Name (_ADR, 0x000D0002)
818 Name (_DDN, "TBT DMA0 controller")
819 Name (_STR, Unicode ("TBT DMA0 controller"))
820 Name (DUID, 0) /* TBT DMA number */
821 Name (DCPM, TCSS_DMA0)
822
823 Method (_STA, 0x0, NotSerialized)
824 {
John Zhaob8febf42020-06-11 18:05:23 -0700825 If (DME0 == 1) {
826 Return (0x0F)
827 } Else {
828 Return (0x0)
829 }
John Zhaoca584082020-03-16 15:33:06 -0700830 }
831 #include "tcss_dma.asl"
832 }
833
834 /*
835 * TCSS DMA1 device
836 */
837 Device (TDM1)
838 {
839 Name (_ADR, 0x000D0003)
840 Name (_DDN, "TBT DMA1 controller")
841 Name (_STR, Unicode ("TBT DMA1 controller"))
842 Name (DUID, 1) /* TBT DMA number */
843 Name (DCPM, TCSS_DMA1)
844
845 Method (_STA, 0x0, NotSerialized)
846 {
John Zhaob8febf42020-06-11 18:05:23 -0700847 If (DME1 == 1) {
848 Return (0x0F)
849 } Else {
850 Return (0x0)
851 }
John Zhaoca584082020-03-16 15:33:06 -0700852 }
853 #include "tcss_dma.asl"
854 }
855
856 /*
857 * TCSS PCIE Root Port #00
858 */
859 Device (TRP0)
860 {
861 Name (_ADR, 0x00070000)
862 Name (TUID, 0) /* TBT PCIE RP Number 0 for RP00 */
863 Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */
864 Name (LMSL, 0) /* PCIE LTR max snoop Latency */
865 Name (LNSL, 0) /* PCIE LTR max no snoop Latency */
866 Name (DCPM, TCSS_TBT_PCIE0_RP0)
867
868 Method (_STA, 0x0, NotSerialized)
869 {
John Zhaob8febf42020-06-11 18:05:23 -0700870 If (TRE0 == 1) {
871 Return (0x0F)
872 } Else {
873 Return (0x0)
874 }
John Zhaoca584082020-03-16 15:33:06 -0700875 }
John Zhaob8febf42020-06-11 18:05:23 -0700876
John Zhaoca584082020-03-16 15:33:06 -0700877 Method (_INI)
878 {
879 LTEN = 0
880 LMSL = 0x88C8
881 LNSL = 0x88C8
882 }
883 #include "tcss_pcierp.asl"
884 }
885
886 /*
887 * TCSS PCIE Root Port #01
888 */
889 Device (TRP1)
890 {
891 Name (_ADR, 0x00070001)
892 Name (TUID, 1) /* TBT PCIE RP Number 1 for RP01 */
893 Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */
894 Name (LMSL, 0) /* PCIE LTR max snoop Latency */
895 Name (LNSL, 0) /* PCIE LTR max no snoop Latency */
896 Name (DCPM, TCSS_TBT_PCIE0_RP1)
897
898 Method (_STA, 0x0, NotSerialized)
899 {
John Zhaob8febf42020-06-11 18:05:23 -0700900 If (TRE1 == 1) {
901 Return (0x0F)
902 } Else {
903 Return (0x0)
904 }
John Zhaoca584082020-03-16 15:33:06 -0700905 }
John Zhaob8febf42020-06-11 18:05:23 -0700906
John Zhaoca584082020-03-16 15:33:06 -0700907 Method (_INI)
908 {
909 LTEN = 0
910 LMSL = 0x88C8
911 LNSL = 0x88C8
912 }
913 #include "tcss_pcierp.asl"
914 }
915
916 /*
917 * TCSS PCIE Root Port #02
918 */
919 Device (TRP2)
920 {
921 Name (_ADR, 0x00070002)
922 Name (TUID, 2) /* TBT PCIE RP Number 2 for RP02 */
923 Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */
924 Name (LMSL, 0) /* PCIE LTR max snoop Latency */
925 Name (LNSL, 0) /* PCIE LTR max no snoop Latency */
926 Name (DCPM, TCSS_TBT_PCIE0_RP2)
927
928 Method (_STA, 0x0, NotSerialized)
929 {
John Zhaob8febf42020-06-11 18:05:23 -0700930 If (TRE2 == 1) {
931 Return (0x0F)
932 } Else {
933 Return (0x0)
934 }
John Zhaoca584082020-03-16 15:33:06 -0700935 }
John Zhaob8febf42020-06-11 18:05:23 -0700936
John Zhaoca584082020-03-16 15:33:06 -0700937 Method (_INI)
938 {
939 LTEN = 0
940 LMSL = 0x88C8
941 LNSL = 0x88C8
942 }
943 #include "tcss_pcierp.asl"
944 }
945
946 /*
947 * TCSS PCIE Root Port #03
948 */
949 Device (TRP3)
950 {
951 Name (_ADR, 0x00070003)
952 Name (TUID, 3) /* TBT PCIE RP Number 3 for RP03 */
953 Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */
954 Name (LMSL, 0) /* PCIE LTR max snoop Latency */
955 Name (LNSL, 0) /* PCIE LTR max no snoop Latency */
956 Name (DCPM, TCSS_TBT_PCIE0_RP3)
957
958 Method (_STA, 0x0, NotSerialized)
959 {
John Zhaob8febf42020-06-11 18:05:23 -0700960 If (TRE3 == 1) {
961 Return (0x0F)
962 } Else {
963 Return (0x0)
964 }
John Zhaoca584082020-03-16 15:33:06 -0700965 }
John Zhaob8febf42020-06-11 18:05:23 -0700966
John Zhaoca584082020-03-16 15:33:06 -0700967 Method (_INI)
968 {
969 LTEN = 0
970 LMSL = 0x88C8
971 LNSL = 0x88C8
972 }
973 #include "tcss_pcierp.asl"
974 }
975}