2 * This file is part of the coreboot project.
4 * Copyright (c) 2011 Sven Schnelle <svens@stackframe.org>
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
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.
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,
22 Field(ERAM, ByteAcc, NoLock, Preserve)
25 B0ST, 4, /* Battery 0 state */
27 B0CH, 1, /* Battery 0 charging */
28 B0DI, 1, /* Battery 0 discharging */
29 B0PR, 1, /* Battery 0 present */
31 B1ST, 4, /* Battery 1 state */
33 B1CH, 1, /* Battery 1 charging, */
34 B1DI, 1, /* Battery 1 discharging,*/
35 B1PR, 1 /* Battery 1 present */
40 Field (ERAM, ByteAcc, NoLock, Preserve)
43 BARC, 16, /* Battery remaining capacity */
44 BAFC, 16, /* Battery full charge capacity */
46 BAPR, 16, /* Battery present rate */
47 BAVO, 16, /* Battery Voltage */
51 Field (ERAM, ByteAcc, NoLock, Preserve)
59 Field (ERAM, ByteAcc, NoLock, Preserve)
62 BADC, 16, /* Design Capacity */
63 BADV, 16, /* Design voltage */
70 /* PAGE == 0x04: Battery type */
71 Field (ERAM, ByteAcc, NoLock, Preserve)
78 /* PAGE == 0x05: Battery OEM information */
79 Field (ERAM, ByteAcc, NoLock, Preserve)
85 /* PAGE == 0x06: Battery name */
86 Field (ERAM, ByteAcc, NoLock, Preserve)
93 * Arg1: Battery Status Package
97 Method(BSTA, 4, NotSerialized)
103 Store(Arg0, PAGE) /* Battery dynamic information */
107 if (Arg2) // charging
109 Or(2, Local0, Local0)
111 If (LGreaterEqual (Local2, 0x8000)) {
116 if (Arg3) // discharging
118 Or(1, Local0, Local0)
119 Subtract(0x10000, Local2, Local2)
122 Store(Local0, Index(Arg1, 0x00))
125 Multiply (BARC, 10, Index(Arg1, 2))
126 Multiply (Local2, BAVO, Local2)
127 Divide (Local2, 1000, Local3, Index(Arg1, 1))
129 Store(BARC, Index(Arg1, 2))
130 Store(Local2, Index(Arg1, 1))
132 Store(BAVO, Index(Arg1, 3))
137 Method(BINF, 2, NotSerialized)
139 Acquire(ECLK, 0xffff)
140 Or(1, Arg1, PAGE) /* Battery 0 static information */
141 Xor(BAMA, 1, Index(Arg0, 0))
150 Multiply (Local1, 10, Local1)
151 Multiply (Local2, 10, Local2)
154 Store(Local1, Index(Arg0, 1)) // Design Capacity
155 Store(Local2, Index(Arg0, 2)) // Last full charge capacity
156 Store(BADV, Index(Arg0, 4)) // Design Voltage
157 Divide (Local2, 20, Local0, Index(Arg0, 5)) // Warning capacity
160 Name (SERN, Buffer (0x06) { " " })
164 Divide (Local0, 0x0A, Local2, Local0)
165 Add (Local2, 48, Index (SERN, Local1))
168 Store (SERN, Index (Arg0, 10)) // Serial Number
171 Name (TYPE, Buffer() { 0, 0, 0, 0, 0 })
173 Store(TYPE, Index (Arg0, 11)) // Battery type
175 Store(BAOE, Index (Arg0, 12)) // OEM information
177 Store(BANA, Index (Arg0, 9)) // Model number
184 Name (_HID, EisaId ("PNP0C0A"))
186 Name (_PCL, Package () { \_SB })
188 Name (BATS, Package ()
190 0x00, // 0: PowerUnit: Report in mWh
191 0xFFFFFFFF, // 1: Design cap
192 0xFFFFFFFF, // 2: Last full charge cap
193 0x01, // 3: Battery Technology
194 10800, // 4: Design Voltage (mV)
195 0x00, // 5: Warning design capacity
196 200, // 6: Low design capacity
197 1, // 7: granularity1
198 1, // 8: granularity2
199 "", // 9: Model number
200 "", // A: Serial number
201 "", // B: Battery Type
202 "" // C: OEM information
205 Method (_BIF, 0, NotSerialized)
207 Return (BINF(BATS, 0))
210 Name (BATI, Package ()
215 // Bit 2 - critical state
216 0, // Battery present Rate
217 0, // Battery remaining capacity
218 0 // Battery present voltage
221 Method (_BST, 0, NotSerialized)
224 Return (BSTA(0, BATI, B0CH, B0DI))
230 Method (_STA, 0, NotSerialized)
242 Name (_HID, EisaId ("PNP0C0A"))
244 Name (_PCL, Package () { \_SB })
246 Name (BATS, Package ()
248 0x00, // 0: PowerUnit: Report in mWh
249 0xFFFFFFFF, // 1: Design cap
250 0xFFFFFFFF, // 2: Last full charge cap
251 0x01, // 3: Battery Technology
252 10800, // 4: Design Voltage (mV)
253 0x00, // 5: Warning design capacity
254 200, // 6: Low design capacity
255 1, // 7: granularity1
256 1, // 8: granularity2
257 "", // 9: Model number
258 "", // A: Serial number
259 "", // B: Battery Type
260 "" // C: OEM information
263 Method (_BIF, 0, NotSerialized)
265 Return (BINF(BATS, 0x10))
268 Name (BATI, Package ()
273 // Bit 2 - critical state
274 0, // Battery present Rate
275 0, // Battery remaining capacity
276 0 // Battery present voltage
279 Method (_BST, 0, NotSerialized)
282 Return (BSTA(0x10, BATI, B1CH, B1DI))
288 Method (_STA, 0, NotSerialized)
298 /* Battery 0 critical */
299 Method(_Q24, 0, NotSerialized)
304 /* Battery 1 critical */
305 Method(_Q25, 0, NotSerialized)
310 /* Battery 0 attach/detach */
311 Method(_Q4A, 0, NotSerialized)
316 /* Battery 0 state change */
317 Method(_Q4B, 0, NotSerialized)
322 /* Battery 1 attach/detach */
323 Method(_Q4C, 0, NotSerialized)
328 /* Battery 1 state change */
329 Method(_Q4D, 0, NotSerialized)