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