mainboard/intel/avenuecity_crb: Update full IIO configuration
[coreboot2.git] / src / mainboard / roda / rk886ex / acpi / battery.asl
blob8f4f00c751bd6a51340cfd3ad6002d7ab6727937
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 Name(\CBA1, 0x60)
4 Name(\CBA2, 0x60)
6 Device (BAT1)
8         Name(_HID, EisaId("PNP0C0A"))
9         Name(_UID, 1)
11         Name(_PCL, Package(){ _SB })
12         Name(PSTA, 0x1f)
13         Name(PBIF, Package() {
14                 0x00,
15                 0x78,
16                 0x64,
17                 0x01,
18                 0x2b5c, // Capacity?
19                 0x05,
20                 0x03,
21                 0x01,
22                 0x01,
23                 "???",  // Name
24                 "???",  // Number
25                 "???",  // Type
26                 "???"   // Vendor
27         })
28         Name(PBST, Package() { 0x01, 0x16, 0x64, 0x2b5c })
30         /* Status */
31         Method(_STA, 0)
32         {
33                 If(\_SB.PCI0.LPCB.EC0.ECON) {
34                         If(\_SB.PCI0.LPCB.EC0.P62S) {
35                                 Return(0x0f)
36                         } Else {
37                                 Return(0x1f)
38                         }
39                 } Else {
40                         Return(0x0f)
41                 }
42         }
44         /* Battery Info */
45         Method(_BIF, 0)
46         {
47                 If(\_SB.PCI0.LPCB.EC0.ECON) {
48                         If(\_SB.PCI0.LPCB.EC0.P62S) {
49                                 IVBI()
50                                 IVBS()
51                         } Else {
52                                 UPBI()
53                         }
54                 }
56                 Return(PBIF)
57         }
59         /* Battery Status */
60         Method(_BST, 0)
61         {
62                 If(\_SB.PCI0.LPCB.EC0.ECON) {
63                         UPBS()
64                 }
66                 Return(PBST)
67         }
69         /* Update Battery Info */
70         Method(UPBI, 0)
71         {
72                 PBIF [1] = 0x78
73                 PBIF [2] = 0x64
74                 PBIF [4] = 0x2b5c
75                 PBIF [9] = "Bat1"
76                 PBIF [10] = "001"
77                 PBIF [11] = "LION"
78                 PBIF [12] = "Panasonic"
79         }
81         Method(UPBS, 0)
82         {
83                 Local0 = \_SB.PCI0.LPCB.EC0.QEVT
84                 If (~Local0) {
85                         GP38 = 0
86                         Sleep(0x64)
87                         Local0 = GP38
88                         If (~Local0) {
89                                 Local0 = RDW (0x0d)
90                                 If (Local0 != 0xeeee) {
91                                         If (Local0 <= 0x64) {
92                                                 CBA1 = Local0
93                                         }
94                                 }
95                         }
96                 }
98                 Local0 = CBA1
99                 PBST [2] = Local0
100                 PBST [3] = DerefOf (PBIF [4])
101                 Local1 = 0
103                 If (PWRS) {
104                         If (Local0 < 0x64) {
105                                 Local1 = 2
106                         }
107                 } Else {
108                         If (Local0 <= 0x5) {
109                                 Local1 = 4
110                         } Else {
111                                 Local1 = 1
112                         }
113                 }
115                 PBST [0] = Local1
116                 If (\_SB.PCI0.LPCB.EC0.P63S) {
117                         PBST [1] = 0x16
118                 } Else  {
119                         PBST [1] = 0x0b
120                 }
121         }
123         // Invalidate Battery Info
124         Method(IVBI, 0)
125         {
126                 PBIF [1] = 0xffffffff
127                 PBIF [2] = 0xffffffff
128                 PBIF [4] = 0xffffffff
129                 PBIF [9] = "Bad"
130                 PBIF [10] = "Bad"
131                 PBIF [11] = "Bad"
132                 PBIF [12] = "Bad"
133                 PBIF [0] = 1
134         }
136         Method(IVBS, 0)
137         {
138                 PBST [0] = 0
139                 PBST [1] = 0xffffffff
140                 PBST [2] = 0xffffffff
141                 PBST [3] = 0xffffffff
142         }
146 Device (BAT2)
148         Name(_HID, EisaId("PNP0C0A"))
149         Name(_UID, 2)
151         Name(_PCL, Package(){ _SB })
152         Name(PSTA, 0x1f)
153         Name(PBIF, Package() {
154                 0x00,
155                 0x78,
156                 0x64,
157                 0x01,
158                 0x2b5c, // Capacity?
159                 0x05,
160                 0x03,
161                 0x01,
162                 0x01,
163                 "???",  // Name
164                 "???",  // Number
165                 "???",  // Type
166                 "???"   // Vendor
167         })
168         Name(PBST, Package() { 0x01, 0x16, 0x64, 0x2b5c })
170         /* Status */
171         Method(_STA, 0)
172         {
173                 If(\_SB.PCI0.LPCB.EC0.ECON) {
174                         If(\_SB.PCI0.LPCB.EC0.P63S) {
175                                 Return(0x0f)
176                         } Else {
177                                 Return(0x1f)
178                         }
179                 } Else {
180                         Return(0x0f)
181                 }
182         }
184         /* Battery Info */
185         Method(_BIF, 0)
186         {
187                 If(\_SB.PCI0.LPCB.EC0.ECON) {
188                         If(\_SB.PCI0.LPCB.EC0.P63S) {
189                                 IVBI()
190                                 IVBS()
191                         } Else {
192                                 UPBI()
193                         }
194                 }
196                 Return(PBIF)
197         }
199         /* Battery Status */
200         Method(_BST, 0)
201         {
202                 If(\_SB.PCI0.LPCB.EC0.ECON) {
203                         UPBS()
204                 }
206                 Return(PBST)
207         }
209         /* Update Battery Info */
210         Method(UPBI, 0)
211         {
212                 PBIF [1] = 0x78
213                 PBIF [2] = 0x64
214                 PBIF [4] = 0x2b5c
215                 PBIF [9] = "Bat2"
216                 PBIF [10] = "002"
217                 PBIF [11] = "LION"
218                 PBIF [12] = "Panasonic"
219         }
221         Method(UPBS, 0)
222         {
223                 Local0 = \_SB.PCI0.LPCB.EC0.QEVT
224                 If (~Local0) {
225                         GP38 = 0
226                         Sleep(0x64)
227                         Local0 = GP38
228                         If (~Local0) {
229                                 Local0 = RDW (0x0d)
230                                 If (Local0 != 0xeeee) {
231                                         If (Local0 <= 0x64) {
232                                                 CBA2 = Local0
233                                         }
234                                 }
235                         }
236                 }
238                 Local0 = CBA2
239                 PBST [2] = Local0
240                 PBST [3] = DerefOf (PBIF [4])
241                 Local1 = 0
243                 If (PWRS) {
244                         If (Local0 < 0x64) {
245                                 Local1 = 2
246                         }
247                 } Else {
248                         If (Local0 <= 0x5) {
249                                 Local1 = 4
250                         } Else {
251                                 Local1 = 1
252                         }
253                 }
255                 PBST [0] = Local1
256                 If (\_SB.PCI0.LPCB.EC0.P62S) {
257                         PBST [1] = 0x16
258                 } Else  {
259                         PBST [1] = 0x0b
260                 }
261         }
263         // Invalidate Battery Info
264         Method(IVBI, 0)
265         {
266                 PBIF [1] = 0xffffffff
267                 PBIF [2] = 0xffffffff
268                 PBIF [4] = 0xffffffff
269                 PBIF [9] = "Bad"
270                 PBIF [10] = "Bad"
271                 PBIF [11] = "Bad"
272                 PBIF [12] = "Bad"
273                 PBIF [0] = 1
274         }
276         Method(IVBS, 0)
277         {
278                 PBST [0] = 0
279                 PBST [1] = 0xffffffff
280                 PBST [2] = 0xffffffff
281                 PBST [3] = 0xffffffff
282         }
285 Method (RDW, 1)
287         \_SB.PCI0.LPCB.EC0.SMAD = 0x16
288         \_SB.PCI0.LPCB.EC0.SMCM = Arg0
289         \_SB.PCI0.LPCB.EC0.SMPR = 0x09
290         While (\_SB.PCI0.LPCB.EC0.SMPR != 0x00) {
291                 Stall (1)
292         }
294         Return (\_SB.PCI0.LPCB.EC0.SMW0)
297 Device (ADP1)
299         Name (_HID, "ACPI0003")
300         Method (_PSR, 0)
301         {
302                 If (\_SB.PCI0.LPCB.EC0.ECON) {
303                         Local0 = \_SB.PCI0.LPCB.EC0.P60S
304                         If (Local0) {
305                                 PWRS = 0
306                         } Else {
307                                 PWRS = 1
308                         }
309                 }
311                 Stall (0x02)
312                 Return (PWRS)
313         }
315         Method (_PCL, 0)
316         {
317                 Return (_SB)
318         }