1
0
Fork 0
mirror of https://github.com/tylernguyen/x1c6-hackintosh.git synced 2025-02-05 09:33:13 -06:00
x1c6-hackintosh/patches/SSDT-XHC2.dsl

333 lines
10 KiB
Text
Raw Normal View History

//
// USB-C 3.1 Gen2-controller
//
// The controller is part of the alpine ridge Thunderbolt-controller.
//
// At the moment there is no known way to have - or at least I haven't found it yet -
// to have native Thunderbolt incl. power-management and USB-C 3.1 Gen2-hotplug at the
// same time. For the moment I opted for thunderbolt and the runtime power saving.
//
// So sadly, this is broken on runtime for the moment :(
//
// Credits @benbender
2020-11-03 11:58:35 -06:00
DefinitionBlock ("", "SSDT", 2, "tyler", "_XHC2", 0x00001000)
{
/* Support methods */
External (DTGP, MethodObj)
External (OSDW, MethodObj) // OS Is Darwin?
External (_SB.PCI0.RP09.RUSB, IntObj)
External (_SB.PCI0.RP09.RTBT, IntObj)
External (_SB.PCI0.RP09.GXCI, IntObj)
External (_SB.PCI0.RP09.GNHI, IntObj)
2020-11-03 11:58:35 -06:00
External (_SB.PCI0.RP09.UGIO, MethodObj)
External (_SB.PCI0.RP09.TBST, MethodObj)
2020-11-03 11:58:35 -06:00
External (_SB.PCI0.RP09.UPSB.DSB2, DeviceObj)
External (_SB.PCI0.RP09.UPSB.PCED, MethodObj)
External (_SB.PCI0.RP09.UPSB.MDUV, IntObj)
External (_SB.PCI0.RP09.UPSB.DSB2.PCIA, FieldUnitObj)
External (_SB.PCI0.RP09.UPSB.DSB2.IIP3, FieldUnitObj)
External (_SB.PCI0.RP09.UPSB.DSB2.PRSR, FieldUnitObj)
External (_SB.PCI0.RP09.UPSB.DSB2.LACR, FieldUnitObj)
External (_SB.PCI0.RP09.UPSB.DSB2.LACT, FieldUnitObj)
External (_SB.PCI0.RP09.UPSB.DSB2.LTRN, FieldUnitObj)
External (_SB.PCI0.RP09.UPN1, IntObj)
External (_SB.PCI0.RP09.UPN2, IntObj)
2020-11-03 11:58:35 -06:00
External (TBSE, IntObj)
External (TBTS, IntObj)
External (TBAS, IntObj)
External (USME, IntObj)
Name (U2OP, One) // Companion controller present?
Scope (_SB.PCI0.RP09.UPSB.DSB2)
{
Device (XHC2)
{
Name (_ADR, Zero) // _ADR: Address
Name (SDPC, Zero)
OperationRegion (A1E0, PCI_Config, Zero, 0x40)
Field (A1E0, ByteAcc, NoLock, Preserve)
{
AVND, 32,
BMIE, 3,
Offset (0x18),
PRIB, 8,
SECB, 8,
SUBB, 8,
Offset (0x1E),
, 13,
MABT, 1
}
/**
* PCI Enable downstream
*/
2020-11-03 11:58:35 -06:00
Method (PCED, 0, Serialized)
{
Debug = "TB:DSB2:XHC2:PCED"
Debug = "TB:DSB2:XHC2:PCED - Request USB-GPIO to be enabled & force TBT-GPIO"
2020-11-03 11:58:35 -06:00
\_SB.PCI0.RP09.GXCI = One
\_SB.PCI0.RP09.GNHI = One
2020-11-03 11:58:35 -06:00
// this powers up both TBT and USB when needed
If (\_SB.PCI0.RP09.UGIO () != Zero)
{
Debug = "TB:DSB2:XHC2:PCED - GPIOs changed, restored = true"
2020-11-03 11:58:35 -06:00
\_SB.PCI0.RP09.UPSB.DSB2.PRSR = One
}
// Local0 = Zero
// Local1 = Zero
Local5 = (Timer + 0x00989680)
2020-11-03 11:58:35 -06:00
Debug = Concatenate ("TB:DSB2:XHC2:PCED - restored flag, THUNDERBOLT_PCI_LINK_MGMT_DEVICE.PRSR: ", \_SB.PCI0.RP09.UPSB.DSB2.PRSR)
2020-11-03 11:58:35 -06:00
If (\_SB.PCI0.RP09.UPSB.DSB2.PRSR != Zero)
{
Debug = "TB:DSB2:XHC2:PCED - Wait for power up"
Debug = "TB:DSB2:XHC2:PCED - Wait for downstream bridge to appear"
Local5 = (Timer + 0x00989680)
2020-11-03 11:58:35 -06:00
While (Timer <= Local5)
{
Debug = "TB:DSB2:XHC2:PCED - Wait for link training..."
2020-11-03 11:58:35 -06:00
If (\_SB.PCI0.RP09.UPSB.DSB2.LACR == Zero)
{
If (\_SB.PCI0.RP09.UPSB.DSB2.LTRN != One)
{
Debug = "TB:DSB2:XHC2:PCED - Link training cleared"
2020-11-03 11:58:35 -06:00
Break
}
}
ElseIf ((\_SB.PCI0.RP09.UPSB.DSB2.LTRN != One) && (\_SB.PCI0.RP09.UPSB.DSB2.LACT == One))
{
Debug = "TB:DSB2:XHC2:PCED - Link training cleared and link is active"
2020-11-03 11:58:35 -06:00
Break
}
Sleep (0x0A)
2020-11-03 11:58:35 -06:00
}
Sleep (0x96)
2020-11-03 11:58:35 -06:00
}
\_SB.PCI0.RP09.UPSB.DSB2.PRSR = Zero
While (Timer <= Local5)
{
Debug = "TB:DSB2:XHC2:PCED - Wait for config space..."
2020-11-03 11:58:35 -06:00
If (\_SB.PCI0.RP09.UPSB.DSB2.XHC2.AVND != 0xFFFFFFFF)
{
Debug = "TB:DSB2:XHC2:PCED - DSB2 Up - Read VID/DID"
2020-11-03 11:58:35 -06:00
\_SB.PCI0.RP09.UPSB.DSB2.PCIA = One
Break
}
Sleep (0x0A)
2020-11-03 11:58:35 -06:00
}
\_SB.PCI0.RP09.UPSB.DSB2.IIP3 = Zero
}
Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method
{
Local0 = Package (0x06)
{
"USBBusNumber",
Zero,
"AAPL,xhci-clock-id",
One,
"UsbCompanionControllerPresent",
One
}
2020-11-03 11:58:35 -06:00
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
Name (HS, Package (0x01)
{
"XHC"
2020-11-03 11:58:35 -06:00
})
2020-11-03 11:58:35 -06:00
Name (FS, Package (0x01)
{
"XHC"
2020-11-03 11:58:35 -06:00
})
2020-11-03 11:58:35 -06:00
Name (LS, Package (0x01)
{
"XHC"
2020-11-03 11:58:35 -06:00
})
Method (_PRW, 0, NotSerialized) // _PRW: Power Resources for Wake
{
Return (Package ()
2020-11-03 11:58:35 -06:00
{
0x6D,
0x03
})
}
Method (_PS0, 0, Serialized) // _PS0: Power State 0
{
Debug = "TB:DSB2:XHC2:_PS0"
2020-11-03 11:58:35 -06:00
If (OSDW ())
{
PCED ()
\_SB.PCI0.RP09.TBST ()
2020-11-03 11:58:35 -06:00
}
}
Method (_PS3, 0, Serialized) // _PS3: Power State 3
{
Debug = "TB:DSB2:XHC2:_PS3"
If (OSDW ())
{
\_SB.PCI0.RP09.TBST ()
}
2020-11-03 11:58:35 -06:00
}
/**
* Run Time Power Check
* Called by XHC driver when idle
*/
2020-11-03 11:58:35 -06:00
Method (RTPC, 1, Serialized)
{
Debug = Concatenate ("TB:DSB2:XHC2:RTPC called with Arg0: ", Arg0)
If (Arg0 <= One)
2020-11-03 11:58:35 -06:00
{
Debug = Concatenate ("TB:NHI0:RTPC setting RUSB to: ", Arg0)
2020-11-03 11:58:35 -06:00
\_SB.PCI0.RP09.RUSB = Arg0
2020-11-03 11:58:35 -06:00
// Force TB on
If (Arg0 == One)
2020-11-03 11:58:35 -06:00
{
Debug = Concatenate ("TB:NHI0:RTPC forcing RTBT to: ", Arg0)
\_SB.PCI0.RP09.RTBT = One
2020-11-03 11:58:35 -06:00
}
}
Return (Zero)
}
/**
* USB cable check
* Called by XHC driver to check cable status
* Used as idle hint.
*
* Return:
* kUSBTypeCCableTypeNone = 0,
* kUSBTypeCCableTypeUSB = 1,
*/
2020-11-03 11:58:35 -06:00
Method (MODU, 0, Serialized)
{
Debug = Concatenate ("TB:DSB2:XHC2:MODU - return: ", \_SB.PCI0.RP09.UPSB.MDUV)
2020-11-03 11:58:35 -06:00
Return (\_SB.PCI0.RP09.UPSB.MDUV)
}
Device (RHUB)
{
Name (_ADR, Zero) // _ADR: Address
Device (SSP1)
{
Name (_ADR, 0x03) // _ADR: Address
Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities
{
0xFF,
0x09,
Zero,
Zero
})
Name (HS, Package ()
2020-11-03 11:58:35 -06:00
{
"XHC",
2020-11-03 11:58:35 -06:00
0x03
})
Name (FS, Package ()
2020-11-03 11:58:35 -06:00
{
"XHC",
2020-11-03 11:58:35 -06:00
0x03
})
Name (LS, Package ()
2020-11-03 11:58:35 -06:00
{
"XHC",
2020-11-03 11:58:35 -06:00
0x03
})
2020-11-03 11:58:35 -06:00
Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method
{
Local0 = Package ()
{
"UsbCPortNumber",
\_SB.PCI0.RP09.UPN1,
"UsbCompanionPortPresent",
One
}
2020-11-03 11:58:35 -06:00
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}
Device (SSP2)
{
Name (_ADR, 0x04) // _ADR: Address
Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities
{
0xFF,
0x09,
Zero,
Zero
})
Name (HS, Package ()
2020-11-03 11:58:35 -06:00
{
"XHC",
2020-11-03 11:58:35 -06:00
0x04
})
Name (FS, Package ()
2020-11-03 11:58:35 -06:00
{
"XHC",
2020-11-03 11:58:35 -06:00
0x04
})
Name (LS, Package ()
2020-11-03 11:58:35 -06:00
{
"XHC",
2020-11-03 11:58:35 -06:00
0x04
})
Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method
{
Local0 = Package ()
{
"UsbCPortNumber",
\_SB.PCI0.RP09.UPN2,
"UsbCompanionPortPresent",
One
}
2020-11-03 11:58:35 -06:00
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}
}
}
}
2020-11-03 11:58:35 -06:00
}