drivers/mipi: Add support for KD_KD110N11_51IE panel
[coreboot2.git] / src / ec / apple / acpi / battery.asl
blob13761b36e62f05bd927eb429f5981133dd541f11
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 Field(ERAM, ByteAcc, NoLock, Preserve)
5         Offset(0x20),
6         SPTR,   8,
7         SSTS,   8,
8         SADR,   8,
9         SCMD,   8,
10         SBFR,   256,
13 Field(ERAM, ByteAcc, Lock, Preserve)
15         Offset(0x24),
16         SBDW,   16,
19 Method(SBPC, 0, NotSerialized)
21         Local0 = 1000
22         While (Local0)
23         {
24                 If (SPTR == 0x00)
25                 {
26                         Return()
27                 }
29                 Sleep(1)
30                 Local0--
31         }
34 Method(SBRW, 2, NotSerialized)
36         Acquire(ECLK, 0xFFFF)
37         SADR = Arg0 << 1
38         SCMD = Arg1
39         SPTR = 0x09
40         SBPC()
41         Local0 = SBDW
42         Release(ECLK)
43         Return(Local0)
46 Method(SBRB, 2, NotSerialized)
48         Acquire(ECLK, 0xFFFF)
49         SADR = Arg0 << 1
50         SCMD = Arg1
51         SPTR = 0x0B
52         SBPC()
53         Local0 = SBFR
54         Release(ECLK)
55         Return(Local0)
58 Device(BAT0)
60         Name(_HID, EisaId("PNP0C0A"))
61         Name(_UID, 0x00)
62         Name(_PCL, Package() { \_SB })
64         Name(BATS, Package()
65         {
66                 0x00,           // 0: PowerUnit: Report in mWh
67                 0xFFFFFFFF,     // 1: Design cap
68                 0xFFFFFFFF,     // 2: Last full charge cap
69                 0x01,           // 3: Battery Technology
70                 10800,          // 4: Design Voltage(mV)
71                 0x00,           // 5: Warning design capacity
72                 200,            // 6: Low design capacity
73                 10,             // 7: granularity1
74                 10,             // 8: granularity2
75                 "",             // 9: Model number
76                 "",             // A: Serial number
77                 "",             // B: Battery Type
78                 ""              // C: OEM information
79         })
81         Name(BATI, Package()
82         {
83                 0, // Battery State
84                    // Bit 0 - discharge
85                    // Bit 1 - charge
86                    // Bit 2 - critical state
87                 0, // Battery present Rate
88                 0, // Battery remaining capacity
89                 0  // Battery present voltage
90         })
92         Method(_BIF, 0, NotSerialized)
93         {
94                 BATS[1] = ^^SBRW(0x0B, 0x18) * 10
95                 BATS[2] = ^^SBRW(0x0B, 0x10) * 10
97                 BATS[4] = ^^SBRW(0x0B, 0x19)
98                 BATS[9] = ^^SBRB(0x0B, 0x21)
99                 BATS[11] = ^^SBRB(0x0B, 0x22)
100                 BATS[12] = ^^SBRB(0x0B, 0x20)
102                 Return(BATS)
103         }
105         Method(_STA, 0, NotSerialized)
106         {
107                 If (^^SBRW(0x0A, 0x01) & 0x01) {
108                         Return(0x1f)
109                 } else {
110                         Return(0x0f)
111                 }
112         }
114         Method(_BST, 0, NotSerialized)
115         {
116                 /* Check for battery presence.  */
117                 If (!(^^SBRW(0x0A, 0x01) & 0x01)) {
118                         Return(Package(4) {
119                                 0,
120                                 0xFFFFFFFF,
121                                 0xFFFFFFFF,
122                                 0xFFFFFFFF
123                         })
124                 }
126                 Local1 = ^^SBRW(0x0B, 0x09)
127                 BATI[3] = Local1
128                 Local0 = ^^SBRW(0x0B, 0x0A)
130                 /* Sign-extend Local0.  */
131                 If (Local0 & 0x8000)
132                 {
133                         Local0 = ~Local0
134                         Local0++
135                         Local0 &= 0xFFFF
136                 }
138                 Local0 *= Local1
139                 BATI[1] = Local0 / 1000
140                 BATI[2] = ^^SBRW(0x0B, 0x0F) * 10
141                 If (HPAC) {
142                         If (!(^^SBRW(0x0B, 0x16) & 0x40)) {
143                                 BATI[0] = 2
144                         } Else {
145                                 BATI[0] = 0
146                         }
147                 } Else {
148                         BATI[0] = 1
149                 }
151                 Return(BATI)
152         }