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