| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
/* Arg0: Battery |
| 4 |
* Arg1: Battery Status Package |
| 5 |
* Arg2: charging |
| 6 |
* Arg3: discharging |
| 7 |
*/ |
| 8 |
Method(BSTA, 4, NotSerialized) |
| 9 |
{ |
| 10 |
Acquire(ECLK, 0xffff) |
| 11 |
Local0 = 0 |
| 12 |
|
| 13 |
PAGE = 0 |
| 14 |
|
| 15 |
Local2 = BAPR |
| 16 |
|
| 17 |
if (Arg2) // charging |
| 18 |
{ |
| 19 |
Local0 |= 2 |
| 20 |
|
| 21 |
If (Local2 == 0x8000) { |
| 22 |
Local2 = 0 |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
if (Arg3) // discharging |
| 27 |
{ |
| 28 |
Local0 |= 1 |
| 29 |
Local2 = 0x10000 - Local2 |
| 30 |
} |
| 31 |
|
| 32 |
Arg1[0] = Local0 |
| 33 |
|
| 34 |
PAGE = 0 |
| 35 |
Arg1[2] = BARC |
| 36 |
Arg1[1] = Local2 |
| 37 |
|
| 38 |
PAGE = 0 |
| 39 |
Arg1[3] = BAVO |
| 40 |
Release(ECLK) |
| 41 |
Return (Arg1) |
| 42 |
} |
| 43 |
|
| 44 |
Method(BINF, 2, Serialized) |
| 45 |
{ |
| 46 |
Acquire(ECLK, 0xffff) |
| 47 |
PAGE = 0 |
| 48 |
Local2 = BAFC |
| 49 |
PAGE = 1 |
| 50 |
Local1 = BADC |
| 51 |
|
| 52 |
Arg0[1] = Local1 // Design Capacity |
| 53 |
Arg0[2] = Local2 // Last full charge capacity |
| 54 |
PAGE = 1 |
| 55 |
Arg0[4] = BADV // Design Voltage |
| 56 |
Arg0[5] = Local2 / 20 // Warning capacity |
| 57 |
|
| 58 |
PAGE = 1 |
| 59 |
Local0 = BASN |
| 60 |
Name (SERN, Buffer (0x06) { " " }) |
| 61 |
Local1 = 4 |
| 62 |
While (Local0) |
| 63 |
{ |
| 64 |
Local2 = Local0 |
| 65 |
Local0 /= 0x0A |
| 66 |
Local2 -= (Local0 * 0x0A) |
| 67 |
SERN[Local1] = Local2 + 48 |
| 68 |
Local1-- |
| 69 |
} |
| 70 |
Arg0[10] = SERN // Serial Number |
| 71 |
|
| 72 |
Name (TYPE, Buffer() { 0, 0, 0, 0, 0 }) |
| 73 |
PAGE = 4 |
| 74 |
TYPE = BATY |
| 75 |
Arg0[11] = TYPE // Battery type |
| 76 |
PAGE = 5 |
| 77 |
Arg0[12] = BAOE // OEM information |
| 78 |
PAGE = 2 |
| 79 |
Arg0[9] = BANA // Model number |
| 80 |
Release(ECLK) |
| 81 |
Return (Arg0) |
| 82 |
} |
| 83 |
|
| 84 |
Device (BAT0) |
| 85 |
{ |
| 86 |
Name (_HID, EisaId ("PNP0C0A")) |
| 87 |
Name (_UID, 0x00) |
| 88 |
Name (_PCL, Package () { \_SB }) |
| 89 |
|
| 90 |
Name (BATS, Package () |
| 91 |
{ |
| 92 |
0x00, // 0: PowerUnit: Report in mWh |
| 93 |
0xFFFFFFFF, // 1: Design cap |
| 94 |
0xFFFFFFFF, // 2: Last full charge cap |
| 95 |
0x01, // 3: Battery Technology |
| 96 |
10800, // 4: Design Voltage (mV) |
| 97 |
0x00, // 5: Warning design capacity |
| 98 |
200, // 6: Low design capacity |
| 99 |
1, // 7: granularity1 |
| 100 |
1, // 8: granularity2 |
| 101 |
"", // 9: Model number |
| 102 |
"", // A: Serial number |
| 103 |
"", // B: Battery Type |
| 104 |
"" // C: OEM information |
| 105 |
}) |
| 106 |
|
| 107 |
Method (_BIF, 0, NotSerialized) |
| 108 |
{ |
| 109 |
Return (BINF(BATS, 0)) |
| 110 |
} |
| 111 |
|
| 112 |
Name (BATI, Package () |
| 113 |
{ |
| 114 |
0, // Battery State |
| 115 |
// Bit 0 - discharge |
| 116 |
// Bit 1 - charge |
| 117 |
// Bit 2 - critical state |
| 118 |
0, // Battery present Rate |
| 119 |
0, // Battery remaining capacity |
| 120 |
0 // Battery present voltage |
| 121 |
}) |
| 122 |
|
| 123 |
Method (_BST, 0, NotSerialized) |
| 124 |
{ |
| 125 |
if (B0PR) { |
| 126 |
Return (BSTA(0, BATI, B0CH, B0DI)) |
| 127 |
} else { |
| 128 |
Return (BATS) |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
Method (_STA, 0, NotSerialized) |
| 133 |
{ |
| 134 |
if (B0PR) { |
| 135 |
Return (0x1f) |
| 136 |
} else { |
| 137 |
Return (0x0f) |
| 138 |
} |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
/* Battery attach/detach */ |
| 143 |
Method(_Q40, 0, NotSerialized) |
| 144 |
{ |
| 145 |
Notify(BAT0, 0x81) |
| 146 |
} |
| 147 |
Method(_Q41, 0, NotSerialized) |
| 148 |
{ |
| 149 |
Notify(BAT0, 0x81) |
| 150 |
} |
| 151 |
|
| 152 |
Method(_Q48, 0, NotSerialized) |
| 153 |
{ |
| 154 |
Notify(BAT0, 0x80) |
| 155 |
} |
| 156 |
Method(_Q4C, 0, NotSerialized) |
| 157 |
{ |
| 158 |
Notify(BAT0, 0x80) |
| 159 |
} |