Lines Matching +full:higher +full:- +full:than +full:- +full:threshold
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* intel_pch_thermal.c - Intel PCH Thermal driver
28 #define PCH_THERMAL_DID_CNL_H 0xA379 /* CNL-H PCH */
29 #define PCH_THERMAL_DID_CNL_LP 0x02F9 /* CNL-LP PCH */
30 #define PCH_THERMAL_DID_CML_H 0X06F9 /* CML-H PCH */
34 /* Wildcat Point-LP PCH Thermal registers */
52 /* Wildcat Point-LP PCH Thermal Register bit definitions */
54 #define WPT_TSC_CPDE 0x01 /* Catastrophic Power-Down Enable */
58 #define WPT_TSEL_PLDB 0x80 /* TSEL Policy Lock-Down Bit */
63 /* Resolution of 1/2 degree C and an offset of -50C */
64 #define PCH_TEMP_OFFSET (-50)
102 adev = ACPI_COMPANION(&ptd->pdev->dev); in pch_wpt_add_acpi_psv_trip()
109 trip->type = THERMAL_TRIP_PASSIVE; in pch_wpt_add_acpi_psv_trip()
110 trip->temperature = temp; in pch_wpt_add_acpi_psv_trip()
125 *temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in pch_thermal_get_temp()
164 enum pch_board_ids board_id = id->driver_data; in intel_pch_thermal_probe()
171 ptd = devm_kzalloc(&pdev->dev, sizeof(*ptd), GFP_KERNEL); in intel_pch_thermal_probe()
173 return -ENOMEM; in intel_pch_thermal_probe()
176 ptd->pdev = pdev; in intel_pch_thermal_probe()
180 dev_err(&pdev->dev, "failed to enable pci device\n"); in intel_pch_thermal_probe()
186 dev_err(&pdev->dev, "failed to request pci region\n"); in intel_pch_thermal_probe()
190 ptd->hw_base = pci_ioremap_bar(pdev, 0); in intel_pch_thermal_probe()
191 if (!ptd->hw_base) { in intel_pch_thermal_probe()
192 err = -ENOMEM; in intel_pch_thermal_probe()
193 dev_err(&pdev->dev, "failed to map mem base\n"); in intel_pch_thermal_probe()
198 if (WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL)) { in intel_pch_thermal_probe()
199 ptd->bios_enabled = true; in intel_pch_thermal_probe()
203 tsel = readb(ptd->hw_base + WPT_TSEL); in intel_pch_thermal_probe()
205 * When TSEL's Policy Lock-Down bit is 1, TSEL become RO. in intel_pch_thermal_probe()
209 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in intel_pch_thermal_probe()
210 err = -ENODEV; in intel_pch_thermal_probe()
214 writeb(tsel|WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in intel_pch_thermal_probe()
215 if (!(WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL))) { in intel_pch_thermal_probe()
216 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in intel_pch_thermal_probe()
217 err = -ENODEV; in intel_pch_thermal_probe()
222 trip_temp = readw(ptd->hw_base + WPT_CTT); in intel_pch_thermal_probe()
229 trip_temp = readw(ptd->hw_base + WPT_PHL); in intel_pch_thermal_probe()
238 ptd->tzd = thermal_zone_device_register_with_trips(board_names[board_id], in intel_pch_thermal_probe()
242 if (IS_ERR(ptd->tzd)) { in intel_pch_thermal_probe()
243 dev_err(&pdev->dev, "Failed to register thermal zone %s\n", in intel_pch_thermal_probe()
245 err = PTR_ERR(ptd->tzd); in intel_pch_thermal_probe()
248 err = thermal_zone_device_enable(ptd->tzd); in intel_pch_thermal_probe()
255 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_probe()
257 iounmap(ptd->hw_base); in intel_pch_thermal_probe()
262 dev_err(&pdev->dev, "pci device failed to probe\n"); in intel_pch_thermal_probe()
270 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_remove()
271 iounmap(ptd->hw_base); in intel_pch_thermal_remove()
285 if (!ptd->bios_enabled) { in intel_pch_thermal_suspend_noirq()
286 tsel = readb(ptd->hw_base + WPT_TSEL); in intel_pch_thermal_suspend_noirq()
287 writeb(tsel & 0xFE, ptd->hw_base + WPT_TSEL); in intel_pch_thermal_suspend_noirq()
295 /* Get the PCH temperature threshold value */ in intel_pch_thermal_suspend_noirq()
296 pch_thr_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TSPM)); in intel_pch_thermal_suspend_noirq()
299 pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in intel_pch_thermal_suspend_noirq()
302 dev_warn(&ptd->pdev->dev, in intel_pch_thermal_suspend_noirq()
303 …"CPU-PCH current temp [%dC] higher than the threshold temp [%dC], S0ix might fail. Start cooling..… in intel_pch_thermal_suspend_noirq()
307 * If current PCH temperature is higher than configured PCH threshold in intel_pch_thermal_suspend_noirq()
309 * go down below the threshold value which helps to allow system enter in intel_pch_thermal_suspend_noirq()
311 * temperature stays above threshold, notify the warning message in intel_pch_thermal_suspend_noirq()
319 dev_warn(&ptd->pdev->dev, "Wakeup event detected, abort cooling\n"); in intel_pch_thermal_suspend_noirq()
324 dev_dbg(&ptd->pdev->dev, in intel_pch_thermal_suspend_noirq()
325 …"CPU-PCH current temp [%dC] higher than the threshold temp [%dC], sleep %d times for %d ms duratio… in intel_pch_thermal_suspend_noirq()
329 pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in intel_pch_thermal_suspend_noirq()
333 dev_warn(&ptd->pdev->dev, in intel_pch_thermal_suspend_noirq()
334 "CPU-PCH is hot [%dC] after %d ms delay. S0ix might fail\n", in intel_pch_thermal_suspend_noirq()
338 dev_info(&ptd->pdev->dev, in intel_pch_thermal_suspend_noirq()
339 "CPU-PCH is cool [%dC] after %d ms delay\n", in intel_pch_thermal_suspend_noirq()
342 dev_info(&ptd->pdev->dev, in intel_pch_thermal_suspend_noirq()
343 "CPU-PCH is cool [%dC]\n", in intel_pch_thermal_suspend_noirq()
355 if (ptd->bios_enabled) in intel_pch_thermal_resume()
358 tsel = readb(ptd->hw_base + WPT_TSEL); in intel_pch_thermal_resume()
360 writeb(tsel | WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in intel_pch_thermal_resume()