Angel Pons | 58c0d32 | 2020-04-05 13:20:46 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 2 | |
Arthur Heymans | f7d1c8d | 2018-11-28 12:22:59 +0100 | [diff] [blame] | 3 | /* Generated by acpigen */ |
| 4 | External (\PPKG, MethodObj) |
| 5 | |
Matt DeVillier | 45e11aa | 2016-12-18 11:59:58 -0600 | [diff] [blame] | 6 | #include <variant/thermal.h> |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 7 | |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 8 | // Thermal Zone |
| 9 | |
Martin Roth | a50b1f9 | 2018-05-06 18:13:19 -0500 | [diff] [blame] | 10 | #define HAVE_THERMALZONE |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 11 | Scope (\_TZ) |
| 12 | { |
| 13 | ThermalZone (THRM) |
| 14 | { |
| 15 | Name (_TC1, 0x02) |
| 16 | Name (_TC2, 0x05) |
| 17 | |
| 18 | // Thermal zone polling frequency: 10 seconds |
| 19 | Name (_TZP, 100) |
| 20 | |
| 21 | // Thermal sampling period for passive cooling: 2 seconds |
| 22 | Name (_TSP, 20) |
| 23 | |
| 24 | // Convert from Degrees C to 1/10 Kelvin for ACPI |
| 25 | Method (CTOK, 1) { |
| 26 | // 10th of Degrees C |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 27 | Local0 = Arg0 * 10 |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 28 | |
| 29 | // Convert to Kelvin |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 30 | Local0 += 2732 |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 31 | |
| 32 | Return (Local0) |
| 33 | } |
| 34 | |
| 35 | // Threshold for OS to shutdown |
| 36 | Method (_CRT, 0, Serialized) |
| 37 | { |
| 38 | Return (CTOK (\TCRT)) |
| 39 | } |
| 40 | |
| 41 | // Threshold for passive cooling |
| 42 | Method (_PSV, 0, Serialized) |
| 43 | { |
| 44 | Return (CTOK (\TPSV)) |
| 45 | } |
| 46 | |
| 47 | // Processors used for passive cooling |
| 48 | Method (_PSL, 0, Serialized) |
| 49 | { |
| 50 | Return (\PPKG ()) |
| 51 | } |
| 52 | |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 53 | Method (TCHK, 0, Serialized) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 54 | { |
| 55 | // Get Temperature from TIN# set in NVS |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 56 | Local0 = \_SB.PCI0.LPCB.EC0.TINS (TMPS) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 57 | |
| 58 | // Check for sensor not calibrated |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 59 | If (Local0 == \_SB.PCI0.LPCB.EC0.TNCA) { |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 60 | Return (CTOK(0)) |
| 61 | } |
| 62 | |
| 63 | // Check for sensor not present |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 64 | If (Local0 == \_SB.PCI0.LPCB.EC0.TNPR) { |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 65 | Return (CTOK(0)) |
| 66 | } |
| 67 | |
| 68 | // Check for sensor not powered |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 69 | If (Local0 == \_SB.PCI0.LPCB.EC0.TNOP) { |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 70 | Return (CTOK(0)) |
| 71 | } |
| 72 | |
| 73 | // Check for sensor bad reading |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 74 | If (Local0 == \_SB.PCI0.LPCB.EC0.TBAD) { |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 75 | Return (CTOK(0)) |
| 76 | } |
| 77 | |
| 78 | // Adjust by offset to get Kelvin |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 79 | Local0 += \_SB.PCI0.LPCB.EC0.TOFS |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 80 | |
| 81 | // Convert to 1/10 Kelvin |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 82 | Local0 *= 10 |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 83 | Return (Local0) |
| 84 | } |
| 85 | |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 86 | Method (_TMP, 0, Serialized) |
| 87 | { |
| 88 | // Get temperature from EC in deci-kelvin |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 89 | Local0 = TCHK () |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 90 | |
| 91 | // Critical temperature in deci-kelvin |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 92 | Local1 = CTOK (\TCRT) |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 93 | |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 94 | If (Local0 >= Local1) { |
Felix Singer | 3884a41 | 2021-12-28 17:01:28 +0100 | [diff] [blame] | 95 | Printf ("CRITICAL TEMPERATURE: %o", Local0) |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 96 | |
| 97 | // Wait 1 second for EC to re-poll |
| 98 | Sleep (1000) |
| 99 | |
| 100 | // Re-read temperature from EC |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 101 | Local0 = TCHK () |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 102 | |
Felix Singer | 3884a41 | 2021-12-28 17:01:28 +0100 | [diff] [blame] | 103 | Printf ("RE-READ TEMPERATURE: %o", Local0) |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | Return (Local0) |
| 107 | } |
| 108 | |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 109 | /* CTDP Down */ |
| 110 | Method (_AC0) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 111 | If (\FLVL <= 0) { |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 112 | Return (CTOK (CTL_TDP_THRESHOLD_OFF)) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 113 | } Else { |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 114 | Return (CTOK (CTL_TDP_THRESHOLD_ON)) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 115 | } |
| 116 | } |
| 117 | |
| 118 | /* CTDP Nominal */ |
| 119 | Method (_AC1) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 120 | If (\FLVL <= 1) { |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 121 | Return (CTOK (CTL_TDP_THRESHILD_NORMAL)) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 122 | } Else { |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 123 | Return (CTOK (CTL_TDP_THRESHILD_NORMAL)) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
| 127 | Name (_AL0, Package () { TDP0 }) |
| 128 | Name (_AL1, Package () { TDP1 }) |
| 129 | |
| 130 | PowerResource (TNP0, 0, 0) |
| 131 | { |
| 132 | Method (_STA) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 133 | If (\FLVL <= 0) { |
Felix Singer | dfbb634 | 2022-12-26 08:39:35 +0100 | [diff] [blame^] | 134 | Return (1) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 135 | } Else { |
| 136 | Return (Zero) |
| 137 | } |
| 138 | } |
| 139 | Method (_ON) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 140 | \FLVL = 0 |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 141 | |
| 142 | /* Enable Power Limit */ |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 143 | \_SB.PCI0.MCHC.CTLE (CTL_TDP_POWER_LIMIT) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 144 | |
| 145 | Notify (\_TZ.THRM, 0x81) |
| 146 | } |
| 147 | Method (_OFF) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 148 | \FLVL = 1 |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 149 | |
| 150 | /* Disable Power Limit */ |
| 151 | \_SB.PCI0.MCHC.CTLD () |
| 152 | |
| 153 | Notify (\_TZ.THRM, 0x81) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | PowerResource (TNP1, 0, 0) |
| 158 | { |
| 159 | Method (_STA) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 160 | If (\FLVL <= 1) { |
Felix Singer | dfbb634 | 2022-12-26 08:39:35 +0100 | [diff] [blame^] | 161 | Return (1) |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 162 | } Else { |
| 163 | Return (Zero) |
| 164 | } |
| 165 | } |
| 166 | Method (_ON) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 167 | \FLVL = 1 |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 168 | Notify (\_TZ.THRM, 0x81) |
| 169 | } |
| 170 | Method (_OFF) { |
Elyes HAOUAS | 9c19a4f | 2020-10-08 09:30:03 +0200 | [diff] [blame] | 171 | \FLVL = 1 |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 172 | Notify (\_TZ.THRM, 0x81) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | Device (TDP0) |
| 177 | { |
| 178 | Name (_HID, EISAID ("PNP0C0B")) |
| 179 | Name (_UID, 0) |
| 180 | Name (_PR0, Package () { TNP0 }) |
| 181 | } |
| 182 | |
| 183 | Device (TDP1) |
| 184 | { |
| 185 | Name (_HID, EISAID ("PNP0C0B")) |
| 186 | Name (_UID, 1) |
| 187 | Name (_PR0, Package () { TNP1 }) |
| 188 | } |
| 189 | } |
| 190 | } |