diff --git a/EFI/OC/ACPI/SSDT-BATX.aml b/EFI/OC/ACPI/#SSDT-BATX.aml similarity index 100% rename from EFI/OC/ACPI/SSDT-BATX.aml rename to EFI/OC/ACPI/#SSDT-BATX.aml diff --git a/EFI/OC/ACPI/SSDT-EC.aml b/EFI/OC/ACPI/#SSDT-EC.aml similarity index 100% rename from EFI/OC/ACPI/SSDT-EC.aml rename to EFI/OC/ACPI/#SSDT-EC.aml diff --git a/EFI/OC/ACPI/SSDT-BAT0.aml b/EFI/OC/ACPI/SSDT-BAT0.aml deleted file mode 100644 index d1f0f8e5..00000000 Binary files a/EFI/OC/ACPI/SSDT-BAT0.aml and /dev/null differ diff --git a/EFI/OC/ACPI/SSDT-BATC.aml b/EFI/OC/ACPI/SSDT-BATC.aml index e57572e2..c4bd7046 100644 Binary files a/EFI/OC/ACPI/SSDT-BATC.aml and b/EFI/OC/ACPI/SSDT-BATC.aml differ diff --git a/EFI/OC/ACPI/SSDT-BATT.aml b/EFI/OC/ACPI/SSDT-BATT.aml new file mode 100644 index 00000000..9f393c1f Binary files /dev/null and b/EFI/OC/ACPI/SSDT-BATT.aml differ diff --git a/EFI/OC/ACPI/SSDT-NTFY.aml b/EFI/OC/ACPI/SSDT-NTFY.aml index 79c6c262..bc8b4cc8 100644 Binary files a/EFI/OC/ACPI/SSDT-NTFY.aml and b/EFI/OC/ACPI/SSDT-NTFY.aml differ diff --git a/EFI/OC/Config.plist b/EFI/OC/Config.plist index 73510b89..c4675d1c 100644 --- a/EFI/OC/Config.plist +++ b/EFI/OC/Config.plist @@ -287,162 +287,6 @@ TableSignature - - Comment - Mutex:MCPU=0 - Count - 0 - Enabled - - Find - AU1DUFUH - Limit - 0 - Mask - - OemTableId - - Replace - AU1DUFUA - ReplaceMask - - Skip - 0 - TableLength - 0 - TableSignature - - - - Comment - Mutex:BATM=0 - Count - 0 - Enabled - - Find - AUJBVE0H - Limit - 0 - Mask - - OemTableId - - Replace - AUJBVE0A - ReplaceMask - - Skip - 0 - TableLength - 0 - TableSignature - - - - Comment - Mutex:MSMI=0 - Count - 0 - Enabled - - Find - AU1TTUkH - Limit - 0 - Mask - - OemTableId - - Replace - AU1TTUkA - ReplaceMask - - Skip - 0 - TableLength - 0 - TableSignature - - - - Comment - Mutex:BFWM=0 - Count - 0 - Enabled - - Find - AUJGV00H - Limit - 0 - Mask - - OemTableId - - Replace - AUJGV00A - ReplaceMask - - Skip - 0 - TableLength - 0 - TableSignature - - - - Comment - Mutex:XDHK=0 - Count - 0 - Enabled - - Find - AVhESEsH - Limit - 0 - Mask - - OemTableId - - Replace - AVhESEsA - ReplaceMask - - Skip - 0 - TableLength - 0 - TableSignature - - - - Comment - Mutex:MWMI=0 - Count - 0 - Enabled - - Find - AU1XTUkH - Limit - 0 - Mask - - OemTableId - - Replace - AU1XTUkA - ReplaceMask - - Skip - 0 - TableLength - 0 - TableSignature - - Comment _Q22 to XQ22 @@ -627,39 +471,13 @@ Comment - BATW to XATW - Count - 0 - Enabled - - Find - QkFUVwE= - Limit - 0 - Mask - - OemTableId - - Replace - WEFUVwE= - ReplaceMask - - Skip - 0 - TableLength - 0 - TableSignature - - - - Comment - BFCC to XFCC + BATW to WBAT Count 0 Enabled Find - QkZDQwA= + TwdCQVRXAQ== Limit 0 Mask @@ -667,7 +485,7 @@ OemTableId Replace - WEZDQwA= + TwdXQkFUAQ== ReplaceMask Skip @@ -1503,7 +1321,7 @@ PasswordSalt ScanPolicy - 19857667 + 0 SecureBootModel Default Vault diff --git a/Files/Patches/SSDT-BAT0.dsl b/Files/Patches/#SSDT-BAT0.dsl similarity index 100% rename from Files/Patches/SSDT-BAT0.dsl rename to Files/Patches/#SSDT-BAT0.dsl diff --git a/Files/Patches/#SSDT-BATC.dsl b/Files/Patches/#SSDT-BATC.dsl new file mode 100755 index 00000000..68a0d81b --- /dev/null +++ b/Files/Patches/#SSDT-BATC.dsl @@ -0,0 +1,213 @@ +// ThinkPad-LPC +DefinitionBlock ("", "SSDT", 2, "T460s", "BATC", 0) +{ + External(\_SB.PCI0.LPC.EC, DeviceObj) + + Scope(\_SB.PCI0.LPC.EC) + { + External(BAT0._HID, IntObj) + External(BAT0._STA, MethodObj) + External(BAT0._BIF, MethodObj) + External(BAT0._BST, MethodObj) + External(BAT1, DeviceObj) + External(BAT1._HID, IntObj) + External(BAT1._STA, MethodObj) + External(BAT1._BIF, MethodObj) + External(BAT1._BST, MethodObj) + Device(BATC) + { + Name(_HID, EisaId ("PNP0C0A")) + Name(_UID, 0x02) + + Method(_INI) + { + // disable original battery objects by setting invalid _HID + ^^BAT0._HID = 0 + ^^BAT1._HID = 0 + } + + Method(CVWA, 3) + // Convert mW to mA (or mWh to mAh) + // Arg0 is mW or mWh (or mA/mAh in the case Arg2==0) + // Arg1 is mV (usually design voltage) + // Arg2 is whether conversion is needed (non-zero for convert) + // return is mA or mAh + { + If (Arg2) + { + Arg0 = (Arg0 * 1000) / Arg1 + } + Return(Arg0) + } + + Method(_STA) + { + // call original _STA for BAT0 and BAT1 + // result is bitwise OR between them + + If (_OSI ("Darwin")) + { + Return(^^BAT0._STA() | ^^BAT1._STA()) + } + Else + { + Return (0) + } + } + + Name(B0CO, 0x00) // BAT0 0/1 needs conversion to mAh + Name(B1CO, 0x00) // BAT1 0/1 needs conversion to mAh + Name(B0DV, 0x00) // BAT0 design voltage + Name(B1DV, 0x00) // BAT1 design voltage + + Method(_BST) + { + // Local0 BAT0._BST + // Local1 BAT1._BST + // Local2 BAT0._STA + // Local3 BAT1._STA + // Local4/Local5 scratch + + // gather battery data from BAT0 + Local0 = ^^BAT0._BST() + Local2 = ^^BAT0._STA() + If (0x1f == Local2) + { + // check for invalid remaining capacity + Local4 = DerefOf(Local0[2]) + If (!Local4 || Ones == Local4) { Local2 = 0; } + } + // gather battery data from BAT1 + Local1 = ^^BAT1._BST() + Local3 = ^^BAT1._STA() + If (0x1f == Local3) + { + // check for invalid remaining capacity + Local4 = DerefOf(Local1[2]) + If (!Local4 || Ones == Local4) { Local3 = 0; } + } + // find primary and secondary battery + If (0x1f != Local2 && 0x1f == Local3) + { + // make primary use BAT1 data + Local0 = Local1 // BAT1._BST result + Local2 = Local3 // BAT1._STA result + Local3 = 0 // no secondary battery + } + // combine batteries into Local0 result if possible + If (0x1f == Local2 && 0x1f == Local3) + { + // _BST 0 - Battery State - if one battery is charging, then charging, else discharging + Local4 = DerefOf(Local0[0]) + Local5 = DerefOf(Local1[0]) + If (Local4 == 2 || Local5 == 2) + { + // 2 = charging + Local0[0] = 2 + } + ElseIf (Local4 == 1 || Local5 == 1) + { + // 1 = discharging + Local0[0] = 1 + } + ElseIf (Local4 == 5 || Local5 == 5) + { + // critical and discharging + Local0[0] = 5 + } + ElseIf (Local4 == 4 || Local5 == 4) + { + // critical + Local0[0] = 4 + } + // if none of the above, just leave as BAT0 is + + // Note: Following code depends on _BIF being called before _BST to set B0CO and B1CO + + // _BST 1 - Battery Present Rate - Add BAT0 and BAT1 values + Local0[1] = CVWA(DerefOf(Local0[1]), B0DV, B0CO) + CVWA(DerefOf(Local1[1]), B1DV, B1CO) + // _BST 2 - Battery Remaining Capacity - Add BAT0 and BAT1 values + Local0[2] = CVWA(DerefOf(Local0[2]), B0DV, B0CO) + CVWA(DerefOf(Local1[2]), B1DV, B1CO) + // _BST 3 - Battery Present Voltage - Average BAT0 and BAT1 values + Local0[3] = (DerefOf(Local0[3]) + DerefOf(Local1[3])) / 2 + } + Return(Local0) + } // _BST + + Method(_BIF) + { + // Local0 BAT0._BIF + // Local1 BAT1._BIF + // Local2 BAT0._STA + // Local3 BAT1._STA + // Local4/Local5 scratch + + // gather and validate data from BAT0 + Local0 = ^^BAT0._BIF() + Local2 = ^^BAT0._STA() + If (0x1f == Local2) + { + // check for invalid design capacity + Local4 = DerefOf(Local0[1]) + If (!Local4 || Ones == Local4) { Local2 = 0; } + // check for invalid max capacity + Local4 = DerefOf(Local0[2]) + If (!Local4 || Ones == Local4) { Local2 = 0; } + // check for invalid design voltage + Local4 = DerefOf(Local0[4]) + If (!Local4 || Ones == Local4) { Local2 = 0; } + } + // gather and validate data from BAT1 + Local1 = ^^BAT1._BIF() + Local3 = ^^BAT1._STA() + If (0x1f == Local3) + { + // check for invalid design capacity + Local4 = DerefOf(Local1[1]) + If (!Local4 || Ones == Local4) { Local3 = 0; } + // check for invalid max capacity + Local4 = DerefOf(Local1[2]) + If (!Local4 || Ones == Local4) { Local3 = 0; } + // check for invalid design voltage + Local4 = DerefOf(Local1[4]) + If (!Local4 || Ones == Local4) { Local3 = 0; } + } + // find primary and secondary battery + If (0x1f != Local2 && 0x1f == Local3) + { + // make primary use BAT1 data + Local0 = Local1 // BAT1._BIF result + Local2 = Local3 // BAT1._STA result + Local3 = 0 // no secondary battery + } + // combine batteries into Local0 result if possible + If (0x1f == Local2 && 0x1f == Local3) + { + // _BIF 0 - Power Unit - 0 = mWh | 1 = mAh + // set B0CO/B1CO if convertion to amps needed + B0CO = !DerefOf(Local0[0]) + B1CO = !DerefOf(Local1[0]) + // set _BIF[0] = 1 => mAh + Local0[0] = 1 + // _BIF 4 - Design Voltage - store value for each Battery in mV + B0DV = DerefOf(Local0[4]) // cache BAT0 voltage + B1DV = DerefOf(Local1[4]) // cache BAT1 voltage + // _BIF 1 - Design Capacity - add BAT0 and BAT1 values + Local0[1] = CVWA(DerefOf(Local0[1]), B0DV, B0CO) + CVWA(DerefOf(Local1[1]), B1DV, B1CO) + // _BIF 2 - Last Full Charge Capacity - add BAT0 and BAT1 values + Local0[2] = CVWA(DerefOf(Local0[2]), B0DV, B0CO) + CVWA(DerefOf(Local1[2]), B1DV, B1CO) + // _BIF 3 - Battery Technology - leave BAT0 value + // _BIF 4 - Design Voltage - average BAT0 and BAT1 values + Local0[4] = (B0DV + B1DV) / 2 + // _BIF 5 - Design Capacity Warning - add BAT0 and BAT1 values + Local0[5] = CVWA(DerefOf(Local0[5]), B0DV, B0CO) + CVWA(DerefOf(Local1[5]), B1DV, B1CO) + // _BIF 6 - Design Capacity of Low - add BAT0 and BAT1 values + Local0[6] = CVWA(DerefOf(Local0[6]), B0DV, B0CO) + CVWA(DerefOf(Local1[6]), B1DV, B1CO) + // _BIF 7+ - Leave BAT0 values for now + } + Return(Local0) + } // _BIF + } // BATC + } // Scope(...) +} +// EOF \ No newline at end of file diff --git a/Files/Patches/SSDT-BATX.dsl b/Files/Patches/#SSDT-BATX.dsl similarity index 100% rename from Files/Patches/SSDT-BATX.dsl rename to Files/Patches/#SSDT-BATX.dsl diff --git a/Files/Patches/SSDT-EC.dsl b/Files/Patches/#SSDT-EC.dsl similarity index 100% rename from Files/Patches/SSDT-EC.dsl rename to Files/Patches/#SSDT-EC.dsl diff --git a/Files/Patches/#SSDT-NTFY.dsl b/Files/Patches/#SSDT-NTFY.dsl new file mode 100755 index 00000000..8d6fc469 --- /dev/null +++ b/Files/Patches/#SSDT-NTFY.dsl @@ -0,0 +1,199 @@ +// +// For ACPI Patch: +// _Q22 to XQ22: +// Find: 5f51 3232 +// Replace: 5851 3232 +// +// _Q24 to XQ24: +// Find: 5f51 3234 +// Replace: 5851 3234 +// +// _Q25 to XQ25: +// Find: 5f51 3235 +// Replace: 5851 3235 +// +// _Q4A to XQ4A: +// Find: 5f51 3441 +// Replace: 5851 3441 +// +// _Q4B to XQ4B: +// Find: 5f51 3442 +// Replace: 5851 3442 +// +// _Q4D to XQ4D: +// Find: 5f51 3444 +// Replace: 5851 3444 +// +// BATW to XATW: +// Find: 4241 545701 +// Replace: 5841 545701 +// +DefinitionBlock ("", "SSDT", 2, "T460s", "NTFY", 0) +{ + External (\_SB.PCI0.LPC.EC, DeviceObj) + External (\_SB.PCI0.LPC.EC.BATC, DeviceObj) + // + External (\_SB.PCI0.LPC.EC.BAT1.XB1S, IntObj) + External (\_SB.PCI0.LPC.EC.BAT1.B1ST, IntObj) + External (\_SB.PCI0.LPC.EC.BAT1.SBLI, IntObj) + // + External (\_SB.PCI0.LPC.EC.CLPM, MethodObj) + External (\_SB.PCI0.LPC.EC.HKEY.MHKQ, MethodObj) + // + External (\BT2T, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.SLUL, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.HB0A, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.HB1A, FieldUnitObj) + // + External (\_SB.PCI0.LPC.EC.XQ22, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ24, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ25, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ4A, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ4B, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ4C, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ4D, MethodObj) + External (\_SB.PCI0.LPC.EC.XATW, MethodObj) + + Scope (\_SB.PCI0.LPC.EC) + { + Method (_Q22, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + If (_OSI ("Darwin")) + { + CLPM () + If (HB0A) + { + Notify (BATC, 0x80) // Status Change + } + + If (HB1A) + { + Notify (BATC, 0x80) // Status Change + } + } + Else + { + \_SB.PCI0.LPC.EC.XQ22 () + } + } + + Method (_Q24, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + If (_OSI ("Darwin")) + { + CLPM () + Notify (BATC, 0x80) // Status Change + } + Else + { + \_SB.PCI0.LPC.EC.XQ24 () + } + } + + Method (_Q25, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + If (_OSI ("Darwin")) + { + If ((^BAT1.B1ST & ^BAT1.XB1S)) + { + CLPM () + Notify (BATC, 0x80) // Status Change + } + } + Else + { + \_SB.PCI0.LPC.EC.XQ25 () + } + } + + Method (_Q4A, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + If (_OSI ("Darwin")) + { + CLPM () + Notify (BATC, 0x81) // Information Change + } + Else + { + \_SB.PCI0.LPC.EC.XQ4A () + } + } + + Method (_Q4B, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + If (_OSI ("Darwin")) + { + CLPM () + Notify (BATC, 0x80) // Status Change + } + Else + { + \_SB.PCI0.LPC.EC.XQ4B () + } + } + + Method (_Q4D, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + If (_OSI ("Darwin")) + { + CLPM () + If (\BT2T) + { + If ((^BAT1.SBLI == 0x01)) + { + Sleep (0x0A) + If ((HB1A && (SLUL == 0x00))) + { + ^BAT1.XB1S = 0x01 + Notify (\_SB.PCI0.LPC.EC.BATC, 0x01) // Device Check + } + } + ElseIf ((SLUL == 0x01)) + { + ^BAT1.XB1S = 0x00 + Notify (\_SB.PCI0.LPC.EC.BATC, 0x03) // Eject Request + } + } + + If ((^BAT1.B1ST & ^BAT1.XB1S)) + { + Notify (BATC, 0x80) // Status Change + } + } + Else + { + \_SB.PCI0.LPC.EC.XQ4D () + } + } + + Method (BATW, 1, NotSerialized) + { + If (_OSI ("Darwin")) + { + If (\BT2T) + { + Local0 = \_SB.PCI0.LPC.EC.BAT1.XB1S + If ((HB1A && !SLUL)) + { + Local1 = 0x01 + } + Else + { + Local1 = 0x00 + } + + If ((Local0 ^ Local1)) + { + \_SB.PCI0.LPC.EC.BAT1.XB1S = Local1 + Notify (\_SB.PCI0.LPC.EC.BATC, 0x01) // Device Check + } + } + } + Else + { + \_SB.PCI0.LPC.EC.XATW (Arg0) + } + } + } +} + diff --git a/Files/Patches/SSDT-BATC.dsl b/Files/Patches/SSDT-BATC.dsl old mode 100755 new mode 100644 index 68a0d81b..fa803477 --- a/Files/Patches/SSDT-BATC.dsl +++ b/Files/Patches/SSDT-BATC.dsl @@ -1,19 +1,40 @@ -// ThinkPad-LPC -DefinitionBlock ("", "SSDT", 2, "T460s", "BATC", 0) +// An SSDT to combine two batteries into one as BATC +// initial work/testing by ag6952563 (with assistance by RehabMan) +// finalize into generic SSDT by RehabMan +// some code cleanup/optimization/and bug fixing by RehabMan +// +// OS X support for multiple batteries is a bit buggy. +// This SSDT can be used to combine two batteries into one, +// avoiding the bugs. It may need modification depending on +// the ACPI path of your existing battery objects. + +// To use this SSDT, +// The Notify of both BAT0 or BAT1 objects must be redirected to BATC. +// These Notify is used to tell the system when a battery is removed or added. +// +// To Notify BATC, SSDT-NTFY.aml is required with accompanied binary patches. +// +// Also, ACPIBatteryManager.kext v1.70.0 or greater or SMCBatteryManager.kext +// must be used. If the Notify code is not patched, or the latest kext is not used, +// detection of battery removal/adding will not work correctly. + + +DefinitionBlock ("", "SSDT", 2, "T460", "BATC", 0) { - External(\_SB.PCI0.LPC.EC, DeviceObj) - - Scope(\_SB.PCI0.LPC.EC) + External (\_SB.PCI0.LPC.EC, DeviceObj) + External (\_SB.PCI0.LPC.EC.BAT0, DeviceObj) + External (\_SB.PCI0.LPC.EC.BAT0._BIF, MethodObj) // 0 Arguments + External (\_SB.PCI0.LPC.EC.BAT0._BST, MethodObj) // 0 Arguments + External (\_SB.PCI0.LPC.EC.BAT0._HID, IntObj) + External (\_SB.PCI0.LPC.EC.BAT0._STA, MethodObj) // 0 Arguments + External (\_SB.PCI0.LPC.EC.BAT1, DeviceObj) + External (\_SB.PCI0.LPC.EC.BAT1._BIF, MethodObj) // 0 Arguments + External (\_SB.PCI0.LPC.EC.BAT1._BST, MethodObj) // 0 Arguments + External (\_SB.PCI0.LPC.EC.BAT1._HID, IntObj) + External (\_SB.PCI0.LPC.EC.BAT1._STA, MethodObj) // 0 Arguments + + Scope (\_SB.PCI0.LPC.EC) { - External(BAT0._HID, IntObj) - External(BAT0._STA, MethodObj) - External(BAT0._BIF, MethodObj) - External(BAT0._BST, MethodObj) - External(BAT1, DeviceObj) - External(BAT1._HID, IntObj) - External(BAT1._STA, MethodObj) - External(BAT1._BIF, MethodObj) - External(BAT1._BST, MethodObj) Device(BATC) { Name(_HID, EisaId ("PNP0C0A")) @@ -44,15 +65,7 @@ DefinitionBlock ("", "SSDT", 2, "T460s", "BATC", 0) { // call original _STA for BAT0 and BAT1 // result is bitwise OR between them - - If (_OSI ("Darwin")) - { - Return(^^BAT0._STA() | ^^BAT1._STA()) - } - Else - { - Return (0) - } + Return(^^BAT0._STA() | ^^BAT1._STA()) } Name(B0CO, 0x00) // BAT0 0/1 needs conversion to mAh @@ -206,8 +219,7 @@ DefinitionBlock ("", "SSDT", 2, "T460s", "BATC", 0) // _BIF 7+ - Leave BAT0 values for now } Return(Local0) - } // _BIF - } // BATC - } // Scope(...) + } // END of _BIF on BATC + } // END of BATC Device + } // END of Scope \_SB.PCI0.LPC.EC } -// EOF \ No newline at end of file diff --git a/Files/Patches/SSDT-BATT.dsl b/Files/Patches/SSDT-BATT.dsl new file mode 100644 index 00000000..0df24a85 --- /dev/null +++ b/Files/Patches/SSDT-BATT.dsl @@ -0,0 +1,394 @@ +// Lenovo ThinkPad T460 Dual Battery Configuration +// created by shmilee -- adapted by tluck for T460 +// converted to Hotpatch with help of T450's SSDT +// from jsassu20 By Junaed. +// fixes Improper Battery Level and Status Reporting +// for further info refer to T440p, X220, Guide +// 'How to patch DSDT for working battery status' +// +// OperationRegion (ECOR, EmbeddedControl, 0x00, 0x0100) +// 1. declaration accessed: +// SBRC, 16, SBFC, 16, SBAC, 16, SBVO, 16, SBBM, 16, +// SBDC, 16, SBDV, 16, SBSN, 16, +// HWAC, 16 (Accessed on _WAK and GPE _L17) +// HSPD, 16 (Accessed on custom SMCD Device for fan readings) +// SBCH, 32 +// SBMN, 128 +// SBDN, 128 +// 2. declaration not accessed: +// HWAK, 16, HDEN, 32, HDEP, 32, +// SBAE, 16, SBRS, 16, SBAF, 16, SBBS, 16 +// SBMD, 16, SBCC, 16 +// SBOM, 16, SBSI, 16, SBDT, 16, +// +// Binary patch required to change GBIF and GBST to XBIF and XBST +// change (GBIF,3,N) to XBIF (Battery) +// Find: R0JJRgM= Replace: WEJJRgM= +// +// change (GBST,4,N) to XBST (Battery) +// Find: R0JTVAQ= Replace: WEJTVAQ= + +DefinitionBlock ("", "SSDT", 2, "T460", "BATT", 0) +{ + External (\_SB.PCI0.LPC.EC, DeviceObj) + External (\_SB.PCI0.LPC.EC.BATW, MethodObj) // 1 Arguments + External (\_SB.PCI0.LPC.EC.XBIF, MethodObj) // 3 Arguments + External (\_SB.PCI0.LPC.EC.XBST, MethodObj) // 4 Arguments + External (\_SB.PCI0.LPC.EC.AC._PSR, MethodObj) // 0 Arguments + External (\_SB.PCI0.LPC.EC.BATM, MutexObj) + External (\_SB.PCI0.LPC.EC.HIID, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.BSWR, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.BSWA, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.B0I0, IntObj) + External (\_SB.PCI0.LPC.EC.B0I1, IntObj) + External (\_SB.PCI0.LPC.EC.B0I2, IntObj) + External (\_SB.PCI0.LPC.EC.B0I3, IntObj) + External (\_SB.PCI0.LPC.EC.B1I0, IntObj) + External (\_SB.PCI0.LPC.EC.B1I1, IntObj) + External (\_SB.PCI0.LPC.EC.B1I2, IntObj) + External (\_SB.PCI0.LPC.EC.B1I3, IntObj) + + Method (B1B2, 2, NotSerialized) + { + Return ((Arg0 | (Arg1 << 0x08))) + } + + Method (B1B4, 4, NotSerialized) + { + Local0 = Arg3 + Local0 = (Arg2 | (Local0 << 0x08)) + Local0 = (Arg1 | (Local0 << 0x08)) + Local0 = (Arg0 | (Local0 << 0x08)) + Return (Local0) + } + + Scope (\_SB.PCI0.LPC.EC) + { + OperationRegion (BRAM, EmbeddedControl, Zero, 0x0100) + Field (BRAM, ByteAcc, NoLock, Preserve) + { + Offset (0xA0), + BRC0, 8, + BRC1, 8, + BFC0, 8, + BFC1, 8, + Offset (0xA8), + BAC0, 8, + BAC1, 8, + BVO0, 8, + BVO1, 8 + } + + Field (BRAM, ByteAcc, NoLock, Preserve) + { + Offset (0xA0), + BBM0, 8, + BBM1, 8 + } + + Field (BRAM, ByteAcc, NoLock, Preserve) + { + Offset (0xA0), + BDC0, 8, + BDC1, 8, + BDV0, 8, + BDV1, 8, + Offset (0xAA), + BSN0, 8, + BSN1, 8 + } + + Field (BRAM, ByteAcc, NoLock, Preserve) + { + Offset (0xA0), + BCH0, 8, + BCH1, 8, + BCH2, 8, + BCH3, 8 + } + + Field (BRAM, ByteAcc, NoLock, Preserve) + { + Offset (0xA0), + BMNX, 128 + } + + Field (BRAM, ByteAcc, NoLock, Preserve) + { + Offset (0xA0), + BDNX, 128 + } + + Method (RE1B, 1, Serialized) + { + OperationRegion (ERAM, EmbeddedControl, Arg0, One) + Field (ERAM, ByteAcc, NoLock, Preserve) + { + BYTE, 8 + } + + Return (BYTE) /* \_SB_.PCI0.LPC_.EC__.RE1B.BYTE */ + } + + Method (RECB, 2, Serialized) + { + Arg1 = ((Arg1 + 0x07) >> 0x03) + Name (TEMP, Buffer (Arg1){}) + Arg1 += Arg0 + Local0 = Zero + While ((Arg0 < Arg1)) + { + TEMP [Local0] = RE1B (Arg0) + Arg0++ + Local0++ + } + + Return (TEMP) /* \_SB_.PCI0.LPC_.EC__.RECB.TEMP */ + } + + Method (WE1B, 2, Serialized) + { + OperationRegion (ERAM, EmbeddedControl, Arg0, One) + Field (ERAM, ByteAcc, NoLock, Preserve) + { + BYTE, 8 + } + + BYTE = Arg1 + } + + Method (WECB, 3, Serialized) + { + Arg1 = ((Arg1 + 0x07) >> 0x03) // Arg1 = ceil(Arg1 / 8), this is loop counter + + Local7 = Buffer (Arg1) {} // Initial buffer to be written + Local7 = Arg2 + + Arg1 += Arg0 // Shift write window to target area + Local0 = Zero // Buffer index + + While ((Arg0 < Arg1)) + { + WE1B (Arg0, DerefOf (Local7 [Local0])) + Arg0++ // Offset++ + Local0++ // Index++ + } + } + + Method (GBIF, 3, Serialized) + { + If (_OSI ("Darwin")) + { + Acquire (BATM, 0xFFFF) + If (Arg2) + { + HIID = (Arg0 | One) + Local7 = B1B2 (BBM0, BBM1) + Local7 >>= 0x0F + Arg1 [Zero] = (Local7 ^ One) + HIID = Arg0 + If (Local7) + { + Local1 = (B1B2 (BFC0, BFC1) * 0x0A) + } + Else + { + Local1 = B1B2 (BFC0, BFC1) + } + + Arg1 [0x02] = Local1 + HIID = (Arg0 | 0x02) + If (Local7) + { + Local0 = (B1B2 (BDC0, BDC1) * 0x0A) + } + Else + { + Local0 = B1B2 (BDC0, BDC1) + } + + Arg1 [One] = Local0 + Divide (Local1, 0x14, Local2, Arg1 [0x05]) + If (Local7) + { + Arg1 [0x06] = 0xC8 + } + ElseIf (B1B2 (BDV0, BDV1)) + { + Divide (0x00030D40, B1B2 (BDV0, BDV1), Local2, Arg1 [0x06]) + } + Else + { + Arg1 [0x06] = Zero + } + + Arg1 [0x04] = B1B2 (BDV0, BDV1) + Local0 = B1B2 (BSN0, BSN1) + Name (SERN, Buffer (0x06) + { + " " + }) + Local2 = 0x04 + While (Local0) + { + Divide (Local0, 0x0A, Local1, Local0) + SERN [Local2] = (Local1 + 0x30) + Local2-- + } + + Arg1 [0x0A] = SERN /* \_SB_.PCI0.LPC_.EC__.GBIF.SERN */ + HIID = (Arg0 | 0x06) + Arg1 [0x09] = RECB (0xA0, 0x80) + HIID = (Arg0 | 0x04) + Name (BTYP, Buffer (0x05) + { + 0x00, 0x00, 0x00, 0x00, 0x00 // ..... + }) + BTYP = B1B4 (BCH0, BCH1, BCH2, BCH3) + Arg1 [0x0B] = BTYP /* \_SB_.PCI0.LPC_.EC__.GBIF.BTYP */ + HIID = (Arg0 | 0x05) + Arg1 [0x0C] = RECB (0xA0, 0x80) + } + Else + { + Arg1 [One] = 0xFFFFFFFF + Arg1 [0x05] = Zero + Arg1 [0x06] = Zero + Arg1 [0x02] = 0xFFFFFFFF + } + + Release (BATM) + Return (Arg1) + } + Else + { + Return (\_SB.PCI0.LPC.EC.XBIF (Arg0, Arg1, Arg2)) + } + } // END of GBIF + + Method (GBST, 4, NotSerialized) + { + If (_OSI ("Darwin")) + { + Acquire (BATM, 0xFFFF) + If ((Arg1 & 0x20)) + { + Local0 = 0x02 + } + ElseIf ((Arg1 & 0x40)) + { + Local0 = One + } + Else + { + Local0 = Zero + } + + If ((Arg1 & 0x07)){} + Else + { + Local0 |= 0x04 + } + + If (((Arg1 & 0x07) == 0x07)) + { + Local0 = 0x04 + Local1 = Zero + Local2 = Zero + Local3 = Zero + } + Else + { + HIID = Arg0 + Local3 = B1B2 (BVO0, BVO1) + If (Arg2) + { + Local2 = (B1B2 (BRC0, BRC1) * 0x0A) + } + Else + { + Local2 = B1B2 (BRC0, BRC1) + } + + Local1 = B1B2 (BAC0, BAC1) + If ((Local1 >= 0x8000)) + { + If ((Local0 & One)) + { + Local1 = (0x00010000 - Local1) + } + Else + { + Local1 = Zero + } + } + ElseIf (!(Local0 & 0x02)) + { + Local1 = Zero + } + + If (Arg2) + { + Local1 *= Local3 + Divide (Local1, 0x03E8, Local7, Local1) + } + } + + Local5 = (One << (Arg0 >> 0x04)) + BSWA |= BSWR /* \_SB_.PCI0.LPC_.EC__.BSWR */ + If (((BSWA & Local5) == Zero)) + { + Arg3 [Zero] = Local0 + Arg3 [One] = Local1 + Arg3 [0x02] = Local2 + Arg3 [0x03] = Local3 + If ((Arg0 == Zero)) + { + B0I0 = Local0 + B0I1 = Local1 + B0I2 = Local2 + B0I3 = Local3 + } + Else + { + B1I0 = Local0 + B1I1 = Local1 + B1I2 = Local2 + B1I3 = Local3 + } + } + ElseIf (^AC._PSR ()) + { + If ((Arg0 == Zero)) + { + Arg3 [Zero] = B0I0 /* \_SB_.PCI0.LPC_.EC__.B0I0 */ + Arg3 [One] = B0I1 /* \_SB_.PCI0.LPC_.EC__.B0I1 */ + Arg3 [0x02] = B0I2 /* \_SB_.PCI0.LPC_.EC__.B0I2 */ + Arg3 [0x03] = B0I3 /* \_SB_.PCI0.LPC_.EC__.B0I3 */ + } + Else + { + Arg3 [Zero] = B1I0 /* \_SB_.PCI0.LPC_.EC__.B1I0 */ + Arg3 [One] = B1I1 /* \_SB_.PCI0.LPC_.EC__.B1I1 */ + Arg3 [0x02] = B1I2 /* \_SB_.PCI0.LPC_.EC__.B1I2 */ + Arg3 [0x03] = B1I3 /* \_SB_.PCI0.LPC_.EC__.B1I3 */ + } + } + Else + { + Arg3 [Zero] = Local0 + Arg3 [One] = Local1 + Arg3 [0x02] = Local2 + Arg3 [0x03] = Local3 + } + + Release (BATM) + Return (Arg3) + } + Else + { + Return (\_SB.PCI0.LPC.EC.XBST (Arg0, Arg1, Arg2, Arg3)) + } + } // END of GBST + } // END of Scope \_SB.PCI0.LPC.EC +} diff --git a/Files/Patches/SSDT-NTFY.dsl b/Files/Patches/SSDT-NTFY.dsl old mode 100755 new mode 100644 index 8d6fc469..343f7b81 --- a/Files/Patches/SSDT-NTFY.dsl +++ b/Files/Patches/SSDT-NTFY.dsl @@ -1,58 +1,59 @@ +// SSDT for Notify BAT0 and BAT1 to BATC +// ACPI binary patches required to function // -// For ACPI Patch: -// _Q22 to XQ22: -// Find: 5f51 3232 -// Replace: 5851 3232 +// Change _Q22 to XQ22: +// Find: X1EyMg== Replace: WFEyMg== // -// _Q24 to XQ24: -// Find: 5f51 3234 -// Replace: 5851 3234 +// Change _Q24 to XQ24: +// Find: X1EyNA== Replace: WFEyNA== // -// _Q25 to XQ25: -// Find: 5f51 3235 -// Replace: 5851 3235 +// Change _Q25 to XQ25: +// Find: X1EyNQ== Replace: WFEyNQ== // -// _Q4A to XQ4A: -// Find: 5f51 3441 -// Replace: 5851 3441 +// Change _Q4A to XQ4A: +// Find: X1E0QQ== Replace: WFE0QQ== // -// _Q4B to XQ4B: -// Find: 5f51 3442 -// Replace: 5851 3442 +// Change _Q4B to XQ4B: +// Find: X1E0Qg== Replace: WFE0Qg== // -// _Q4D to XQ4D: -// Find: 5f51 3444 -// Replace: 5851 3444 +// Change _Q4C to XQ4C: +// Find: X1E0Qw== Replace: WFE0Qw== // -// BATW to XATW: -// Find: 4241 545701 -// Replace: 5841 545701 +// Change _Q4D to XQ4D: +// Find: X1E0RA== Replace: WFE0RA== // -DefinitionBlock ("", "SSDT", 2, "T460s", "NTFY", 0) +// Change BATW to WBAT: +// Find: TwdCQVRXAQ== Replace: TwdXQkFUAQ== + +DefinitionBlock ("", "SSDT", 2, "T460", "NTFY", 0) { + // Common definitions External (\_SB.PCI0.LPC.EC, DeviceObj) + External (\_SB.PCI0.LPC.EC.BAT1, DeviceObj) External (\_SB.PCI0.LPC.EC.BATC, DeviceObj) - // - External (\_SB.PCI0.LPC.EC.BAT1.XB1S, IntObj) - External (\_SB.PCI0.LPC.EC.BAT1.B1ST, IntObj) - External (\_SB.PCI0.LPC.EC.BAT1.SBLI, IntObj) - // - External (\_SB.PCI0.LPC.EC.CLPM, MethodObj) - External (\_SB.PCI0.LPC.EC.HKEY.MHKQ, MethodObj) - // - External (\BT2T, FieldUnitObj) - External (\_SB.PCI0.LPC.EC.SLUL, FieldUnitObj) External (\_SB.PCI0.LPC.EC.HB0A, FieldUnitObj) External (\_SB.PCI0.LPC.EC.HB1A, FieldUnitObj) - // + External (\_SB.PCI0.LPC.EC.CLPM, MethodObj) // 0 Argugements + External (\_SB.PCI0.LPC.EC.HKEY.MHKQ, MethodObj) // 1 Arguments + + // BAT1 definitions + External (\BT2T, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.SLUL, FieldUnitObj) + External (\_SB.PCI0.LPC.EC.BAT1.B1ST, IntObj) + External (\_SB.PCI0.LPC.EC.BAT1.SBLI, IntObj) + External (\_SB.PCI0.LPC.EC.BAT1.XB1S, IntObj) + External (\_SB.PCI0.LPC.EC.BAT0.B0ST, IntObj) + + // Notify BAT0 and BAT1 to BATC External (\_SB.PCI0.LPC.EC.XQ22, MethodObj) - External (\_SB.PCI0.LPC.EC.XQ24, MethodObj) - External (\_SB.PCI0.LPC.EC.XQ25, MethodObj) External (\_SB.PCI0.LPC.EC.XQ4A, MethodObj) External (\_SB.PCI0.LPC.EC.XQ4B, MethodObj) - External (\_SB.PCI0.LPC.EC.XQ4C, MethodObj) + External (\_SB.PCI0.LPC.EC.BAT1.XQ4C, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ24, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ4D, MethodObj) - External (\_SB.PCI0.LPC.EC.XATW, MethodObj) + External (\_SB.PCI0.LPC.EC.XQ25, MethodObj) + External (\_SB.PCI0.LPC.EC.WBAT, MethodObj) Scope (\_SB.PCI0.LPC.EC) { @@ -76,50 +77,34 @@ DefinitionBlock ("", "SSDT", 2, "T460s", "NTFY", 0) \_SB.PCI0.LPC.EC.XQ22 () } } - - Method (_Q24, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + + Method (_Q4A, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF { If (_OSI ("Darwin")) { CLPM () - Notify (BATC, 0x80) // Status Change - } - Else - { - \_SB.PCI0.LPC.EC.XQ24 () - } - } - - Method (_Q25, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF - { - If (_OSI ("Darwin")) - { - If ((^BAT1.B1ST & ^BAT1.XB1S)) - { - CLPM () - Notify (BATC, 0x80) // Status Change - } + Notify (BATC, 0x81) // Information Change } Else { - \_SB.PCI0.LPC.EC.XQ25 () + \_SB.PCI0.LPC.EC.XQ4A () } } - - Method (_Q4A, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + + Method (_Q4B, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF { If (_OSI ("Darwin")) { CLPM () - Notify (BATC, 0x81) // Information Change + Notify (BATC, 0x80) // Status Change } Else { - \_SB.PCI0.LPC.EC.XQ4A () + \_SB.PCI0.LPC.EC.XQ4B () } } - - Method (_Q4B, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + + Method (_Q24, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF { If (_OSI ("Darwin")) { @@ -128,10 +113,10 @@ DefinitionBlock ("", "SSDT", 2, "T460s", "NTFY", 0) } Else { - \_SB.PCI0.LPC.EC.XQ4B () + \_SB.PCI0.LPC.EC.XQ24 () } } - + Method (_Q4D, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF { If (_OSI ("Darwin")) @@ -139,18 +124,18 @@ DefinitionBlock ("", "SSDT", 2, "T460s", "NTFY", 0) CLPM () If (\BT2T) { - If ((^BAT1.SBLI == 0x01)) + If ((^BAT1.SBLI == One)) { Sleep (0x0A) - If ((HB1A && (SLUL == 0x00))) + If ((HB1A && (SLUL == Zero))) { - ^BAT1.XB1S = 0x01 - Notify (\_SB.PCI0.LPC.EC.BATC, 0x01) // Device Check + ^BAT1.XB1S = One + Notify (\_SB.PCI0.LPC.EC.BATC, One) // Device Check } } - ElseIf ((SLUL == 0x01)) + ElseIf ((SLUL == One)) { - ^BAT1.XB1S = 0x00 + ^BAT1.XB1S = Zero Notify (\_SB.PCI0.LPC.EC.BATC, 0x03) // Eject Request } } @@ -165,7 +150,23 @@ DefinitionBlock ("", "SSDT", 2, "T460s", "NTFY", 0) \_SB.PCI0.LPC.EC.XQ4D () } } - + + Method (_Q25, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + If (_OSI ("Darwin")) + { + If ((^BAT1.B1ST & ^BAT1.XB1S)) + { + CLPM () + Notify (BATC, 0x80) // Status Change + } + } + Else + { + \_SB.PCI0.LPC.EC.XQ25 () + } + } + Method (BATW, 1, NotSerialized) { If (_OSI ("Darwin")) @@ -175,23 +176,51 @@ DefinitionBlock ("", "SSDT", 2, "T460s", "NTFY", 0) Local0 = \_SB.PCI0.LPC.EC.BAT1.XB1S If ((HB1A && !SLUL)) { - Local1 = 0x01 + Local1 = One } Else { - Local1 = 0x00 + Local1 = Zero } If ((Local0 ^ Local1)) { \_SB.PCI0.LPC.EC.BAT1.XB1S = Local1 - Notify (\_SB.PCI0.LPC.EC.BATC, 0x01) // Device Check + Notify (\_SB.PCI0.LPC.EC.BATC, One) // Device Check } } } Else { - \_SB.PCI0.LPC.EC.XATW (Arg0) + \_SB.PCI0.LPC.EC.WBAT (Arg0) + } + } + } + + Scope (\_SB.PCI0.LPC.EC.BAT1) + { + Method (_Q4C, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF + { + + \_SB.PCI0.LPC.EC.CLPM () + If (\_SB.PCI0.LPC.EC.HB1A) + { + \_SB.PCI0.LPC.EC.HKEY.MHKQ (0x4010) + } + Else + { + \_SB.PCI0.LPC.EC.HKEY.MHKQ (0x4011) + If (\_SB.PCI0.LPC.EC.BAT1.XB1S) + { + If (_OSI ("Darwin")) + { + Notify (\_SB.PCI0.LPC.EC.BATC, 0x03) // Eject Request + } + Else + { + Notify (\_SB.PCI0.LPC.EC.BAT1, 0x03) + } + } } } }