1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
/* SPDX-License-Identifier: GPL-2.0-only */
// Scope (EC0)
Device (BATX)
{
Name (_HID, EISAID ("PNP0C0A"))
Name (_UID, 1)
Name (_PCL, Package () { \_SB })
//
// Indicator of BATX attach/detach
// Battery X Information
// Battery X Status
//
Name (BXST, Zero)
//
// Default Static Battery Information
//
Name (PBIF, Package()
{
0, // 0: Power Unit
0xFFFFFFFF, // 1: Design Capacity
0xFFFFFFFF, // 2: Last Full Charge Capacity
1, // 3: Battery Technology(Rechargeable)
10800, // 4: Design Voltage 10.8V
0, // 5: Design capacity of warning
0, // 6: Design capacity of low
1, // 7: Battery capacity granularity 1
1, // 8: Battery capacity granularity 2
"", // 9: Model Number
"", // 10: Serial Number
"", // 11: Battery Type
"" // 12: OEM Infomration
})
Name (PBST, Package ()
{
0x00000000, // Battery State
0xFFFFFFFF, // Battery Present Rate
0xFFFFFFFF, // Battery Remaining Capacity
0xFFFFFFFF, // Battery Present Voltage
})
// Workaround for full battery status, enabled by default
Name (BFWK, One)
// Method to enable full battery workaround
Method (BFWE)
{
BFWK = One
}
// Method to disable full battery workaround
Method (BFWD)
{
BFWK = Zero
}
// Method to wait for EC to be ready after changing the Battery Info ID
// Selector
Method (WAEC)
{
Local0 = 20 // Timeout 100 msec
While (HSID == 0)
{
// EC Is not ready
Sleep (5)
Local0--
If (Local0 == 0)
{
Break
}
}
}
// Battery Slot Status
Method (_STA, 0, Serialized)
{
BXST = MBTS
If (BXST)
{
// Battery is present
Return (0x1F)
}
Else
{
Return (0x0F)
}
}
Method (_BIF, 0, Serialized)
{
// Update fields from EC
//
// Information ID 1 -
//
HIID = One
WAEC ()
//
// Power Unit
// SMART battery : 1 - 10mWh : 0 - mAh
// ACPI spec : 0 - mWh : 1 - mAh
//
Local7 = SBCM
XOr (Local7, One, PBIF[0])
//
// Information ID 0 -
//
HIID = Zero
WAEC ()
//
// Last Full Charge Capacity
//
If (Local7)
{
PBIF[2] = SBFC * 10
}
Else
{
PBIF[2] = SBFC
}
//
// Information ID 2 -
//
HIID = 2
WAEC ()
//
// Design capacity
//
If (Local7)
{
Local0 = SBDC * 10
}
Else
{
Local0 = SBDC
}
PBIF[1] = Local0
//
// Design capacity of High (5%)
// Design capacity of Low (1%)
//
PBIF[5] = Local0 / 20
PBIF[6] = Local0 / 100
//
// Design voltage
//
PBIF[4] = SBDV
//
// Serial Number
//
PBIF[10] = ToHexString (SBSN)
//
// Information ID 4 -
//
HIID = 4
WAEC ()
//
// Battery Type - Device Chemistry
//
PBIF[11] = ToString (Concatenate(SBCH, 0x00))
//
// Information ID 5 -
//
HIID = 5
WAEC ()
//
// OEM Information - Manufacturer Name
//
PBIF[12] = ToString (Concatenate(SBMN, 0x00))
//
// Information ID 6 -
//
HIID = 6
WAEC ()
//
// Model Number - Device Name
//
PBIF[9] = ToString (Concatenate(SBDN, 0x00))
Return (PBIF)
}
Method (_BST, 0, Serialized)
{
// Update Battery First Used Date, if requested
If (BFUD)
{
// TODO: Handle First Used Date Request
//\BFUD()
}
//
// 0: BATTERY STATE
//
// bit 0 = discharging
// bit 1 = charging
// bit 2 = critical level
//
// Get battery state from EC
If (And (HB0S, 0x20))
{
Local0 = 2
}
Else
{
if (And (HB0S, 0x40))
{
Local0 = One
}
Else
{
Local0 = Zero
}
}
// Set critical flag if battery is empty
If (And (HB0S, 0x0F) == 0)
{
Or (Local0, 4, Local0)
}
Local1 = Zero
// Check if AC is present
If (ACPW)
{
// Set only charging/discharging bits
And (Local0, 0x03, Local1)
}
Else
{
// Always discharging when on battery power
Local1 = One
}
// Flag if the battery level is critical
And (Local0, 0x04, Local4)
Or (Local1, Local4, Local1)
PBST[0] = Local1
//
// 1: BATTERY PRESENT RATE/CURRENT
//
Local1 = ECAC
If (Local1 >= 0x8000)
{
If (And (Local0, 1))
{
Local1 = 0x10000 - Local1
}
Else
{
// Error
Local1 = Zero
}
}
Else
{
If (!(AND (Local0, 2)))
{
// Battery is not charging
Local1 = Zero
}
}
XOr (DerefOf (PBIF[0]), One, Local6)
If (Local6)
{
Local1 *= ECVO
Local1 /= 1000
}
PBST[1] = Local1
//
// 2: BATTERY REMAINING CAPACITY
//
// Get Power unit from the battery static information
// SMART battery : 1 - 10mWh : 0 - mAh
// ACPI spec : 0 - mWh : 1 - mAh
If (Local6)
{
Local1 = ECRC * 10
}
Else
{
Local1 = ECRC
}
If (BFWK && ACPW && !Local0)
{
// On AC power and battery is neither charging
// nor discharging. Linux expects a full battery
// to report same capacity as last full charge.
// https://bugzilla.kernel.org/show_bug.cgi?id=12632
// TODO: Is SBRS the "battery gas gauge"?
Local2 = SBRS
// See if within ~3% of full
ShiftRight (Local2, 5, Local3)
If (Local1 > Local2 - Local3 && Local1 < Local2 + Local3)
{
Local1 = Local2
}
}
PBST[2] = Local1
//
// 3: BATTERY PRESENT VOLTAGE
//
PBST[3] = ECVO
Return (PBST)
}
}
|