Debian Codegraph @

src/ec/quanta/ene_kb3940q/acpi/ec.asl

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 /*
4 * The mainboard must define a PNOT method to handle power
5 * state notifications and Notify CPU device objects to
6 * re-evaluate their _PPC and _CST tables.
7 */
8
9 External (\_SB.CP00._PPC, IntObj)
10
11 Device (EC0)
12 {
13 Name (_HID, EISAID ("PNP0C09"))
14 Name (_UID, 1)
15 Name (_GPE, EC_SCI_GPI + 16) // GPE for Runtime SCI
16
17 OperationRegion (ERAM, EmbeddedControl, 0x00, 0xff)
18 Field (ERAM, ByteAcc, Lock, Preserve)
19 {
20 // EC Name Space Configuration
21
22 Offset(0x40),
23 BDC0, 16, // Batt Design Capacity ; 40h, 41h
24 BDV0, 16, // Batt Design Voltage ; 42h, 43h
25 BFC0, 16, // Batt Last Full Charge Capacity ; 44h, 45h
26 BPC0, 16, // Batt Current ; 46h, 47h
27 BRC0, 16, // Batt Remaining Capacity ; 48h, 49h
28 BPV0, 16, // Batt Present Voltage ; 4Ah, 4Bh
29 BCG0, 16, // Batt Charge current ; 4Ch, 4Dh
30 BACV, 16, // Batt Charging Voltage ; 4Eh, 4Fh
31 BTM0, 16, // Batt Battery Temp ; 50h, 51h
32 BSN0, 16, // Batt Serial Number ; 52h, 53h
33 BPCT, 16, // Batt Percentage of full charge ; 54h, 55h
34 BSSB, 16, // BATT Battery Status SMB ; 56h, 57h
35 CYC0, 16, // Batt Cycle Counter ; 58h, 59h
36 BMD0, 16, // Manufacture Date ; 5Ah, 5Bh
37 // Batt Day ; BIT[4:0] (Day)
38 // Batt Month ; BIT[9:5] (Month)
39 // Batt Year ; BIT[15:10] (Year)
40
41
42 Offset(0x60),
43 BCHM, 32, // Battery Chemistry ; 60h - 64h
44 BATD, 56, // Battery Device name ; 64h - 6Ah
45
46 Offset(0x70),
47 ADPT, 1, // AC Adapter Status for OS ; 70h.0
48 ADPN, 1, // AC Adapter H/W status ; 70h.1
49 BTIN, 1, // Battery Present ; 70h.2
50 BTBD, 1, // Battery Malfunction ; 70h.3
51 ACMD, 1, // ACPI Mode ; 70h.4
52 , 1, // Reserved ; 70h.5
53 SSBS, 1, // 1=Standard BIOS, 0=coreboot ; 70h.6
54 PSTH, 1, // Passive Thermal Policy ; 70h.7
55 BST0, 8, // Battery Status ; 71h
56 // Bit0 : Discharging
57 // Bit1 : Charging
58 // Bit2 : Discharging and Critical Low
59 // Bit3-7 : Reserved
60 LIDF, 1, // Lid is open ; 72h.0
61 GPRC, 1, // Recovery GPI Status ; 72h.1
62 , 6, // Reserved ; 72h.2-7
63 TPLD, 1, // TouchPad LED Activation ; 73h.0
64 TPST, 1, // Touchpad LED Status ; 73h.1
65 , 6, // Reserved ; 73h.2-7
66
67 Offset(0x78),
68 CTMP, 8, // Current CPU Temperature ; 78h
69 SKTB, 8, // GPU Temperature ; 79h
70 LTM1, 8, // Local Temp 1 ; 7Ah
71 LTM2, 8, // Local Temp 2 ; 7Bh
72 FTCH, 16, // Fan Tachometer value ; 7Ch - 7Dh
73 FDBG, 16, // Fan Debug - Override Fan Tach value ; 7Eh - 7Fh
74 , 1, // Reserved ; 80h.0
75 KBID, 1, // 0=EN KBD, 1=JP KBD ; 80h.1
76 , 6, // Reserved ; 80h.2-7
77 NPST, 8, // Number of P-State level ; 81h
78 MPST, 8, // Maximum P-State ; 82h
79 KWAK, 1, // Keyboard WAKE(0=Disable,1=Enable) ; 83h.0
80 TWAK, 1, // TouchPad WAKE(0=Disable,1=Enable) ; 83h.1
81 , 1, // Reserved ; 83h.2
82 LWAK, 1, // LAN Wake Enable (0=Disable, 1=Enable); 83h.3
83 RWAK, 1, // RTC Wake Enable(0=DIsable,1=Enable) ; 83h.4
84 , 3, // Reserved ; 83h.5-7
85 KBEV, 1, // Keyboard Wake Event ; 84h.0
86 TPEV, 1, // TouchPad Wake Event ; 84h.1
87 LDEV, 1, // Lid Wake Event ; 84h.2
88 , 4, // Reserved ; 84h.3-6
89 PBEV, 1, // Power Button Wake Event ; 84h.7
90
91 ECCD, 8, // EC Code State ; 85h
92 ROFW, 8, // RO FW Reason ID ; 86h
93
94 Offset(0xBA),
95 FWVR, 48, // EC Firmware Version ; BAh-BFh
96
97 Offset(0xC0),
98 SMPR, 8, // SMBus protocol register ; C0h
99 SMST, 8, // SMBus status register ; C1h
100 SMAD, 8, // SMBus address register ; C2h
101 SMCM, 8, // SMBus command register ; C3h
102 SMD0, 0x100, // SMBus data regs (32) ; C4h - E3h
103 BCNT, 8, // SMBus Block Count ; E4h
104 }
105
106 Method (_CRS, 0, Serialized)
107 {
108 Name (ECMD, ResourceTemplate()
109 {
110 IO (Decode16, 0x62, 0x62, 0, 1)
111 IO (Decode16, 0x66, 0x66, 0, 1)
112 })
113 Return (ECMD)
114 }
115
116 Method(_STA)
117 {
118 Return(0x0F)
119 }
120
121
122 Method (_REG, 2, NotSerialized)
123 {
124 // Initialize AC power state
125 \PWRS = ADPT
126
127 // Initialize LID switch state
128 \LIDS = LIDF
129
130 // Force a read of CPU temperature
131 Local0 = CTMP
132
133 // Use Local0 to avoid iasl warning: Method Local is set but never used
134 Local0 &= Ones
135
136 // Find and program number of P-States
137 MPST = SizeOf (\_SB.CP00._PSS)
138 Printf ("Programming number of P-states: %o", MPST)
139
140 // Find and program the current P-State
141 NPST = \_SB.CP00._PPC
142 Printf ("Programming Current P-state: %o", NPST)
143 }
144
145 /*
146 * EC Query Responses
147 *
148 * Lid Status Change 06h
149 * Wifi Button Event (F12) 07h
150 * TZ Event Update CPU Temp 08h
151 * CPU P-State Down 0Eh
152 * CPU P-State UP 0Fh
153
154 * AC plug in 10h
155 * AC removed 11h
156 * Battery Plugged in 12h
157 * Battery Removed 13h
158 * Battery State Change 14h
159 */
160
161 // Wifi Button Event
162 Method (_Q07)
163 {
164 Printf ("Wifi Button Event 0x07")
165 }
166
167 // Thermal Event
168 Method (_Q08)
169 {
170 Printf ("Thermal Event 0x08")
171 Notify(\_TZ.THRM, 0x80)
172 }
173
174 // Pstate Down
175 Method (_Q0E)
176 {
177 Printf ("Pstate Event 0x0E")
178
179 Local0 = \_SB.CP00._PPC
180 Local1 = PPCM - 1
181
182 If(Local0 < Local1) {
183 Local0++
184 \PPCN ()
185 }
186
187 NPST = Local0
188 }
189
190 // Pstate Up
191 Method (_Q0F)
192 {
193 Printf ("Pstate Event 0x0F")
194 Local0 = \_SB.CP00._PPC
195
196 If(Local0) {
197 Local0--
198 \PPCN ()
199 }
200
201 NPST = Local0
202 }
203
204 // AC Power Connected
205 Method (_Q10, 0, NotSerialized)
206 {
207 Printf ("AC Insertion Event 0x10")
208 \PWRS = 1
209 Notify (AC, 0x80)
210 Notify (BATX, 0x80)
211 \PNOT ()
212 }
213
214 // AC Power Removed
215 Method (_Q11, 0, NotSerialized)
216 {
217 Printf ("AC Detach Event 0x11")
218 \PWRS = 0
219 Notify (AC, 0x80)
220 Notify (BATX, 0x80)
221 \PNOT ()
222 }
223
224 // Battery State Change - Attach Event
225 Method (_Q12, 0, NotSerialized)
226 {
227 Printf ("Battery Insertion Event 0x12")
228
229 Notify (BATX, 0x81)
230 Notify (BATX, 0x80)
231 \PNOT ()
232 }
233
234 // Battery State Change - Detach Event
235 Method (_Q13, 0, NotSerialized)
236 {
237 Printf ("Battery Detach Event 0x13")
238
239 Notify (BATX, 0x81)
240 Notify (BATX, 0x80)
241 \PNOT ()
242 }
243
244
245 // Battery State Change Event
246 Method (_Q14, 0, NotSerialized)
247 {
248 Printf ("Battery State Change Event 0x14")
249
250 Notify (BATX, 0x80)
251 }
252
253 // Lid Switch Event
254 Method (_Q06)
255 {
256 Printf ("Lid Switch Event 0x06")
257 sleep(20)
258 \LIDS = LIDF
259 Notify (\_SB.LID0, 0x80)
260 }
261
262 #include "ac.asl"
263 #include "battery.asl"
264 }