Skip to content

Commit 72ffc28

Browse files
dlezcanorafaeljw
authored andcommitted
thermal: intel: quark_dts: Use generic trip points
Make the intel_quark_dts_thermal driver register an array of generic trip points along with the thermal zone and drop the trip points thermal zone callbacks that are not used any more from it. Signed-off-by: Daniel Lezcano <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 8526eb7 commit 72ffc28

File tree

1 file changed

+20
-35
lines changed

1 file changed

+20
-35
lines changed

drivers/thermal/intel/intel_quark_dts_thermal.c

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#define QRK_DTS_MASK_TP_THRES 0xFF
8585
#define QRK_DTS_SHIFT_TP 8
8686
#define QRK_DTS_ID_TP_CRITICAL 0
87+
#define QRK_DTS_ID_TP_HOT 1
8788
#define QRK_DTS_SAFE_TP_THRES 105
8889

8990
/* Thermal Sensor Register Lock */
@@ -104,6 +105,7 @@ struct soc_sensor_entry {
104105
u32 store_ptps;
105106
u32 store_dts_enable;
106107
struct thermal_zone_device *tzone;
108+
struct thermal_trip trips[QRK_MAX_DTS_TRIPS];
107109
};
108110

109111
static struct soc_sensor_entry *soc_dts;
@@ -172,9 +174,9 @@ static int soc_dts_disable(struct thermal_zone_device *tzd)
172174
return ret;
173175
}
174176

175-
static int _get_trip_temp(int trip, int *temp)
177+
static int get_trip_temp(int trip)
176178
{
177-
int status;
179+
int status, temp;
178180
u32 out;
179181

180182
mutex_lock(&dts_update_mutex);
@@ -183,29 +185,18 @@ static int _get_trip_temp(int trip, int *temp)
183185
mutex_unlock(&dts_update_mutex);
184186

185187
if (status)
186-
return status;
188+
return THERMAL_TEMP_INVALID;
187189

188190
/*
189191
* Thermal Sensor Programmable Trip Point Register has 8-bit
190192
* fields for critical (catastrophic) and hot set trip point
191193
* thresholds. The threshold value is always offset by its
192194
* temperature base (50 degree Celsius).
193195
*/
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;
196198

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;
209200
}
210201

211202
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,
262253
return update_trip_temp(tzd->devdata, trip, temp);
263254
}
264255

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-
276256
static int sys_get_curr_temp(struct thermal_zone_device *tzd,
277257
int *temp)
278258
{
@@ -315,10 +295,7 @@ static int sys_change_mode(struct thermal_zone_device *tzd,
315295

316296
static struct thermal_zone_device_ops tzone_ops = {
317297
.get_temp = sys_get_curr_temp,
318-
.get_trip_temp = sys_get_trip_temp,
319-
.get_trip_type = sys_get_trip_type,
320298
.set_trip_temp = sys_set_trip_temp,
321-
.get_crit_temp = sys_get_crit_temp,
322299
.change_mode = sys_change_mode,
323300
};
324301

@@ -385,10 +362,18 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
385362
goto err_ret;
386363
}
387364

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);
392377
if (IS_ERR(aux_entry->tzone)) {
393378
err = PTR_ERR(aux_entry->tzone);
394379
goto err_ret;

0 commit comments

Comments
 (0)