2 * This file is part of the coreboot project.
4 * Copyright (C) 2013 Google Inc.
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.
21 Name (_HID, EISAID ("PNP0C0A"))
23 Name (_PCL, Package () { \_SB })
26 // Indicator of BATX attach/detach
27 // Battery X Information
33 // Default Static Battery Information
38 0xFFFFFFFF, // 1: Design Capacity
39 0xFFFFFFFF, // 2: Last Full Charge Capacity
40 1, // 3: Battery Technology(Rechargable)
41 10800, // 4: Design Voltage 10.8V
42 0, // 5: Design capacity of warning
43 0, // 6: Design capacity of low
44 1, // 7: Battery capacity granularity 1
45 1, // 8: Battery capacity granularity 2
46 "", // 9: Model Number
47 "", // 10: Serial Number
48 "", // 11: Battery Type
49 "" // 12: OEM Infomration
52 Name (PBST, Package ()
54 0x00000000, // Battery State
55 0xFFFFFFFF, // Battery Present Rate
56 0xFFFFFFFF, // Battery Remaining Capacity
57 0xFFFFFFFF, // Battery Present Voltage
60 // Workaround for full battery status, enabled by default
63 // Method to enable full battery workaround
69 // Method to disable full battery workaround
75 // Method to wait for EC to be ready after changing the Battery Info ID
79 Store (20, Local0) // Timeout 100 msec
80 While (LEqual (HSID, Zero))
85 If (LEqual (Local0, Zero))
92 // Battery Slot Status
93 Method (_STA, 0, Serialized)
107 Method (_BIF, 0, Serialized)
109 // Update fields from EC
112 // Information ID 1 -
119 // SMART battery : 1 - 10mWh : 0 - mAh
120 // ACPI spec : 0 - mWh : 1 - mAh
123 XOr (Local7, One, Index (PBIF, 0))
126 // Information ID 0 -
132 // Last Full Charge Capacity
136 Multiply (SBFC, 10, Index (PBIF, 2))
140 Store (SBFC, Index (PBIF, 2))
144 // Information ID 2 -
154 Multiply (SBDC, 10, Local0)
160 Store (Local0, Index(PBIF, One))
163 // Design capacity of High (5%)
164 // Design capacity of Low (1%)
166 Divide (Local0, 20, Local1, Index (PBIF, 5))
167 Divide (Local0, 100, Local1, Index (PBIF, 6))
172 Store (SBDV, Index (PBIF, 4))
177 Store (ToHexString (SBSN), Index (PBIF, 10))
180 // Information ID 4 -
186 // Battery Type - Device Chemistry
188 Store (ToString (SBCH), Index (PBIF, 11))
191 // Information ID 5 -
197 // OEM Information - Manufacturer Name
199 Store (ToString (SBMN), Index (PBIF, 12))
202 // Information ID 6 -
208 // Model Number - Device Name
210 Store (ToString (SBDN), Index (PBIF, 9))
215 Method (_BST, 0, Serialized)
217 // Update Battery First Used Date, if requested
220 // TODO: Handle First Used Date Request
227 // bit 0 = discharging
229 // bit 2 = critical level
232 // Get battery state from EC
233 If (And (HB0S, 0x20))
239 if (And (HB0S, 0x40))
249 // Set critical flag if battery is empty
250 If (LEqual (And (HB0S, 0x0F), 0))
252 Or (Local0, 4, Local0)
257 // Check if AC is present
260 // Set only charging/discharging bits
261 And (Local0, 0x03, Local1)
265 // Always discharging when on battery power
269 // Flag if the battery level is critical
270 And (Local0, 0x04, Local4)
271 Or (Local1, Local4, Local1)
272 Store (Local1, Index (PBST, 0))
275 // 1: BATTERY PRESENT RATE/CURRENT
278 If (LGreaterEqual (Local1, 0x8000))
282 Subtract (0x10000, Local1, Local1)
292 If (LNot (AND (Local0, 2)))
294 // Battery is not charging
299 XOr (DerefOf (Index (PBIF, Zero)), One, Local6)
303 Multiply (ECVO, Local1, Local1)
304 Divide (Local1, 1000, Local7, Local1)
306 Store (Local1, Index (PBST, One))
309 // 2: BATTERY REMAINING CAPACITY
311 // Get Power unit from the battery static information
312 // SMART battery : 1 - 10mWh : 0 - mAh
313 // ACPI spec : 0 - mWh : 1 - mAh
316 Multiply (ECRC, 10, Local1)
323 If (LAnd (BFWK, LAnd (ACPW, LNot (Local0))))
325 // On AC power and battery is neither charging
326 // nor discharging. Linux expects a full battery
327 // to report same capacity as last full charge.
328 // https://bugzilla.kernel.org/show_bug.cgi?id=12632
329 // TODO: Is SBRS the "battery gas gauge"?
332 // See if within ~3% of full
333 ShiftRight (Local2, 5, Local3)
334 If (LAnd (LGreater (Local1, Subtract (Local2, Local3)),
335 LLess (Local1, Add (Local2, Local3))))
337 Store (Local2, Local1)
340 Store (Local1, Index (PBST, 2))
343 // 3: BATTERY PRESENT VOLTAGE
345 Store (ECVO, Index (PBST, 3))