blob: bcb26bfe80f2ca46877bae23cdba1ff8d4d68907 [file] [log] [blame]
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Stefan Reinauerd6682e82013-02-21 15:39:35 -080014 */
15
16/*
17 * The mainboard must define a PNOT method to handle power
18 * state notifications and Notify CPU device objects to
19 * re-evaluate their _PPC and _CST tables.
20 */
21
Duncan Lauried338b462013-07-31 15:30:41 -070022// Mainboard specific throttle handler
23External (\_TZ.THRT, MethodObj)
Duncan Lauriead8d9132013-12-10 07:41:33 -080024External (\_SB.DPTF.TEVT, MethodObj)
Duncan Laurie3f1500f2014-03-06 08:37:49 -080025External (\_SB.DPTF.TCHG, DeviceObj)
Duncan Lauried338b462013-07-31 15:30:41 -070026
Stefan Reinauerd6682e82013-02-21 15:39:35 -080027Device (EC0)
28{
29 Name (_HID, EISAID ("PNP0C09"))
30 Name (_UID, 1)
Duncan Laurie045222f2013-05-21 07:49:11 -070031 Name (_GPE, EC_SCI_GPI)
Stefan Reinauerd6682e82013-02-21 15:39:35 -080032 Name (TOFS, EC_TEMP_SENSOR_OFFSET)
Duncan Laurie433432b2013-06-03 10:38:22 -070033 Name (TNCA, EC_TEMP_SENSOR_NOT_CALIBRATED)
34 Name (TNOP, EC_TEMP_SENSOR_NOT_POWERED)
35 Name (TBAD, EC_TEMP_SENSOR_ERROR)
36 Name (TNPR, EC_TEMP_SENSOR_NOT_PRESENT)
Stefan Reinauerd6682e82013-02-21 15:39:35 -080037 Name (DWRN, 15) // Battery capacity warning at 15%
38 Name (DLOW, 10) // Battery capacity low at 10%
39
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -070040 OperationRegion (ERAM, EmbeddedControl, 0x00, EC_ACPI_MEM_MAPPED_BEGIN)
Stefan Reinauerd6682e82013-02-21 15:39:35 -080041 Field (ERAM, ByteAcc, Lock, Preserve)
42 {
43 Offset (0x00),
44 RAMV, 8, // EC RAM Version
45 TSTB, 8, // Test Byte
46 TSTC, 8, // Complement of Test Byte
47 KBLV, 8, // Keyboard Backlight
Duncan Lauriead8d9132013-12-10 07:41:33 -080048 FAND, 8, // Set Fan Duty Cycle
Duncan Laurie93e24442014-01-06 12:30:52 -080049 PATI, 8, // Programmable Auxiliary Trip Sensor ID
50 PATT, 8, // Programmable Auxiliary Trip Threshold
51 PATC, 8, // Programmable Auxiliary Trip Commit
Duncan Lauriee6b280e2014-02-10 16:21:05 -080052 CHGL, 8, // Charger Current Limit
Stefan Reinauerd6682e82013-02-21 15:39:35 -080053 }
54
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -070055#if CONFIG_EC_GOOGLE_CHROMEEC_ACPI_MEMMAP
56 OperationRegion (EMEM, EmbeddedControl,
57 EC_ACPI_MEM_MAPPED_BEGIN, EC_ACPI_MEM_MAPPED_SIZE)
58 Field (EMEM, ByteAcc, Lock, Preserve)
59#else
Stefan Reinauerd6682e82013-02-21 15:39:35 -080060 OperationRegion (EMEM, SystemIO, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE)
61 Field (EMEM, ByteAcc, NoLock, Preserve)
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -070062#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -080063 {
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -070064 #include "emem.asl"
Stefan Reinauerd6682e82013-02-21 15:39:35 -080065 }
66
67 Method (TINS, 1, Serialized)
68 {
69 Switch (ToInteger (Arg0))
70 {
71 Case (0) { Return (TIN0) }
72 Case (1) { Return (TIN1) }
73 Case (2) { Return (TIN2) }
74 Case (3) { Return (TIN3) }
75 Case (4) { Return (TIN4) }
76 Case (5) { Return (TIN5) }
77 Case (6) { Return (TIN6) }
78 Case (7) { Return (TIN7) }
79 Case (8) { Return (TIN8) }
80 Case (9) { Return (TIN9) }
81 Default { Return (TIN0) }
82 }
83 }
84
Duncan Laurie20373c02015-09-22 09:40:37 -070085 Method (_CRS, 0, Serialized)
Stefan Reinauerd6682e82013-02-21 15:39:35 -080086 {
87 Name (ECMD, ResourceTemplate()
88 {
89 IO (Decode16,
90 EC_LPC_ADDR_ACPI_DATA,
91 EC_LPC_ADDR_ACPI_DATA,
92 0, 1)
93 IO (Decode16,
94 EC_LPC_ADDR_ACPI_CMD,
95 EC_LPC_ADDR_ACPI_CMD,
96 0, 1)
97 })
98 Return (ECMD)
99 }
100
101 Method (_REG, 2, NotSerialized)
102 {
103 // Initialize AC power state
104 Store (ACEX, \PWRS)
105
106 // Initialize LID switch state
107 Store (LIDS, \LIDS)
108 }
109
Duncan Lauriead8d9132013-12-10 07:41:33 -0800110 /* Read requested temperature and check against EC error values */
111 Method (TSRD, 1, Serialized)
112 {
113 Store (\_SB.PCI0.LPCB.EC0.TINS (Arg0), Local0)
114
115 /* Check for sensor not calibrated */
116 If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNCA)) {
117 Return (Zero)
118 }
119
120 /* Check for sensor not present */
121 If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNPR)) {
122 Return (Zero)
123 }
124
125 /* Check for sensor not powered */
126 If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNOP)) {
127 Return (Zero)
128 }
129
130 /* Check for sensor bad reading */
131 If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TBAD)) {
132 Return (Zero)
133 }
134
135 /* Adjust by offset to get Kelvin */
136 Add (\_SB.PCI0.LPCB.EC0.TOFS, Local0, Local0)
137
138 /* Convert to 1/10 Kelvin */
139 Multiply (Local0, 10, Local0)
140
141 Return (Local0)
142 }
143
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800144 // Lid Closed Event
145 Method (_Q01, 0, NotSerialized)
146 {
147 Store ("EC: LID CLOSE", Debug)
148 Store (LIDS, \LIDS)
149 Notify (\_SB.LID0, 0x80)
150 }
151
152 // Lid Open Event
153 Method (_Q02, 0, NotSerialized)
154 {
155 Store ("EC: LID OPEN", Debug)
156 Store (LIDS, \LIDS)
157 Notify (\_SB.LID0, 0x80)
158 }
159
160 // Power Button
161 Method (_Q03, 0, NotSerialized)
162 {
163 Store ("EC: POWER BUTTON", Debug)
164 Notify (\_SB.PWRB, 0x80)
165 }
166
167 // AC Connected
168 Method (_Q04, 0, NotSerialized)
169 {
170 Store ("EC: AC CONNECTED", Debug)
171 Store (ACEX, \PWRS)
172 Notify (AC, 0x80)
Duncan Laurie3f1500f2014-03-06 08:37:49 -0800173 If (CondRefOf (\_SB.DPTF.TCHG)) {
174 Notify (\_SB.DPTF.TCHG, 0x80)
175 }
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800176 \PNOT ()
177 }
178
179 // AC Disconnected
180 Method (_Q05, 0, NotSerialized)
181 {
182 Store ("EC: AC DISCONNECTED", Debug)
183 Store (ACEX, \PWRS)
184 Notify (AC, 0x80)
Duncan Laurie3f1500f2014-03-06 08:37:49 -0800185 If (CondRefOf (\_SB.DPTF.TCHG)) {
186 Notify (\_SB.DPTF.TCHG, 0x80)
187 }
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800188 \PNOT ()
189 }
190
191 // Battery Low Event
192 Method (_Q06, 0, NotSerialized)
193 {
194 Store ("EC: BATTERY LOW", Debug)
195 Notify (BAT0, 0x80)
196 }
197
198 // Battery Critical Event
199 Method (_Q07, 0, NotSerialized)
200 {
201 Store ("EC: BATTERY CRITICAL", Debug)
202 Notify (BAT0, 0x80)
203 }
204
205 // Battery Info Event
206 Method (_Q08, 0, NotSerialized)
207 {
208 Store ("EC: BATTERY INFO", Debug)
209 Notify (BAT0, 0x81)
210 }
211
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800212 // Thermal Overload Event
213 Method (_Q0A, 0, NotSerialized)
214 {
215 Store ("EC: THERMAL OVERLOAD", Debug)
216 Notify (\_TZ, 0x80)
217 }
218
219 // Thermal Event
220 Method (_Q0B, 0, NotSerialized)
221 {
222 Store ("EC: THERMAL", Debug)
223 Notify (\_TZ, 0x80)
224 }
225
226 // USB Charger
227 Method (_Q0C, 0, NotSerialized)
228 {
229 Store ("EC: USB CHARGER", Debug)
230 }
231
232 // Key Pressed
233 Method (_Q0D, 0, NotSerialized)
234 {
235 Store ("EC: KEY PRESSED", Debug)
236 }
237
Duncan Laurie18d9899b2013-08-28 09:54:04 -0700238 // Thermal Shutdown Imminent
239 Method (_Q10, 0, NotSerialized)
240 {
241 Store ("EC: THERMAL SHUTDOWN", Debug)
242 Notify (\_TZ, 0x80)
243 }
244
245 // Battery Shutdown Imminent
246 Method (_Q11, 0, NotSerialized)
247 {
248 Store ("EC: BATTERY SHUTDOWN", Debug)
249 Notify (BAT0, 0x80)
250 }
251
Duncan Lauried338b462013-07-31 15:30:41 -0700252 // Throttle Start
253 Method (_Q12, 0, NotSerialized)
254 {
255 Store ("EC: THROTTLE START", Debug)
Duncan Laurie20373c02015-09-22 09:40:37 -0700256 If (CondRefOf (\_TZ.THRT)) {
Duncan Lauried338b462013-07-31 15:30:41 -0700257 \_TZ.THRT (1)
258 }
259 }
260
261 // Throttle Stop
262 Method (_Q13, 0, NotSerialized)
263 {
264 Store ("EC: THROTTLE STOP", Debug)
Duncan Laurie20373c02015-09-22 09:40:37 -0700265 If (CondRefOf (\_TZ.THRT)) {
Duncan Lauried338b462013-07-31 15:30:41 -0700266 \_TZ.THRT (0)
267 }
268 }
269
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700270#ifdef EC_ENABLE_PD_MCU_DEVICE
271 // PD event
272 Method (_Q16, 0, NotSerialized)
273 {
274 Store ("EC: GOT PD EVENT", Debug)
275 Notify (ECPD, 0x80)
276 }
277#endif
278
Duncan Lauried8401182014-09-29 08:32:19 -0700279 // Battery Status
280 Method (_Q17, 0, NotSerialized)
281 {
282 Store ("EC: BATTERY STATUS", Debug)
283 Notify (BAT0, 0x80)
284 }
285
Duncan Lauriead8d9132013-12-10 07:41:33 -0800286 /*
287 * Dynamic Platform Thermal Framework support
288 */
289
Duncan Laurie93e24442014-01-06 12:30:52 -0800290 /* Mutex for EC PAT interface */
291 Mutex (PATM, 1)
292
Duncan Lauriead8d9132013-12-10 07:41:33 -0800293 /*
294 * Set Aux Trip Point 0
295 * Arg0 = Temp Sensor ID
296 * Arg1 = Value to set
297 */
298 Method (PAT0, 2, Serialized)
299 {
Duncan Laurie93e24442014-01-06 12:30:52 -0800300 If (Acquire (^PATM, 1000)) {
301 Return (0)
302 }
303
Duncan Laurie93e24442014-01-06 12:30:52 -0800304 /* Set sensor ID */
305 Store (ToInteger (Arg0), ^PATI)
306
Duncan Laurie8be67592014-01-09 10:01:05 -0800307 /* Temperature is passed in 1/10 Kelvin */
Duncan Laurie20373c02015-09-22 09:40:37 -0700308 Divide (ToInteger (Arg1), 10, , Local1)
Duncan Laurie8be67592014-01-09 10:01:05 -0800309
310 /* Adjust by EC temperature offset */
311 Subtract (Local1, ^TOFS, ^PATT)
Duncan Laurie93e24442014-01-06 12:30:52 -0800312
313 /* Set commit value with SELECT=0 and ENABLE=1 */
314 Store (0x02, ^PATC)
315
316 Release (^PATM)
317 Return (1)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800318 }
319
320 /*
321 * Set Aux Trip Point 1
322 * Arg0 = Temp Sensor ID
323 * Arg1 = Value to set
324 */
325 Method (PAT1, 2, Serialized)
326 {
Duncan Laurie93e24442014-01-06 12:30:52 -0800327 If (Acquire (^PATM, 1000)) {
328 Return (0)
329 }
330
Duncan Laurie93e24442014-01-06 12:30:52 -0800331 /* Set sensor ID */
332 Store (ToInteger (Arg0), ^PATI)
333
Duncan Laurie8be67592014-01-09 10:01:05 -0800334 /* Temperature is passed in 1/10 Kelvin */
Duncan Laurie20373c02015-09-22 09:40:37 -0700335 Divide (ToInteger (Arg1), 10, , Local1)
Duncan Laurie8be67592014-01-09 10:01:05 -0800336
337 /* Adjust by EC temperature offset */
338 Subtract (Local1, ^TOFS, ^PATT)
Duncan Laurie93e24442014-01-06 12:30:52 -0800339
340 /* Set commit value with SELECT=1 and ENABLE=1 */
341 Store (0x03, ^PATC)
342
343 Release (^PATM)
344 Return (1)
345 }
346
Duncan Laurie8be67592014-01-09 10:01:05 -0800347 /* Disable Aux Trip Points
348 * Arg0 = Temp Sensor ID
349 */
350 Method (PATD, 1, Serialized)
Duncan Laurie93e24442014-01-06 12:30:52 -0800351 {
352 If (Acquire (^PATM, 1000)) {
353 Return (0)
354 }
355
Duncan Laurie8be67592014-01-09 10:01:05 -0800356 Store (ToInteger (Arg0), ^PATI)
Duncan Laurie93e24442014-01-06 12:30:52 -0800357 Store (0x00, ^PATT)
358
359 /* Disable PAT0 */
360 Store (0x00, ^PATC)
361
362 /* Disable PAT1 */
363 Store (0x01, ^PATC)
364
365 Release (^PATM)
366 Return (1)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800367 }
368
369 /*
Duncan Laurie93e24442014-01-06 12:30:52 -0800370 * Thermal Threshold Event
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800371 */
Duncan Laurie8be67592014-01-09 10:01:05 -0800372 Method (_Q09, 0, NotSerialized)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800373 {
Duncan Laurie93e24442014-01-06 12:30:52 -0800374 If (Acquire (^PATM, 1000)) {
375 Return ()
Duncan Lauriead8d9132013-12-10 07:41:33 -0800376 }
Duncan Laurie93e24442014-01-06 12:30:52 -0800377
Duncan Laurie93e24442014-01-06 12:30:52 -0800378 /* Read sensor ID for event */
379 Store (^PATI, Local0)
380
381 /* When sensor ID returns 0xFF then no more events */
382 While (LNotEqual (Local0, EC_TEMP_SENSOR_NOT_PRESENT))
383 {
Duncan Laurie20373c02015-09-22 09:40:37 -0700384 If (CondRefOf (\_SB.DPTF.TEVT)) {
Aaron Durbinb3ce6582014-05-13 09:23:10 -0500385 \_SB.DPTF.TEVT (Local0)
386 }
387
Duncan Laurie93e24442014-01-06 12:30:52 -0800388 /* Keep reaading sensor ID for event */
389 Store (^PATI, Local0)
390 }
391
392 Release (^PATM)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800393 }
394
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800395 /*
396 * Set Charger Current Limit
397 * Arg0 = Current Limit in 64mA steps
398 */
399 Method (CHGS, 1, Serialized)
400 {
401 Store (ToInteger (Arg0), ^CHGL)
402 }
403
404 /*
405 * Disable Charger Current Limit
406 */
407 Method (CHGD, 0, Serialized)
408 {
409 Store (0xFF, ^CHGL)
410 }
411
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800412 #include "ac.asl"
413 #include "battery.asl"
Duncan Laurie612163eb2014-06-13 10:35:22 -0700414
415#ifdef EC_ENABLE_ALS_DEVICE
416 #include "als.asl"
417#endif
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700418
Duncan Laurieef549a02015-09-01 09:47:55 -0700419#ifdef EC_ENABLE_KEYBOARD_BACKLIGHT
420 #include "keyboard_backlight.asl"
421#endif
422
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700423#ifdef EC_ENABLE_PD_MCU_DEVICE
424 #include "pd.asl"
425#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800426}