summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-01-30 20:04:05 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-02-02 21:06:09 +0100
commitc5f43242f48ac81d57f50592acf7d425640d9f83 (patch)
tree765c9332d66e5bd6a1c1c68e3c9b1c88e1675f1c /drivers/thermal
parentthermal: intel: intel_pch: Fold two functions into their callers (diff)
downloadlinux-c5f43242f48ac81d57f50592acf7d425640d9f83.tar.xz
linux-c5f43242f48ac81d57f50592acf7d425640d9f83.zip
thermal: intel: intel_pch: Fold suspend and resume routines into their callers
Fold pch_suspend() and pch_resume(), that each have only one caller, into their respective callers to make the code somewhat easier to follow. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Tested-by: Zhang Rui <rui.zhang@intel.com> Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/intel/intel_pch_thermal.c155
1 files changed, 71 insertions, 84 deletions
diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c
index fa6cd4dd2f56..ffb2acd0fd45 100644
--- a/drivers/thermal/intel/intel_pch_thermal.c
+++ b/drivers/thermal/intel/intel_pch_thermal.c
@@ -117,88 +117,6 @@ static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip)
}
#endif
-/* Cool the PCH when it's overheat in .suspend_noirq phase */
-static int pch_suspend(struct pch_thermal_device *ptd)
-{
- u8 tsel;
- int pch_delay_cnt = 0;
- u16 pch_thr_temp, pch_cur_temp;
-
- /* Shutdown the thermal sensor if it is not enabled by BIOS */
- if (!ptd->bios_enabled) {
- tsel = readb(ptd->hw_base + WPT_TSEL);
- writeb(tsel & 0xFE, ptd->hw_base + WPT_TSEL);
- return 0;
- }
-
- /* Do not check temperature if it is not s2idle */
- if (pm_suspend_via_firmware())
- return 0;
-
- /* Get the PCH temperature threshold value */
- pch_thr_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TSPM));
-
- /* Get the PCH current temperature value */
- pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
-
- /*
- * If current PCH temperature is higher than configured PCH threshold
- * value, run some delay loop with sleep to let the current temperature
- * go down below the threshold value which helps to allow system enter
- * lower power S0ix suspend state. Even after delay loop if PCH current
- * temperature stays above threshold, notify the warning message
- * which helps to indentify the reason why S0ix entry was rejected.
- */
- while (pch_delay_cnt < delay_cnt) {
- if (pch_cur_temp < pch_thr_temp)
- break;
-
- if (pm_wakeup_pending()) {
- dev_warn(&ptd->pdev->dev, "Wakeup event detected, abort cooling\n");
- return 0;
- }
-
- pch_delay_cnt++;
- dev_dbg(&ptd->pdev->dev,
- "CPU-PCH current temp [%dC] higher than the threshold temp [%dC], sleep %d times for %d ms duration\n",
- pch_cur_temp, pch_thr_temp, pch_delay_cnt, delay_timeout);
- msleep(delay_timeout);
- /* Read the PCH current temperature for next cycle. */
- pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
- }
-
- if (pch_cur_temp >= pch_thr_temp)
- dev_warn(&ptd->pdev->dev,
- "CPU-PCH is hot [%dC] after %d ms delay. S0ix might fail\n",
- pch_cur_temp, pch_delay_cnt * delay_timeout);
- else {
- if (pch_delay_cnt)
- dev_info(&ptd->pdev->dev,
- "CPU-PCH is cool [%dC] after %d ms delay\n",
- pch_cur_temp, pch_delay_cnt * delay_timeout);
- else
- dev_info(&ptd->pdev->dev,
- "CPU-PCH is cool [%dC]\n",
- pch_cur_temp);
- }
-
- return 0;
-}
-
-static int pch_resume(struct pch_thermal_device *ptd)
-{
- u8 tsel;
-
- if (ptd->bios_enabled)
- return 0;
-
- tsel = readb(ptd->hw_base + WPT_TSEL);
-
- writeb(tsel | WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL);
-
- return 0;
-}
-
static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp)
{
struct pch_thermal_device *ptd = tzd->devdata;
@@ -372,15 +290,84 @@ static void intel_pch_thermal_remove(struct pci_dev *pdev)
static int intel_pch_thermal_suspend_noirq(struct device *device)
{
struct pch_thermal_device *ptd = dev_get_drvdata(device);
+ u16 pch_thr_temp, pch_cur_temp;
+ int pch_delay_cnt = 0;
+ u8 tsel;
+
+ /* Shutdown the thermal sensor if it is not enabled by BIOS */
+ if (!ptd->bios_enabled) {
+ tsel = readb(ptd->hw_base + WPT_TSEL);
+ writeb(tsel & 0xFE, ptd->hw_base + WPT_TSEL);
+ return 0;
+ }
+
+ /* Do not check temperature if it is not s2idle */
+ if (pm_suspend_via_firmware())
+ return 0;
+
+ /* Get the PCH temperature threshold value */
+ pch_thr_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TSPM));
+
+ /* Get the PCH current temperature value */
+ pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
- return pch_suspend(ptd);
+ /*
+ * If current PCH temperature is higher than configured PCH threshold
+ * value, run some delay loop with sleep to let the current temperature
+ * go down below the threshold value which helps to allow system enter
+ * lower power S0ix suspend state. Even after delay loop if PCH current
+ * temperature stays above threshold, notify the warning message
+ * which helps to indentify the reason why S0ix entry was rejected.
+ */
+ while (pch_delay_cnt < delay_cnt) {
+ if (pch_cur_temp < pch_thr_temp)
+ break;
+
+ if (pm_wakeup_pending()) {
+ dev_warn(&ptd->pdev->dev, "Wakeup event detected, abort cooling\n");
+ return 0;
+ }
+
+ pch_delay_cnt++;
+ dev_dbg(&ptd->pdev->dev,
+ "CPU-PCH current temp [%dC] higher than the threshold temp [%dC], sleep %d times for %d ms duration\n",
+ pch_cur_temp, pch_thr_temp, pch_delay_cnt, delay_timeout);
+ msleep(delay_timeout);
+ /* Read the PCH current temperature for next cycle. */
+ pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
+ }
+
+ if (pch_cur_temp >= pch_thr_temp)
+ dev_warn(&ptd->pdev->dev,
+ "CPU-PCH is hot [%dC] after %d ms delay. S0ix might fail\n",
+ pch_cur_temp, pch_delay_cnt * delay_timeout);
+ else {
+ if (pch_delay_cnt)
+ dev_info(&ptd->pdev->dev,
+ "CPU-PCH is cool [%dC] after %d ms delay\n",
+ pch_cur_temp, pch_delay_cnt * delay_timeout);
+ else
+ dev_info(&ptd->pdev->dev,
+ "CPU-PCH is cool [%dC]\n",
+ pch_cur_temp);
+ }
+
+ return 0;
}
static int intel_pch_thermal_resume(struct device *device)
{
struct pch_thermal_device *ptd = dev_get_drvdata(device);
+ u8 tsel;
- return pch_resume(ptd);
+ if (ptd->bios_enabled)
+ return 0;
+
+ tsel = readb(ptd->hw_base + WPT_TSEL);
+
+ writeb(tsel | WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL);
+
+ return 0;
}
static const struct pci_device_id intel_pch_thermal_id[] = {