ec/google/wilco/acpi: Add DPTF support
[coreboot.git] / src / ec / google / wilco / acpi / event.asl
blob21721f27502f18f94a83afc6b1db29d05b256500
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright 2018 Google LLC
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
17 /* ACPI_POWER_RECORD */
18 Name (ECPR, 0)
20 Method (ECQP, 0, Serialized)
22         Local0 = R (APWR)
23         Local1 = Local0 ^ ECPR
24         ECPR = Local0
26         If (EBIT (APAC, Local1)) {
27                 Printf ("AC Power Status Changed")
28                 Notify (AC, 0x80)
29         }
31         If (EBIT (APB1, Local1)) {
32                 If (EBIT (APB1, Local0)) {
33                         Printf ("BAT0 Inserted")
34                         Notify (BAT0, 0x81)
35                 } Else {
36                         Printf ("BAT0 Removed")
37                         Notify (BAT0, 0x80)
38                         Notify (BAT0, 0x81)
39                 }
40         }
42         If (EBIT (APC1, Local1)) {
43                 Printf ("BAT0 Status Change")
44                 Notify (BAT0, 0x80)
45         }
48 /* Handle events in PmEv1 */
49 Method (ECQ1, 1, Serialized)
51         /* Power button pressed */
52         If (EBIT (E1PB, Arg0)) {
53                 Printf ("Power Button Event")
54                 /* Do not notify \_SB.PWRB here to prevent double event */
55         }
57         /* LID state changed */
58         If (EBIT (E1LD, Arg0)) {
59                 Printf ("Lid State Changed")
60                 Notify (^LID, 0x80)
61         }
63         /* Power Event */
64         If (EBIT (E1PW, Arg0)) {
65                 Printf ("Power Event")
66                 ECQP ()
67         }
69         /* Sleep Button */
70         If (EBIT (E1SB, Arg0)) {
71                 Printf ("Sleep Button")
72         }
75 /* Handle events in PmEv2 */
76 Method (ECQ2, 1, Serialized)
78         Printf ("EVT2: %o", Arg0)
80         If (EBIT (E2QS, Arg0)) {
81                 Printf ("QS EVENT")
82                 Notify (^WLCO, 0x90)
83         }
86 /* Handle events in PmEv3 */
87 Method (ECQ3, 1, Serialized)
89         Printf ("EVT3: %o", Arg0)
91         /* Theraml Events */
92         If (EBIT (E3TH, Arg0)) {
93                 ^PATX ()
94         }
97 /* Handle events in PmEv4 */
98 Method (ECQ4, 1, Serialized)
100         Printf ("EVT4: %o", Arg0)
103 /* Process all events */
104 Method (_Q66, 0, Serialized)
106         Local0 = R (EVT1)
107         If (Local0) {
108                 ECQ1 (Local0)
109         }
111         Local0 = R (EVT2)
112         If (Local0) {
113                 ECQ2 (Local0)
114         }
116         Local0 = R (EVT3)
117         If (Local0) {
118                 ECQ3 (Local0)
119         }
121         Local0 = R (EVT4)
122         If (Local0) {
123                 ECQ4 (Local0)
124         }
127 /* Get Event Buffer */
128 Method (QSET, 0, Serialized)
130         /* Get count of event bytes */
131         Local0 = R (QSEC)
132         Name (QBUF, Buffer (Local0) {})
134         /* Fill QS event buffer with Local0 bytes */
135         For (Local1 = 0, Local1 < Local0, Local1++) {
136                 QBUF[Local1] = R (QSEB)
137         }
139         Printf ("QS = %o", QBUF)
140         Return (QBUF)