blob: 4e8e1cd55fd865a793f6409eac9739334eec7973 [file] [log] [blame]
Angel Pons210a0082020-04-02 23:48:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer020b22a2012-03-30 17:06:43 -07002
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
9Device (EC0)
10{
11 Name (_HID, EISAID ("PNP0C09"))
12 Name (_UID, 1)
13 Name (_GPE, EC_GPE) // GPE for Runtime SCI
14
15 OperationRegion (ERAM, EmbeddedControl, 0x00, 0xff)
16 Field (ERAM, ByteAcc, Lock, Preserve)
17 {
18 Offset (0x80),
19 BTEX, 1, // Battery Exists
20 , 1,
21 ACEX, 1, // AC Exists
22 , 5,
23 Offset (0x83),
24 LIDS, 1, // Lid Switch State
25 , 7,
26 BTST, 8, // Battery State
27 Offset (0xA2),
28 BTRA, 16, // Battery Remaining Capacity
29 BTPR, 16, // Battery Present Rate
30 BTVO, 16, // Battery Present Voltage
31 Offset (0xB0),
32 BTDA, 16, // Battery Design Capacity
33 BTDF, 16, // Battery Last Full Charge Capacity
34 BTDV, 16, // Battery Design Voltage
35 BTDL, 16, // Battery Design Low
36 Offset (0xC0),
37 CPUT, 8, // CPU Temperature
38 Offset (0xCA),
39 FSL0, 1, // Fan Speed Level 0
40 FSL1, 1, // Fan Speed Level 1
41 FSL2, 1, // Fan Speed Level 2
42 FSL3, 1, // Fan Speed Level 3
43 FSL4, 1, // Fan Speed Level 4
44 , 2,
45 FCOS, 1, // Fan Speed OS Control
46 }
47
Matt DeVillieraa95af62017-07-06 17:19:17 -050048 Method (_CRS, 0, Serialized)
Stefan Reinauer020b22a2012-03-30 17:06:43 -070049 {
50 Name (ECMD, ResourceTemplate()
51 {
52 IO (Decode16, 0x62, 0x62, 0, 1)
53 IO (Decode16, 0x66, 0x66, 0, 1)
54 })
55 Return (ECMD)
56 }
57
58 Method (_REG, 2, NotSerialized)
59 {
60 // Initialize AC power state
Felix Singer4da79a72022-12-12 04:57:27 +010061 \PWRS = ACEX
Stefan Reinauer020b22a2012-03-30 17:06:43 -070062
63 // Initialize LID switch state
Felix Singer4da79a72022-12-12 04:57:27 +010064 \LIDS = LIDS
Stefan Reinauer020b22a2012-03-30 17:06:43 -070065
66 // Enable OS control of fan speed
Felix Singerca4b5872022-12-26 08:17:06 +010067 FCOS = 1
Stefan Reinauer020b22a2012-03-30 17:06:43 -070068
69 // Force a read of CPU temperature
Felix Singer4da79a72022-12-12 04:57:27 +010070 Local0 = CPUT
Vladimir Serbinenkob27c24f2016-02-08 00:10:44 +010071 /* So that we don't get a warning that Local0 is unused. */
Felix Singer0e790c62021-12-31 13:57:14 +010072 Local0++
Stefan Reinauer020b22a2012-03-30 17:06:43 -070073 }
74
75 PowerResource (FNP0, 0, 0)
76 {
Matt DeVillieraa95af62017-07-06 17:19:17 -050077 Method (_STA) {
Felix Singercdba42c2022-01-02 03:54:23 +010078 If (\FLVL <= 0) {
Felix Singerca4b5872022-12-26 08:17:06 +010079 Return (1)
Matt DeVillieraa95af62017-07-06 17:19:17 -050080 } Else {
81 Return (Zero)
82 }
83 }
Stefan Reinauer020b22a2012-03-30 17:06:43 -070084 Method (_ON) {
85 If (FCOS) {
Felix Singerca4b5872022-12-26 08:17:06 +010086 FSL0 = 1
Felix Singer4da79a72022-12-12 04:57:27 +010087 \FLVL = 0
Stefan Reinauer020b22a2012-03-30 17:06:43 -070088 Notify (\_TZ.THRM, 0x81)
89 }
90 }
91 Method (_OFF) {
92 If (FCOS) {
Felix Singer4da79a72022-12-12 04:57:27 +010093 FSL0 = Zero
94 \FLVL = 1
Stefan Reinauer020b22a2012-03-30 17:06:43 -070095 Notify (\_TZ.THRM, 0x81)
96 }
97 }
98 }
99
100 PowerResource (FNP1, 0, 0)
101 {
Matt DeVillieraa95af62017-07-06 17:19:17 -0500102 Method (_STA) {
Felix Singercdba42c2022-01-02 03:54:23 +0100103 If (\FLVL <= 1) {
Felix Singerca4b5872022-12-26 08:17:06 +0100104 Return (1)
Matt DeVillieraa95af62017-07-06 17:19:17 -0500105 } Else {
106 Return (Zero)
107 }
108 }
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700109 Method (_ON) {
110 If (FCOS) {
Felix Singerca4b5872022-12-26 08:17:06 +0100111 FSL1 = 1
Felix Singer4da79a72022-12-12 04:57:27 +0100112 \FLVL = 1
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700113 Notify (\_TZ.THRM, 0x81)
114 }
115 }
116 Method (_OFF) {
117 If (FCOS) {
Felix Singer4da79a72022-12-12 04:57:27 +0100118 FSL1 = Zero
119 \FLVL = 2
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700120 Notify (\_TZ.THRM, 0x81)
121 }
122 }
123 }
124
125 PowerResource (FNP2, 0, 0)
126 {
Matt DeVillieraa95af62017-07-06 17:19:17 -0500127 Method (_STA) {
Felix Singercdba42c2022-01-02 03:54:23 +0100128 If (\FLVL <= 2) {
Felix Singerca4b5872022-12-26 08:17:06 +0100129 Return (1)
Matt DeVillieraa95af62017-07-06 17:19:17 -0500130 } Else {
131 Return (Zero)
132 }
133 }
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700134 Method (_ON) {
135 If (FCOS) {
Felix Singerca4b5872022-12-26 08:17:06 +0100136 FSL2 = 1
Felix Singer4da79a72022-12-12 04:57:27 +0100137 \FLVL = 2
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700138 Notify (\_TZ.THRM, 0x81)
139 }
140 }
141 Method (_OFF) {
142 If (FCOS) {
Felix Singer4da79a72022-12-12 04:57:27 +0100143 FSL2 = Zero
144 \FLVL = 3
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700145 Notify (\_TZ.THRM, 0x81)
146 }
147 }
148 }
149
150 PowerResource (FNP3, 0, 0)
151 {
Matt DeVillieraa95af62017-07-06 17:19:17 -0500152 Method (_STA) {
Felix Singercdba42c2022-01-02 03:54:23 +0100153 If (\FLVL <= 3) {
Felix Singerca4b5872022-12-26 08:17:06 +0100154 Return (1)
Matt DeVillieraa95af62017-07-06 17:19:17 -0500155 } Else {
156 Return (Zero)
157 }
158 }
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700159 Method (_ON) {
160 If (FCOS) {
Felix Singerca4b5872022-12-26 08:17:06 +0100161 FSL3 = 1
Felix Singer4da79a72022-12-12 04:57:27 +0100162 \FLVL = 3
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700163 Notify (\_TZ.THRM, 0x81)
164 }
165 }
166 Method (_OFF) {
167 If (FCOS) {
Felix Singer4da79a72022-12-12 04:57:27 +0100168 FSL3 = Zero
169 \FLVL = 4
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700170 Notify (\_TZ.THRM, 0x81)
171 }
172 }
173 }
174
175 PowerResource (FNP4, 0, 0)
176 {
Matt DeVillieraa95af62017-07-06 17:19:17 -0500177 Method (_STA) {
Felix Singercdba42c2022-01-02 03:54:23 +0100178 If (\FLVL <= 4) {
Felix Singerca4b5872022-12-26 08:17:06 +0100179 Return (1)
Matt DeVillieraa95af62017-07-06 17:19:17 -0500180 } Else {
181 Return (Zero)
182 }
Elyes HAOUAS88607a42018-10-05 10:36:45 +0200183 }
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700184 Method (_ON) {
185 If (FCOS) {
Felix Singerca4b5872022-12-26 08:17:06 +0100186 FSL4 = 1
Felix Singer4da79a72022-12-12 04:57:27 +0100187 \FLVL = 4
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700188 Notify (\_TZ.THRM, 0x81)
189 }
190 }
191 Method (_OFF) {
192 If (FCOS) {
Felix Singer4da79a72022-12-12 04:57:27 +0100193 FSL4 = Zero
194 \FLVL = 5
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700195 Notify (\_TZ.THRM, 0x81)
196 }
197 }
198 }
199
200 Device (FAN0)
201 {
202 Name (_HID, EISAID ("PNP0C0B"))
203 Name (_UID, 0)
204 Name (_PR0, Package () { FNP0 })
205 }
206
207 Device (FAN1)
208 {
209 Name (_HID, EISAID ("PNP0C0B"))
210 Name (_UID, 1)
211 Name (_PR0, Package () { FNP1 })
212 }
213
214 Device (FAN2)
215 {
216 Name (_HID, EISAID ("PNP0C0B"))
217 Name (_UID, 2)
218 Name (_PR0, Package () { FNP2 })
219 }
220
221 Device (FAN3)
222 {
223 Name (_HID, EISAID ("PNP0C0B"))
224 Name (_UID, 3)
225 Name (_PR0, Package () { FNP3 })
226 }
227
228 Device (FAN4)
229 {
230 Name (_HID, EISAID ("PNP0C0B"))
231 Name (_UID, 4)
232 Name (_PR0, Package () { FNP4 })
233 }
234
235 // AC Power Connected
236 Method (_Q51, 0, NotSerialized)
237 {
Felix Singerca4b5872022-12-26 08:17:06 +0100238 \PWRS = 1
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700239 Notify (AC, 0x80)
240 \PNOT ()
241 }
242
243 // AC Power Removed
244 Method (_Q52, 0, NotSerialized)
245 {
Felix Singer4da79a72022-12-12 04:57:27 +0100246 \PWRS = Zero
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700247 Notify (AC, 0x80)
248 \PNOT ()
249 }
250
251 // Battery State Change
252 Method (_Q53, 0, NotSerialized)
253 {
254 Notify (BAT0, 0x80)
255 Notify (BAT0, 0x81)
256 }
257
258 // Battery State Change
259 Method (_Q54, 0, NotSerialized)
260 {
261 Notify (BAT0, 0x80)
262 Notify (BAT0, 0x81)
263 }
264
265 // Power State Change
266 Method (_Q55, 0, NotSerialized)
267 {
268 \PNOT ()
269 }
270
271 // Lid Switch Event
272 Method (_Q5E, 0, NotSerialized)
273 {
Felix Singer4da79a72022-12-12 04:57:27 +0100274 \LIDS = LIDS
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700275 Notify (\_SB.LID0, 0x80)
276 }
277
278 // Lid Switch Event
279 Method (_Q5F, 0, NotSerialized)
280 {
Felix Singer4da79a72022-12-12 04:57:27 +0100281 \LIDS = LIDS
Stefan Reinauer020b22a2012-03-30 17:06:43 -0700282 Notify (\_SB.LID0, 0x80)
283 }
284
285 #include "ac.asl"
286 #include "battery.asl"
287}