Skip to content

Commit 63e39fc

Browse files
bigunclemaxdlezcano
authored andcommitted
thermal/drivers/sun8i: Extend H6 calibration to support 4 sensors
The H616 SoC resembles the H6 thermal sensor controller, with a few changes like four sensors. Extend sun50i_h6_ths_calibrate() function to support calibration of these sensors. Co-developed-by: Martin Botka <[email protected]> Signed-off-by: Martin Botka <[email protected]> Signed-off-by: Maksim Kiselev <[email protected]> Reviewed-by: Andre Przywara <[email protected]> Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Acked-by: Vasily Khoruzhick <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d7bf0a1 commit 63e39fc

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

drivers/thermal/sun8i_thermal.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,21 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev,
222222
struct device *dev = tmdev->dev;
223223
int i, ft_temp;
224224

225-
if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num)
225+
if (!caldata[0])
226226
return -EINVAL;
227227

228228
/*
229229
* efuse layout:
230230
*
231-
* 0 11 16 32
232-
* +-------+-------+-------+
233-
* |temp| |sensor0|sensor1|
234-
* +-------+-------+-------+
231+
* 0 11 16 27 32 43 48 57
232+
* +----------+-----------+-----------+-----------+
233+
* | temp | |sensor0| |sensor1| |sensor2| |
234+
* +----------+-----------+-----------+-----------+
235+
* ^ ^ ^
236+
* | | |
237+
* | | sensor3[11:8]
238+
* | sensor3[7:4]
239+
* sensor3[3:0]
235240
*
236241
* The calibration data on the H6 is the ambient temperature and
237242
* sensor values that are filled during the factory test stage.
@@ -244,9 +249,16 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev,
244249
ft_temp = (caldata[0] & FT_TEMP_MASK) * 100;
245250

246251
for (i = 0; i < tmdev->chip->sensor_num; i++) {
247-
int sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
248-
int cdata, offset;
249-
int sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
252+
int sensor_reg, sensor_temp, cdata, offset;
253+
254+
if (i == 3)
255+
sensor_reg = (caldata[1] >> 12)
256+
| ((caldata[2] >> 12) << 4)
257+
| ((caldata[3] >> 12) << 8);
258+
else
259+
sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
260+
261+
sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
250262

251263
/*
252264
* Calibration data is CALIBRATE_DEFAULT - (calculated

0 commit comments

Comments
 (0)