46
46
* measured by the on-die thermal monitor are within 0 <= Tj <= 90. So,
47
47
* assume 89°C is critical temperature.
48
48
*/
49
+ #define ACERHDF_DEFAULT_TEMP_FANON 60000
50
+ #define ACERHDF_DEFAULT_TEMP_FANOFF 53000
49
51
#define ACERHDF_TEMP_CRIT 89000
50
52
#define ACERHDF_FAN_OFF 0
51
53
#define ACERHDF_FAN_AUTO 1
@@ -70,8 +72,8 @@ static int kernelmode;
70
72
#endif
71
73
72
74
static unsigned int interval = 10 ;
73
- static unsigned int fanon = 60000 ;
74
- static unsigned int fanoff = 53000 ;
75
+ static unsigned int fanon = ACERHDF_DEFAULT_TEMP_FANON ;
76
+ static unsigned int fanoff = ACERHDF_DEFAULT_TEMP_FANOFF ;
75
77
static unsigned int verbose ;
76
78
static unsigned int list_supported ;
77
79
static unsigned int fanstate = ACERHDF_FAN_AUTO ;
@@ -137,6 +139,15 @@ struct ctrl_settings {
137
139
int mcmd_enable ;
138
140
};
139
141
142
+ static struct thermal_trip trips [] = {
143
+ [0 ] = { .temperature = ACERHDF_DEFAULT_TEMP_FANON ,
144
+ .hysteresis = ACERHDF_DEFAULT_TEMP_FANON - ACERHDF_DEFAULT_TEMP_FANOFF ,
145
+ .type = THERMAL_TRIP_ACTIVE },
146
+
147
+ [1 ] = { .temperature = ACERHDF_TEMP_CRIT ,
148
+ .type = THERMAL_TRIP_CRITICAL }
149
+ };
150
+
140
151
static struct ctrl_settings ctrl_cfg __read_mostly ;
141
152
142
153
/* Register addresses and values for different BIOS versions */
@@ -326,6 +337,15 @@ static void acerhdf_check_param(struct thermal_zone_device *thermal)
326
337
fanon = ACERHDF_MAX_FANON ;
327
338
}
328
339
340
+ if (fanon < fanoff ) {
341
+ pr_err ("fanoff temperature (%d) is above fanon temperature (%d), clamping to %d\n" ,
342
+ fanoff , fanon , fanon );
343
+ fanoff = fanon ;
344
+ };
345
+
346
+ trips [0 ].temperature = fanon ;
347
+ trips [0 ].hysteresis = fanon - fanoff ;
348
+
329
349
if (kernelmode && prev_interval != interval ) {
330
350
if (interval > ACERHDF_MAX_INTERVAL ) {
331
351
pr_err ("interval too high, set to %d\n" ,
@@ -424,43 +444,6 @@ static int acerhdf_change_mode(struct thermal_zone_device *thermal,
424
444
return 0 ;
425
445
}
426
446
427
- static int acerhdf_get_trip_type (struct thermal_zone_device * thermal , int trip ,
428
- enum thermal_trip_type * type )
429
- {
430
- if (trip == 0 )
431
- * type = THERMAL_TRIP_ACTIVE ;
432
- else if (trip == 1 )
433
- * type = THERMAL_TRIP_CRITICAL ;
434
- else
435
- return - EINVAL ;
436
-
437
- return 0 ;
438
- }
439
-
440
- static int acerhdf_get_trip_hyst (struct thermal_zone_device * thermal , int trip ,
441
- int * temp )
442
- {
443
- if (trip != 0 )
444
- return - EINVAL ;
445
-
446
- * temp = fanon - fanoff ;
447
-
448
- return 0 ;
449
- }
450
-
451
- static int acerhdf_get_trip_temp (struct thermal_zone_device * thermal , int trip ,
452
- int * temp )
453
- {
454
- if (trip == 0 )
455
- * temp = fanon ;
456
- else if (trip == 1 )
457
- * temp = ACERHDF_TEMP_CRIT ;
458
- else
459
- return - EINVAL ;
460
-
461
- return 0 ;
462
- }
463
-
464
447
static int acerhdf_get_crit_temp (struct thermal_zone_device * thermal ,
465
448
int * temperature )
466
449
{
@@ -474,13 +457,9 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
474
457
.unbind = acerhdf_unbind ,
475
458
.get_temp = acerhdf_get_ec_temp ,
476
459
.change_mode = acerhdf_change_mode ,
477
- .get_trip_type = acerhdf_get_trip_type ,
478
- .get_trip_hyst = acerhdf_get_trip_hyst ,
479
- .get_trip_temp = acerhdf_get_trip_temp ,
480
460
.get_crit_temp = acerhdf_get_crit_temp ,
481
461
};
482
462
483
-
484
463
/*
485
464
* cooling device callback functions
486
465
* get maximal fan cooling state
@@ -710,10 +689,10 @@ static int __init acerhdf_register_thermal(void)
710
689
if (IS_ERR (cl_dev ))
711
690
return - EINVAL ;
712
691
713
- thz_dev = thermal_zone_device_register ("acerhdf" , 2 , 0 , NULL ,
714
- & acerhdf_dev_ops ,
715
- & acerhdf_zone_params , 0 ,
716
- (kernelmode ) ? interval * 1000 : 0 );
692
+ thz_dev = thermal_zone_device_register_with_trips ("acerhdf" , trips , ARRAY_SIZE ( trips ) ,
693
+ 0 , NULL , & acerhdf_dev_ops ,
694
+ & acerhdf_zone_params , 0 ,
695
+ (kernelmode ) ? interval * 1000 : 0 );
717
696
if (IS_ERR (thz_dev ))
718
697
return - EINVAL ;
719
698
0 commit comments