Combine Broadwell Chromeboxes using variant board scheme
[coreboot.git] / src / mainboard / google / jecht / variants / guado / include / variant / acpi / thermal.asl
blob1cd1b9b713e62b4f188c09fda8ce6087c0e3fa1f
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2014 The Chromium OS Authors. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
16 #include "../thermal.h"
18 // Thermal Zone
20 Scope (\_TZ)
22         ThermalZone (THRM)
23         {
24                 Name (_TC1, 0x02)
25                 Name (_TC2, 0x05)
27                 // Thermal zone polling frequency: 10 seconds
28                 Name (_TZP, 100)
30                 // Thermal sampling period for passive cooling: 2 seconds
31                 Name (_TSP, 20)
33                 // Convert from Degrees C to 1/10 Kelvin for ACPI
34                 Method (CTOK, 1) {
35                         // 10th of Degrees C
36                         Multiply (Arg0, 10, Local0)
38                         // Convert to Kelvin
39                         Add (Local0, 2732, Local0)
41                         Return (Local0)
42                 }
44                 // Threshold for OS to shutdown
45                 Method (_CRT, 0, Serialized)
46                 {
47                         Return (CTOK (\TCRT))
48                 }
50                 // Threshold for passive cooling
51                 Method (_PSV, 0, Serialized)
52                 {
53                         Return (CTOK (\TPSV))
54                 }
56                 // Processors used for passive cooling
57                 Method (_PSL, 0, Serialized)
58                 {
59                         Return (\PPKG ())
60                 }
62                 // Start fan at state 4 = lowest temp state
63                 Method (_INI)
64                 {
65                         Store (4, \FLVL)
66                         Store (FAN4_PWM, \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
67                         Notify (\_TZ.THRM, 0x81)
68                 }
70                 Method (TCHK, 0, Serialized)
71                 {
72                         // Get CPU Temperature from PECI via SuperIO TMPIN3
73                         Store (\_SB.PCI0.LPCB.SIO.ENVC.TIN3, Local0)
75                         // Check for "no reading available
76                         If (LEqual (Local0, 0x80)) {
77                                 Return (CTOK (FAN0_THRESHOLD_ON))
78                         }
80                         // Check for invalid readings
81                         If (LOr (LEqual (Local0, 255), LEqual (Local0, 0))) {
82                                 Return (CTOK (FAN0_THRESHOLD_ON))
83                         }
85                         // PECI raw value is an offset from Tj_max
86                         Subtract (255, Local0, Local1)
88                         // Handle values greater than Tj_max
89                         If (LGreaterEqual (Local1, \TMAX)) {
90                                 Return (CTOK (\TMAX))
91                         }
93                         // Subtract from Tj_max to get temperature
94                         Subtract (\TMAX, Local1, Local0)
95                         Return (CTOK (Local0))
96                 }
98                 Method (_TMP, 0, Serialized)
99                 {
100                         // Get temperature from SuperIO in deci-kelvin
101                         Store (TCHK (), Local0)
103                         // Critical temperature in deci-kelvin
104                         Store (CTOK (\TMAX), Local1)
106                         If (LGreaterEqual (Local0, Local1)) {
107                                 Store ("CRITICAL TEMPERATURE", Debug)
108                                 Store (Local0, Debug)
110                                 // Wait 1 second for SuperIO to re-poll
111                                 Sleep (1000)
113                                 // Re-read temperature from SuperIO
114                                 Store (TCHK (), Local0)
116                                 Store ("RE-READ TEMPERATURE", Debug)
117                                 Store (Local0, Debug)
118                         }
120                         Return (Local0)
121                 }
123                 Method (_AC0) {
124                         If (LLessEqual (\FLVL, 0)) {
125                                 Return (CTOK (FAN0_THRESHOLD_OFF))
126                         } Else {
127                                 Return (CTOK (FAN0_THRESHOLD_ON))
128                         }
129                 }
131                 Method (_AC1) {
132                         If (LLessEqual (\FLVL, 1)) {
133                                 Return (CTOK (FAN1_THRESHOLD_OFF))
134                         } Else {
135                                 Return (CTOK (FAN1_THRESHOLD_ON))
136                         }
137                 }
139                 Method (_AC2) {
140                         If (LLessEqual (\FLVL, 2)) {
141                                 Return (CTOK (FAN2_THRESHOLD_OFF))
142                         } Else {
143                                 Return (CTOK (FAN2_THRESHOLD_ON))
144                         }
145                 }
147                 Method (_AC3) {
148                         If (LLessEqual (\FLVL, 3)) {
149                                 Return (CTOK (FAN3_THRESHOLD_OFF))
150                         } Else {
151                                 Return (CTOK (FAN3_THRESHOLD_ON))
152                         }
153                 }
155                 Method (_AC4) {
156                         If (LLessEqual (\FLVL, 4)) {
157                                 Return (CTOK (0))
158                         } Else {
159                                 Return (CTOK (0))
160                         }
161                 }
163                 Name (_AL0, Package () { FAN0 })
164                 Name (_AL1, Package () { FAN1 })
165                 Name (_AL2, Package () { FAN2 })
166                 Name (_AL3, Package () { FAN3 })
167                 Name (_AL4, Package () { FAN4 })
169                 PowerResource (FNP0, 0, 0)
170                 {
171                         Method (_STA) {
172                                 If (LLessEqual (\FLVL, 0)) {
173                                         Return (One)
174                                 } Else {
175                                         Return (Zero)
176                                 }
177                         }
178                         Method (_ON)  {
179                                 If (LNot (_STA ())) {
180                                         Store (0, \FLVL)
181                                         Store (FAN0_PWM,
182                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
183                                         Notify (\_TZ.THRM, 0x81)
184                                 }
185                         }
186                         Method (_OFF) {
187                                 If (_STA ()) {
188                                         Store (1, \FLVL)
189                                         Store (FAN1_PWM,
190                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
191                                         Notify (\_TZ.THRM, 0x81)
192                                 }
193                         }
194                 }
196                 PowerResource (FNP1, 0, 0)
197                 {
198                         Method (_STA) {
199                                 If (LLessEqual (\FLVL, 1)) {
200                                         Return (One)
201                                 } Else {
202                                         Return (Zero)
203                                 }
204                         }
205                         Method (_ON)  {
206                                 If (LNot (_STA ())) {
207                                         Store (1, \FLVL)
208                                         Store (FAN1_PWM,
209                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
210                                         Notify (\_TZ.THRM, 0x81)
211                                 }
212                         }
213                         Method (_OFF) {
214                                 If (_STA ()) {
215                                         Store (2, \FLVL)
216                                         Store (FAN2_PWM,
217                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
218                                         Notify (\_TZ.THRM, 0x81)
219                                 }
220                         }
221                 }
223                 PowerResource (FNP2, 0, 0)
224                 {
225                         Method (_STA) {
226                                 If (LLessEqual (\FLVL, 2)) {
227                                         Return (One)
228                                 } Else {
229                                         Return (Zero)
230                                 }
231                         }
232                         Method (_ON)  {
233                                 If (LNot (_STA ())) {
234                                         Store (2, \FLVL)
235                                         Store (FAN2_PWM,
236                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
237                                         Notify (\_TZ.THRM, 0x81)
238                                 }
239                         }
240                         Method (_OFF) {
241                                 If (_STA ()) {
242                                         Store (3, \FLVL)
243                                         Store (FAN3_PWM,
244                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
245                                         Notify (\_TZ.THRM, 0x81)
246                                 }
247                         }
248                 }
250                 PowerResource (FNP3, 0, 0)
251                 {
252                         Method (_STA) {
253                                 If (LLessEqual (\FLVL, 3)) {
254                                         Return (One)
255                                 } Else {
256                                         Return (Zero)
257                                 }
258                         }
259                         Method (_ON)  {
260                                 If (LNot (_STA ())) {
261                                         Store (3, \FLVL)
262                                         Store (FAN3_PWM,
263                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
264                                         Notify (\_TZ.THRM, 0x81)
265                                 }
266                         }
267                         Method (_OFF) {
268                                 If (_STA ()) {
269                                         Store (4, \FLVL)
270                                         Store (FAN4_PWM,
271                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
272                                         Notify (\_TZ.THRM, 0x81)
273                                 }
274                         }
275                 }
277                 PowerResource (FNP4, 0, 0)
278                 {
279                         Method (_STA) {
280                                 If (LLessEqual (\FLVL, 4)) {
281                                         Return (One)
282                                 } Else {
283                                         Return (Zero)
284                                 }
285                         }
286                         Method (_ON)  {
287                                 If (LNot (_STA ())) {
288                                         Store (4, \FLVL)
289                                         Store (FAN4_PWM,
290                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
291                                         Notify (\_TZ.THRM, 0x81)
292                                 }
293                         }
294                         Method (_OFF) {
295                                 If (_STA ()) {
296                                         Store (4, \FLVL)
297                                         Store (FAN4_PWM,
298                                                 \_SB.PCI0.LPCB.SIO.ENVC.F2PS)
299                                         Notify (\_TZ.THRM, 0x81)
300                                 }
301                         }
302                 }
304                 Device (FAN0)
305                 {
306                         Name (_HID, EISAID ("PNP0C0B"))
307                         Name (_UID, 0)
308                         Name (_PR0, Package () { FNP0 })
309                 }
311                 Device (FAN1)
312                 {
313                         Name (_HID, EISAID ("PNP0C0B"))
314                         Name (_UID, 1)
315                         Name (_PR0, Package () { FNP1 })
316                 }
318                 Device (FAN2)
319                 {
320                         Name (_HID, EISAID ("PNP0C0B"))
321                         Name (_UID, 2)
322                         Name (_PR0, Package () { FNP2 })
323                 }
325                 Device (FAN3)
326                 {
327                         Name (_HID, EISAID ("PNP0C0B"))
328                         Name (_UID, 3)
329                         Name (_PR0, Package () { FNP3 })
330                 }
332                 Device (FAN4)
333                 {
334                         Name (_HID, EISAID ("PNP0C0B"))
335                         Name (_UID, 4)
336                         Name (_PR0, Package () { FNP4 })
337                 }
338         }