| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
Device (BAT) |
| 4 |
{ |
| 5 |
Name (_HID, EisaId ("PNP0C0A")) |
| 6 |
Name (_UID, 1) |
| 7 |
Name (_PCL, Package () { \_SB }) |
| 8 |
|
| 9 |
Name (PBIF, Package () { |
| 10 |
0x00000001, /* 0x00: Power Unit: mAh */ |
| 11 |
0xFFFFFFFF, /* 0x01: Design Capacity */ |
| 12 |
0xFFFFFFFF, /* 0x02: Last Full Charge Capacity */ |
| 13 |
0x00000001, /* 0x03: Battery Technology: Rechargeable */ |
| 14 |
0xFFFFFFFF, /* 0x04: Design Voltage */ |
| 15 |
0x00000003, /* 0x05: Design Capacity of Warning */ |
| 16 |
0xFFFFFFFF, /* 0x06: Design Capacity of Low */ |
| 17 |
0x00000001, /* 0x07: Capacity Granularity 1 */ |
| 18 |
0x00000001, /* 0x08: Capacity Granularity 2 */ |
| 19 |
"S10", /* 0x09: Model Number */ |
| 20 |
"", /* 0x0a: Serial Number */ |
| 21 |
"LION", /* 0x0b: Battery Type */ |
| 22 |
"TPS" /* 0x0c: OEM Information */ |
| 23 |
}) |
| 24 |
|
| 25 |
Name (PBIX, Package () { |
| 26 |
0x00000000, // 0x00: Revision |
| 27 |
0x00000001, // 0x01: Power Unit: mAh |
| 28 |
0xFFFFFFFF, // 0x02: Design Capacity |
| 29 |
0xFFFFFFFF, // 0x03: Last Full Charge Capacity |
| 30 |
0x00000001, // 0x04: Battery Technology: Rechargeable |
| 31 |
0xFFFFFFFF, // 0x05: Design Voltage |
| 32 |
0x00000003, // 0x06: Design Capacity of Warning |
| 33 |
0xFFFFFFFF, // 0x07: Design Capacity of Low |
| 34 |
0x00000000, // 0x08: Cycle Count |
| 35 |
0x00018000, // 0x09: Measurement Accuracy (98.3%?) |
| 36 |
0x000001F4, // 0x0a: Max Sampling Time (500ms) |
| 37 |
0x0000000a, // 0x0b: Min Sampling Time (10ms) |
| 38 |
0xFFFFFFFF, // 0x0c: Max Averaging Interval |
| 39 |
0xFFFFFFFF, // 0x0d: Min Averaging Interval |
| 40 |
0x00000001, // 0x0e: Capacity Granularity 1 |
| 41 |
0x00000001, // 0x0f: Capacity Granularity 2 |
| 42 |
"S10", // 0x10: Model Number |
| 43 |
"", // 0x11: Serial Number |
| 44 |
"LION", // 0x12: Battery Type |
| 45 |
"TPS" // 0x13: OEM Information |
| 46 |
}) |
| 47 |
|
| 48 |
Name (PBST, Package () { |
| 49 |
0x00000000, /* 0x00: Battery State */ |
| 50 |
0xFFFFFFFF, /* 0x01: Battery Present Rate */ |
| 51 |
0xFFFFFFFF, /* 0x02: Battery Remaining Capacity */ |
| 52 |
0xFFFFFFFF, /* 0x03: Battery Present Voltage */ |
| 53 |
}) |
| 54 |
Name (BSTP, 0) |
| 55 |
|
| 56 |
/* Battery Capacity warning at 15% */ |
| 57 |
Name (DWRN, 15) |
| 58 |
|
| 59 |
/* Battery Capacity low at 10% */ |
| 60 |
Name (DLOW, 10) |
| 61 |
|
| 62 |
/* Workaround for full battery status, enabled by default */ |
| 63 |
Name (BFWK, 1) |
| 64 |
|
| 65 |
/* Method to enable full battery workaround */ |
| 66 |
Method (BFWE) |
| 67 |
{ |
| 68 |
BFWK = 1 |
| 69 |
} |
| 70 |
|
| 71 |
/* Method to disable full battery workaround */ |
| 72 |
Method (BFWD) |
| 73 |
{ |
| 74 |
BFWK = 0 |
| 75 |
} |
| 76 |
|
| 77 |
Method (_STA, 0, Serialized) |
| 78 |
{ |
| 79 |
If (BTEX) { |
| 80 |
Return (0x1F) |
| 81 |
} Else { |
| 82 |
Return (0x0F) |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
Method (_BIF, 0, Serialized) |
| 87 |
{ |
| 88 |
/* Last Full Charge Capacity */ |
| 89 |
PBIF [2] = BTDF |
| 90 |
|
| 91 |
/* Design Voltage */ |
| 92 |
PBIF [4] = BTDV |
| 93 |
|
| 94 |
/* Design Capacity */ |
| 95 |
Local0 = BTDA |
| 96 |
PBIF [1] = Local0 |
| 97 |
|
| 98 |
/* Design Capacity of Warning */ |
| 99 |
Local2 = (Local0 * DWRN) / 100 |
| 100 |
PBIF [5] = Local2 |
| 101 |
|
| 102 |
/* Design Capacity of Low */ |
| 103 |
Local2 = (Local0 * DLOW) / 100 |
| 104 |
PBIF [6] = Local2 |
| 105 |
|
| 106 |
Return (PBIF) |
| 107 |
} |
| 108 |
|
| 109 |
Method (_BIX, 0, Serialized) |
| 110 |
{ |
| 111 |
/* Last Full Charge Capacity */ |
| 112 |
PBIX [3] = BTDF |
| 113 |
|
| 114 |
/* Design Voltage */ |
| 115 |
PBIX [5] = BTDV |
| 116 |
|
| 117 |
/* Design Capacity */ |
| 118 |
Local0 = BTDA |
| 119 |
PBIX [2] = Local0 |
| 120 |
|
| 121 |
/* Design Capacity of Warning */ |
| 122 |
Local2 = (Local0 * DWRN) / 100 |
| 123 |
PBIX [6] = Local2 |
| 124 |
|
| 125 |
/* Design Capacity of Low */ |
| 126 |
Local2 = (Local0 * DLOW) / 100 |
| 127 |
PBIX [7] = Local2 |
| 128 |
|
| 129 |
Return (PBIX) |
| 130 |
} |
| 131 |
|
| 132 |
Method (_BST, 0, Serialized) |
| 133 |
{ |
| 134 |
/* |
| 135 |
* 0: BATTERY STATE |
| 136 |
* |
| 137 |
* bit 0 = discharging |
| 138 |
* bit 1 = charging |
| 139 |
* bit 2 = critical level |
| 140 |
*/ |
| 141 |
|
| 142 |
/* Check if AC is present */ |
| 143 |
If (ACEX) { |
| 144 |
/* Read battery status from EC */ |
| 145 |
Local0 = BSTS |
| 146 |
} Else { |
| 147 |
/* Always discharging when on battery power */ |
| 148 |
Local0 = 0x01 |
| 149 |
} |
| 150 |
|
| 151 |
/* Check for critical battery level */ |
| 152 |
If (BFCR) { |
| 153 |
Local0 |= 0x04 |
| 154 |
} |
| 155 |
PBST [0] = Local0 |
| 156 |
|
| 157 |
/* Notify if battery state has changed since last time */ |
| 158 |
If (Local0 != BSTP) { |
| 159 |
BSTP = Local0 |
| 160 |
Notify (BAT, 0x80) |
| 161 |
} |
| 162 |
|
| 163 |
/* |
| 164 |
* 1: BATTERY PRESENT RATE |
| 165 |
*/ |
| 166 |
Local1 = BTPR |
| 167 |
If (Local1 & 0x8000) { |
| 168 |
Local0 = ~Local1 & 0x7FFF |
| 169 |
Local0++ |
| 170 |
} Else { |
| 171 |
Local0 = Local1 & 0x7FFF |
| 172 |
} |
| 173 |
If(Local0 < 0x0352) |
| 174 |
{ |
| 175 |
Local0 = 0x0352 |
| 176 |
} |
| 177 |
PBST [1] = Local0 |
| 178 |
|
| 179 |
/* |
| 180 |
* 2: BATTERY REMAINING CAPACITY |
| 181 |
*/ |
| 182 |
Local0 = BTRA |
| 183 |
If (BFWK && ACEX && !BSTS) { |
| 184 |
Local1 = BTDF |
| 185 |
|
| 186 |
/* See if within ~6% of full */ |
| 187 |
Local2 = Local1 >> 4 |
| 188 |
If ((Local0 > (Local1 - Local2)) && (Local0 < (Local1 + Local2))) |
| 189 |
{ |
| 190 |
Local0 = Local1 |
| 191 |
} |
| 192 |
} |
| 193 |
PBST [2] = Local0 |
| 194 |
|
| 195 |
/* |
| 196 |
* 3: BATTERY PRESENT VOLTAGE |
| 197 |
*/ |
| 198 |
PBST [3] = BTVO |
| 199 |
|
| 200 |
Return (PBST) |
| 201 |
} |
| 202 |
} |