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