| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
// Thermal Zone |
| 4 |
|
| 5 |
External (\PPKG, MethodObj) |
| 6 |
|
| 7 |
#define HAVE_THERMALZONE |
| 8 |
Scope (\_TZ) |
| 9 |
{ |
| 10 |
// Handler for throttle requests on this platform |
| 11 |
// 0 = Stop throttling |
| 12 |
// 1 = Start throttling |
| 13 |
Method (THRT, 1, Serialized) |
| 14 |
{ |
| 15 |
If (Arg0 == 0) { |
| 16 |
/* Disable Power Limit */ |
| 17 |
\_SB.PCI0.MCHC.CTLD () |
| 18 |
} Else { |
| 19 |
/* Enable Power Limit */ |
| 20 |
\_SB.PCI0.MCHC.CTLE (\F0PW) |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
ThermalZone (THRM) |
| 25 |
{ |
| 26 |
Name (_TC1, 0x02) |
| 27 |
Name (_TC2, 0x05) |
| 28 |
|
| 29 |
// Thermal zone polling frequency: 10 seconds |
| 30 |
Name (_TZP, 100) |
| 31 |
|
| 32 |
// Thermal sampling period for passive cooling: 2 seconds |
| 33 |
Name (_TSP, 20) |
| 34 |
|
| 35 |
// Convert from Degrees C to 1/10 Kelvin for ACPI |
| 36 |
Method (CTOK, 1) { |
| 37 |
// 10th of Degrees C |
| 38 |
Local0 = Arg0 * 10 |
| 39 |
|
| 40 |
// Convert to Kelvin |
| 41 |
Local0 += 2732 |
| 42 |
|
| 43 |
Return (Local0) |
| 44 |
} |
| 45 |
|
| 46 |
// Threshold for OS to shutdown |
| 47 |
Method (_CRT, 0, Serialized) |
| 48 |
{ |
| 49 |
Return (CTOK (\TCRT)) |
| 50 |
} |
| 51 |
|
| 52 |
// Threshold for passive cooling |
| 53 |
Method (_PSV, 0, Serialized) |
| 54 |
{ |
| 55 |
Return (CTOK (\TPSV)) |
| 56 |
} |
| 57 |
|
| 58 |
// Processors used for passive cooling |
| 59 |
Method (_PSL, 0, Serialized) |
| 60 |
{ |
| 61 |
Return (\PPKG ()) |
| 62 |
} |
| 63 |
|
| 64 |
Method (TCHK, 0, Serialized) |
| 65 |
{ |
| 66 |
// Get Temperature from TIN# set in NVS |
| 67 |
Local0 = \_SB.PCI0.LPCB.EC0.TINS (TMPS) |
| 68 |
|
| 69 |
// Check for sensor not calibrated |
| 70 |
If (Local0 == \_SB.PCI0.LPCB.EC0.TNCA) { |
| 71 |
Return (CTOK(0)) |
| 72 |
} |
| 73 |
|
| 74 |
// Check for sensor not present |
| 75 |
If (Local0 == \_SB.PCI0.LPCB.EC0.TNPR) { |
| 76 |
Return (CTOK(0)) |
| 77 |
} |
| 78 |
|
| 79 |
// Check for sensor not powered |
| 80 |
If (Local0 == \_SB.PCI0.LPCB.EC0.TNOP) { |
| 81 |
Return (CTOK(0)) |
| 82 |
} |
| 83 |
|
| 84 |
// Check for sensor bad reading |
| 85 |
If (Local0 == \_SB.PCI0.LPCB.EC0.TBAD) { |
| 86 |
Return (CTOK(0)) |
| 87 |
} |
| 88 |
|
| 89 |
// Adjust by offset to get Kelvin |
| 90 |
Local0 += \_SB.PCI0.LPCB.EC0.TOFS |
| 91 |
|
| 92 |
// Convert to 1/10 Kelvin |
| 93 |
Local0 *= 10 |
| 94 |
Return (Local0) |
| 95 |
} |
| 96 |
|
| 97 |
Method (_TMP, 0, Serialized) |
| 98 |
{ |
| 99 |
// Get temperature from EC in deci-kelvin |
| 100 |
Local0 = TCHK () |
| 101 |
|
| 102 |
// Critical temperature in deci-kelvin |
| 103 |
Local1 = CTOK (\TCRT) |
| 104 |
|
| 105 |
If (Local0 >= Local1) { |
| 106 |
Printf ("CRITICAL TEMPERATURE: %o", Local0) |
| 107 |
|
| 108 |
// Wait 1 second for EC to re-poll |
| 109 |
Sleep (1000) |
| 110 |
|
| 111 |
// Re-read temperature from EC |
| 112 |
Local0 = TCHK () |
| 113 |
|
| 114 |
Printf ("RE-READ TEMPERATURE: %o", Local0) |
| 115 |
} |
| 116 |
|
| 117 |
Return (Local0) |
| 118 |
} |
| 119 |
} |
| 120 |
} |