mb/google/auron/acpi: Use Printf() for debug prints
[coreboot.git] / src / mainboard / google / auron / acpi / thermal.asl
blob898ef26ef2a0bee403b4976408ac426824a9450b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* Generated by acpigen */
4 External (\PPKG, MethodObj)
6 #include <variant/thermal.h>
8 // Thermal Zone
10 #define HAVE_THERMALZONE
11 Scope (\_TZ)
13         ThermalZone (THRM)
14         {
15                 Name (_TC1, 0x02)
16                 Name (_TC2, 0x05)
18                 // Thermal zone polling frequency: 10 seconds
19                 Name (_TZP, 100)
21                 // Thermal sampling period for passive cooling: 2 seconds
22                 Name (_TSP, 20)
24                 // Convert from Degrees C to 1/10 Kelvin for ACPI
25                 Method (CTOK, 1) {
26                         // 10th of Degrees C
27                         Local0 = Arg0 * 10
29                         // Convert to Kelvin
30                         Local0 += 2732
32                         Return (Local0)
33                 }
35                 // Threshold for OS to shutdown
36                 Method (_CRT, 0, Serialized)
37                 {
38                         Return (CTOK (\TCRT))
39                 }
41                 // Threshold for passive cooling
42                 Method (_PSV, 0, Serialized)
43                 {
44                         Return (CTOK (\TPSV))
45                 }
47                 // Processors used for passive cooling
48                 Method (_PSL, 0, Serialized)
49                 {
50                         Return (\PPKG ())
51                 }
53                 Method (TCHK, 0, Serialized)
54                 {
55                         // Get Temperature from TIN# set in NVS
56                         Local0 = \_SB.PCI0.LPCB.EC0.TINS (TMPS)
58                         // Check for sensor not calibrated
59                         If (Local0 == \_SB.PCI0.LPCB.EC0.TNCA) {
60                                 Return (CTOK(0))
61                         }
63                         // Check for sensor not present
64                         If (Local0 == \_SB.PCI0.LPCB.EC0.TNPR) {
65                                 Return (CTOK(0))
66                         }
68                         // Check for sensor not powered
69                         If (Local0 == \_SB.PCI0.LPCB.EC0.TNOP) {
70                                 Return (CTOK(0))
71                         }
73                         // Check for sensor bad reading
74                         If (Local0 == \_SB.PCI0.LPCB.EC0.TBAD) {
75                                 Return (CTOK(0))
76                         }
78                         // Adjust by offset to get Kelvin
79                         Local0 += \_SB.PCI0.LPCB.EC0.TOFS
81                         // Convert to 1/10 Kelvin
82                         Local0 *= 10
83                         Return (Local0)
84                 }
86                 Method (_TMP, 0, Serialized)
87                 {
88                         // Get temperature from EC in deci-kelvin
89                         Local0 = TCHK ()
91                         // Critical temperature in deci-kelvin
92                         Local1 = CTOK (\TCRT)
94                         If (Local0 >= Local1) {
95                                 Printf ("CRITICAL TEMPERATURE: %o", Local0)
97                                 // Wait 1 second for EC to re-poll
98                                 Sleep (1000)
100                                 // Re-read temperature from EC
101                                 Local0 = TCHK ()
103                                 Printf ("RE-READ TEMPERATURE: %o", Local0)
104                         }
106                         Return (Local0)
107                 }
109                 /* CTDP Down */
110                 Method (_AC0) {
111                         If (\FLVL <= 0) {
112                                 Return (CTOK (CTL_TDP_THRESHOLD_OFF))
113                         } Else {
114                                 Return (CTOK (CTL_TDP_THRESHOLD_ON))
115                         }
116                 }
118                 /* CTDP Nominal */
119                 Method (_AC1) {
120                         If (\FLVL <= 1) {
121                                 Return (CTOK (CTL_TDP_THRESHILD_NORMAL))
122                         } Else {
123                                 Return (CTOK (CTL_TDP_THRESHILD_NORMAL))
124                         }
125                 }
127                 Name (_AL0, Package () { TDP0 })
128                 Name (_AL1, Package () { TDP1 })
130                 PowerResource (TNP0, 0, 0)
131                 {
132                         Method (_STA) {
133                                 If (\FLVL <= 0) {
134                                         Return (One)
135                                 } Else {
136                                         Return (Zero)
137                                 }
138                         }
139                         Method (_ON)  {
140                                 \FLVL = 0
142                                 /* Enable Power Limit */
143                                 \_SB.PCI0.MCHC.CTLE (CTL_TDP_POWER_LIMIT)
145                                 Notify (\_TZ.THRM, 0x81)
146                         }
147                         Method (_OFF) {
148                                 \FLVL = 1
150                                 /* Disable Power Limit */
151                                 \_SB.PCI0.MCHC.CTLD ()
153                                 Notify (\_TZ.THRM, 0x81)
154                         }
155                 }
157                 PowerResource (TNP1, 0, 0)
158                 {
159                         Method (_STA) {
160                                 If (\FLVL <= 1) {
161                                         Return (One)
162                                 } Else {
163                                         Return (Zero)
164                                 }
165                         }
166                         Method (_ON)  {
167                                 \FLVL = 1
168                                 Notify (\_TZ.THRM, 0x81)
169                         }
170                         Method (_OFF) {
171                                 \FLVL = 1
172                                 Notify (\_TZ.THRM, 0x81)
173                         }
174                 }
176                 Device (TDP0)
177                 {
178                         Name (_HID, EISAID ("PNP0C0B"))
179                         Name (_UID, 0)
180                         Name (_PR0, Package () { TNP0 })
181                 }
183                 Device (TDP1)
184                 {
185                         Name (_HID, EISAID ("PNP0C0B"))
186                         Name (_UID, 1)
187                         Name (_PR0, Package () { TNP1 })
188                 }
189         }