@@ -117,57 +117,6 @@ static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip)
117
117
}
118
118
#endif
119
119
120
- static int pch_hw_init (struct pch_thermal_device * ptd )
121
- {
122
- int nr_trips = 0 ;
123
- u16 trip_temp ;
124
- u8 tsel ;
125
-
126
- /* Check if BIOS has already enabled thermal sensor */
127
- if (WPT_TSEL_ETS & readb (ptd -> hw_base + WPT_TSEL )) {
128
- ptd -> bios_enabled = true;
129
- goto read_trips ;
130
- }
131
-
132
- tsel = readb (ptd -> hw_base + WPT_TSEL );
133
- /*
134
- * When TSEL's Policy Lock-Down bit is 1, TSEL become RO.
135
- * If so, thermal sensor cannot enable. Bail out.
136
- */
137
- if (tsel & WPT_TSEL_PLDB ) {
138
- dev_err (& ptd -> pdev -> dev , "Sensor can't be enabled\n" );
139
- return - ENODEV ;
140
- }
141
-
142
- writeb (tsel |WPT_TSEL_ETS , ptd -> hw_base + WPT_TSEL );
143
- if (!(WPT_TSEL_ETS & readb (ptd -> hw_base + WPT_TSEL ))) {
144
- dev_err (& ptd -> pdev -> dev , "Sensor can't be enabled\n" );
145
- return - ENODEV ;
146
- }
147
-
148
- read_trips :
149
- trip_temp = readw (ptd -> hw_base + WPT_CTT );
150
- trip_temp &= 0x1FF ;
151
- if (trip_temp ) {
152
- ptd -> trips [nr_trips ].temperature = GET_WPT_TEMP (trip_temp );
153
- ptd -> trips [nr_trips ++ ].type = THERMAL_TRIP_CRITICAL ;
154
- }
155
-
156
- trip_temp = readw (ptd -> hw_base + WPT_PHL );
157
- trip_temp &= 0x1FF ;
158
- if (trip_temp ) {
159
- ptd -> trips [nr_trips ].temperature = GET_WPT_TEMP (trip_temp );
160
- ptd -> trips [nr_trips ++ ].type = THERMAL_TRIP_HOT ;
161
- }
162
-
163
- return nr_trips + pch_wpt_add_acpi_psv_trip (ptd , nr_trips );
164
- }
165
-
166
- static int pch_get_temp (struct pch_thermal_device * ptd )
167
- {
168
- return GET_WPT_TEMP (WPT_TEMP_TSR & readw (ptd -> hw_base + WPT_TEMP ));
169
- }
170
-
171
120
/* Cool the PCH when it's overheat in .suspend_noirq phase */
172
121
static int pch_suspend (struct pch_thermal_device * ptd )
173
122
{
@@ -254,7 +203,7 @@ static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp)
254
203
{
255
204
struct pch_thermal_device * ptd = tzd -> devdata ;
256
205
257
- * temp = pch_get_temp ( ptd );
206
+ * temp = GET_WPT_TEMP ( WPT_TEMP_TSR & readw ( ptd -> hw_base + WPT_TEMP ) );
258
207
return 0 ;
259
208
}
260
209
@@ -310,8 +259,10 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev,
310
259
enum board_ids board_id = id -> driver_data ;
311
260
const struct board_info * bi = & board_info [board_id ];
312
261
struct pch_thermal_device * ptd ;
262
+ int nr_trips = 0 ;
263
+ u16 trip_temp ;
264
+ u8 tsel ;
313
265
int err ;
314
- int nr_trips ;
315
266
316
267
ptd = devm_kzalloc (& pdev -> dev , sizeof (* ptd ), GFP_KERNEL );
317
268
if (!ptd )
@@ -339,12 +290,47 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev,
339
290
goto error_release ;
340
291
}
341
292
342
- nr_trips = pch_hw_init (ptd );
343
- if (nr_trips < 0 ) {
344
- err = nr_trips ;
293
+ /* Check if BIOS has already enabled thermal sensor */
294
+ if (WPT_TSEL_ETS & readb (ptd -> hw_base + WPT_TSEL )) {
295
+ ptd -> bios_enabled = true;
296
+ goto read_trips ;
297
+ }
298
+
299
+ tsel = readb (ptd -> hw_base + WPT_TSEL );
300
+ /*
301
+ * When TSEL's Policy Lock-Down bit is 1, TSEL become RO.
302
+ * If so, thermal sensor cannot enable. Bail out.
303
+ */
304
+ if (tsel & WPT_TSEL_PLDB ) {
305
+ dev_err (& ptd -> pdev -> dev , "Sensor can't be enabled\n" );
306
+ err = - ENODEV ;
345
307
goto error_cleanup ;
346
308
}
347
309
310
+ writeb (tsel |WPT_TSEL_ETS , ptd -> hw_base + WPT_TSEL );
311
+ if (!(WPT_TSEL_ETS & readb (ptd -> hw_base + WPT_TSEL ))) {
312
+ dev_err (& ptd -> pdev -> dev , "Sensor can't be enabled\n" );
313
+ err = - ENODEV ;
314
+ goto error_cleanup ;
315
+ }
316
+
317
+ read_trips :
318
+ trip_temp = readw (ptd -> hw_base + WPT_CTT );
319
+ trip_temp &= 0x1FF ;
320
+ if (trip_temp ) {
321
+ ptd -> trips [nr_trips ].temperature = GET_WPT_TEMP (trip_temp );
322
+ ptd -> trips [nr_trips ++ ].type = THERMAL_TRIP_CRITICAL ;
323
+ }
324
+
325
+ trip_temp = readw (ptd -> hw_base + WPT_PHL );
326
+ trip_temp &= 0x1FF ;
327
+ if (trip_temp ) {
328
+ ptd -> trips [nr_trips ].temperature = GET_WPT_TEMP (trip_temp );
329
+ ptd -> trips [nr_trips ++ ].type = THERMAL_TRIP_HOT ;
330
+ }
331
+
332
+ nr_trips += pch_wpt_add_acpi_psv_trip (ptd , nr_trips );
333
+
348
334
ptd -> tzd = thermal_zone_device_register_with_trips (bi -> name , ptd -> trips ,
349
335
nr_trips , 0 , ptd ,
350
336
& tzd_ops , NULL , 0 , 0 );
0 commit comments