| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
/* ACPI_POWER_RECORD */ |
| 4 |
Name (ECPR, 0) |
| 5 |
|
| 6 |
Method (ECQP, 0, Serialized) |
| 7 |
{ |
| 8 |
Local0 = R (PWSR) |
| 9 |
Local1 = Local0 ^ ECPR |
| 10 |
ECPR = Local0 |
| 11 |
|
| 12 |
If (EBIT (ACEX, Local1)) { |
| 13 |
Printf ("AC Power Status Changed") |
| 14 |
Notify (AC, 0x80) |
| 15 |
} |
| 16 |
|
| 17 |
If (EBIT (BTEX, Local1)) { |
| 18 |
If (EBIT (BTEX, Local0)) { |
| 19 |
Printf ("BAT0 Inserted") |
| 20 |
Notify (BAT0, 0x81) |
| 21 |
} Else { |
| 22 |
Printf ("BAT0 Removed") |
| 23 |
Notify (BAT0, 0x80) |
| 24 |
Notify (BAT0, 0x81) |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
/* |
| 29 |
* Battery status is cleared when read so always use the value from |
| 30 |
* PWSR directly regardless of the previous value stored in ECPR. |
| 31 |
*/ |
| 32 |
If (EBIT (BTSC, Local0)) { |
| 33 |
Printf ("BAT0 Status Change") |
| 34 |
Notify (BAT0, 0x80) |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
/* Handle events in PmEv1 */ |
| 39 |
Method (ECQ1, 1, Serialized) |
| 40 |
{ |
| 41 |
/* Power button pressed */ |
| 42 |
If (EBIT (E1PB, Arg0)) { |
| 43 |
Printf ("Power Button Event") |
| 44 |
/* Do not notify \_SB.PWRB here to prevent double event */ |
| 45 |
} |
| 46 |
|
| 47 |
/* LID state changed */ |
| 48 |
If (EBIT (E1LD, Arg0)) { |
| 49 |
Printf ("Lid State Changed") |
| 50 |
Notify (^LID0, 0x80) |
| 51 |
} |
| 52 |
|
| 53 |
/* Power Event */ |
| 54 |
If (EBIT (E1PW, Arg0)) { |
| 55 |
Printf ("Power Event") |
| 56 |
ECQP () |
| 57 |
} |
| 58 |
|
| 59 |
/* Sleep Button */ |
| 60 |
If (EBIT (E1SB, Arg0)) { |
| 61 |
Printf ("Sleep Button") |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
/* Handle events in PmEv2 */ |
| 66 |
Method (ECQ2, 1, Serialized) |
| 67 |
{ |
| 68 |
Printf ("EVT2: %o", Arg0) |
| 69 |
|
| 70 |
If (EBIT (E2QS, Arg0)) { |
| 71 |
Printf ("QS EVENT") |
| 72 |
Notify (^WEVT, 0x90) |
| 73 |
} |
| 74 |
|
| 75 |
If (EBIT (E2OR, Arg0)) { |
| 76 |
If (R (OTBL)) { |
| 77 |
Printf ("EC event indicates tablet mode") |
| 78 |
Notify (^VBTN, ^VTBL) |
| 79 |
} Else { |
| 80 |
Printf ("EC event indicates laptop mode") |
| 81 |
Notify (^VBTN, ^VLAP) |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
/* Handle events in PmEv3 */ |
| 87 |
Method (ECQ3, 1, Serialized) |
| 88 |
{ |
| 89 |
Printf ("EVT3: %o", Arg0) |
| 90 |
|
| 91 |
If (EBIT (E3CP, Arg0)) { |
| 92 |
If (R (P2PB)) { |
| 93 |
Printf ("Power button pressed") |
| 94 |
Notify (^VBTN, ^VPPB) |
| 95 |
} Else { |
| 96 |
Printf ("Power button released") |
| 97 |
Notify (^VBTN, ^VRPB) |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
#ifdef EC_ENABLE_DPTF |
| 102 |
/* Theraml Events */ |
| 103 |
If (EBIT (E3TH, Arg0)) { |
| 104 |
^PATX () |
| 105 |
} |
| 106 |
#endif |
| 107 |
} |
| 108 |
|
| 109 |
/* Handle events in PmEv4 */ |
| 110 |
Method (ECQ4, 1, Serialized) |
| 111 |
{ |
| 112 |
Printf ("EVT4: %o", Arg0) |
| 113 |
} |
| 114 |
|
| 115 |
/* Process all events */ |
| 116 |
Method (_Q66, 0, Serialized) |
| 117 |
{ |
| 118 |
Local0 = R (EVT1) |
| 119 |
If (Local0) { |
| 120 |
ECQ1 (Local0) |
| 121 |
} |
| 122 |
|
| 123 |
Local0 = R (EVT2) |
| 124 |
If (Local0) { |
| 125 |
ECQ2 (Local0) |
| 126 |
} |
| 127 |
|
| 128 |
Local0 = R (EVT3) |
| 129 |
If (Local0) { |
| 130 |
ECQ3 (Local0) |
| 131 |
} |
| 132 |
|
| 133 |
Local0 = R (EVT4) |
| 134 |
If (Local0) { |
| 135 |
ECQ4 (Local0) |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
/* UCSI SCI uses a unique event code */ |
| 140 |
Method (_Q79, 0, Serialized) |
| 141 |
{ |
| 142 |
If (ISSX == 0) { |
| 143 |
Printf ("EC _Q79 UCSI Event") |
| 144 |
|
| 145 |
\_SB.UCSI.RMSG() |
| 146 |
|
| 147 |
Notify (\_SB.UCSI, 0x80) |
| 148 |
^UCEP = 0 |
| 149 |
} Else { |
| 150 |
Printf ("EC _Q79 UCSI Event Masked in S0ix") |
| 151 |
^UCEP = 1 |
| 152 |
} |
| 153 |
} |