Skip to content

Instantly share code, notes, and snippets.

@peterychuang
Created October 17, 2017 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterychuang/9b318b39ccfac34e0253b355bf076e70 to your computer and use it in GitHub Desktop.
Save peterychuang/9b318b39ccfac34e0253b355bf076e70 to your computer and use it in GitHub Desktop.
dsdt_gpe_ec.txt
Device (EC)
{
Name (_HID, EisaId ("PNP0C09") /* Embedded Controller Device */) // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
IO (Decode16,
0x0062, // Range Minimum
0x0062, // Range Maximum
0x00, // Alignment
0x01, // Length
)
IO (Decode16,
0x0066, // Range Minimum
0x0066, // Range Maximum
0x00, // Alignment
0x01, // Length
)
})
Name (_GPE, 0x07) // _GPE: General Purpose Events
Method (_PRW, 0, NotSerialized) // _PRW: Power Resources for Wake
{
If (OSDW ())
{
Return (Package (0x02)
{
0x6F,
0x04
})
}
Else
{
Return (Package (0x02)
{
0x6F,
0x03
})
}
}
Name (ECOK, Zero)
OperationRegion (ECOR, EmbeddedControl, Zero, 0xFF)
Field (ECOR, ByteAcc, NoLock, Preserve)
{
ECVS, 8,
Offset (0x02),
Offset (0x03),
G3HT, 1,
, 5,
LVME, 1,
PRST, 1,
WBCB, 1,
DSLP, 1,
Offset (0x05),
Offset (0x06),
WKRS, 8,
Offset (0x09),
LDSB, 8,
Offset (0x0D),
CMDS, 8,
DATA, 8,
INDX, 8,
ECSS, 8,
PLIM, 8,
ALB0, 8,
ALB1, 8,
WTLB, 8,
WTMB, 8,
Offset (0x20),
SPTR, 8,
SSTS, 8,
SADR, 8,
SCMD, 8,
SBFR, 256,
SCNT, 8,
SAAD, 8,
SAD0, 8,
SAD1, 8,
SMUX, 8,
Offset (0x54),
POR0, 8,
POR1, 8,
POR2, 8,
POR3, 8,
PWRP, 8,
PWQP, 8,
PSRP, 8,
PSQP, 8,
Offset (0x60),
ELSW, 1,
EACP, 1,
ECDI, 1,
ENMI, 1,
Offset (0x61),
EMHP, 1,
PSOC, 1,
Offset (0x62),
Offset (0x63),
Offset (0x64),
SWLO, 1,
SWLC, 1,
SWAI, 1,
SWAR, 1,
SWCI, 1,
SWCE, 1,
SWMI, 1,
SWMR, 1,
SWPB, 1,
SWGP, 1,
SWPM, 1,
SWWT, 1,
SWLB, 1,
Offset (0x66),
Offset (0x67),
Offset (0x68),
EWLO, 1,
EWLC, 1,
EWAI, 1,
EWAR, 1,
EWCI, 1,
EWCE, 1,
EWMI, 1,
EWMR, 1,
EWPB, 1,
EWGP, 1,
EWPM, 1,
ENWT, 1,
EWLB, 1,
EWDK, 1,
Offset (0x6A),
Offset (0x6B),
Offset (0x6C),
LWLO, 1,
LWLC, 1,
LWAI, 1,
LWAR, 1,
LWCI, 1,
LWCE, 1,
LWMI, 1,
LWMR, 1,
LWPB, 1,
LWGP, 1,
LWPM, 1,
LWWT, 1,
LWLB, 1,
Offset (0x6E),
Offset (0x6F),
Offset (0x70)
}
Field (ECOR, ByteAcc, Lock, Preserve)
{
Offset (0x03),
G3AD, 1,
BLOD, 1,
S4WE, 1,
APWC, 1,
BTPC, 1,
SOCR, 1,
Offset (0x04),
Offset (0x6C),
LWE0, 8,
LWE1, 8,
LWE2, 8,
LWE3, 8
}
Field (ECOR, ByteAcc, NoLock, Preserve)
{
Offset (0x24),
SBDW, 16,
Offset (0x46),
SADW, 16
}
Method (WAKE, 0, NotSerialized)
{
If (ECOK)
{
Debug = "EC Wake reason ="
Debug = WKRS /* \_SB_.PCI0.LPCB.EC__.WKRS */
Debug = EWAI /* \_SB_.PCI0.LPCB.EC__.EWAI */
Debug = EWAR /* \_SB_.PCI0.LPCB.EC__.EWAR */
Return (WKRS) /* \_SB_.PCI0.LPCB.EC__.WKRS */
}
Else
{
Return (Zero)
}
}
Method (SETP, 3, NotSerialized)
{
If ((Arg0 == Zero))
{
If ((Arg1 == Zero))
{
PWRP = Arg2
}
ElseIf ((Arg1 == One))
{
PWQP = Arg2
}
}
ElseIf ((Arg0 == One))
{
If ((Arg1 == Zero))
{
PSRP = Arg2
}
ElseIf ((Arg1 == One))
{
PSQP = Arg2
}
}
}
Method (RQOP, 1, NotSerialized)
{
Local0 = (Arg0 & 0xFF)
POR0 = Local0
Local0 = ((Arg0 >> 0x08) & 0xFF)
POR1 = Local0
Local0 = ((Arg0 >> 0x10) & 0xFF)
POR2 = Local0
Local0 = ((Arg0 >> 0x14) & 0xFF)
POR3 = Local0
}
Method (QROP, 0, NotSerialized)
{
Local0 = POR0 /* \_SB_.PCI0.LPCB.EC__.POR0 */
Local1 = POR1 /* \_SB_.PCI0.LPCB.EC__.POR1 */
Local0 += (Local1 << 0x08)
Local1 = POR2 /* \_SB_.PCI0.LPCB.EC__.POR2 */
Local0 += (Local1 << 0x10)
Local1 = POR3 /* \_SB_.PCI0.LPCB.EC__.POR3 */
Local0 += (Local1 << 0x18)
Return (Local0)
}
Method (PORS, 2, NotSerialized)
{
If ((Arg0 == Zero))
{
If ((Arg1 == Zero))
{
Return (PWRP) /* \_SB_.PCI0.LPCB.EC__.PWRP */
}
ElseIf ((Arg1 == One))
{
Return (PWQP) /* \_SB_.PCI0.LPCB.EC__.PWQP */
}
}
ElseIf ((Arg0 == One))
{
If ((Arg1 == Zero))
{
Return (PSRP) /* \_SB_.PCI0.LPCB.EC__.PSRP */
}
ElseIf ((Arg1 == One))
{
Return (PSQP) /* \_SB_.PCI0.LPCB.EC__.PSQP */
}
}
Return (0xFF)
}
Device (SMB0)
{
Name (_HID, "ACPI0001" /* SMBus 1.0 Host Controller */) // _HID: Hardware ID
Name (_EC, 0x2010) // _EC_: Embedded Controller
Mutex (SMTX, 0x00)
Method (_STA, 0, NotSerialized) // _STA: Status
{
If (OSDW ())
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
Device (SBS0)
{
Name (_HID, "ACPI0002" /* Smart Battery Subsystem */) // _HID: Hardware ID
Name (_SBS, One) // _SBS: Smart Battery Subsystem
}
Method (SBPC, 1, NotSerialized)
{
Local0 = Arg0
While (Local0)
{
If ((SPTR == Zero))
{
Return ((SSTS & 0x1F))
}
Sleep (One)
Local0--
}
Return (0x18)
}
Method (SBRW, 3, NotSerialized)
{
Local0 = One
If (!Acquire (SMTX, 0xFFFF))
{
If ((SPTR == Zero))
{
SADR = (Arg0 << One)
SCMD = Arg1
SPTR = 0x09
Local0 = SBPC (0x03E8)
If (!Local0)
{
Arg2 = SBDW /* \_SB_.PCI0.LPCB.EC__.SBDW */
}
}
Release (SMTX)
}
Return (Local0)
}
Method (SBRB, 3, NotSerialized)
{
Local0 = One
Local1 = Buffer (One)
{
0x00 /* . */
}
If (!Acquire (SMTX, 0xFFFF))
{
If ((SPTR == Zero))
{
SADR = (Arg0 << One)
SCMD = Arg1
SPTR = 0x0B
Local0 = SBPC (0x03E8)
If (!Local0)
{
Arg2 = SBFR /* \_SB_.PCI0.LPCB.EC__.SBFR */
}
}
Release (SMTX)
}
Return (Local0)
}
}
Method (_Q10, 0, NotSerialized) // _Qxx: EC Query
{
If (OSDW ())
{
Notify (SMB0, 0x80) // Status Change
}
ElseIf ((SSTS & 0x40))
{
If (!Acquire (^SMB0.SMTX, 0xFFFF))
{
Local0 = (SAAD >> One)
If ((Local0 == 0x0A))
{
^^^^BAT0.BNOT (SADW)
}
SSTS = Zero
Release (^SMB0.SMTX)
}
}
}
Method (_Q11, 0, NotSerialized) // _Qxx: EC Query
{
Notify (EC, 0x83) // Device-Specific Change
}
Method (_Q12, 0, NotSerialized) // _Qxx: EC Query
{
Notify (EC, 0x84) // Reserved
}
Method (_Q20, 0, NotSerialized) // _Qxx: EC Query
{
LIDS = ELSW /* \_SB_.PCI0.LPCB.EC__.ELSW */
Debug = "LidState - ELSW ="
Debug = ELSW /* \_SB_.PCI0.LPCB.EC__.ELSW */
^^^IGPU.CLID = ELSW /* \_SB_.PCI0.LPCB.EC__.ELSW */
Debug = "LidState - CLID ="
Debug = ^^^IGPU.CLID /* \_SB_.PCI0.IGPU.CLID */
Notify (LID0, 0x80) // Status Change
}
Method (_Q21, 0, NotSerialized) // _Qxx: EC Query
{
If (EACP)
{
PWRS = One
}
Else
{
PWRS = Zero
}
Notify (ADP1, 0x80) // Status Change
PNOT ()
}
Method (_Q40, 0, NotSerialized) // _Qxx: EC Query
{
Notify (ALS0, 0x80) // Status Change
}
Method (_Q5A, 0, NotSerialized) // _Qxx: EC Query
{
Notify (SLPB, 0x80) // Status Change
}
Method (_Q80, 0, NotSerialized) // _Qxx: EC Query
{
Notify (\_PR.CPU0, 0x80) // Performance Capability Change
Notify (\_PR.CPU1, 0x80) // Performance Capability Change
Notify (\_PR.CPU2, 0x80) // Performance Capability Change
Notify (\_PR.CPU3, 0x80) // Performance Capability Change
Notify (\_PR.CPU4, 0x80) // Performance Capability Change
Notify (\_PR.CPU5, 0x80) // Performance Capability Change
Notify (\_PR.CPU6, 0x80) // Performance Capability Change
Notify (\_PR.CPU7, 0x80) // Performance Capability Change
If ((^^^IGPU.VID0 == 0x8086))
{
Local0 = IGPS /* \IGPS */
Local0 = (RP0C - Local0)
RPSL = Local0
}
Else
{
Notify (^^^PEG0.GFX0, 0x81) // Information Change
}
}
Method (_QCE, 0, NotSerialized) // _Qxx: EC Query
{
Debug = "EC:_QCE"
}
Method (_QCF, 0, NotSerialized) // _Qxx: EC Query
{
Debug = "EC:_QCF"
If (!OSDW ())
{
Notify (SLPB, 0x80) // Status Change
}
}
Method (_QD0, 0, NotSerialized) // _Qxx: EC Query
{
Debug = "EC:_QD0"
}
Method (_REG, 2, NotSerialized) // _REG: Region Availability
{
If (((Arg0 == 0x03) || (OSYS >= 0x07D6)))
{
ECOK = Arg1
If ((Arg1 == One))
{
ECSS = Zero
LIDS = ELSW /* \_SB_.PCI0.LPCB.EC__.ELSW */
Debug = "LidState - ELSW ="
Debug = ELSW /* \_SB_.PCI0.LPCB.EC__.ELSW */
Debug = "LidState - LIDS ="
Debug = LIDS /* \LIDS */
^^^IGPU.CLID = ELSW /* \_SB_.PCI0.LPCB.EC__.ELSW */
Debug = "LidState - CLID ="
Debug = ^^^IGPU.CLID /* \_SB_.PCI0.IGPU.CLID */
PWRS = EACP /* \_SB_.PCI0.LPCB.EC__.EACP */
Notify (ADP1, 0x80) // Status Change
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment