blob: bceb23c92dce38635aab5f328b4d144c756e4e53 [file] [log] [blame]
Matt DeVillier7d57d562021-04-14 13:15:43 -05001/* SPDX-License-Identifier: GPL-2.0-only */
2
3Scope (\_SB) {
4 #include "ac.asl"
5 #include "battery.asl"
6 #include "buttons.asl"
7 #include "hid.asl"
8 #include "lid.asl"
9 #include "librem-ec.asl"
10}
11
12Device (\_SB.PCI0.LPCB.EC0)
13{
14 Name (_HID, EisaId ("PNP0C09") /* Embedded Controller Device */) // _HID: Hardware ID
15 Name (_GPE, EC_GPE_SCI) // _GPE: General Purpose Events
16 Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
17 {
18 IO (Decode16,
19 0x0062, // Range Minimum
20 0x0062, // Range Maximum
21 0x00, // Alignment
22 0x01, // Length
23 )
24 IO (Decode16,
25 0x0066, // Range Minimum
26 0x0066, // Range Maximum
27 0x00, // Alignment
28 0x01, // Length
29 )
30 })
31
32 #include "ec_ram.asl"
33
34 Name (ECOK, Zero)
35 Method (_REG, 2, Serialized) // _REG: Region Availability
36 {
Felix Singerdcebf6c2021-12-26 15:24:25 +010037 Printf ("EC: _REG %o %o", ToHexString(Arg0), ToHexString(Arg1))
Felix Singerca4b5872022-12-26 08:17:06 +010038 If ((Arg0 == 0x03) && (Arg1 == 1)) {
Matt DeVillier7d57d562021-04-14 13:15:43 -050039 // Enable hardware touchpad lock, airplane mode, and keyboard backlight keys
40 ECOS = 1
41
42 // Enable software display brightness keys
43 WINF = 1
44
45 // Set current AC state
46 ^^^^AC.ACFG = ADP
47 // Update battery information and status
48 ^^^^BAT0.UPBI()
49 ^^^^BAT0.UPBS()
50
51 // Notify of changes
52 Notify(^^^^AC, Zero)
53 Notify(^^^^BAT0, Zero)
54
55 PNOT ()
56
57 // EC is now available
58 ECOK = Arg1
59
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050060 // Reset Librem EC Device
61 ^^^^LIEC.RSET()
Matt DeVillier7d57d562021-04-14 13:15:43 -050062 }
63 }
64
Matt DeVillier7d57d562021-04-14 13:15:43 -050065 Method (PTS, 1, Serialized) {
Felix Singerdcebf6c2021-12-26 15:24:25 +010066 Printf ("EC: PTS: %o", ToHexString(Arg0))
Matt DeVillier7d57d562021-04-14 13:15:43 -050067 If (ECOK) {
Matt DeVillier7d57d562021-04-14 13:15:43 -050068 // Clear wake cause
69 WFNO = Zero
70 }
71 }
72
73 Method (WAK, 1, Serialized) {
Felix Singerdcebf6c2021-12-26 15:24:25 +010074 Printf ("EC: WAK: %o", ToHexString(Arg0))
Matt DeVillier7d57d562021-04-14 13:15:43 -050075 If (ECOK) {
Matt DeVillier7d57d562021-04-14 13:15:43 -050076 // Set current AC state
77 ^^^^AC.ACFG = ADP
78
79 // Update battery information and status
80 ^^^^BAT0.UPBI()
81 ^^^^BAT0.UPBS()
82
83 // Notify of changes
84 Notify(^^^^AC, Zero)
85 Notify(^^^^BAT0, Zero)
86
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050087 // Reset Librem EC Device
88 ^^^^LIEC.RSET()
Matt DeVillier7d57d562021-04-14 13:15:43 -050089 }
90 }
91
92 Method (_Q0A, 0, NotSerialized) // Touchpad Toggle
93 {
Felix Singerdcebf6c2021-12-26 15:24:25 +010094 Printf ("EC: Touchpad Toggle")
Matt DeVillier7d57d562021-04-14 13:15:43 -050095 }
96
97 Method (_Q0B, 0, NotSerialized) // Screen Toggle
98 {
Felix Singerdcebf6c2021-12-26 15:24:25 +010099 Printf ("EC: Screen Toggle")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500100 }
101
102 Method (_Q0C, 0, NotSerialized) // Mute
103 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100104 Printf ("EC: Mute")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500105 }
106
107 Method (_Q0D, 0, NotSerialized) // Keyboard Backlight
108 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100109 Printf ("EC: Keyboard Backlight")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500110 }
111
112 Method (_Q0E, 0, NotSerialized) // Volume Down
113 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100114 Printf ("EC: Volume Down")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500115 }
116
117 Method (_Q0F, 0, NotSerialized) // Volume Up
118 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100119 Printf ("EC: Volume Up")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500120 }
121
122 Method (_Q10, 0, NotSerialized) // Switch Video Mode
123 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100124 Printf ("EC: Switch Video Mode")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500125 }
126
127 Method (_Q11, 0, NotSerialized) // Brightness Down
128 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100129 Printf ("EC: Brightness Down")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500130 if (^^^^HIDD.HRDY) {
131 ^^^^HIDD.HPEM (20)
132 }
133 }
134
135 Method (_Q12, 0, NotSerialized) // Brightness Up
136 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100137 Printf ("EC: Brightness Up")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500138 if (^^^^HIDD.HRDY) {
139 ^^^^HIDD.HPEM (19)
140 }
141 }
142
143 Method (_Q13, 0, NotSerialized) // Camera Toggle
144 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100145 Printf ("EC: Camera Toggle")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500146 }
147
148 Method (_Q14, 0, NotSerialized) // Airplane Mode
149 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100150 Printf ("EC: Airplane Mode")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500151 if (^^^^HIDD.HRDY) {
152 ^^^^HIDD.HPEM (8)
153 }
154 // TODO: hardware airplane mode
155 }
156
157 Method (_Q15, 0, NotSerialized) // Suspend Button
158 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100159 Printf ("EC: Suspend Button")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500160 Notify (SLPB, 0x80)
161 }
162
163 Method (_Q16, 0, NotSerialized) // AC Detect
164 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100165 Printf ("EC: AC Detect")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500166 ^^^^AC.ACFG = ADP
167 Notify (AC, 0x80) // Status Change
168 If (BAT0)
169 {
170 Notify (^^^^BAT0, 0x81) // Information Change
171 Notify (^^^^BAT0, 0x80) // Status Change
172 }
173 }
174
175 Method (_Q17, 0, NotSerialized) // BAT0 Update
176 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100177 Printf ("EC: BAT0 Update (17)")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500178 Notify (^^^^BAT0, 0x81) // Information Change
179 }
180
181 Method (_Q19, 0, NotSerialized) // BAT0 Update
182 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100183 Printf ("EC: BAT0 Update (19)")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500184 Notify (^^^^BAT0, 0x81) // Information Change
185 }
186
187 Method (_Q1B, 0, NotSerialized) // Lid Close
188 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100189 Printf ("EC: Lid Close")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500190 Notify (LID0, 0x80)
191 }
192
193 Method (_Q1C, 0, NotSerialized) // Thermal Trip
194 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100195 Printf ("EC: Thermal Trip")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500196 /* TODO
197 Notify (\_TZ.TZ0, 0x81) // Thermal Trip Point Change
198 Notify (\_TZ.TZ0, 0x80) // Thermal Status Change
199 */
200 }
201
202 Method (_Q1D, 0, NotSerialized) // Power Button
203 {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100204 Printf ("EC: Power Button")
Matt DeVillier7d57d562021-04-14 13:15:43 -0500205 Notify (PWRB, 0x80)
206 }
207
208 Method (_Q50, 0, NotSerialized) // Other Events
209 {
210 Local0 = OEM4
211 If (Local0 == 0x8A) {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100212 Printf ("EC: White Keyboard Backlight")
Nicole Faerbere00ea2f2021-04-15 05:59:37 -0500213 Notify (^^^^LIEC, 0x80)
Matt DeVillier7d57d562021-04-14 13:15:43 -0500214 } ElseIf (Local0 == 0x9F) {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100215 Printf ("EC: Color Keyboard Toggle")
Nicole Faerbere00ea2f2021-04-15 05:59:37 -0500216 Notify (^^^^LIEC, 0x81)
Matt DeVillier7d57d562021-04-14 13:15:43 -0500217 } ElseIf (Local0 == 0x81) {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100218 Printf ("EC: Color Keyboard Down")
Nicole Faerbere00ea2f2021-04-15 05:59:37 -0500219 Notify (^^^^LIEC, 0x82)
Matt DeVillier7d57d562021-04-14 13:15:43 -0500220 } ElseIf (Local0 == 0x82) {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100221 Printf ("EC: Color Keyboard Up")
Nicole Faerbere00ea2f2021-04-15 05:59:37 -0500222 Notify (^^^^LIEC, 0x83)
Matt DeVillier7d57d562021-04-14 13:15:43 -0500223 } ElseIf (Local0 == 0x80) {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100224 Printf ("EC: Color Keyboard Color Change")
Nicole Faerbere00ea2f2021-04-15 05:59:37 -0500225 Notify (^^^^LIEC, 0x84)
Matt DeVillier7d57d562021-04-14 13:15:43 -0500226 } Else {
Felix Singerdcebf6c2021-12-26 15:24:25 +0100227 Printf ("EC: Other: %o", ToHexString(Local0))
Matt DeVillier7d57d562021-04-14 13:15:43 -0500228 }
229 }
230
Matt DeVillier7d57d562021-04-14 13:15:43 -0500231 #include "battery_thresholds.asl"
Matt DeVillier7d57d562021-04-14 13:15:43 -0500232}