soc/intel/xeon_sp: Allow OS to control LTR and AER
[coreboot2.git] / src / ec / compal / ene932 / acpi / battery.asl
blobc2adf617360b32bafc6fff98e4451972819f1736
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 // Scope (EC0)
5 Device (BATX)
7         Name (_HID, EISAID ("PNP0C0A"))
8         Name (_UID, 1)
9         Name (_PCL, Package () { \_SB })
11         Name (PBIF, Package () {
12                 0x00000001,  // Power Unit: mAh
13                 0xFFFFFFFF,  // Design Capacity
14                 0xFFFFFFFF,  // Last Full Charge Capacity
15                 0x00000001,  // Battery Technology: Rechargeable
16                 0xFFFFFFFF,  // Design Voltage
17                 0x00000003,  // Design Capacity of Warning
18                 0xFFFFFFFF,  // Design Capacity of Low
19                 0x00000001,  // Capacity Granularity 1
20                 0x00000001,  // Capacity Granularity 2
21                 "",          // Model Number
22                 "",          // Serial Number
23                 "LION",      // Battery Type
24                 ""           // OEM Information
25         })
27         Name (PBST, Package () {
28                 0x00000000,  // Battery State
29                 0xFFFFFFFF,  // Battery Present Rate
30                 0xFFFFFFFF,  // Battery Remaining Capacity
31                 0xFFFFFFFF,  // Battery Present Voltage
32         })
33         Name (BTNM, 0)  // Battery number
35         // Workaround for full battery status, enabled by default
36         Name (BFWK, 1)
38         // Method to enable full battery workaround
39         Method (BFWE)
40         {
41                 BFWK = 1
42         }
44         // Method to disable full battery workaround
45         Method (BFWD)
46         {
47                 BFWK = 0
48         }
50         Method (_STA, 0, Serialized)
51         {
52                 If (BOL0) {
53                         Return (0x1F)
54                 } Else {
55                         Return (0x0F)
56                 }
57         }
59         Method (_BIF, 0, Serialized)
60         {
61                 // Update fields from EC
62                 PBIF [0] = BAM0
63                 PBIF [1] = BDC0
64                 PBIF [2] = BFC0
65                 PBIF [4] = BDV0
66                 Local1 = BFC0 / 100
67                 Local1 *= 10
68                 PBIF [5] = Local1
69                 Local1 = BFC0 / 100
70                 Local1 *= 3
71                 PBIF [6] = Local1
73                 PBIF [9] = ToString (Concatenate (BATD, 0x00))  // model
74                 PBIF [10] = ToHexString (BSN0)  // serial
75                 PBIF [12] = ToString (BMFN)  // vendor
77                 BTNM = BDN0     // Save the battery number
79                 Return (PBIF)
80         }
82         Method (_BST, 0, Serialized)
83         {
84                 //
85                 // 0: BATTERY STATE
86                 //
87                 // bit 0 = discharging
88                 // bit 1 = charging
89                 // bit 2 = critical level
90                 //
92                 // Get battery state from EC and save it for the charging workaround
93                 Local0 = BST0
94                 PBST [0] = Local0
96                 //
97                 // 1: BATTERY PRESENT RATE/CURRENT
98                 //
100                 Local1 = BAC0
101                 Local1 = 0xFFFF - Local1
102                 PBST [1] = Local1
104                 //
105                 // 2: BATTERY REMAINING CAPACITY
106                 //
107                 Local1 = BFC0 * GAU0
108                 Local2 = Local1 % 100
109                 Local1 /= 100
111                 If (BFWK && ADPT && !Local0) {
112                         // On AC power and battery is neither charging
113                         // nor discharging.  Linux expects a full battery
114                         // to report same capacity as last full charge.
115                         // https://bugzilla.kernel.org/show_bug.cgi?id=12632
116                         Local2 = GAU0
118                         // See if within ~3% of full
119                         Local3 = Local2 >> 5
120                         If ((Local1 > (Local2 - Local3)) && (Local1 < (Local2 + Local3)))
121                         {
122                                 Local1 = Local2
123                         }
124                 }
125                 PBST [2] = Local1
127                 //
128                 // 3: BATTERY PRESENT VOLTAGE
129                 //
130                 PBST [3] = BPV0
132                 // Check the Battery Number
133                 If(BDN0 != BTNM) {
134                         Notify(BATX, 0x81)
135                 }
137                 Return (PBST)
138         }