cpu/x86/smm/pci_resource_store: Store DEV/VEN ID
[coreboot2.git] / src / mainboard / google / beltino / acpi / thermal.asl
blob3463028bbdfc1d6d82decbade1d82a2735c1c4a3
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 External (\PPKG, MethodObj)
5 #include <variant/thermal.h>
7 // Thermal Zone
9 #define HAVE_THERMALZONE
10 Scope (\_TZ)
12         ThermalZone (THRM)
13         {
14                 Name (_TC1, 0x02)
15                 Name (_TC2, 0x05)
17                 // Thermal zone polling frequency: 10 seconds
18                 Name (_TZP, 100)
20                 // Thermal sampling period for passive cooling: 2 seconds
21                 Name (_TSP, 20)
23                 // Convert from Degrees C to 1/10 Kelvin for ACPI
24                 Method (CTOK, 1) {
25                         // 10th of Degrees C
26                         Local0 = Arg0 * 10
28                         // Convert to Kelvin
29                         Local0 += 2732
31                         Return (Local0)
32                 }
34                 // Threshold for OS to shutdown
35                 Method (_CRT, 0, Serialized)
36                 {
37                         Return (CTOK (\TCRT))
38                 }
40                 // Threshold for passive cooling
41                 Method (_PSV, 0, Serialized)
42                 {
43                         Return (CTOK (\TPSV))
44                 }
46                 // Processors used for passive cooling
47                 Method (_PSL, 0, Serialized)
48                 {
49                         Return (\PPKG ())
50                 }
52                 // Start fan at state 4 = lowest temp state
53                 Method (_INI)
54                 {
55                         \FLVL = 4
56                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN4_PWM
57                         Notify (\_TZ.THRM, 0x81)
58                 }
60                 Method (TCHK, 0, Serialized)
61                 {
62                         // Get CPU Temperature from PECI via SuperIO TMPIN3
63                         Local0 = \_SB.PCI0.LPCB.SIO.ENVC.TIN3
65                         // Check for "no reading available"
66                         If (Local0 == 0x80) {
67                                 Return (CTOK (FAN0_THRESHOLD_ON))
68                         }
70                         // Check for invalid readings
71                         If ((Local0 == 255) || (Local0 == 0)) {
72                                 Return (CTOK (FAN0_THRESHOLD_ON))
73                         }
75                         // PECI raw value is an offset from Tj_max
76                         Local1 = 255 - Local0
78                         // Handle values greater than Tj_max
79                         If (Local1 >= \TMAX) {
80                                 Return (CTOK (\TMAX))
81                         }
83                         // Subtract from Tj_max to get temperature
84                         Local0 = \TMAX - Local1
85                         Return (CTOK (Local0))
86                 }
88                 Method (_TMP, 0, Serialized)
89                 {
90                         // Get temperature from SuperIO in deci-kelvin
91                         Local0 = TCHK ()
93                         // Critical temperature in deci-kelvin
94                         Local1 = CTOK (\TMAX)
96                         If (Local0 >= Local1) {
97                                 Printf ("CRITICAL TEMPERATURE: %o", Local0)
99                                 // Wait 1 second for SuperIO to re-poll
100                                 Sleep (1000)
102                                 // Re-read temperature from SuperIO
103                                 Local0 = TCHK ()
105                                 Printf ("RE-READ TEMPERATURE: %o", Local0)
106                         }
108                         Return (Local0)
109                 }
111                 Method (_AC0) {
112                         If (\FLVL <= 0) {
113                                 Return (CTOK (FAN0_THRESHOLD_OFF))
114                         } Else {
115                                 Return (CTOK (FAN0_THRESHOLD_ON))
116                         }
117                 }
119                 Method (_AC1) {
120                         If (\FLVL <= 1) {
121                                 Return (CTOK (FAN1_THRESHOLD_OFF))
122                         } Else {
123                                 Return (CTOK (FAN1_THRESHOLD_ON))
124                         }
125                 }
127                 Method (_AC2) {
128                         If (\FLVL <= 2) {
129                                 Return (CTOK (FAN2_THRESHOLD_OFF))
130                         } Else {
131                                 Return (CTOK (FAN2_THRESHOLD_ON))
132                         }
133                 }
135                 Method (_AC3) {
136                         If (\FLVL <= 3) {
137                                 Return (CTOK (FAN3_THRESHOLD_OFF))
138                         } Else {
139                                 Return (CTOK (FAN3_THRESHOLD_ON))
140                         }
141                 }
143                 Method (_AC4) {
144                         If (\FLVL <= 4) {
145                                 Return (CTOK (FAN4_THRESHOLD_OFF))
146                         } Else {
147                                 Return (CTOK (FAN4_THRESHOLD_ON))
148                         }
149                 }
151                 Name (_AL0, Package () { FAN0 })
152                 Name (_AL1, Package () { FAN1 })
153                 Name (_AL2, Package () { FAN2 })
154                 Name (_AL3, Package () { FAN3 })
155                 Name (_AL4, Package () { FAN4 })
157                 PowerResource (FNP0, 0, 0)
158                 {
159                         Method (_STA) {
160                                 If (\FLVL <= 0) {
161                                         Return (1)
162                                 } Else {
163                                         Return (0)
164                                 }
165                         }
166                         Method (_ON)  {
167                                 If (!_STA ()) {
168                                         \FLVL = 0
169                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN0_PWM
170                                         Notify (\_TZ.THRM, 0x81)
171                                 }
172                         }
173                         Method (_OFF) {
174                                 If (_STA ()) {
175                                         \FLVL = 1
176                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN1_PWM
177                                         Notify (\_TZ.THRM, 0x81)
178                                 }
179                         }
180                 }
182                 PowerResource (FNP1, 0, 0)
183                 {
184                         Method (_STA) {
185                                 If (\FLVL <= 1) {
186                                         Return (1)
187                                 } Else {
188                                         Return (0)
189                                 }
190                         }
191                         Method (_ON)  {
192                                 If (!_STA ()) {
193                                         \FLVL = 1
194                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN1_PWM
195                                         Notify (\_TZ.THRM, 0x81)
196                                 }
197                         }
198                         Method (_OFF) {
199                                 If (_STA ()) {
200                                         \FLVL = 2
201                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN2_PWM
202                                         Notify (\_TZ.THRM, 0x81)
203                                 }
204                         }
205                 }
207                 PowerResource (FNP2, 0, 0)
208                 {
209                         Method (_STA) {
210                                 If (\FLVL <= 2) {
211                                         Return (1)
212                                 } Else {
213                                         Return (0)
214                                 }
215                         }
216                         Method (_ON)  {
217                                 If (!_STA ()) {
218                                         \FLVL = 2
219                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN2_PWM
220                                         Notify (\_TZ.THRM, 0x81)
221                                 }
222                         }
223                         Method (_OFF) {
224                                 If (_STA ()) {
225                                         \FLVL = 3
226                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN3_PWM
227                                         Notify (\_TZ.THRM, 0x81)
228                                 }
229                         }
230                 }
232                 PowerResource (FNP3, 0, 0)
233                 {
234                         Method (_STA) {
235                                 If (\FLVL <= 3) {
236                                         Return (1)
237                                 } Else {
238                                         Return (0)
239                                 }
240                         }
241                         Method (_ON)  {
242                                 If (!_STA ()) {
243                                         \FLVL = 3
244                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN3_PWM
245                                         Notify (\_TZ.THRM, 0x81)
246                                 }
247                         }
248                         Method (_OFF) {
249                                 If (_STA ()) {
250                                         \FLVL = 4
251                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN4_PWM
252                                         Notify (\_TZ.THRM, 0x81)
253                                 }
254                         }
255                 }
257                 PowerResource (FNP4, 0, 0)
258                 {
259                         Method (_STA) {
260                                 If (\FLVL <= 4) {
261                                         Return (1)
262                                 } Else {
263                                         Return (0)
264                                 }
265                         }
266                         Method (_ON)  {
267                                 If (!_STA ()) {
268                                         \FLVL = 4
269                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN4_PWM
270                                         Notify (\_TZ.THRM, 0x81)
271                                 }
272                         }
273                         Method (_OFF) {
274                                 If (_STA ()) {
275                                         \FLVL = 4
276                                         \_SB.PCI0.LPCB.SIO.ENVC.F2PS = FAN4_PWM
277                                         Notify (\_TZ.THRM, 0x81)
278                                 }
279                         }
280                 }
282                 Device (FAN0)
283                 {
284                         Name (_HID, EISAID ("PNP0C0B"))
285                         Name (_UID, 0)
286                         Name (_PR0, Package () { FNP0 })
287                 }
289                 Device (FAN1)
290                 {
291                         Name (_HID, EISAID ("PNP0C0B"))
292                         Name (_UID, 1)
293                         Name (_PR0, Package () { FNP1 })
294                 }
296                 Device (FAN2)
297                 {
298                         Name (_HID, EISAID ("PNP0C0B"))
299                         Name (_UID, 2)
300                         Name (_PR0, Package () { FNP2 })
301                 }
303                 Device (FAN3)
304                 {
305                         Name (_HID, EISAID ("PNP0C0B"))
306                         Name (_UID, 3)
307                         Name (_PR0, Package () { FNP3 })
308                 }
310                 Device (FAN4)
311                 {
312                         Name (_HID, EISAID ("PNP0C0B"))
313                         Name (_UID, 4)
314                         Name (_PR0, Package () { FNP4 })
315                 }
316         }