| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
#define PBST_STATE 0 |
| 4 |
#define PBST_PRESENT_RATE 1 |
| 5 |
#define PBST_REMAINING_CAP 2 |
| 6 |
#define PBST_PRESENT_VOLT 3 |
| 7 |
|
| 8 |
#define PBIX_DESIGN_CAP 2 |
| 9 |
#define PBIX_LAST_FULL_CHG_CAP 3 |
| 10 |
#define PBIX_DESIGN_VOLT 5 |
| 11 |
#define PBIX_DESIGN_CAP_WARN 6 |
| 12 |
#define PBIX_DESIGN_CAP_LOW 7 |
| 13 |
#define PBIX_CYCLE_COUNT 8 |
| 14 |
#define PBIX_MODEL 16 |
| 15 |
#define PBIX_SERIAL 17 |
| 16 |
#define PBIX_TYPE 18 |
| 17 |
#define PBIX_OEM_INFO 19 |
| 18 |
|
| 19 |
Device (BAT0) |
| 20 |
{ |
| 21 |
Name (_HID, EisaId ("PNP0C0A")) |
| 22 |
Name (_UID, 0) |
| 23 |
Name (_PCL, Package () { \_SB }) |
| 24 |
|
| 25 |
Name (BFCC, 0) /* Full Charge Capacity */ |
| 26 |
|
| 27 |
Name (PBST, Package () { |
| 28 |
0, // Battery State |
| 29 |
// [0] : Discharging |
| 30 |
// [1] : Charging |
| 31 |
// [2] : Critical Low |
| 32 |
0, // Battery Present Rate |
| 33 |
0, // Battery Remaining Capacity |
| 34 |
0, // Battery Present Voltage |
| 35 |
}) |
| 36 |
|
| 37 |
Name (PBIX, Package () { |
| 38 |
1, // Revision |
| 39 |
1, // Power Unit (1 = mA(h)) |
| 40 |
0, // Design Capacity |
| 41 |
0, // Last Full Charge Capacity |
| 42 |
1, // Battery Technology (1 = rechargeable) |
| 43 |
0, // Design Voltage |
| 44 |
0, // Design Capacity of Warning |
| 45 |
0, // Design Capacity of Low |
| 46 |
0, // Cycle Count |
| 47 |
95000, // Measurement Accuracy (95 %) |
| 48 |
0, // Max Sampling Time |
| 49 |
0, // Min Sampling Time |
| 50 |
0, // Max Averaging Interval |
| 51 |
0, // Min Averaging Interval |
| 52 |
1, // Battery Capacity Granularity 1 (low < warning) |
| 53 |
1, // Battery Capacity Granularity 2 (warning < full) |
| 54 |
" ", // Model Number |
| 55 |
" ", // Serial Number |
| 56 |
" ", // Battery Type |
| 57 |
" ", // OEM Information |
| 58 |
0, // Battery Swapping Capability (0 = not swappable) |
| 59 |
}) |
| 60 |
|
| 61 |
Method (_STA) |
| 62 |
{ |
| 63 |
Local0 = 0x0f |
| 64 |
|
| 65 |
If (\_SB.PCI0.LPCB.EC0.BAT0) |
| 66 |
{ |
| 67 |
Local0 |= 0x10 /* battery present */ |
| 68 |
} |
| 69 |
|
| 70 |
Return (Local0) |
| 71 |
} |
| 72 |
|
| 73 |
Method (_BST) |
| 74 |
{ |
| 75 |
/* |
| 76 |
* Trigger update of static info update when |
| 77 |
* the last full charge capacity changes. |
| 78 |
* (This is what the vendor does.) |
| 79 |
*/ |
| 80 |
If (BFCC != ToInteger (\_SB.PCI0.LPCB.EC0.BFC0)) |
| 81 |
{ |
| 82 |
Notify (BAT0, 0x81) /* information change */ |
| 83 |
} |
| 84 |
|
| 85 |
/* Convert signed current to absolute value */ |
| 86 |
Local0 = ToInteger (\_SB.PCI0.LPCB.EC0.BPR0) |
| 87 |
If (Local0 & 0x8000) |
| 88 |
{ |
| 89 |
Local0 = (~Local0 & 0xffff) + 1 |
| 90 |
} |
| 91 |
|
| 92 |
PBST [PBST_STATE] = ToInteger (\_SB.PCI0.LPCB.EC0.BST0) |
| 93 |
PBST [PBST_PRESENT_RATE] = Local0 |
| 94 |
PBST [PBST_REMAINING_CAP] = ToInteger (\_SB.PCI0.LPCB.EC0.BRC0) |
| 95 |
PBST [PBST_PRESENT_VOLT] = ToInteger (\_SB.PCI0.LPCB.EC0.BPV0) |
| 96 |
|
| 97 |
Return (PBST) |
| 98 |
} |
| 99 |
|
| 100 |
Method (_BIX) |
| 101 |
{ |
| 102 |
BFCC = ToInteger (\_SB.PCI0.LPCB.EC0.BFC0) |
| 103 |
PBIX [PBIX_DESIGN_CAP] = ToInteger (\_SB.PCI0.LPCB.EC0.BDC0) |
| 104 |
PBIX [PBIX_LAST_FULL_CHG_CAP] = ToInteger (\_SB.PCI0.LPCB.EC0.BFC0) |
| 105 |
PBIX [PBIX_DESIGN_VOLT] = ToInteger (\_SB.PCI0.LPCB.EC0.BDV0) |
| 106 |
PBIX [PBIX_DESIGN_CAP_WARN] = ToInteger (\_SB.PCI0.LPCB.EC0.BCW0) |
| 107 |
PBIX [PBIX_DESIGN_CAP_LOW] = ToInteger (\_SB.PCI0.LPCB.EC0.BCL0) |
| 108 |
PBIX [PBIX_CYCLE_COUNT] = ToInteger (\_SB.PCI0.LPCB.EC0.CYC0) |
| 109 |
PBIX [PBIX_MODEL] = ToBuffer (\_SB.PCI0.LPCB.EC0.BMO0) |
| 110 |
PBIX [PBIX_SERIAL] = ToHexString (\_SB.PCI0.LPCB.EC0.BSN0) |
| 111 |
PBIX [PBIX_TYPE] = ToBuffer (\_SB.PCI0.LPCB.EC0.BTY0) |
| 112 |
PBIX [PBIX_OEM_INFO] = ToBuffer (\_SB.PCI0.LPCB.EC0.BIF0) |
| 113 |
|
| 114 |
Return (PBIX) |
| 115 |
} |
| 116 |
} |