66
66
#define WPT_TEMP_OFFSET (PCH_TEMP_OFFSET * MILLIDEGREE_PER_DEGREE)
67
67
#define GET_PCH_TEMP (x ) (((x) / 2) + PCH_TEMP_OFFSET)
68
68
69
+ #define PCH_MAX_TRIPS 3 /* critical, hot, passive */
70
+
69
71
/* Amount of time for each cooling delay, 100ms by default for now */
70
72
static unsigned int delay_timeout = 100 ;
71
73
module_param (delay_timeout , int , 0644 );
@@ -83,12 +85,7 @@ struct pch_thermal_device {
83
85
const struct pch_dev_ops * ops ;
84
86
struct pci_dev * pdev ;
85
87
struct thermal_zone_device * tzd ;
86
- int crt_trip_id ;
87
- unsigned long crt_temp ;
88
- int hot_trip_id ;
89
- unsigned long hot_temp ;
90
- int psv_trip_id ;
91
- unsigned long psv_temp ;
88
+ struct thermal_trip trips [PCH_MAX_TRIPS ];
92
89
bool bios_enabled ;
93
90
};
94
91
@@ -103,33 +100,22 @@ static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
103
100
int * nr_trips )
104
101
{
105
102
struct acpi_device * adev ;
106
-
107
- ptd -> psv_trip_id = -1 ;
103
+ int ret ;
108
104
109
105
adev = ACPI_COMPANION (& ptd -> pdev -> dev );
110
- if (adev ) {
111
- unsigned long long r ;
112
- acpi_status status ;
113
-
114
- status = acpi_evaluate_integer (adev -> handle , "_PSV" , NULL ,
115
- & r );
116
- if (ACPI_SUCCESS (status )) {
117
- unsigned long trip_temp ;
118
-
119
- trip_temp = deci_kelvin_to_millicelsius (r );
120
- if (trip_temp ) {
121
- ptd -> psv_temp = trip_temp ;
122
- ptd -> psv_trip_id = * nr_trips ;
123
- ++ (* nr_trips );
124
- }
125
- }
126
- }
106
+ if (!adev )
107
+ return ;
108
+
109
+ ret = thermal_acpi_trip_passive (adev , & ptd -> trips [* nr_trips ]);
110
+ if (ret )
111
+ return ;
112
+
113
+ ++ (* nr_trips );
127
114
}
128
115
#else
129
116
static void pch_wpt_add_acpi_psv_trip (struct pch_thermal_device * ptd ,
130
117
int * nr_trips )
131
118
{
132
- ptd -> psv_trip_id = -1 ;
133
119
134
120
}
135
121
#endif
@@ -164,21 +150,19 @@ static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)
164
150
}
165
151
166
152
read_trips :
167
- ptd -> crt_trip_id = -1 ;
168
153
trip_temp = readw (ptd -> hw_base + WPT_CTT );
169
154
trip_temp &= 0x1FF ;
170
155
if (trip_temp ) {
171
- ptd -> crt_temp = GET_WPT_TEMP (trip_temp );
172
- ptd -> crt_trip_id = 0 ;
156
+ ptd -> trips [ * nr_trips ]. temperature = GET_WPT_TEMP (trip_temp );
157
+ ptd -> trips [ * nr_trips ]. type = THERMAL_TRIP_CRITICAL ;
173
158
++ (* nr_trips );
174
159
}
175
160
176
- ptd -> hot_trip_id = -1 ;
177
161
trip_temp = readw (ptd -> hw_base + WPT_PHL );
178
162
trip_temp &= 0x1FF ;
179
163
if (trip_temp ) {
180
- ptd -> hot_temp = GET_WPT_TEMP (trip_temp );
181
- ptd -> hot_trip_id = * nr_trips ;
164
+ ptd -> trips [ * nr_trips ]. temperature = GET_WPT_TEMP (trip_temp );
165
+ ptd -> trips [ * nr_trips ]. type = THERMAL_TRIP_HOT ;
182
166
++ (* nr_trips );
183
167
}
184
168
@@ -299,48 +283,13 @@ static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp)
299
283
return ptd -> ops -> get_temp (ptd , temp );
300
284
}
301
285
302
- static int pch_get_trip_type (struct thermal_zone_device * tzd , int trip ,
303
- enum thermal_trip_type * type )
304
- {
305
- struct pch_thermal_device * ptd = tzd -> devdata ;
306
-
307
- if (ptd -> crt_trip_id == trip )
308
- * type = THERMAL_TRIP_CRITICAL ;
309
- else if (ptd -> hot_trip_id == trip )
310
- * type = THERMAL_TRIP_HOT ;
311
- else if (ptd -> psv_trip_id == trip )
312
- * type = THERMAL_TRIP_PASSIVE ;
313
- else
314
- return - EINVAL ;
315
-
316
- return 0 ;
317
- }
318
-
319
- static int pch_get_trip_temp (struct thermal_zone_device * tzd , int trip , int * temp )
320
- {
321
- struct pch_thermal_device * ptd = tzd -> devdata ;
322
-
323
- if (ptd -> crt_trip_id == trip )
324
- * temp = ptd -> crt_temp ;
325
- else if (ptd -> hot_trip_id == trip )
326
- * temp = ptd -> hot_temp ;
327
- else if (ptd -> psv_trip_id == trip )
328
- * temp = ptd -> psv_temp ;
329
- else
330
- return - EINVAL ;
331
-
332
- return 0 ;
333
- }
334
-
335
286
static void pch_critical (struct thermal_zone_device * tzd )
336
287
{
337
288
dev_dbg (& tzd -> device , "%s: critical temperature reached\n" , tzd -> type );
338
289
}
339
290
340
291
static struct thermal_zone_device_ops tzd_ops = {
341
292
.get_temp = pch_thermal_get_temp ,
342
- .get_trip_type = pch_get_trip_type ,
343
- .get_trip_temp = pch_get_trip_temp ,
344
293
.critical = pch_critical ,
345
294
};
346
295
@@ -429,8 +378,9 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev,
429
378
if (err )
430
379
goto error_cleanup ;
431
380
432
- ptd -> tzd = thermal_zone_device_register (bi -> name , nr_trips , 0 , ptd ,
433
- & tzd_ops , NULL , 0 , 0 );
381
+ ptd -> tzd = thermal_zone_device_register_with_trips (bi -> name , ptd -> trips ,
382
+ nr_trips , 0 , ptd ,
383
+ & tzd_ops , NULL , 0 , 0 );
434
384
if (IS_ERR (ptd -> tzd )) {
435
385
dev_err (& pdev -> dev , "Failed to register thermal zone %s\n" ,
436
386
bi -> name );
0 commit comments