blob: cc12a2a295f618d65ab29a9e3590b67230b16781 [file] [log] [blame]
Angel Pons210a0082020-04-02 23:48:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -08002
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
Christian Walterbe3979c2019-12-18 15:07:59 +01009External (\_SB.CP00._PPC, IntObj)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080010
11Device (EC0)
12{
13 Name (_HID, EISAID ("PNP0C09"))
14 Name (_UID, 1)
Felix Singere2c105e2021-12-30 02:55:21 +010015 Name (_GPE, EC_SCI_GPI + 16) // GPE for Runtime SCI
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080016
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
Martin Rothe18e6422017-06-03 20:03:18 -060053 SSBS, 1, // 1=Standard BIOS, 0=coreboot ; 70h.6
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080054 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
Martin Roth0949e732021-10-01 14:28:22 -060078 MPST, 8, // Maximum P-State ; 82h
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080079 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
Martin Roth8b954f52015-11-23 10:35:11 -0700106 Method (_CRS, 0, Serialized)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800107 {
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
Felix Singer612801d2022-12-12 04:56:53 +0100125 \PWRS = ADPT
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800126
127 // Initialize LID switch state
Felix Singer612801d2022-12-12 04:56:53 +0100128 \LIDS = LIDF
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800129
130 // Force a read of CPU temperature
Felix Singer612801d2022-12-12 04:56:53 +0100131 Local0 = CTMP
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800132
Martin Rothd890b452015-12-10 08:04:44 -0700133 // Use Local0 to avoid iasl warning: Method Local is set but never used
Felix Singer35e65a82022-12-16 07:11:17 +0100134 Local0 &= Ones
Martin Rothd890b452015-12-10 08:04:44 -0700135
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800136 // Find and program number of P-States
Felix Singer612801d2022-12-12 04:56:53 +0100137 MPST = SizeOf (\_SB.CP00._PSS)
Felix Singer58e67892021-12-27 07:17:19 +0100138 Printf ("Programming number of P-states: %o", MPST)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800139
140 // Find and program the current P-State
Felix Singer612801d2022-12-12 04:56:53 +0100141 NPST = \_SB.CP00._PPC
Felix Singer58e67892021-12-27 07:17:19 +0100142 Printf ("Programming Current P-state: %o", NPST)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800143 }
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 {
Felix Singer58e67892021-12-27 07:17:19 +0100164 Printf ("Wifi Button Event 0x07")
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800165 }
166
167 // Thermal Event
168 Method (_Q08)
169 {
Felix Singer58e67892021-12-27 07:17:19 +0100170 Printf ("Thermal Event 0x08")
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800171 Notify(\_TZ.THRM, 0x80)
172 }
173
174 // Pstate Down
175 Method (_Q0E)
176 {
Felix Singer58e67892021-12-27 07:17:19 +0100177 Printf ("Pstate Event 0x0E")
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800178
Felix Singer612801d2022-12-12 04:56:53 +0100179 Local0 = \_SB.CP00._PPC
Felix Singerae2d14b2021-12-30 00:23:46 +0100180 Local1 = PPCM - 1
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800181
Felix Singerd5d4b442022-01-02 01:32:42 +0100182 If(Local0 < Local1) {
Felix Singer70f59e22021-12-31 14:02:52 +0100183 Local0++
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800184 \PPCN ()
185 }
186
Felix Singer612801d2022-12-12 04:56:53 +0100187 NPST = Local0
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800188 }
189
190 // Pstate Up
191 Method (_Q0F)
192 {
Felix Singer58e67892021-12-27 07:17:19 +0100193 Printf ("Pstate Event 0x0F")
Felix Singer612801d2022-12-12 04:56:53 +0100194 Local0 = \_SB.CP00._PPC
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800195
196 If(Local0) {
Felix Singer9f8ce8f2021-12-31 14:16:58 +0100197 Local0--
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800198 \PPCN ()
199 }
200
Felix Singer612801d2022-12-12 04:56:53 +0100201 NPST = Local0
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800202 }
203
204 // AC Power Connected
205 Method (_Q10, 0, NotSerialized)
206 {
Felix Singer58e67892021-12-27 07:17:19 +0100207 Printf ("AC Insertion Event 0x10")
Felix Singerca4b5872022-12-26 08:17:06 +0100208 \PWRS = 1
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800209 Notify (AC, 0x80)
210 Notify (BATX, 0x80)
211 \PNOT ()
212 }
213
214 // AC Power Removed
215 Method (_Q11, 0, NotSerialized)
216 {
Felix Singer58e67892021-12-27 07:17:19 +0100217 Printf ("AC Detach Event 0x11")
Felix Singer612801d2022-12-12 04:56:53 +0100218 \PWRS = Zero
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800219 Notify (AC, 0x80)
220 Notify (BATX, 0x80)
221 \PNOT ()
222 }
223
224 // Battery State Change - Attach Event
225 Method (_Q12, 0, NotSerialized)
226 {
Felix Singer58e67892021-12-27 07:17:19 +0100227 Printf ("Battery Insertion Event 0x12")
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800228
229 Notify (BATX, 0x81)
230 Notify (BATX, 0x80)
231 \PNOT ()
232 }
233
234 // Battery State Change - Detach Event
235 Method (_Q13, 0, NotSerialized)
236 {
Felix Singer58e67892021-12-27 07:17:19 +0100237 Printf ("Battery Detach Event 0x13")
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800238
239 Notify (BATX, 0x81)
240 Notify (BATX, 0x80)
241 \PNOT ()
242 }
243
244
245 // Battery State Change Event
246 Method (_Q14, 0, NotSerialized)
247 {
Felix Singer58e67892021-12-27 07:17:19 +0100248 Printf ("Battery State Change Event 0x14")
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800249
250 Notify (BATX, 0x80)
251 }
252
253 // Lid Switch Event
254 Method (_Q06)
255 {
Felix Singer58e67892021-12-27 07:17:19 +0100256 Printf ("Lid Switch Event 0x06")
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800257 sleep(20)
Felix Singer612801d2022-12-12 04:56:53 +0100258 \LIDS = LIDF
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800259 Notify (\_SB.LID0, 0x80)
260 }
261
262 #include "ac.asl"
263 #include "battery.asl"
264}