drivers/mipi: Add support for KD_KD110N11_51IE panel
[coreboot2.git] / src / mainboard / getac / p470 / acpi / battery.asl
blob4eca3f01093c200d810b17dfe817a5a5b8e0a91f
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 Scope(\_SB) {
5         Name(NIMH, "NiMH")
6         Name(LION, "Lion")
8         Device (BAT0)
9         {
10                 Name(_HID, EisaId("PNP0C0A"))
11                 Name(_UID, 1)
13                 Name(_PCL, Package(){ \_SB })
15                 Name(PBST, Package() { 0x00, 0x04b0, 0x0bb8, 0x03e8 })
17                 /* Status */
18                 Method(_STA, 0)
19                 {
20                         Sleep(120)
21                         If (\_SB.PCI0.LPCB.EC0.BAT) {
22                                 Return (0x1f)
23                         } Else {
24                                 Return (0x0f)
25                         }
26                 }
28                 /* Battery Info */
29                 Method(_BIF, 0, Serialized)
30                 {
31                         Name(PBIF, Package() {
32                                 0x01,
33                                 0x0fa0,
34                                 0x0fa0,
35                                 0x01,
36                                 0x2ee0, // Capacity?
37                                 0x012c,
38                                 0x96,
39                                 0x01,
40                                 0x01,
41                                 "Battery",      // Name
42                                 "",             // Number
43                                 "LIon",         // Type
44                                 "Generic"       // Vendor
45                         })
47                         // Is battery there?
48                         Local0 = _STA ()
49                         Local0 &= 0x10
50                         If (!Local0) {
51                                 Return (PBIF)
52                         }
54                         PBIF [1] = \_SB.PCI0.LPCB.EC0.BDC0
55                         PBIF [4] = \_SB.PCI0.LPCB.EC0.BDV0
57                         Local0 = \_SB.PCI0.LPCB.EC0.BFC0
58                         PBIF [2] = Local0
60                         Local2 = Local0 / 10
61                         PBIF [5] = Local2
63                         Local2 = Local0 / 20
64                         PBIF [6] = Local2
66                         If (\_SB.PCI0.LPCB.EC0.BTYP) {
67                                 PBIF [11] = NIMH
68                         } Else {
69                                 PBIF [11] = LION
70                         }
72                         Return (PBIF)
73                 }
75                 /* Battery Status */
76                 Method(_BST, 0)
77                 {
78                         If (\_SB.PCI0.LPCB.EC0.BAT) {
79                                 PBST [3] = \_SB.PCI0.LPCB.EC0.BPV0
81                                 Local3 = \_SB.PCI0.LPCB.EC0.BRC0 * 100
82                                 Local0 = Local3 / \_SB.PCI0.LPCB.EC0.BFC0
83                                 Local3 = \_SB.PCI0.LPCB.EC0.BFC0 * Local0
84                                 Local0 = Local3 / 100
85                                 Local0++
86                                 PBST [2] = Local0
88                                 Local3 = \_SB.PCI0.LPCB.EC0.BRC0
89                                 Local0 = \_SB.PCI0.LPCB.EC0.BPR0
90                                 Local0 = ~Local0 & 0xFFFF
91                                 PBST [1] = Local0
93                                 // AC Power connected?
94                                 If (\_SB.PCI0.LPCB.EC0.ADP) {
95                                         If (\_SB.PCI0.LPCB.EC0.CHRG) {
96                                                 PBST [0] = 2
97                                         } Else {
98                                                 PBST [0] = 0
99                                         }
100                                 } Else {
101                                         If (Local3 < 25) {
102                                                 PBST [0] = 5
103                                         } Else {
104                                                 PBST [0] = 1
105                                         }
106                                 }
107                         }
108                         Return (PBST)
109                 }
110         }
113         Device (BAT1)
114         {
115                 Name(_HID, EisaId("PNP0C0A"))
116                 Name(_UID, 1)
118                 Name(_PCL, Package(){ \_SB })
120                 Name(PBST, Package() { 0x00, 0x04b0, 0x0bb8, 0x03e8 })
122                 /* Status */
123                 Method(_STA, 0)
124                 {
125                         Sleep(120)
126                         If (\_SB.PCI0.LPCB.EC0.BAT2) {
127                                 Return (0x1f)
128                         } Else {
129                                 Return (0x0f)
130                         }
131                 }
133                 /* Battery Info */
134                 Method(_BIF, 0, Serialized)
135                 {
136                         Name(PBIF, Package() {
137                                 0x01,
138                                 0x0fa0,
139                                 0x0fa0,
140                                 0x01,
141                                 0x2ee0, // Capacity?
142                                 0x012c,
143                                 0x96,
144                                 0x01,
145                                 0x01,
146                                 "Battery",      // Name
147                                 "",             // Number
148                                 "LIon",         // Type
149                                 "Generic"       // Vendor
150                         })
152                         // Is battery there?
153                         Local0 = _STA ()
154                         Local0 &= 0x10
155                         If (!Local0) {
156                                 Return (PBIF)
157                         }
159                         PBIF [1] = \_SB.PCI0.LPCB.EC0.BDC2
160                         PBIF [4] = \_SB.PCI0.LPCB.EC0.BDV2
162                         Local0 = \_SB.PCI0.LPCB.EC0.BFC2
163                         PBIF [2] = Local0
165                         Local2 = Local0 / 10
166                         PBIF [5] = Local2
168                         Local2 = Local0 / 20
169                         PBIF [6] = Local2
171                         If (\_SB.PCI0.LPCB.EC0.BTY2) {
172                                 PBIF [11] = NIMH
173                         } Else {
174                                 PBIF [11] = LION
175                         }
177                         Return (PBIF)
178                 }
180                 /* Battery Status */
181                 Method(_BST, 0)
182                 {
183                         If (\_SB.PCI0.LPCB.EC0.BAT2) {
184                                 PBST [3] = \_SB.PCI0.LPCB.EC0.BPV2
186                                 Local3 = \_SB.PCI0.LPCB.EC0.BRC2 * 100
187                                 Local0 = Local3 / \_SB.PCI0.LPCB.EC0.BRC2
188                                 Local3 = \_SB.PCI0.LPCB.EC0.BFC2 * Local0
189                                 Local0 = Local3 / 100
190                                 Local0++
191                                 PBST [2] = Local0
193                                 Local3 = \_SB.PCI0.LPCB.EC0.BRC2
194                                 Local0 = \_SB.PCI0.LPCB.EC0.BPR2
195                                 Local0 = ~Local0 & 0xFFFF
196                                 PBST [1] = Local0
198                                 // AC Power connected?
199                                 If (\_SB.PCI0.LPCB.EC0.ADP) {
200                                         If (\_SB.PCI0.LPCB.EC0.CRG2) {
201                                                 PBST [0] = 2
202                                         } Else {
203                                                 PBST [0] = 0
204                                         }
205                                 } Else {
206                                         If (Local3 < 25) {
207                                                 PBST [0] = 5
208                                         } Else {
209                                                 PBST [0] = 1
210                                         }
211                                 }
212                         }
213                         Return (PBST)
214                 }
215         }
217         Name (PWRS, 0)
218         Name (ACFG, 0)
220         Device (AC)
221         {
222                 Name (_HID, "ACPI0003")
223                 Name (ACST, 0x00)
224                 Method (_PSR, 0)
225                 {
226                         If (ACFG) {
227                                 Local0 = ACST
228                         } Else {
229                                 Local0 = \_SB.PCI0.LPCB.EC0.ADP
230                                 ACST = Local0
231                                 ACFG = 1
232                         }
233                         Sleep(120)
234                         Return (Local0)
235                 }
237                 Name(_PCL, Package(){
238                         \_SB,
239                         BAT0,
240                         BAT1
241                 })
242         }