blob: 91846f103099de798f2beb9123d115bfba6b147e [file] [log] [blame]
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
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.
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000015 */
16
17Device(EC0)
18{
19 Name (_HID, EISAID("PNP0C09"))
20 Name (_UID, 1)
21
22 Name (_GPE, 23) // GPI07 / GPE23 -> Runtime SCI
23
24 OperationRegion(ERAM, EmbeddedControl, 0x00, 0x37)
25 Field (ERAM, ByteAcc, NoLock, Preserve)
26 {
27 MODE, 1, // Thermal Policy (Quiet/Perform)
28 FAN, 1, // Fan Power (On/Off)
29 LIDS, 1, // LID Status (0=Open/1=Close)
30 LSW0, 1, // LCD Power Switch
31
32 BTYP, 1, // Battery Type (0=LiIon/1=NiMh)
33 MWKE, 1, // Enable Wakeup from RI
34 ADP, 1, // AC Adapter (0=Offline/1=Online)
35 BAT, 1, // Battery (0=Not Present/1=Present)
36 SLPT, 3, // Set Sleep Type on SLP enter (1=S1...4=S4)
37 CHRG, 1, // 0=Battery not charging/1=Battery charging
38 RI_W, 1, // Wake-up event source is RI
39 KB_W, 1, // Wake-up event source is keyboard
40 BATW, 1, // Wake-up event source is Battery Low
41 PMEW, 1, // Wake-up event source is PME
42
43 // Battery 0 Registers
44 // Battery Life = BRC0/BPR0
45 // Battery percentage = BRC0/BFC0 * 100
46 BDC0, 16, // Designed Capacity
47 BFC0, 16, // Last Full Charge Capacity
48 BDV0, 16, // Design Voltage
49 BPR0, 16, // Battery Present Rate
50 BRC0, 16, // Battery Remaining Capacity
51 BPV0, 16, // Battery Present Voltage
52
53 Offset(0x11),
54 CTMP, 8, // CPU Temperature
55 Offset(0x15),
56 CTRO, 8, // EC throttling on trip point
57 CRTT, 8, // Critical Shut-down Temperature
58 Offset(0x17),
59 BKLL, 8, // Backlight Level
60
61 // Battery 2 Registers
62 Offset(0x20),
63 , 4,
64 BTY2, 1, // Battery Type (0=LiIon/1=NiMh)
65 , 2,
66 BAT2, 1, // Battery (0=Not Present/1=Present)
67 , 3,
68 CRG2, 1, // 0=Battery not charging/1=Battery charging
69 Offset(0x22),
70 BDC2, 16, // Designed Capacity
71 BFC2, 16, // Last Full Charge Capacity
72 BDV2, 16, // Design Voltage
73 BPR2, 16, // Battery Present Rate
74 BRC2, 16, // Battery Remaining Capacity
75 BPV2, 16, // Battery Present Voltage
76 BTP2, 16, // Trip Point
77
78 PBMO, 2, // PBMO power control method
79 ECO, 1, // ECO on/off status
80 SUN, 1, // Sunlight Readable
81 RF, 1, // RF Enable/Disable status
82 DOCK, 1, // Dock In/Out status
83 CBAT, 1, // Car Battery status
84 APPS, 1, // OSD utility status
85 Offset(0x33),
86 ODDS, 1
87 }
88
89 Method (_CRS, 0)
90 {
91 Name (ECMD, ResourceTemplate()
92 {
93 IO (Decode16, 0x62, 0x62, 1, 1)
94 IO (Decode16, 0x66, 0x66, 1, 1)
95 })
96
97 Return (ECMD)
98 }
99
100 // EC Query methods, called upon SCI interrupts.
101 Method (_Q01, 0)
102 {
Timothy Pearson033bb4b2015-02-10 22:21:39 -0600103 Notify (\_PR.CP00, 0x80)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000104 If(ADP) {
105 Store(1, \_SB.AC.ACST)
106 TRAP(0xe3)
107 Store(1, PWRS)
108 TRAP(0x2b)
109 } Else {
110 Store(0, \_SB.AC.ACST)
111 Notify(\_SB.AC, 0x80)
112 Notify(\_SB.BAT0, 0x80)
113 Store(0, PWRS)
114 TRAP(0x2b)
115 }
116
117 PNOT()
Vladimir Serbinenko24813c12014-10-16 10:39:06 +0200118 Notify(\_SB.BAT0, 0x80) // Execute BAT0 _BST
119 Notify(\_SB.BAT1, 0x80) // Execute BAT1 _BST
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000120 }
121
122 Method (_Q02, 0)
123 {
124 If(BAT) {
125 Notify(\_SB.BAT0, 0x00)
126 Notify(\_SB.AC, 0x80)
127 } Else {
128 Notify(\_SB.AC, 0x80)
129 Notify(\_SB.BAT0, 0x01)
130 }
131
132 PNOT()
Vladimir Serbinenko24813c12014-10-16 10:39:06 +0200133 Notify(\_SB.BAT0, 0x80) // Execute BAT0 _BST
134 Notify(\_SB.BAT1, 0x80) // Execute BAT1 _BST
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000135 }
136
137 Method (_Q05, 0)
138 {
139 Notify(SLPB, 0x80)
140 PNOT()
Vladimir Serbinenko24813c12014-10-16 10:39:06 +0200141 Notify(\_SB.BAT0, 0x80) // Execute BAT0 _BST
142 Notify(\_SB.BAT1, 0x80) // Execute BAT1 _BST
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000143 }
144
145 Method (_Q07, 0)
146 {
147 TRAP(0xe0)
148
149 If (LEqual(RTCF, 0x00)) {
150 Notify(LID0, 0x80)
151 } else {
152 TRAP(0xc1)
153 }
154 }
Patrick Georgi472efa62012-02-16 20:44:20 +0100155
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000156 Method (_Q09, 0)
157 {
158 Notify(BAT0, 0x80)
159 Notify(BAT1, 0x80)
160 }
161
162 Method (_Q0A, 0)
163 {
164 Notify(\_TZ.THRM, 0x80)
165 }
Patrick Georgi472efa62012-02-16 20:44:20 +0100166
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000167 Method (_Q20, 0)
168 {
169 Notify(\_SB.ECO, 0x81)
170 }
171
172 Method (_Q21, 0)
173 {
174 Notify(\_SB.ECO, 0x82)
175 }
176
177 Method (_Q22, 0)
178 {
179 Notify(\_SB.ECO, 0x83)
180 }
181
182 Method (_Q23, 0)
183 {
184 Notify(\_SB.ECO, 0x84)
185 }
186
187 Method (_Q24, 0)
188 {
189 Store(0x3f, HOTK)
190 If(IGDS) {
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100191 Notify (\_SB.PCI0.GFX0, 0x82)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000192 } Else {
193 TRAP(0xE1)
194 }
195 Notify (\_SB.ECO, 0x85)
196 }
197
198 Method (_Q25, 0)
199 {
200 Store(0x40, HOTK)
201 TRAP(0xe1)
202 Notify(\_SB.ECO, 0x86)
203 }
204
205 Method (_Q26, 0)
206 {
207 Store(0x41, HOTK)
208 TRAP(0xe1)
209 Notify(\_SB.ECO, 0x87)
210 }
211
212 Method (_Q27, 0)
213 {
214 Notify(\_SB.ECO, 0x88)
215 }
216
217 Method (_Q28, 0)
218 {
219 Notify(\_SB.ECO, 0x89)
220 }
221
222 Method (_Q29, 0)
223 {
224 Notify(\_SB.ECO, 0x8a)
225 }
226
227 Method (_Q2A, 0)
228 {
229 Store(0x57, HOTK)
230 TRAP(0xe1)
231 Notify(\_SB.ECO, 0x8b)
232 }
233
234 Method (_Q2B, 0)
235 {
236 Notify(SLPB, 0x80)
237 Notify(\_SB.ECO, 0x8c)
238 }
239
240 Method (_Q2C, 0)
241 {
242 Store(0x59, HOTK)
243 TRAP(0xe1)
244 }
245
246 Method (_Q38, 0)
247 {
248 // IDE TODO
249 }
250
251 Method (_Q39, 0)
252 {
253 // SATA TODO
254 }
255
256 Method (_Q3A, 0)
257 {
258 Store(1, BRTL)
259 Notify(\_SB.ECO, 0x93)
260 }
261
262 Method (_Q3B, 0)
263 {
264 Store(0, BRTL)
265 Notify(\_SB.ECO, 0x93)
266 }
267
268 Method (_Q3C, 0)
269 {
270 Store(1, SUN)
271 Notify(\_SB.ECO, 0x92)
272 }
273
274 Method (_Q3D, 0)
275 {
276 Store(0, SUN)
277 Notify(\_SB.ECO, 0x92)
278 }
279
280 /* Enable RF device */
281 Method (_Q3E, 0)
282 {
283 TRAP(0xdf)
284 }
285
286 /* Disable RF device */
287 Method (_Q3F, 0)
288 {
289 TRAP(0xc0)
290 }
291
292 /* ACBS LAN Power On */
293 Method (_Q40, 0)
294 {
295 TRAP(0xd0)
296 Sleep(500)
297 Notify(RP04, 0)
298 }
299
300 /* ACBS LAN Power Off */
301 Method (_Q41, 0)
302 {
303 TRAP(0xd1)
304 }
305
306 Method (_Q42, 0)
307 {
308 TRAP(0xf3)
309 }
310
311 Method (_Q43, 0)
312 {
313 TRAP(0xf4)
314 }
315
316 Method (_Q48, 0)
317 {
318 TRAP(0xd2) // Check AC Status
319 Store (1, ODDS)
320 Notify(\_SB.ECO, 0x90)
321 }
322
323 Method (_Q49, 0)
324 {
325 TRAP(0xd2) // Check AC Status
326 Store (0, ODDS)
327 Notify(\_SB.ECO, 0x90)
328 }
329
330
331 Method (_Q4C, 0)
332 {
333 Notify(\_SB.ECO, 0x94)
334 }
335
336 Method (_Q4D, 0)
337 {
338 Notify(\_SB.ECO, 0x95)
339 }
340
341 Method (_Q4E, 0)
342 {
343 // PATA TODO
344 }
345
346 Method (_Q4F, 0)
347 {
348 TRAP(0xf9)
349 Notify(\_SB.ECO, 0x95)
350 }
351
352 Method (_Q5C, 0)
353 {
354 // Store(2, IGPS)
355 Notify(\_SB.ECO, 0x94)
356 }
357
358 Method (_Q70, 0)
359 {
360 Notify(\_SB.ECO, 0x96)
361 }
362
363 Method (_Q71, 0)
364 {
365 Notify(\_SB.ECO, 0x97)
366 }
367
368 // TODO Scope _SB devices for AC power, LID, Power button
369}
370
371Scope(\_SB)
372{
373 /* This device is used by the GETAC P470 Windows drivers. */
374
375 Device (ECO)
376 {
377 Name(_HID, "MTC0303") // MTC0303 BIOS Service Provider
378 Method (GDPD, 0, Serialized)
379 {
380 // Set flag byte to zero
381 Store (0, Local0)
382
383 If (And(BRTL, 0x01)) {
384 Or(Local0, 0x01, Local0)
385 }
386
387 If (And(BRTL, 0x02)) {
388 Or(Local0, 0x04, Local0)
389 }
390
391 If (And(BRTL, 0x04)) {
392 Or(Local0, 0x02, Local0)
393 }
394
395 If (And(BRTL, 0x30)) {
396 Or(Local0, 0x10, Local0)
397 }
398
399 If (And(BRTL, 0x40)) {
400 Or(Local0, 0x40, Local0)
401 }
402
403 Return (Local0)
404 }
405
406 Method (GDPC, 0, Serialized)
407 {
408 Store (0, Local0)
409
410 If (And(BRTL, 0x10)) {
411 Or(Local0, 0x04, Local0)
412 }
413
414 If (And( BRTL, 0x20)) {
415 Or(Local0, 0x01, Local0)
416 }
417
418 If (And(BRTL, 0x40)) {
419 Or(Local0, 0x02, Local0)
420 }
421
422 Return (Local0)
423 }
424
425 /* Set Brightness Level */
426 Method(SBLL, 1, Serialized)
427 {
428 Store (Arg0, BRTL)
Patrick Georgi72a2eaf2012-12-19 16:32:47 +0100429 TRAP(0xd5) // See mainboard's smihandler.c
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000430 Return (0)
431 }
432
433 /* Get Brightness Level */
434 Method(GBLL, 0, Serialized)
435 {
Patrick Georgi72a2eaf2012-12-19 16:32:47 +0100436 TRAP(0xd6) // See mainboard's smihandler.c
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000437 Return (BRTL)
438 }
439
440 /* Get Brightness Level Medium? */
441 Method(GBLM, 0, Serialized)
442 {
443 Store(0x3f, BRTL)
444 // XXX don't we have to set the brightness?
445 Return(BRTL)
446 }
447
448 /* ??? */
449 Method(SUTE, 1, Serialized)
450 {
451 If (And(Arg0, 0x01)) {
452 TRAP(0xf5)
453 } Else {
454 TRAP(0xf6)
455 }
456 Return (0)
457 }
458
459 /* ??? */
460 Method(GECO, 0, Serialized)
461 {
462 TRAP(0xd7)
463 Return (ODDS)
464 }
465
466 /* ??? */
467 Method(GBSL, 0, Serialized)
468 {
469 TRAP(0xd8)
470 Return (BRTL)
471 }
472
473 /* ??? Get LED/Device Enable Status */
474 Method(GRFD, 0, Serialized)
475 {
476 /* Let coreboot update the flags */
477 TRAP(0xe5)
478
479 Store (0, Local0)
480 If(And(RFDV, 0x01)) {
481 Or(Local0, 0x01, Local0)
482 }
483 If(And(RFDV, 0x02)) {
484 Or(Local0, 0x02, Local0)
485 }
486 If(And(RFDV, 0x02)) {
487 Or(Local0, 0x02, Local0)
488 }
489 If(And(RFDV, 0x04)) {
490 Or(Local0, 0x04, Local0)
491 }
492 If(And(RFDV, 0x08)) {
493 Or(Local0, 0x08, Local0)
494 }
Sven Schnelle8a539b62011-04-01 07:28:35 +0000495 If(And(GP15, 0x01)) { // GDIS
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000496 Or(Local0, 0x10, Local0)
497 }
Sven Schnelle8a539b62011-04-01 07:28:35 +0000498 If(And(GP12, 0x01)) { // WIFI Led (WLED)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000499 Or(Local0, 0x20, Local0)
500 }
501 If(And(BTEN, 0x01)) { // BlueTooth Enable
502 Or(Local0, 0x40, Local0)
503 }
Sven Schnelle8a539b62011-04-01 07:28:35 +0000504 If(And(GP10, 0x01)) { // GPS Enable
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000505 Or(Local0, 0x80, Local0)
506 }
507
508 Return (Local0)
509 }
510
511 /* Set RFD */
512 Method(SRFD, 1, Serialized)
513 {
514 If (And(Arg0, 0x01)) {
Sven Schnelle8a539b62011-04-01 07:28:35 +0000515 Store (1, GP14) // GLED
516 Store (1, GP15) // GDIS
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000517 } Else {
Sven Schnelle8a539b62011-04-01 07:28:35 +0000518 Store (0, GP14)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000519 Store (0, GP15)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000520 }
521
522 /* WIFI */
523 If (And(Arg0, 0x02)) {
Sven Schnelle8a539b62011-04-01 07:28:35 +0000524 Store (1, GP12) // WLED
525 Store (1, GP25) // WLAN
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000526 } Else {
Sven Schnelle8a539b62011-04-01 07:28:35 +0000527 Store (0, GP12)
528 Store (0, GP25)
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000529 }
530
531 /* Bluetooth */
532 If (And(Arg0, 0x04)) {
Sven Schnelle8a539b62011-04-01 07:28:35 +0000533 Store (1, GP13) // BLED
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000534 Store (1, BTEN)
535 } Else {
Sven Schnelle8a539b62011-04-01 07:28:35 +0000536 Store (0, GP13) // BLED
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000537 Store (0, BTEN)
538 }
539 Return (0)
540 }
541
542 /* Get DKD */
543 Method(GDKD, 0, Serialized)
544 {
545 TRAP(0xd9)
546 Return (BRTL)
547 }
548
549 /* Set DKD */
550 Method(SDKD, 1, Serialized)
551 {
552 TRAP(0xda)
553 Return (0)
554 }
555
556 /* Set IGD (Graphics) */
557 Method(SIGD, 1, Serialized)
558 {
559 If (And(Arg0, 0x01)) {
560 TRAP(0xf7)
561 } Else {
562 TRAP(0xf8)
563 }
564 Return (0)
565 }
566
567 /* SMI-C? Set Mic? */
568 Method (SMIC, 1, Serialized)
569 {
570 If (And(Arg0, 0x01)) {
571 TRAP(0xeb)
572 } Else {
573 TRAP(0xec)
574 }
575 Return (0)
576 }
577
578 /* ??? */
579 Method(GTSD, 0, Serialized)
580 {
Sven Schnelle8a539b62011-04-01 07:28:35 +0000581 Return (GP19) // TSDT
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000582 }
583
584 /* Not even decent function names anymore? */
585 Method(S024, 1, Serialized)
586 {
587 If (And(Arg0, 0x01)) {
588 TRAP(0xf1)
589 } Else {
590 TRAP(0xf2)
591 }
592 Return (0)
593 }
594
595 /* Get CVD */
596 Method(GCVD, 0, Serialized)
597 {
598 TRAP(0xf9)
599 Return (BRTL)
600 }
601
602 /* ??? Something with PATA */
603 Method(S025, 1, Serialized)
604 {
605 If(And(Arg0, 0x01)) {
606 TRAP(0xfc)
607
608 Store (1, GP33) // CREN
609 Sleep(1500)
610
611 Store (1, GP34) // CRRS
612 Sleep(500)
613
614 Notify(^^PCI0.PATA, 0)
615 Notify(^^PCI0.PATA.PRID, 0)
616 } Else {
617 TRAP(0xfb)
618 Sleep(1500)
619 Store(0, GP33) // CREN
620 Sleep(1500)
621 Notify(^^PCI0.PATA, 0)
622 Notify(^^PCI0.PATA.PRID, 0)
623 Notify(^^PCI0.PATA.PRID.DSK1, 1)
624 Notify(^^PCI0.PATA.PRID.DSK0, 1)
625 }
626 Return (0)
627 }
628
629 /* ??? */
630 Method(G021, 0, Serialized)
631 {
632 TRAP(0xfe)
633 If (LEqual(ACIN, 0)) {
634 TRAP(0xfa)
635 TRAP(0xfd)
636 If (LEqual(ODDS, 1)) {
637 TRAP(0xfb)
638 Notify(^^PCI0.PATA, 0)
639 Notify(^^PCI0.PATA.PRID.DSK1, 1)
640 Notify(^^PCI0.PATA.PRID.DSK0, 1)
641 Sleep (1500)
642 Store (0, GP33) // CREN
643 Sleep (1500)
644 Notify(^^PCI0.PATA, 0)
645 Notify(^^PCI0.PATA.PRID.DSK1, 1)
646 Notify(^^PCI0.PATA.PRID.DSK0, 1)
647 Return (0)
648 }
649 }
650 /* All Else Cases */
651 Notify(ECO, 0xb1)
652 Return (1)
653 }
654
655 /* Get RFS */
656 Method(GRFS, 0, Serialized)
657 {
658 TRAP(0xff)
659 Return(BRTL)
660 }
661
662 /* ??? */
663 Method(S00B, 1, Serialized)
664 {
665 If (And(Arg0, 1)) {
666 TRAP(0xdc)
667 } Else {
668 TRAP(0xdd)
669 }
670 Return (0)
671 }
Patrick Georgi472efa62012-02-16 20:44:20 +0100672
673
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +0000674
675 }
676}