soc/intel/xeon_sp: Allow OS to control LTR and AER
[coreboot2.git] / src / mainboard / purism / librem_jsl / acpi / battery.asl
blob73d5d65c97d6a2ac0c6f0182a6b49d43acf0af42
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 Device (BAT0)
5         Name (_HID, EisaId ("PNP0C0A") /* Control Method Battery */)  // _HID: Hardware ID
6         Name (_UID, Zero)  // _UID: Unique ID
7         Name (_PCL, Package (0x01)  // _PCL: Power Consumer List
8         {
9                 _SB
10         })
12         Name (BTEX, Zero)
14         // Test if EC0 is ready, and if it is, if the battery is present
15         Method (BTOK, 0, NotSerialized)
16         {
17                 If (^^ECOK) {
18                         If (BTEX) {
19                                 Return (One)
20                         }
21                 }
23                 Return (Zero)
24         }
26         Method (_STA, 0, NotSerialized)  // _STA: Status
27         {
28                 If (BTOK ()) {
29                         Printf ("BAT0: _STA: present")
30                         Return (0x1F)
31                 }
33                 Printf ("BAT0: _STA: not present")
34                 Return (0x0F)
35         }
37         Name (PBIF, Package (0x0D)      // Persistent battery information
38         {
39                 One, // 0 - Power Unit - mA/mAh
40                 0xFFFFFFFF, // 1 - Design Capacity
41                 0xFFFFFFFF, // 2 - Last Full Charge Capacity
42                 One, // 3 - Battery Technology
43                 0xFFFFFFFF, // 4 - Design Voltage
44                 Zero, // 5 - Design Capacity of Warning
45                 Zero, // 6 - Design Capacity of Low
46                 Zero, // 7 - Battery Capacity Granularity 1
47                 Zero, // 8 - Battery Capacity Granularity 2
48                 "", // 9 - Model Number
49                 "", // 10 - Serial Number
50                 "", // 11 - Battery Type
51                 "" // 12 - OEM Information
52         })
54         Method (IVBI, 0, NotSerialized) // Set invalid battery information
55         {
56                 PBIF [1] = 0xFFFFFFFF
57                 PBIF [2] = 0xFFFFFFFF
58                 PBIF [5] = Zero
59                 PBIF [6] = Zero
60                 PBIF [7] = Zero
61                 PBIF [8] = Zero
62                 PBIF [9] = ""
63                 PBIF [10] = ""
64                 PBIF [11] = ""
65         }
67         Method (UPBI, 0, Serialized)    // Update battery information
68         {
69                 If (BTOK ()) {
70                         Local0 = ^^BTDC // design cap
71                         Local1 = ^^BTFC // last full capacity
72                         // Design capacity
73                         PBIF [1] = Local0
74                         // Last full charge capacity
75                         PBIF [2] = Local1
76                         // Warn/low capacities - 15% and 10% of design capacity
77                         PBIF [5] = Local1 * 15 / 100
78                         PBIF [6] = Local1 * 10 / 100
79                         // Granularity is 1% of design capacity
80                         PBIF [7] = Local0 / 100
81                         PBIF [8] = Local0 / 100
82                         PBIF [9] = "BAT"
83                         PBIF [10] = "0001"
84                         PBIF [11] = "LION"
85                 }
86                 Else {
87                         IVBI ()
88                 }
89         }
91         Method (_BIF, 0, NotSerialized)  // _BIF: Battery Information
92         {
93                 UPBI ()
94                 Return (PBIF)
95         }
97         Name (PBST, Package (0x04)      // Persistent battery state
98         {
99                 Zero, // 0 - Battery state
100                 0xFFFFFFFF, // 1 - Battery present rate
101                 0xFFFFFFFF, // 2 - Battery remaining capacity
102                 0xFFFFFFFF // 3 - Battery present voltage
103         })
105         Method (IVBS, 0, NotSerialized) // Invalid battery state
106         {
107                 PBST [0] = Zero
108                 PBST [1] = 0xFFFFFFFF
109                 PBST [2] = 0xFFFFFFFF
110                 PBST [3] = 0xFFFFFFFF
111         }
113         Method (UPBS, 0, Serialized)
114         {
115                 If (BTOK ()) {
116                         // Status flags - 3 bits; this EC does not report the
117                         // charge limiting state
118                         PBST [0] = ^^BTST
119                         // Present rate
120                         PBST [1] = ^^BTCR
121                         // Remaining capacity
122                         PBST [2] = ^^BTRC
123                         // Present voltage
124                         PBST [3] = ^^BTVT
125                 }
126                 Else {
127                         IVBS ()
128                 }
129         }
131         Method (_BST, 0, NotSerialized)  // _BST: Battery Status
132         {
133                 UPBS ()
134                 Return (PBST)
135         }