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
|
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2016 Google Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
Device (BAT)
{
Name (_HID, EisaId ("PNP0C0A"))
Name (_UID, 1)
Name (_PCL, Package () { \_SB })
Name (PBIF, Package () {
0x00000001, /* 0x00: Power Unit: mAh */
0xFFFFFFFF, /* 0x01: Design Capacity */
0xFFFFFFFF, /* 0x02: Last Full Charge Capacity */
0x00000001, /* 0x03: Battery Technology: Rechargeable */
0xFFFFFFFF, /* 0x04: Design Voltage */
0x00000003, /* 0x05: Design Capacity of Warning */
0xFFFFFFFF, /* 0x06: Design Capacity of Low */
0x00000001, /* 0x07: Capacity Granularity 1 */
0x00000001, /* 0x08: Capacity Granularity 2 */
"S10", /* 0x09: Model Number */
"", /* 0x0a: Serial Number */
"LION", /* 0x0b: Battery Type */
"TPS" /* 0x0c: OEM Information */
})
Name (PBIX, Package () {
0x00000000, // 0x00: Revision
0x00000001, // 0x01: Power Unit: mAh
0xFFFFFFFF, // 0x02: Design Capacity
0xFFFFFFFF, // 0x03: Last Full Charge Capacity
0x00000001, // 0x04: Battery Technology: Rechargeable
0xFFFFFFFF, // 0x05: Design Voltage
0x00000003, // 0x06: Design Capacity of Warning
0xFFFFFFFF, // 0x07: Design Capacity of Low
0x00000000, // 0x08: Cycle Count
0x00018000, // 0x09: Measurement Accuracy (98.3%?)
0x000001F4, // 0x0a: Max Sampling Time (500ms)
0x0000000a, // 0x0b: Min Sampling Time (10ms)
0xFFFFFFFF, // 0x0c: Max Averaging Interval
0xFFFFFFFF, // 0x0d: Min Averaging Interval
0x00000001, // 0x0e: Capacity Granularity 1
0x00000001, // 0x0f: Capacity Granularity 2
"S10", // 0x10: Model Number
"", // 0x11: Serial Number
"LION", // 0x12: Battery Type
"TPS" // 0x13: OEM Information
})
Name (PBST, Package () {
0x00000000, /* 0x00: Battery State */
0xFFFFFFFF, /* 0x01: Battery Present Rate */
0xFFFFFFFF, /* 0x02: Battery Remaining Capacity */
0xFFFFFFFF, /* 0x03: Battery Present Voltage */
})
Name (BSTP, Zero)
/* Battery Capacity warning at 15% */
Name (DWRN, 15)
/* Battery Capacity low at 10% */
Name (DLOW, 10)
/* Workaround for full battery status, enabled by default */
Name (BFWK, One)
/* Method to enable full battery workaround */
Method (BFWE)
{
Store (One, BFWK)
}
/* Method to disable full battery workaround */
Method (BFWD)
{
Store (Zero, BFWK)
}
Method (_STA, 0, Serialized)
{
If (BTEX) {
Return (0x1F)
} Else {
Return (0x0F)
}
}
Method (_BIF, 0, Serialized)
{
/* Last Full Charge Capacity */
Store (BTDF, Index (PBIF, 2))
/* Design Voltage */
Store (BTDV, Index (PBIF, 4))
/* Design Capacity */
Store (BTDA, Local0)
Store (Local0, Index (PBIF, 1))
/* Design Capacity of Warning */
Divide (Multiply (Local0, DWRN), 100, , Local2)
Store (Local2, Index (PBIF, 5))
/* Design Capacity of Low */
Divide (Multiply (Local0, DLOW), 100, , Local2)
Store (Local2, Index (PBIF, 6))
Return (PBIF)
}
Method (_BIX, 0, Serialized)
{
/* Last Full Charge Capacity */
Store (BTDF, Index (PBIX, 3))
/* Design Voltage */
Store (BTDV, Index (PBIX, 5))
/* Design Capacity */
Store (BTDA, Local0)
Store (Local0, Index (PBIX, 2))
/* Design Capacity of Warning */
Divide (Multiply (Local0, DWRN), 100, , Local2)
Store (Local2, Index (PBIX, 6))
/* Design Capacity of Low */
Divide (Multiply (Local0, DLOW), 100, , Local2)
Store (Local2, Index (PBIX, 7))
Return (PBIX)
}
Method (_BST, 0, Serialized)
{
/*
* 0: BATTERY STATE
*
* bit 0 = discharging
* bit 1 = charging
* bit 2 = critical level
*/
/* Check if AC is present */
If (ACEX) {
/* Read battery status from EC */
Store (BSTS, Local0)
} Else {
/* Always discharging when on battery power */
Store (0x01, Local0)
}
/* Check for critical battery level */
If (BFCR) {
Or (Local0, 0x04, Local0)
}
Store (Local0, Index (PBST, 0))
/* Notify if battery state has changed since last time */
If (LNotEqual (Local0, BSTP)) {
Store (Local0, BSTP)
Notify (BAT, 0x80)
}
/*
* 1: BATTERY PRESENT RATE
*/
Store (BTPR, Local1)
If (And (Local1, 0x8000)) {
And (Not (Local1), 0x7FFF, Local0)
Increment (Local0)
} Else {
And (Local1, 0x7FFF, Local0)
}
/*
* 2: BATTERY REMAINING CAPACITY
*/
Store (BTRA, Local0)
If (LAnd (BFWK, LAnd (ACEX, LNot (BSTS)))) {
Store (BTDF, Local1)
/* See if within ~6% of full */
ShiftRight (Local1, 4, Local2)
If (LAnd (LGreater (Local0, Subtract (Local1, Local2)),
LLess (Local0, Add (Local1, Local2))))
{
Store (Local1, Local0)
}
}
Store (Local0, Index (PBST, 2))
/*
* 3: BATTERY PRESENT VOLTAGE
*/
Store (BTVO, Index (PBST, 3))
Return (PBST)
}
}
|