blob: 24cf2686361619d0a0d6156ef69802895abf7d7b [file] [log] [blame]
Duncan Lauriee52840a2018-10-15 15:19:18 -07001/*
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 */
16
17/* ACPI_POWER_RECORD */
18Name (ECPR, 0)
19
20Method (ECQP, 0, Serialized)
21{
22 Local0 = R (APWR)
23 Local1 = Local0 ^ ECPR
24 ECPR = Local0
25
26 If (EBIT (APAC, Local1)) {
27 Printf ("AC Power Status Changed")
28 Notify (AC, 0x80)
29 }
30
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 }
41
42 If (EBIT (APC1, Local1)) {
43 Printf ("BAT0 Status Change")
44 Notify (BAT0, 0x80)
45 }
46}
47
48/* Handle events in PmEv1 */
49Method (ECQ1, 1, Serialized)
50{
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 }
56
57 /* LID state changed */
58 If (EBIT (E1LD, Arg0)) {
59 Printf ("Lid State Changed")
60 Notify (^LID, 0x80)
61 }
62
63 /* Power Event */
64 If (EBIT (E1PW, Arg0)) {
65 Printf ("Power Event")
66 ECQP ()
67 }
68
69 /* Sleep Button */
70 If (EBIT (E1SB, Arg0)) {
71 Printf ("Sleep Button")
72 }
73}
74
75/* Handle events in PmEv2 */
76Method (ECQ2, 1, Serialized)
77{
78 Printf ("EVT2: %o", Arg0)
Duncan Laurie45b84652018-11-17 12:18:20 -070079
80 If (EBIT (E2QS, Arg0)) {
81 Printf ("QS EVENT")
Duncan Laurieaaac6782019-02-01 09:37:34 -080082 Notify (^WEVT, 0x90)
Duncan Laurie45b84652018-11-17 12:18:20 -070083 }
Duncan Laurie4a2558b2019-02-01 11:44:14 -080084
85 If (EBIT (E2OR, Arg0)) {
86 If (R (OTBL)) {
87 Printf ("EC event indicates tablet mode")
88 Notify (^VBTN, ^VTBL)
89 } Else {
90 Printf ("EC event indicates laptop mode")
91 Notify (^VBTN, ^VLAP)
92 }
93 }
Duncan Lauriee52840a2018-10-15 15:19:18 -070094}
95
96/* Handle events in PmEv3 */
97Method (ECQ3, 1, Serialized)
98{
99 Printf ("EVT3: %o", Arg0)
Duncan Laurie98d7de72018-11-20 17:30:47 -0800100
Duncan Laurie4a2558b2019-02-01 11:44:14 -0800101 If (EBIT (E3CP, Arg0)) {
102 If (R (P2PB)) {
103 Printf ("Power button pressed")
104 Notify (^VBTN, ^VPPB)
105 } Else {
106 Printf ("Power button released")
107 Notify (^VBTN, ^VRPB)
108 }
109 }
110
Duncan Lauriebfb001d2018-12-04 10:13:25 -0800111#ifdef EC_ENABLE_DPTF
Duncan Laurie98d7de72018-11-20 17:30:47 -0800112 /* Theraml Events */
113 If (EBIT (E3TH, Arg0)) {
114 ^PATX ()
115 }
Duncan Lauriebfb001d2018-12-04 10:13:25 -0800116#endif
Duncan Lauriee52840a2018-10-15 15:19:18 -0700117}
118
119/* Handle events in PmEv4 */
120Method (ECQ4, 1, Serialized)
121{
122 Printf ("EVT4: %o", Arg0)
123}
124
Duncan Lauriee52840a2018-10-15 15:19:18 -0700125/* Process all events */
126Method (_Q66, 0, Serialized)
127{
128 Local0 = R (EVT1)
129 If (Local0) {
130 ECQ1 (Local0)
131 }
132
133 Local0 = R (EVT2)
134 If (Local0) {
135 ECQ2 (Local0)
136 }
137
138 Local0 = R (EVT3)
139 If (Local0) {
140 ECQ3 (Local0)
141 }
142
143 Local0 = R (EVT4)
144 If (Local0) {
145 ECQ4 (Local0)
146 }
Duncan Laurie45b84652018-11-17 12:18:20 -0700147}