| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
|
| 3 |
#include <intelblocks/tcss.h> |
| 4 |
#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 */ |
| 30 |
#define TCSS_IOM_ACK_TIMEOUT_IN_MS 100 |
| 31 |
|
| 32 |
#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 |
|
| 43 |
Scope (\_SB) |
| 44 |
{ |
| 45 |
/* |
| 46 |
* Define PCH ACPIBASE IO as an ACPI operating region. The base address can be |
| 47 |
* found in Device 31, Function 2, Offset 40h. |
| 48 |
*/ |
| 49 |
OperationRegion (PMIO, SystemIO, ACPI_BASE_ADDRESS, 0x80) |
| 50 |
Field (PMIO, ByteAcc, NoLock, Preserve) { |
| 51 |
Offset(0x6C), /* 0x6C, General Purpose Event 0 Status [127:96] */ |
| 52 |
, 19, |
| 53 |
CPWS, 1, /* CPU WAKE STATUS */ |
| 54 |
Offset(0x7C), /* 0x7C, General Purpose Event 0 Enable [127:96] */ |
| 55 |
, 19, |
| 56 |
CPWE, 1 /* CPU WAKE EN */ |
| 57 |
} |
| 58 |
|
| 59 |
Name (C2PW, 0) /* Set default value to 0. */ |
| 60 |
|
| 61 |
/* |
| 62 |
* C2PM (CPU to PCH Method) |
| 63 |
* |
| 64 |
* This object is Enable/Disable GPE_CPU_WAKE_EN. |
| 65 |
* Arguments: (4) |
| 66 |
* Arg0 - An Integer containing the device wake capability |
| 67 |
* Arg1 - An Integer containing the target system state |
| 68 |
* Arg2 - An Integer containing the target device state |
| 69 |
* Arg3 - An Integer containing the request device type |
| 70 |
* Return Value: |
| 71 |
* return 0 |
| 72 |
*/ |
| 73 |
Method (C2PM, 4, NotSerialized) |
| 74 |
{ |
| 75 |
Local0 = 1 << Arg3 |
| 76 |
/* This method is used to enable/disable wake from Tcss Device (WKEN). */ |
| 77 |
If (Arg0 && Arg1) |
| 78 |
{ /* If entering Sx and enabling wake, need to enable WAKE capability. */ |
| 79 |
If (CPWE == 0) { /* If CPU WAKE EN is not set, Set it. */ |
| 80 |
If (CPWS) { /* If CPU WAKE STATUS is set, Clear it. */ |
| 81 |
/* Clear CPU WAKE STATUS by writing 1. */ |
| 82 |
CPWS = 1 |
| 83 |
} |
| 84 |
CPWE = 1 /* Set CPU WAKE EN by writing 1. */ |
| 85 |
} |
| 86 |
If ((C2PW & Local0) == 0) { |
| 87 |
/* Set Corresponding Device En BIT in C2PW. */ |
| 88 |
C2PW |= Local0 |
| 89 |
} |
| 90 |
} Else { /* If Staying in S0 or Disabling Wake. */ |
| 91 |
If (Arg0 || Arg2) { /* Check if Exiting D0 and arming for wake. */ |
| 92 |
/* If CPU WAKE EN is not set, Set it. */ |
| 93 |
If (CPWE == 0) { |
| 94 |
/* If CPU WAKE STATUS is set, Clear it. */ |
| 95 |
If (CPWS) { |
| 96 |
/* Clear CPU WAKE STATUS by writing 1. */ |
| 97 |
CPWS = 1 |
| 98 |
} |
| 99 |
CPWE = 1 /* Set CPU WAKE EN by writing 1. */ |
| 100 |
} |
| 101 |
If ((C2PW & Local0) == 0) { |
| 102 |
/* Set Corresponding Device En BIT in C2PW. */ |
| 103 |
C2PW |= Local0 |
| 104 |
} |
| 105 |
} Else { |
| 106 |
/* |
| 107 |
* Disable runtime PME, either because staying in D0 or |
| 108 |
* disabling wake. |
| 109 |
*/ |
| 110 |
If ((C2PW & Local0) != 0) { |
| 111 |
/* |
| 112 |
* Clear Corresponding Device En BIT in C2PW. |
| 113 |
*/ |
| 114 |
C2PW &= ~Local0 |
| 115 |
} |
| 116 |
If ((CPWE != 0) && (C2PW == 0)) { |
| 117 |
/* |
| 118 |
* If CPU WAKE EN is set, Clear it. Clear CPU WAKE EN |
| 119 |
* by writing 0. |
| 120 |
*/ |
| 121 |
CPWE = 0 |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
Return (0) |
| 126 |
} |
| 127 |
|
| 128 |
Method (_OSC, 4, Serialized) |
| 129 |
{ |
| 130 |
CreateDWordField (Arg3, 0, CDW1) |
| 131 |
If (Arg0 == ToUUID("0811B06E-4A27-44F9-8D60-3CBBC22E7B48")) { |
| 132 |
/* Platform-Wide _OSC Capabilities |
| 133 |
* Arg0: UUID = {0811B06E-4A27-44F9-8D60-3CBBC22E7B48} |
| 134 |
* Arg1: Revision ID = 1 |
| 135 |
* Arg2: Count of entries (DWORD) in Arge3 (Integer): 3 |
| 136 |
* Arg3: DWORD capabilities buffer: |
| 137 |
* First DWORD: The standard definition bits are used to return errors. |
| 138 |
* Second DWORD: See ACPI specification Platform-Wide _OSC Capabilities |
| 139 |
* DWORD2 table for Bits 0-17. Bit 18 is newly defined as native USB4 |
| 140 |
* support. The OS sets this bit to indicate support for an OSPM-native |
| 141 |
* USB4 Connection Manager which handles USB4 connection events and |
| 142 |
* link management. |
| 143 |
*/ |
| 144 |
If (Arg1 != REVISION_ID) { |
| 145 |
CDW1 |= UNRECOGNIZED_REVISION |
| 146 |
} |
| 147 |
Return (Arg3) |
| 148 |
#if CONFIG(SOFTWARE_CONNECTION_MANAGER) |
| 149 |
/* |
| 150 |
* Software Connection Manager doesn't work with Linux 5.13 or later and |
| 151 |
* results in TBT ports timing out. Not advertising this results in |
| 152 |
* Firmware Connection Manager being used and TBT works correctly. |
| 153 |
*/ |
| 154 |
} ElseIf (Arg0 == ToUUID("23A0D13A-26AB-486C-9C5F-0FFA525A575A")) { |
| 155 |
/* |
| 156 |
* Operating System Capabilities for USB4 |
| 157 |
* Arg0: UUID = {23A0D13A-26AB-486C-9C5F-0FFA525A575A} |
| 158 |
* Arg1: Revision ID = 1 |
| 159 |
* Arg2: Count of entries (DWORD) in Arg3 (Integer): 3 |
| 160 |
* Arg3: DWORD capabilities buffer: |
| 161 |
* First DWORD: The standard definition bits are used to return errors. |
| 162 |
* Second DWORD: OSPM support field for USB4, bits [31:0] reserved. |
| 163 |
* Third DWORD: OSPM control field for USB4. |
| 164 |
* bit 0: USB tunneling |
| 165 |
* bit 1: DisplayPort tunneling |
| 166 |
* bit 2: PCIe tunneling |
| 167 |
* bit 3: Inter-domain USB4 internet protocol |
| 168 |
* bit 31:4: reserved |
| 169 |
* Return: The platform acknowledges the capabilities buffer by |
| 170 |
* returning a buffer of DWORD of the same length. Masked/Cleared bits |
| 171 |
* in the control field indicate that the platform does not permit OSPM |
| 172 |
* control of the respectively capabilities or features. |
| 173 |
*/ |
| 174 |
CreateDWordField (Arg3, 8, CDW3) |
| 175 |
Local0 = CDW3 |
| 176 |
|
| 177 |
If (Arg1 != REVISION_ID) { |
| 178 |
CDW1 |= UNRECOGNIZED_REVISION |
| 179 |
Return (Arg3) |
| 180 |
} |
| 181 |
Local0 |= USB_TUNNELING | DISPLAY_PORT_TUNNELING | PCIE_TUNNELING | |
| 182 |
INTER_DOMAIN_USB4_INTERNET_PROTOCOL |
| 183 |
CDW3 = Local0 |
| 184 |
Return (Arg3) |
| 185 |
#endif |
| 186 |
} Else { |
| 187 |
CDW1 |= UNRECOGNIZED_UUID |
| 188 |
Return (Arg3) |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
Scope (_GPE) |
| 194 |
{ |
| 195 |
/* PCI Express Hot-Plug wake event */ |
| 196 |
Method (_L61, 0, NotSerialized) |
| 197 |
{ |
| 198 |
/* |
| 199 |
* Delay for 100ms to meet the timing requirements of the PCI Express Base |
| 200 |
* Specification, Revision 1.0A, Section 6.6 ("...software must wait at least |
| 201 |
* 100ms from the end of reset of one or more device before it is permitted |
| 202 |
* to issue Configuration Requests to those devices"). |
| 203 |
*/ |
| 204 |
Sleep (100) |
| 205 |
|
| 206 |
If (CondRefOf (\_SB.PCI0.TXHC)) { |
| 207 |
/* Invoke PCIe root ports wake event handler */ |
| 208 |
\_SB.PCI0.TRP0.HPEV() |
| 209 |
\_SB.PCI0.TRP1.HPEV() |
| 210 |
\_SB.PCI0.TRP2.HPEV() |
| 211 |
\_SB.PCI0.TRP3.HPEV() |
| 212 |
} |
| 213 |
|
| 214 |
/* Check Root Port 0 for a Hot Plug Event if the port is enabled */ |
| 215 |
If (((\_SB.PCI0.TRP0.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP0.HPSX)) { |
| 216 |
If (\_SB.PCI0.TRP0.PDCX) { |
| 217 |
/* Clear all status bits */ |
| 218 |
\_SB.PCI0.TRP0.PDCX = 1 |
| 219 |
\_SB.PCI0.TRP0.HPSX = 1 |
| 220 |
/* |
| 221 |
* Intercept Presence Detect Changed interrupt and make sure |
| 222 |
* the L0s is disabled on empty slots. |
| 223 |
*/ |
| 224 |
If (!\_SB.PCI0.TRP0.PDSX) { |
| 225 |
/* |
| 226 |
* The PCIe slot is empty, so disable L0s on hot unplug. |
| 227 |
*/ |
| 228 |
\_SB.PCI0.TRP0.L0SE = 0 |
| 229 |
} |
| 230 |
/* Performs proper notification to the OS. */ |
| 231 |
Notify (\_SB.PCI0.TRP0, 0) |
| 232 |
} Else { |
| 233 |
/* False event. Clear Hot-Plug status, then exit. */ |
| 234 |
\_SB.PCI0.TRP0.HPSX = 1 |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
/* Check Root Port 1 for a Hot Plug Event if the port is enabled */ |
| 239 |
If (((\_SB.PCI0.TRP1.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP1.HPSX)) { |
| 240 |
If (\_SB.PCI0.TRP1.PDCX) { |
| 241 |
\_SB.PCI0.TRP1.PDCX = 1 |
| 242 |
\_SB.PCI0.TRP1.HPSX = 1 |
| 243 |
If (!\_SB.PCI0.TRP1.PDSX) { |
| 244 |
\_SB.PCI0.TRP1.L0SE = 0 |
| 245 |
} |
| 246 |
Notify (\_SB.PCI0.TRP1, 0) |
| 247 |
} Else { |
| 248 |
\_SB.PCI0.TRP1.HPSX = 1 |
| 249 |
} |
| 250 |
} |
| 251 |
|
| 252 |
/* Check Root Port 2 for a Hot Plug Event if the port is enabled */ |
| 253 |
If (((\_SB.PCI0.TRP2.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP2.HPSX)) { |
| 254 |
If (\_SB.PCI0.TRP2.PDCX) { |
| 255 |
\_SB.PCI0.TRP2.PDCX = 1 |
| 256 |
\_SB.PCI0.TRP2.HPSX = 1 |
| 257 |
If (!\_SB.PCI0.TRP2.PDSX) { |
| 258 |
\_SB.PCI0.TRP2.L0SE = 0 |
| 259 |
} |
| 260 |
Notify (\_SB.PCI0.TRP2, 0) |
| 261 |
} Else { |
| 262 |
\_SB.PCI0.TRP2.HPSX = 1 |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
/* Check Root Port 3 for a Hot Plug Event if the port is enabled */ |
| 267 |
If (((\_SB.PCI0.TRP3.VDID != 0xFFFFFFFF) && \_SB.PCI0.TRP3.HPSX)) { |
| 268 |
If (\_SB.PCI0.TRP3.PDCX) { |
| 269 |
\_SB.PCI0.TRP3.PDCX = 1 |
| 270 |
\_SB.PCI0.TRP3.HPSX = 1 |
| 271 |
If (!\_SB.PCI0.TRP3.PDSX) { |
| 272 |
\_SB.PCI0.TRP3.L0SE = 0 |
| 273 |
} |
| 274 |
Notify (\_SB.PCI0.TRP3, 0) |
| 275 |
} Else { |
| 276 |
\_SB.PCI0.TRP3.HPSX = 1 |
| 277 |
} |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
/* PCI Express power management event */ |
| 282 |
Method (_L69, 0, Serialized) |
| 283 |
{ |
| 284 |
If (CondRefOf (\_SB.PCI0.TXHC)) { |
| 285 |
If (\_SB.PCI0.TRP0.HPME() == 1) { |
| 286 |
Notify (\_SB.PCI0.TDM0, 0x2) |
| 287 |
Notify (\_SB.PCI0.TRP0, 0x2) |
| 288 |
} |
| 289 |
|
| 290 |
If (\_SB.PCI0.TRP1.HPME() == 1) { |
| 291 |
Notify (\_SB.PCI0.TDM0, 0x2) |
| 292 |
Notify (\_SB.PCI0.TRP1, 0x2) |
| 293 |
} |
| 294 |
|
| 295 |
If (\_SB.PCI0.TRP2.HPME() == 1) { |
| 296 |
Notify (\_SB.PCI0.TDM1, 0x2) |
| 297 |
Notify (\_SB.PCI0.TRP2, 0x2) |
| 298 |
} |
| 299 |
|
| 300 |
If (\_SB.PCI0.TRP3.HPME() == 1) { |
| 301 |
Notify (\_SB.PCI0.TDM1, 0x2) |
| 302 |
Notify (\_SB.PCI0.TRP3, 0x2) |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
/* Invoke PCIe root ports power management status handler */ |
| 307 |
\_SB.PCI0.TRP0.HPME() |
| 308 |
\_SB.PCI0.TRP1.HPME() |
| 309 |
\_SB.PCI0.TRP2.HPME() |
| 310 |
\_SB.PCI0.TRP3.HPME() |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
Scope (\_SB.PCI0) |
| 315 |
{ |
| 316 |
Device (IOM) |
| 317 |
{ |
| 318 |
Name (_HID, "INTC107A") |
| 319 |
Name (_DDN, "Intel(R) Meteor Lake Input Output Manager(IOM) driver") |
| 320 |
/* IOM preserved MMIO range from 0x3fff0aa0000 to 0x3fff0aa15ff. */ |
| 321 |
Name (_CRS, ResourceTemplate () { |
| 322 |
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 323 |
NonCacheable, ReadWrite, 0x0, |
| 324 |
IOM_BASE_ADDR, IOM_BASE_ADDR_MAX, 0x0, |
| 325 |
IOM_BASE_SIZE,,,) |
| 326 |
}) |
| 327 |
#if CONFIG(IOM_ACPI_DEVICE_VISIBLE) |
| 328 |
/* ACPI_STATUS_DEVICE_ALL_ON */ |
| 329 |
Name (_STA, 0xF) |
| 330 |
#else |
| 331 |
/* ACPI_STATUS_DEVICE_HIDDEN_ON */ |
| 332 |
Name (_STA, 0xB) |
| 333 |
#endif |
| 334 |
} |
| 335 |
|
| 336 |
/* |
| 337 |
* Operation region defined to access the TCSS_DEVEN. Get the MCHBAR in offset |
| 338 |
* 0x48 in B0:D0:F0. TCSS device enable base address is in offset 0x7090 of MCHBAR. |
| 339 |
*/ |
| 340 |
OperationRegion (TDEN, SystemMemory, (GMHB() + MCHBAR_TCSS_DEVEN_OFFSET), 0x4) |
| 341 |
Field (TDEN, ByteAcc, NoLock, Preserve) |
| 342 |
{ |
| 343 |
TRE0, 1, /* PCIE0_EN */ |
| 344 |
TRE1, 1, /* PCIE1_EN */ |
| 345 |
TRE2, 1, /* PCIE2_EN */ |
| 346 |
TRE3, 1, /* PCIE3_EN */ |
| 347 |
, 4, |
| 348 |
THCE, 1, /* XHCI_EN */ |
| 349 |
TDCE, 1, /* XDCI_EN */ |
| 350 |
DME0, 1, /* TBT_DMA0_EN */ |
| 351 |
DME1, 1, /* TBT_DMA1_EN */ |
| 352 |
, 20 |
| 353 |
} |
| 354 |
|
| 355 |
/* |
| 356 |
* Operation region defined to access the pCode mailbox interface. Get the MCHBAR |
| 357 |
* in offset 0x48 in B0:D0:F0. MMIO address is in offset 0x5DA0 of MCHBAR. |
| 358 |
*/ |
| 359 |
OperationRegion (PBAR, SystemMemory, (GMHB() + 0x5DA0), 0x08) |
| 360 |
Field (PBAR, DWordAcc, NoLock, Preserve) |
| 361 |
{ |
| 362 |
PMBD, 32, /* pCode MailBox Data, offset 0x5DA0 in MCHBAR */ |
| 363 |
PMBC, 8, /* pCode MailBox Command, [7:0] of offset 0x5DA4 in MCHBAR */ |
| 364 |
PSCM, 8, /* pCode MailBox Sub-Command, [15:8] of offset 0x5DA4 in MCHBAR */ |
| 365 |
, 15, /* Reserved */ |
| 366 |
PMBR, 1 /* pCode MailBox RunBit, [31:31] of offset 0x5DA4 in MCHBAR */ |
| 367 |
} |
| 368 |
|
| 369 |
/* |
| 370 |
* Poll pCode MailBox Ready |
| 371 |
* |
| 372 |
* Return 0xFF - Timeout |
| 373 |
* 0x00 - Ready |
| 374 |
*/ |
| 375 |
Method (PMBY, 0) |
| 376 |
{ |
| 377 |
Local0 = 0 |
| 378 |
While (PMBR && (Local0 < 1000)) { |
| 379 |
Local0++ |
| 380 |
Stall (1) |
| 381 |
} |
| 382 |
If (Local0 == 1000) { |
| 383 |
Printf("Timeout occurred.") |
| 384 |
Return (0xFF) |
| 385 |
} |
| 386 |
Return (0) |
| 387 |
} |
| 388 |
|
| 389 |
|
| 390 |
/* |
| 391 |
* From RegBar Base, IOM_TypeC_SW_configuration_1 is in offset 0xC10040, where |
| 392 |
* 0x40 is the register offset. |
| 393 |
*/ |
| 394 |
OperationRegion (IOMR, SystemMemory, IOM_BASE_ADDR, 0x100) |
| 395 |
Field (IOMR, DWordAcc, NoLock, Preserve) |
| 396 |
{ |
| 397 |
Offset(0x40), |
| 398 |
, 15, |
| 399 |
TD3C, 1, /* [15:15] Type C D3 cold bit */ |
| 400 |
TACK, 1, /* [16:16] IOM Acknowledge bit */ |
| 401 |
DPOF, 1, /* [17:17] Set 1 to indicate IOM, all the */ |
| 402 |
/* display is OFF, clear otherwise */ |
| 403 |
Offset(0x70), /* Physical addr is offset 0x70. */ |
| 404 |
IMCD, 32, /* R_SA_IOM_BIOS_MAIL_BOX_CMD */ |
| 405 |
IMDA, 32 /* R_SA_IOM_BIOS_MAIL_BOX_DATA */ |
| 406 |
} |
| 407 |
|
| 408 |
/* |
| 409 |
* TBT Group0 ON method |
| 410 |
*/ |
| 411 |
Method (TG0N, 0) |
| 412 |
{ |
| 413 |
If (\_SB.PCI0.TDM0.VDID == 0xFFFFFFFF) { |
| 414 |
Printf("TDM0 does not exist.") |
| 415 |
} Else { |
| 416 |
If (\_SB.PCI0.TDM0.STAT == 0) { |
| 417 |
/* DMA0 is in D3Cold early. */ |
| 418 |
\_SB.PCI0.TDM0.D3CX() /* RTD3 Exit */ |
| 419 |
|
| 420 |
Printf("Bring TBT RPs out of D3Code.") |
| 421 |
If (\_SB.PCI0.TRP0.VDID != 0xFFFFFFFF) { |
| 422 |
/* RP0 D3 cold exit. */ |
| 423 |
\_SB.PCI0.TRP0.D3CX() |
| 424 |
} |
| 425 |
If (\_SB.PCI0.TRP1.VDID != 0xFFFFFFFF) { |
| 426 |
/* RP1 D3 cold exit. */ |
| 427 |
\_SB.PCI0.TRP1.D3CX() |
| 428 |
} |
| 429 |
} Else { |
| 430 |
Printf("Drop TG0N due to it is already exit D3 cold.") |
| 431 |
} |
| 432 |
|
| 433 |
/* TBT RTD3 exit 10ms delay. */ |
| 434 |
Sleep (10) |
| 435 |
} |
| 436 |
} |
| 437 |
|
| 438 |
/* |
| 439 |
* TBT Group0 OFF method |
| 440 |
*/ |
| 441 |
Method (TG0F, 0) |
| 442 |
{ |
| 443 |
If (\_SB.PCI0.TDM0.VDID == 0xFFFFFFFF) { |
| 444 |
Printf("TDM0 does not exist.") |
| 445 |
} Else { |
| 446 |
If (\_SB.PCI0.TDM0.STAT == 1) { |
| 447 |
/* DMA0 is not in D3Cold now. */ |
| 448 |
\_SB.PCI0.TDM0.D3CE() /* Enable DMA RTD3 */ |
| 449 |
|
| 450 |
Printf("Push TBT RPs to D3Cold together") |
| 451 |
If (\_SB.PCI0.TRP0.VDID != 0xFFFFFFFF) { |
| 452 |
/* Put RP0 to D3 cold. */ |
| 453 |
\_SB.PCI0.TRP0.D3CE() |
| 454 |
} |
| 455 |
If (\_SB.PCI0.TRP1.VDID != 0xFFFFFFFF) { |
| 456 |
/* Put RP1 to D3 cold. */ |
| 457 |
\_SB.PCI0.TRP1.D3CE() |
| 458 |
} |
| 459 |
} |
| 460 |
} |
| 461 |
} |
| 462 |
|
| 463 |
/* |
| 464 |
* TBT Group1 ON method |
| 465 |
*/ |
| 466 |
Method (TG1N, 0) |
| 467 |
{ |
| 468 |
If (\_SB.PCI0.TDM1.VDID == 0xFFFFFFFF) { |
| 469 |
Printf("TDM1 does not exist.") |
| 470 |
} Else { |
| 471 |
If (\_SB.PCI0.TDM1.STAT == 0) { |
| 472 |
/* DMA1 is in D3Cold early. */ |
| 473 |
\_SB.PCI0.TDM1.D3CX() /* RTD3 Exit */ |
| 474 |
|
| 475 |
Printf("Bring TBT RPs out of D3Code.") |
| 476 |
If (\_SB.PCI0.TRP2.VDID != 0xFFFFFFFF) { |
| 477 |
/* RP2 D3 cold exit. */ |
| 478 |
\_SB.PCI0.TRP2.D3CX() |
| 479 |
} |
| 480 |
If (\_SB.PCI0.TRP3.VDID != 0xFFFFFFFF) { |
| 481 |
/* RP3 D3 cold exit. */ |
| 482 |
\_SB.PCI0.TRP3.D3CX() |
| 483 |
} |
| 484 |
} Else { |
| 485 |
Printf("Drop TG1N due to it is already exit D3 cold.") |
| 486 |
} |
| 487 |
|
| 488 |
/* TBT RTD3 exit 10ms delay. */ |
| 489 |
Sleep (10) |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
/* |
| 494 |
* TBT Group1 OFF method |
| 495 |
*/ |
| 496 |
Method (TG1F, 0) |
| 497 |
{ |
| 498 |
If (\_SB.PCI0.TDM1.VDID == 0xFFFFFFFF) { |
| 499 |
Printf("TDM1 does not exist.") |
| 500 |
} Else { |
| 501 |
If (\_SB.PCI0.TDM1.STAT == 1) { |
| 502 |
/* DMA1 is not in D3Cold now */ |
| 503 |
\_SB.PCI0.TDM1.D3CE() /* Enable DMA RTD3. */ |
| 504 |
|
| 505 |
Printf("Push TBT RPs to D3Cold together") |
| 506 |
If (\_SB.PCI0.TRP2.VDID != 0xFFFFFFFF) { |
| 507 |
/* Put RP2 to D3 cold. */ |
| 508 |
\_SB.PCI0.TRP2.D3CE() |
| 509 |
} |
| 510 |
If (\_SB.PCI0.TRP3.VDID != 0xFFFFFFFF) { |
| 511 |
/* Put RP3 to D3 cold */ |
| 512 |
\_SB.PCI0.TRP3.D3CE() |
| 513 |
} |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
PowerResource (TBT0, 5, 1) |
| 519 |
{ |
| 520 |
Method (_STA, 0) |
| 521 |
{ |
| 522 |
Return (\_SB.PCI0.TDM0.STAT) |
| 523 |
} |
| 524 |
|
| 525 |
Method (_ON, 0) |
| 526 |
{ |
| 527 |
TG0N() |
| 528 |
} |
| 529 |
|
| 530 |
Method (_OFF, 0) |
| 531 |
{ |
| 532 |
If (\_SB.PCI0.TDM0.SD3C == 0) { |
| 533 |
TG0F() |
| 534 |
} |
| 535 |
} |
| 536 |
} |
| 537 |
|
| 538 |
PowerResource (TBT1, 5, 1) |
| 539 |
{ |
| 540 |
Method (_STA, 0) |
| 541 |
{ |
| 542 |
Return (\_SB.PCI0.TDM1.STAT) |
| 543 |
} |
| 544 |
|
| 545 |
Method (_ON, 0) |
| 546 |
{ |
| 547 |
TG1N() |
| 548 |
} |
| 549 |
|
| 550 |
Method (_OFF, 0) |
| 551 |
{ |
| 552 |
If (\_SB.PCI0.TDM1.SD3C == 0) { |
| 553 |
TG1F() |
| 554 |
} |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
#if CONFIG(D3COLD_SUPPORT) |
| 559 |
Method (TCON, 0) |
| 560 |
{ |
| 561 |
/* Reset IOM D3 cold bit if it is in D3 cold now. */ |
| 562 |
If (TD3C == 1) /* It was in D3 cold before. */ |
| 563 |
{ |
| 564 |
/* Reset IOM D3 cold bit. */ |
| 565 |
TD3C = 0 /* Request IOM for D3 cold exit sequence. */ |
| 566 |
Local0 = 0 /* Time check counter variable */ |
| 567 |
/* Wait for ack, the maximum wait time for the ack is 100 msec. */ |
| 568 |
While ((TACK != 0) && (Local0 < TCSS_IOM_ACK_TIMEOUT_IN_MS)) { |
| 569 |
/* |
| 570 |
* Wait in this loop until TACK becomes 0 with timeout |
| 571 |
* TCSS_IOM_ACK_TIMEOUT_IN_MS by default. |
| 572 |
*/ |
| 573 |
Sleep (1) /* Delay of 1ms. */ |
| 574 |
Local0++ |
| 575 |
} |
| 576 |
|
| 577 |
If (Local0 == TCSS_IOM_ACK_TIMEOUT_IN_MS) { |
| 578 |
Printf("Error: Timeout occurred.") |
| 579 |
} |
| 580 |
Else |
| 581 |
{ |
| 582 |
Printf("TCSS D3 exit."); |
| 583 |
} |
| 584 |
} |
| 585 |
Else { |
| 586 |
Printf("Drop TCON due to it is already exit D3 cold.") |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
Method (TCOF, 0) |
| 591 |
{ |
| 592 |
If ((\_SB.PCI0.TXHC.SD3C != 0) || (\_SB.PCI0.TDM0.SD3C != 0) |
| 593 |
|| (\_SB.PCI0.TDM1.SD3C != 0)) |
| 594 |
{ |
| 595 |
Printf("Skip D3C entry.") |
| 596 |
Return |
| 597 |
} |
| 598 |
|
| 599 |
/* Request IOM for D3 cold entry sequence. */ |
| 600 |
TD3C = 1 |
| 601 |
} |
| 602 |
|
| 603 |
PowerResource (D3C, 5, 0) |
| 604 |
{ |
| 605 |
/* |
| 606 |
* Variable to save power state |
| 607 |
* 1 - TC Cold request cleared. |
| 608 |
* 0 - TC Cold request sent. |
| 609 |
*/ |
| 610 |
Name (STAT, 0x1) |
| 611 |
|
| 612 |
Method (_STA, 0) |
| 613 |
{ |
| 614 |
Return (STAT) |
| 615 |
} |
| 616 |
|
| 617 |
Method (_ON, 0) |
| 618 |
{ |
| 619 |
\_SB.PCI0.TCON() |
| 620 |
STAT = 1 |
| 621 |
} |
| 622 |
|
| 623 |
Method (_OFF, 0) |
| 624 |
{ |
| 625 |
\_SB.PCI0.TCOF() |
| 626 |
STAT = 0 |
| 627 |
} |
| 628 |
} |
| 629 |
#endif // D3COLD_SUPPORT |
| 630 |
|
| 631 |
/* |
| 632 |
* TCSS xHCI device |
| 633 |
*/ |
| 634 |
Device (TXHC) |
| 635 |
{ |
| 636 |
Name (_ADR, 0x000D0000) |
| 637 |
Name (_DDN, "North XHCI controller") |
| 638 |
Name (_STR, Unicode ("North XHCI controller")) |
| 639 |
Name (DCPM, TCSS_XHCI) |
| 640 |
|
| 641 |
Method (_STA, 0x0, NotSerialized) |
| 642 |
{ |
| 643 |
If (THCE == 1) { |
| 644 |
Return (0x0F) |
| 645 |
} Else { |
| 646 |
Return (0x0) |
| 647 |
} |
| 648 |
} |
| 649 |
#include "tcss_xhci.asl" |
| 650 |
} |
| 651 |
|
| 652 |
/* |
| 653 |
* TCSS DMA0 device |
| 654 |
*/ |
| 655 |
Device (TDM0) |
| 656 |
{ |
| 657 |
Name (_ADR, 0x000D0002) |
| 658 |
Name (_DDN, "TBT DMA0 controller") |
| 659 |
Name (_STR, Unicode ("TBT DMA0 controller")) |
| 660 |
Name (DUID, 0) /* TBT DMA number */ |
| 661 |
Name (DCPM, TCSS_DMA0) |
| 662 |
|
| 663 |
Method (_STA, 0x0, NotSerialized) |
| 664 |
{ |
| 665 |
If (DME0 == 1) { |
| 666 |
Return (0x0F) |
| 667 |
} Else { |
| 668 |
Return (0x0) |
| 669 |
} |
| 670 |
} |
| 671 |
#include "tcss_dma.asl" |
| 672 |
} |
| 673 |
|
| 674 |
/* |
| 675 |
* TCSS DMA1 device |
| 676 |
*/ |
| 677 |
Device (TDM1) |
| 678 |
{ |
| 679 |
Name (_ADR, 0x000D0003) |
| 680 |
Name (_DDN, "TBT DMA1 controller") |
| 681 |
Name (_STR, Unicode ("TBT DMA1 controller")) |
| 682 |
Name (DUID, 1) /* TBT DMA number */ |
| 683 |
Name (DCPM, TCSS_DMA1) |
| 684 |
|
| 685 |
Method (_STA, 0x0, NotSerialized) |
| 686 |
{ |
| 687 |
If (DME1 == 1) { |
| 688 |
Return (0x0F) |
| 689 |
} Else { |
| 690 |
Return (0x0) |
| 691 |
} |
| 692 |
} |
| 693 |
#include "tcss_dma.asl" |
| 694 |
} |
| 695 |
|
| 696 |
/* |
| 697 |
* TCSS PCIE Root Port #00 |
| 698 |
*/ |
| 699 |
Device (TRP0) |
| 700 |
{ |
| 701 |
Name (_ADR, 0x00070000) |
| 702 |
Name (TUID, 0) /* TBT PCIE RP Number 0 for RP00 */ |
| 703 |
Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */ |
| 704 |
Name (LMSL, 0) /* PCIE LTR max snoop Latency */ |
| 705 |
Name (LNSL, 0) /* PCIE LTR max no snoop Latency */ |
| 706 |
Name (DCPM, TCSS_TBT_PCIE0_RP0) |
| 707 |
|
| 708 |
Method (_STA, 0x0, NotSerialized) |
| 709 |
{ |
| 710 |
If (VDID != 0xFFFFFFFF) { |
| 711 |
Return (0x0F) |
| 712 |
} Else { |
| 713 |
Return (0x0) |
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
Method (_INI) |
| 718 |
{ |
| 719 |
LTEN = 0 |
| 720 |
LMSL = 0x88C8 |
| 721 |
LNSL = 0x88C8 |
| 722 |
} |
| 723 |
#include "tcss_pcierp.asl" |
| 724 |
} |
| 725 |
|
| 726 |
/* |
| 727 |
* TCSS PCIE Root Port #01 |
| 728 |
*/ |
| 729 |
Device (TRP1) |
| 730 |
{ |
| 731 |
Name (_ADR, 0x00070001) |
| 732 |
Name (TUID, 1) /* TBT PCIE RP Number 1 for RP01 */ |
| 733 |
Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */ |
| 734 |
Name (LMSL, 0) /* PCIE LTR max snoop Latency */ |
| 735 |
Name (LNSL, 0) /* PCIE LTR max no snoop Latency */ |
| 736 |
Name (DCPM, TCSS_TBT_PCIE0_RP1) |
| 737 |
|
| 738 |
Method (_STA, 0x0, NotSerialized) |
| 739 |
{ |
| 740 |
If (VDID != 0xFFFFFFFF) { |
| 741 |
Return (0x0F) |
| 742 |
} Else { |
| 743 |
Return (0x0) |
| 744 |
} |
| 745 |
} |
| 746 |
|
| 747 |
Method (_INI) |
| 748 |
{ |
| 749 |
LTEN = 0 |
| 750 |
LMSL = 0x88C8 |
| 751 |
LNSL = 0x88C8 |
| 752 |
} |
| 753 |
#include "tcss_pcierp.asl" |
| 754 |
} |
| 755 |
|
| 756 |
/* |
| 757 |
* TCSS PCIE Root Port #02 |
| 758 |
*/ |
| 759 |
Device (TRP2) |
| 760 |
{ |
| 761 |
Name (_ADR, 0x00070002) |
| 762 |
Name (TUID, 2) /* TBT PCIE RP Number 2 for RP02 */ |
| 763 |
Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */ |
| 764 |
Name (LMSL, 0) /* PCIE LTR max snoop Latency */ |
| 765 |
Name (LNSL, 0) /* PCIE LTR max no snoop Latency */ |
| 766 |
Name (DCPM, TCSS_TBT_PCIE0_RP2) |
| 767 |
|
| 768 |
Method (_STA, 0x0, NotSerialized) |
| 769 |
{ |
| 770 |
If (VDID != 0xFFFFFFFF) { |
| 771 |
Return (0x0F) |
| 772 |
} Else { |
| 773 |
Return (0x0) |
| 774 |
} |
| 775 |
} |
| 776 |
|
| 777 |
Method (_INI) |
| 778 |
{ |
| 779 |
LTEN = 0 |
| 780 |
LMSL = 0x88C8 |
| 781 |
LNSL = 0x88C8 |
| 782 |
} |
| 783 |
#include "tcss_pcierp.asl" |
| 784 |
} |
| 785 |
|
| 786 |
/* |
| 787 |
* TCSS PCIE Root Port #03 |
| 788 |
*/ |
| 789 |
Device (TRP3) |
| 790 |
{ |
| 791 |
Name (_ADR, 0x00070003) |
| 792 |
Name (TUID, 3) /* TBT PCIE RP Number 3 for RP03 */ |
| 793 |
Name (LTEN, 0) /* Latency Tolerance Reporting Mechanism, 0:Disable, 1:Enable */ |
| 794 |
Name (LMSL, 0) /* PCIE LTR max snoop Latency */ |
| 795 |
Name (LNSL, 0) /* PCIE LTR max no snoop Latency */ |
| 796 |
Name (DCPM, TCSS_TBT_PCIE0_RP3) |
| 797 |
|
| 798 |
Method (_STA, 0x0, NotSerialized) |
| 799 |
{ |
| 800 |
If (VDID != 0xFFFFFFFF) { |
| 801 |
Return (0x0F) |
| 802 |
} Else { |
| 803 |
Return (0x0) |
| 804 |
} |
| 805 |
} |
| 806 |
|
| 807 |
Method (_INI) |
| 808 |
{ |
| 809 |
LTEN = 0 |
| 810 |
LMSL = 0x88C8 |
| 811 |
LNSL = 0x88C8 |
| 812 |
} |
| 813 |
#include "tcss_pcierp.asl" |
| 814 |
} |
| 815 |
} |