@@ -117,88 +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
- /* Cool the PCH when it's overheat in .suspend_noirq phase */
121
- static int pch_suspend (struct pch_thermal_device * ptd )
122
- {
123
- u8 tsel ;
124
- int pch_delay_cnt = 0 ;
125
- u16 pch_thr_temp , pch_cur_temp ;
126
-
127
- /* Shutdown the thermal sensor if it is not enabled by BIOS */
128
- if (!ptd -> bios_enabled ) {
129
- tsel = readb (ptd -> hw_base + WPT_TSEL );
130
- writeb (tsel & 0xFE , ptd -> hw_base + WPT_TSEL );
131
- return 0 ;
132
- }
133
-
134
- /* Do not check temperature if it is not s2idle */
135
- if (pm_suspend_via_firmware ())
136
- return 0 ;
137
-
138
- /* Get the PCH temperature threshold value */
139
- pch_thr_temp = GET_PCH_TEMP (WPT_TEMP_TSR & readw (ptd -> hw_base + WPT_TSPM ));
140
-
141
- /* Get the PCH current temperature value */
142
- pch_cur_temp = GET_PCH_TEMP (WPT_TEMP_TSR & readw (ptd -> hw_base + WPT_TEMP ));
143
-
144
- /*
145
- * If current PCH temperature is higher than configured PCH threshold
146
- * value, run some delay loop with sleep to let the current temperature
147
- * go down below the threshold value which helps to allow system enter
148
- * lower power S0ix suspend state. Even after delay loop if PCH current
149
- * temperature stays above threshold, notify the warning message
150
- * which helps to indentify the reason why S0ix entry was rejected.
151
- */
152
- while (pch_delay_cnt < delay_cnt ) {
153
- if (pch_cur_temp < pch_thr_temp )
154
- break ;
155
-
156
- if (pm_wakeup_pending ()) {
157
- dev_warn (& ptd -> pdev -> dev , "Wakeup event detected, abort cooling\n" );
158
- return 0 ;
159
- }
160
-
161
- pch_delay_cnt ++ ;
162
- dev_dbg (& ptd -> pdev -> dev ,
163
- "CPU-PCH current temp [%dC] higher than the threshold temp [%dC], sleep %d times for %d ms duration\n" ,
164
- pch_cur_temp , pch_thr_temp , pch_delay_cnt , delay_timeout );
165
- msleep (delay_timeout );
166
- /* Read the PCH current temperature for next cycle. */
167
- pch_cur_temp = GET_PCH_TEMP (WPT_TEMP_TSR & readw (ptd -> hw_base + WPT_TEMP ));
168
- }
169
-
170
- if (pch_cur_temp >= pch_thr_temp )
171
- dev_warn (& ptd -> pdev -> dev ,
172
- "CPU-PCH is hot [%dC] after %d ms delay. S0ix might fail\n" ,
173
- pch_cur_temp , pch_delay_cnt * delay_timeout );
174
- else {
175
- if (pch_delay_cnt )
176
- dev_info (& ptd -> pdev -> dev ,
177
- "CPU-PCH is cool [%dC] after %d ms delay\n" ,
178
- pch_cur_temp , pch_delay_cnt * delay_timeout );
179
- else
180
- dev_info (& ptd -> pdev -> dev ,
181
- "CPU-PCH is cool [%dC]\n" ,
182
- pch_cur_temp );
183
- }
184
-
185
- return 0 ;
186
- }
187
-
188
- static int pch_resume (struct pch_thermal_device * ptd )
189
- {
190
- u8 tsel ;
191
-
192
- if (ptd -> bios_enabled )
193
- return 0 ;
194
-
195
- tsel = readb (ptd -> hw_base + WPT_TSEL );
196
-
197
- writeb (tsel | WPT_TSEL_ETS , ptd -> hw_base + WPT_TSEL );
198
-
199
- return 0 ;
200
- }
201
-
202
120
static int pch_thermal_get_temp (struct thermal_zone_device * tzd , int * temp )
203
121
{
204
122
struct pch_thermal_device * ptd = tzd -> devdata ;
@@ -372,15 +290,84 @@ static void intel_pch_thermal_remove(struct pci_dev *pdev)
372
290
static int intel_pch_thermal_suspend_noirq (struct device * device )
373
291
{
374
292
struct pch_thermal_device * ptd = dev_get_drvdata (device );
293
+ u16 pch_thr_temp , pch_cur_temp ;
294
+ int pch_delay_cnt = 0 ;
295
+ u8 tsel ;
296
+
297
+ /* Shutdown the thermal sensor if it is not enabled by BIOS */
298
+ if (!ptd -> bios_enabled ) {
299
+ tsel = readb (ptd -> hw_base + WPT_TSEL );
300
+ writeb (tsel & 0xFE , ptd -> hw_base + WPT_TSEL );
301
+ return 0 ;
302
+ }
303
+
304
+ /* Do not check temperature if it is not s2idle */
305
+ if (pm_suspend_via_firmware ())
306
+ return 0 ;
307
+
308
+ /* Get the PCH temperature threshold value */
309
+ pch_thr_temp = GET_PCH_TEMP (WPT_TEMP_TSR & readw (ptd -> hw_base + WPT_TSPM ));
310
+
311
+ /* Get the PCH current temperature value */
312
+ pch_cur_temp = GET_PCH_TEMP (WPT_TEMP_TSR & readw (ptd -> hw_base + WPT_TEMP ));
375
313
376
- return pch_suspend (ptd );
314
+ /*
315
+ * If current PCH temperature is higher than configured PCH threshold
316
+ * value, run some delay loop with sleep to let the current temperature
317
+ * go down below the threshold value which helps to allow system enter
318
+ * lower power S0ix suspend state. Even after delay loop if PCH current
319
+ * temperature stays above threshold, notify the warning message
320
+ * which helps to indentify the reason why S0ix entry was rejected.
321
+ */
322
+ while (pch_delay_cnt < delay_cnt ) {
323
+ if (pch_cur_temp < pch_thr_temp )
324
+ break ;
325
+
326
+ if (pm_wakeup_pending ()) {
327
+ dev_warn (& ptd -> pdev -> dev , "Wakeup event detected, abort cooling\n" );
328
+ return 0 ;
329
+ }
330
+
331
+ pch_delay_cnt ++ ;
332
+ dev_dbg (& ptd -> pdev -> dev ,
333
+ "CPU-PCH current temp [%dC] higher than the threshold temp [%dC], sleep %d times for %d ms duration\n" ,
334
+ pch_cur_temp , pch_thr_temp , pch_delay_cnt , delay_timeout );
335
+ msleep (delay_timeout );
336
+ /* Read the PCH current temperature for next cycle. */
337
+ pch_cur_temp = GET_PCH_TEMP (WPT_TEMP_TSR & readw (ptd -> hw_base + WPT_TEMP ));
338
+ }
339
+
340
+ if (pch_cur_temp >= pch_thr_temp )
341
+ dev_warn (& ptd -> pdev -> dev ,
342
+ "CPU-PCH is hot [%dC] after %d ms delay. S0ix might fail\n" ,
343
+ pch_cur_temp , pch_delay_cnt * delay_timeout );
344
+ else {
345
+ if (pch_delay_cnt )
346
+ dev_info (& ptd -> pdev -> dev ,
347
+ "CPU-PCH is cool [%dC] after %d ms delay\n" ,
348
+ pch_cur_temp , pch_delay_cnt * delay_timeout );
349
+ else
350
+ dev_info (& ptd -> pdev -> dev ,
351
+ "CPU-PCH is cool [%dC]\n" ,
352
+ pch_cur_temp );
353
+ }
354
+
355
+ return 0 ;
377
356
}
378
357
379
358
static int intel_pch_thermal_resume (struct device * device )
380
359
{
381
360
struct pch_thermal_device * ptd = dev_get_drvdata (device );
361
+ u8 tsel ;
382
362
383
- return pch_resume (ptd );
363
+ if (ptd -> bios_enabled )
364
+ return 0 ;
365
+
366
+ tsel = readb (ptd -> hw_base + WPT_TSEL );
367
+
368
+ writeb (tsel | WPT_TSEL_ETS , ptd -> hw_base + WPT_TSEL );
369
+
370
+ return 0 ;
384
371
}
385
372
386
373
static const struct pci_device_id intel_pch_thermal_id [] = {
0 commit comments