Commit aed3f249 authored by Srinivas Pandruvada's avatar Srinivas Pandruvada Committed by Zhang Rui

thermal: intel_pch_thermal: Add an ACPI passive trip

On the platforms which has an ACPI companion device associated with
PCH thermal device, read passive trip temperature via ACPI _PSV
control method.
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
parent 1001354c
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/acpi.h>
#include <linux/thermal.h> #include <linux/thermal.h>
#include <linux/pm.h> #include <linux/pm.h>
...@@ -66,9 +67,53 @@ struct pch_thermal_device { ...@@ -66,9 +67,53 @@ struct pch_thermal_device {
unsigned long crt_temp; unsigned long crt_temp;
int hot_trip_id; int hot_trip_id;
unsigned long hot_temp; unsigned long hot_temp;
int psv_trip_id;
unsigned long psv_temp;
bool bios_enabled; bool bios_enabled;
}; };
#ifdef CONFIG_ACPI
/*
* On some platforms, there is a companion ACPI device, which adds
* passive trip temperature using _PSV method. There is no specific
* passive temperature setting in MMIO interface of this PCI device.
*/
static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
int *nr_trips)
{
struct acpi_device *adev;
ptd->psv_trip_id = -1;
adev = ACPI_COMPANION(&ptd->pdev->dev);
if (adev) {
unsigned long long r;
acpi_status status;
status = acpi_evaluate_integer(adev->handle, "_PSV", NULL,
&r);
if (ACPI_SUCCESS(status)) {
unsigned long trip_temp;
trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r);
if (trip_temp) {
ptd->psv_temp = trip_temp;
ptd->psv_trip_id = *nr_trips;
++(*nr_trips);
}
}
}
}
#else
static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
int *nr_trips)
{
ptd->psv_trip_id = -1;
}
#endif
static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)
{ {
u8 tsel; u8 tsel;
...@@ -119,6 +164,8 @@ static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) ...@@ -119,6 +164,8 @@ static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)
++(*nr_trips); ++(*nr_trips);
} }
pch_wpt_add_acpi_psv_trip(ptd, nr_trips);
return 0; return 0;
} }
...@@ -194,6 +241,8 @@ static int pch_get_trip_type(struct thermal_zone_device *tzd, int trip, ...@@ -194,6 +241,8 @@ static int pch_get_trip_type(struct thermal_zone_device *tzd, int trip,
*type = THERMAL_TRIP_CRITICAL; *type = THERMAL_TRIP_CRITICAL;
else if (ptd->hot_trip_id == trip) else if (ptd->hot_trip_id == trip)
*type = THERMAL_TRIP_HOT; *type = THERMAL_TRIP_HOT;
else if (ptd->psv_trip_id == trip)
*type = THERMAL_TRIP_PASSIVE;
else else
return -EINVAL; return -EINVAL;
...@@ -208,6 +257,8 @@ static int pch_get_trip_temp(struct thermal_zone_device *tzd, int trip, int *tem ...@@ -208,6 +257,8 @@ static int pch_get_trip_temp(struct thermal_zone_device *tzd, int trip, int *tem
*temp = ptd->crt_temp; *temp = ptd->crt_temp;
else if (ptd->hot_trip_id == trip) else if (ptd->hot_trip_id == trip)
*temp = ptd->hot_temp; *temp = ptd->hot_temp;
else if (ptd->psv_trip_id == trip)
*temp = ptd->psv_temp;
else else
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment