1 /* SPDX-License-Identifier: GPL-2.0-only */
3 Field(ERAM, ByteAcc, NoLock, Preserve)
6 B0ST, 4, /* Battery 0 state */
8 B0CH, 1, /* Battery 0 charging */
9 B0DI, 1, /* Battery 0 discharging */
10 B0PR, 1, /* Battery 0 present */
12 B1ST, 4, /* Battery 1 state */
14 B1CH, 1, /* Battery 1 charging, */
15 B1DI, 1, /* Battery 1 discharging,*/
16 B1PR, 1 /* Battery 1 present */
21 Field (ERAM, ByteAcc, NoLock, Preserve)
24 BARC, 16, /* Battery remaining capacity */
25 BAFC, 16, /* Battery full charge capacity */
27 BAPR, 16, /* Battery present rate */
28 BAVO, 16, /* Battery Voltage */
32 Field (ERAM, ByteAcc, NoLock, Preserve)
40 Field (ERAM, ByteAcc, NoLock, Preserve)
43 BADC, 16, /* Design Capacity */
44 BADV, 16, /* Design voltage */
51 /* PAGE == 0x04: Battery type */
52 Field (ERAM, ByteAcc, NoLock, Preserve)
59 /* PAGE == 0x05: Battery OEM information */
60 Field (ERAM, ByteAcc, NoLock, Preserve)
66 /* PAGE == 0x06: Battery name */
67 Field (ERAM, ByteAcc, NoLock, Preserve)
74 * Switches the battery information page (16 bytes ERAM @0xa0) with an
75 * optional compile-time delay.
78 * bit7-4: Battery number
79 * bit3-0: Information page number
81 Method(BPAG, 1, NotSerialized)
84 #ifdef BATTERY_PAGE_DELAY_MS
85 Sleep(BATTERY_PAGE_DELAY_MS)
90 * Arg1: Battery Status Package
94 Method(BSTA, 4, NotSerialized)
100 ^BPAG(Arg0) /* Battery dynamic information */
103 * Present rate is a 16bit signed int, positive while charging
104 * and negative while discharging.
108 If (Arg2) // Charging
114 If (Arg3) // Discharging
117 // Negate present rate
118 Local2 = 0x10000 - Local2
120 Else // Full battery, force to 0
127 * The present rate value must be positive now, if it is not we have an
128 * EC bug or inconsistency and force the value to 0.
130 If (Local2 >= 0x8000) {
139 Arg1 [1] = Local2 / 1000
149 Method(BINF, 2, Serialized)
151 Acquire(ECLK, 0xffff)
152 ^BPAG(1 | Arg1) /* Battery 0 static information */
166 Arg0 [1] = Local1 // Design Capacity
167 Arg0 [2] = Local2 // Last full charge capacity
168 Arg0 [4] = BADV // Design Voltage
169 Local0 = Local2 % 20 // FIXME: Local0 not used
170 Arg0 [5] = Local2 / 20 // Warning capacity
173 Name (SERN, Buffer (0x06) { " " })
179 SERN [Local1] = Local2 + 48
182 Arg0 [10] = SERN // Serial Number
185 Name (TYPE, Buffer() { 0, 0, 0, 0, 0 })
187 Arg0 [11] = TYPE // Battery type
189 Arg0 [12] = BAOE // OEM information
191 Arg0 [9] = BANA // Model number
198 Name (_HID, EisaId ("PNP0C0A"))
200 Name (_PCL, Package () { \_SB })
202 Name (BATS, Package ()
204 0x00, // 0: PowerUnit: Report in mWh
205 0xFFFFFFFF, // 1: Design cap
206 0xFFFFFFFF, // 2: Last full charge cap
207 0x01, // 3: Battery Technology
208 10800, // 4: Design Voltage (mV)
209 0x00, // 5: Warning design capacity
210 200, // 6: Low design capacity
211 1, // 7: granularity1
212 1, // 8: granularity2
213 "", // 9: Model number
214 "", // A: Serial number
215 "", // B: Battery Type
216 "" // C: OEM information
219 Method (_BIF, 0, NotSerialized)
221 Return (BINF(BATS, 0))
224 Name (BATI, Package ()
229 // Bit 2 - critical state
230 0, // Battery present Rate
231 0, // Battery remaining capacity
232 0 // Battery present voltage
235 Method (_BST, 0, NotSerialized)
238 Return (BSTA(0, BATI, B0CH, B0DI))
240 Return (Package () { 0, 0, 0, 0 })
244 Method (_STA, 0, NotSerialized)
256 Name (_HID, EisaId ("PNP0C0A"))
258 Name (_PCL, Package () { \_SB })
260 Name (BATS, Package ()
262 0x00, // 0: PowerUnit: Report in mWh
263 0xFFFFFFFF, // 1: Design cap
264 0xFFFFFFFF, // 2: Last full charge cap
265 0x01, // 3: Battery Technology
266 10800, // 4: Design Voltage (mV)
267 0x00, // 5: Warning design capacity
268 200, // 6: Low design capacity
269 1, // 7: granularity1
270 1, // 8: granularity2
271 "", // 9: Model number
272 "", // A: Serial number
273 "", // B: Battery Type
274 "" // C: OEM information
277 Method (_BIF, 0, NotSerialized)
279 Return (BINF(BATS, 0x10))
282 Name (BATI, Package ()
287 // Bit 2 - critical state
288 0, // Battery present Rate
289 0, // Battery remaining capacity
290 0 // Battery present voltage
293 Method (_BST, 0, NotSerialized)
296 Return (BSTA(0x10, BATI, B1CH, B1DI))
298 Return (Package () { 0, 0, 0, 0 })
302 Method (_STA, 0, NotSerialized)
312 /* Battery 0 critical */
313 Method(_Q24, 0, NotSerialized)
318 /* Battery 1 critical */
319 Method(_Q25, 0, NotSerialized)
324 /* Battery 0 attach/detach */
325 Method(_Q4A, 0, NotSerialized)
330 /* Battery 0 state change */
331 Method(_Q4B, 0, NotSerialized)
336 /* Battery 1 attach/detach */
337 Method(_Q4C, 0, NotSerialized)
342 /* Battery 1 state change */
343 Method(_Q4D, 0, NotSerialized)