aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2016-10-03 15:36:24 -0400
committerZhang Rui <rui.zhang@intel.com>2016-10-20 02:15:44 -0400
commitaed3f249f93fe15f16242bbd4e6c3931674b8d91 (patch)
tree44866b2337a587e8067301fffc1b11fbc5d03c54
parent1001354ca34179f3db924eb66672442a173147dc (diff)
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: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r--drivers/thermal/intel_pch_thermal.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/thermal/intel_pch_thermal.c b/drivers/thermal/intel_pch_thermal.c
index 9b4815e81b0d..5cf644a2c012 100644
--- a/drivers/thermal/intel_pch_thermal.c
+++ b/drivers/thermal/intel_pch_thermal.c
@@ -20,6 +20,7 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/acpi.h>
23#include <linux/thermal.h> 24#include <linux/thermal.h>
24#include <linux/pm.h> 25#include <linux/pm.h>
25 26
@@ -66,9 +67,53 @@ struct pch_thermal_device {
66 unsigned long crt_temp; 67 unsigned long crt_temp;
67 int hot_trip_id; 68 int hot_trip_id;
68 unsigned long hot_temp; 69 unsigned long hot_temp;
70 int psv_trip_id;
71 unsigned long psv_temp;
69 bool bios_enabled; 72 bool bios_enabled;
70}; 73};
71 74
75#ifdef CONFIG_ACPI
76
77/*
78 * On some platforms, there is a companion ACPI device, which adds
79 * passive trip temperature using _PSV method. There is no specific
80 * passive temperature setting in MMIO interface of this PCI device.
81 */
82static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
83 int *nr_trips)
84{
85 struct acpi_device *adev;
86
87 ptd->psv_trip_id = -1;
88
89 adev = ACPI_COMPANION(&ptd->pdev->dev);
90 if (adev) {
91 unsigned long long r;
92 acpi_status status;
93
94 status = acpi_evaluate_integer(adev->handle, "_PSV", NULL,
95 &r);
96 if (ACPI_SUCCESS(status)) {
97 unsigned long trip_temp;
98
99 trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r);
100 if (trip_temp) {
101 ptd->psv_temp = trip_temp;
102 ptd->psv_trip_id = *nr_trips;
103 ++(*nr_trips);
104 }
105 }
106 }
107}
108#else
109static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
110 int *nr_trips)
111{
112 ptd->psv_trip_id = -1;
113
114}
115#endif
116
72static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) 117static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)
73{ 118{
74 u8 tsel; 119 u8 tsel;
@@ -119,6 +164,8 @@ read_trips:
119 ++(*nr_trips); 164 ++(*nr_trips);
120 } 165 }
121 166
167 pch_wpt_add_acpi_psv_trip(ptd, nr_trips);
168
122 return 0; 169 return 0;
123} 170}
124 171
@@ -194,6 +241,8 @@ static int pch_get_trip_type(struct thermal_zone_device *tzd, int trip,
194 *type = THERMAL_TRIP_CRITICAL; 241 *type = THERMAL_TRIP_CRITICAL;
195 else if (ptd->hot_trip_id == trip) 242 else if (ptd->hot_trip_id == trip)
196 *type = THERMAL_TRIP_HOT; 243 *type = THERMAL_TRIP_HOT;
244 else if (ptd->psv_trip_id == trip)
245 *type = THERMAL_TRIP_PASSIVE;
197 else 246 else
198 return -EINVAL; 247 return -EINVAL;
199 248
@@ -208,6 +257,8 @@ static int pch_get_trip_temp(struct thermal_zone_device *tzd, int trip, int *tem
208 *temp = ptd->crt_temp; 257 *temp = ptd->crt_temp;
209 else if (ptd->hot_trip_id == trip) 258 else if (ptd->hot_trip_id == trip)
210 *temp = ptd->hot_temp; 259 *temp = ptd->hot_temp;
260 else if (ptd->psv_trip_id == trip)
261 *temp = ptd->psv_temp;
211 else 262 else
212 return -EINVAL; 263 return -EINVAL;
213 264