84
84
#define QRK_DTS_MASK_TP_THRES 0xFF
85
85
#define QRK_DTS_SHIFT_TP 8
86
86
#define QRK_DTS_ID_TP_CRITICAL 0
87
+ #define QRK_DTS_ID_TP_HOT 1
87
88
#define QRK_DTS_SAFE_TP_THRES 105
88
89
89
90
/* Thermal Sensor Register Lock */
@@ -104,6 +105,7 @@ struct soc_sensor_entry {
104
105
u32 store_ptps ;
105
106
u32 store_dts_enable ;
106
107
struct thermal_zone_device * tzone ;
108
+ struct thermal_trip trips [QRK_MAX_DTS_TRIPS ];
107
109
};
108
110
109
111
static struct soc_sensor_entry * soc_dts ;
@@ -172,9 +174,9 @@ static int soc_dts_disable(struct thermal_zone_device *tzd)
172
174
return ret ;
173
175
}
174
176
175
- static int _get_trip_temp (int trip , int * temp )
177
+ static int get_trip_temp (int trip )
176
178
{
177
- int status ;
179
+ int status , temp ;
178
180
u32 out ;
179
181
180
182
mutex_lock (& dts_update_mutex );
@@ -183,29 +185,18 @@ static int _get_trip_temp(int trip, int *temp)
183
185
mutex_unlock (& dts_update_mutex );
184
186
185
187
if (status )
186
- return status ;
188
+ return THERMAL_TEMP_INVALID ;
187
189
188
190
/*
189
191
* Thermal Sensor Programmable Trip Point Register has 8-bit
190
192
* fields for critical (catastrophic) and hot set trip point
191
193
* thresholds. The threshold value is always offset by its
192
194
* temperature base (50 degree Celsius).
193
195
*/
194
- * temp = (out >> (trip * QRK_DTS_SHIFT_TP )) & QRK_DTS_MASK_TP_THRES ;
195
- * temp -= QRK_DTS_TEMP_BASE ;
196
+ temp = (out >> (trip * QRK_DTS_SHIFT_TP )) & QRK_DTS_MASK_TP_THRES ;
197
+ temp -= QRK_DTS_TEMP_BASE ;
196
198
197
- return 0 ;
198
- }
199
-
200
- static inline int sys_get_trip_temp (struct thermal_zone_device * tzd ,
201
- int trip , int * temp )
202
- {
203
- return _get_trip_temp (trip , temp );
204
- }
205
-
206
- static inline int sys_get_crit_temp (struct thermal_zone_device * tzd , int * temp )
207
- {
208
- return _get_trip_temp (QRK_DTS_ID_TP_CRITICAL , temp );
199
+ return temp ;
209
200
}
210
201
211
202
static int update_trip_temp (struct soc_sensor_entry * aux_entry ,
@@ -262,17 +253,6 @@ static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
262
253
return update_trip_temp (tzd -> devdata , trip , temp );
263
254
}
264
255
265
- static int sys_get_trip_type (struct thermal_zone_device * thermal ,
266
- int trip , enum thermal_trip_type * type )
267
- {
268
- if (trip )
269
- * type = THERMAL_TRIP_HOT ;
270
- else
271
- * type = THERMAL_TRIP_CRITICAL ;
272
-
273
- return 0 ;
274
- }
275
-
276
256
static int sys_get_curr_temp (struct thermal_zone_device * tzd ,
277
257
int * temp )
278
258
{
@@ -315,10 +295,7 @@ static int sys_change_mode(struct thermal_zone_device *tzd,
315
295
316
296
static struct thermal_zone_device_ops tzone_ops = {
317
297
.get_temp = sys_get_curr_temp ,
318
- .get_trip_temp = sys_get_trip_temp ,
319
- .get_trip_type = sys_get_trip_type ,
320
298
.set_trip_temp = sys_set_trip_temp ,
321
- .get_crit_temp = sys_get_crit_temp ,
322
299
.change_mode = sys_change_mode ,
323
300
};
324
301
@@ -385,10 +362,18 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
385
362
goto err_ret ;
386
363
}
387
364
388
- aux_entry -> tzone = thermal_zone_device_register ("quark_dts" ,
389
- QRK_MAX_DTS_TRIPS ,
390
- wr_mask ,
391
- aux_entry , & tzone_ops , NULL , 0 , polling_delay );
365
+ aux_entry -> trips [QRK_DTS_ID_TP_CRITICAL ].temperature = get_trip_temp (QRK_DTS_ID_TP_CRITICAL );
366
+ aux_entry -> trips [QRK_DTS_ID_TP_CRITICAL ].type = THERMAL_TRIP_CRITICAL ;
367
+
368
+ aux_entry -> trips [QRK_DTS_ID_TP_HOT ].temperature = get_trip_temp (QRK_DTS_ID_TP_HOT );
369
+ aux_entry -> trips [QRK_DTS_ID_TP_HOT ].type = THERMAL_TRIP_HOT ;
370
+
371
+ aux_entry -> tzone = thermal_zone_device_register_with_trips ("quark_dts" ,
372
+ aux_entry -> trips ,
373
+ QRK_MAX_DTS_TRIPS ,
374
+ wr_mask ,
375
+ aux_entry , & tzone_ops ,
376
+ NULL , 0 , polling_delay );
392
377
if (IS_ERR (aux_entry -> tzone )) {
393
378
err = PTR_ERR (aux_entry -> tzone );
394
379
goto err_ret ;
0 commit comments