blob: 3f5994681788ce319061bae2df014eee2294e416 [file] [log] [blame]
Angel Pons210a0082020-04-02 23:48:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Lauriee52840a2018-10-15 15:19:18 -07002
3/* ACPI_POWER_RECORD */
4Name (ECPR, 0)
5
6Method (ECQP, 0, Serialized)
7{
Duncan Lauriea213ed62019-02-21 17:38:03 -08008 Local0 = R (PWSR)
Duncan Lauriee52840a2018-10-15 15:19:18 -07009 Local1 = Local0 ^ ECPR
10 ECPR = Local0
11
Duncan Lauriea213ed62019-02-21 17:38:03 -080012 If (EBIT (ACEX, Local1)) {
Duncan Lauriee52840a2018-10-15 15:19:18 -070013 Printf ("AC Power Status Changed")
14 Notify (AC, 0x80)
15 }
16
Duncan Lauriea213ed62019-02-21 17:38:03 -080017 If (EBIT (BTEX, Local1)) {
18 If (EBIT (BTEX, Local0)) {
Duncan Lauriee52840a2018-10-15 15:19:18 -070019 Printf ("BAT0 Inserted")
20 Notify (BAT0, 0x81)
21 } Else {
22 Printf ("BAT0 Removed")
23 Notify (BAT0, 0x80)
24 Notify (BAT0, 0x81)
25 }
26 }
27
Mathew King071182a2020-06-02 12:27:06 -060028 /*
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)) {
Duncan Lauriee52840a2018-10-15 15:19:18 -070033 Printf ("BAT0 Status Change")
34 Notify (BAT0, 0x80)
35 }
36}
37
38/* Handle events in PmEv1 */
39Method (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")
Eric Lai5ddce582020-03-13 17:42:03 +080050 Notify (^LID0, 0x80)
Duncan Lauriee52840a2018-10-15 15:19:18 -070051 }
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 */
66Method (ECQ2, 1, Serialized)
67{
68 Printf ("EVT2: %o", Arg0)
Duncan Laurie45b84652018-11-17 12:18:20 -070069
70 If (EBIT (E2QS, Arg0)) {
71 Printf ("QS EVENT")
Duncan Laurieaaac6782019-02-01 09:37:34 -080072 Notify (^WEVT, 0x90)
Duncan Laurie45b84652018-11-17 12:18:20 -070073 }
Duncan Laurie4a2558b2019-02-01 11:44:14 -080074
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 }
Duncan Lauriee52840a2018-10-15 15:19:18 -070084}
85
86/* Handle events in PmEv3 */
87Method (ECQ3, 1, Serialized)
88{
89 Printf ("EVT3: %o", Arg0)
Duncan Laurie98d7de72018-11-20 17:30:47 -080090
Duncan Laurie4a2558b2019-02-01 11:44:14 -080091 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
Duncan Lauriebfb001d2018-12-04 10:13:25 -0800101#ifdef EC_ENABLE_DPTF
Duncan Laurie98d7de72018-11-20 17:30:47 -0800102 /* Theraml Events */
103 If (EBIT (E3TH, Arg0)) {
104 ^PATX ()
105 }
Duncan Lauriebfb001d2018-12-04 10:13:25 -0800106#endif
Duncan Lauriee52840a2018-10-15 15:19:18 -0700107}
108
109/* Handle events in PmEv4 */
110Method (ECQ4, 1, Serialized)
111{
112 Printf ("EVT4: %o", Arg0)
113}
114
Duncan Lauriee52840a2018-10-15 15:19:18 -0700115/* Process all events */
116Method (_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 }
Duncan Laurie45b84652018-11-17 12:18:20 -0700137}
Duncan Lauriec145e542019-04-18 16:37:50 -0700138
139/* UCSI SCI uses a unique event code */
140Method (_Q79, 0, Serialized)
141{
Felix Singer42efd7f2022-12-26 09:38:45 +0100142 If (ISSX == 0) {
Duncan Laurie3cd3cb62020-06-09 15:13:15 -0700143 Printf ("EC _Q79 UCSI Event")
144 Notify (^UCSI, 0x80)
Felix Singer42efd7f2022-12-26 09:38:45 +0100145 ^UCEP = 0
Duncan Laurie3cd3cb62020-06-09 15:13:15 -0700146 } Else {
147 Printf ("EC _Q79 UCSI Event Masked in S0ix")
Felix Singerca4b5872022-12-26 08:17:06 +0100148 ^UCEP = 1
Duncan Laurie3cd3cb62020-06-09 15:13:15 -0700149 }
Duncan Lauriec145e542019-04-18 16:37:50 -0700150}