2
0

012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 6c04a419a4c5fb18edefc44dd676fb95c7f6c55d Mon Sep 17 00:00:00 2001
  2. From: Maksim Kiselev <[email protected]>
  3. Date: Mon, 19 Feb 2024 15:36:36 +0000
  4. Subject: [PATCH] thermal/drivers/sun8i: Extend H6 calibration to support 4
  5. sensors
  6. The H616 SoC resembles the H6 thermal sensor controller, with a few
  7. changes like four sensors.
  8. Extend sun50i_h6_ths_calibrate() function to support calibration of
  9. these sensors.
  10. Co-developed-by: Martin Botka <[email protected]>
  11. Signed-off-by: Martin Botka <[email protected]>
  12. Signed-off-by: Maksim Kiselev <[email protected]>
  13. Reviewed-by: Andre Przywara <[email protected]>
  14. Signed-off-by: Andre Przywara <[email protected]>
  15. Reviewed-by: Jernej Skrabec <[email protected]>
  16. Acked-by: Vasily Khoruzhick <[email protected]>
  17. Signed-off-by: Daniel Lezcano <[email protected]>
  18. Link: https://lore.kernel.org/r/[email protected]
  19. ---
  20. drivers/thermal/sun8i_thermal.c | 28 ++++++++++++++++++++--------
  21. 1 file changed, 20 insertions(+), 8 deletions(-)
  22. --- a/drivers/thermal/sun8i_thermal.c
  23. +++ b/drivers/thermal/sun8i_thermal.c
  24. @@ -224,16 +224,21 @@ static int sun50i_h6_ths_calibrate(struc
  25. struct device *dev = tmdev->dev;
  26. int i, ft_temp;
  27. - if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num)
  28. + if (!caldata[0])
  29. return -EINVAL;
  30. /*
  31. * efuse layout:
  32. *
  33. - * 0 11 16 32
  34. - * +-------+-------+-------+
  35. - * |temp| |sensor0|sensor1|
  36. - * +-------+-------+-------+
  37. + * 0 11 16 27 32 43 48 57
  38. + * +----------+-----------+-----------+-----------+
  39. + * | temp | |sensor0| |sensor1| |sensor2| |
  40. + * +----------+-----------+-----------+-----------+
  41. + * ^ ^ ^
  42. + * | | |
  43. + * | | sensor3[11:8]
  44. + * | sensor3[7:4]
  45. + * sensor3[3:0]
  46. *
  47. * The calibration data on the H6 is the ambient temperature and
  48. * sensor values that are filled during the factory test stage.
  49. @@ -246,9 +251,16 @@ static int sun50i_h6_ths_calibrate(struc
  50. ft_temp = (caldata[0] & FT_TEMP_MASK) * 100;
  51. for (i = 0; i < tmdev->chip->sensor_num; i++) {
  52. - int sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
  53. - int cdata, offset;
  54. - int sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
  55. + int sensor_reg, sensor_temp, cdata, offset;
  56. +
  57. + if (i == 3)
  58. + sensor_reg = (caldata[1] >> 12)
  59. + | ((caldata[2] >> 12) << 4)
  60. + | ((caldata[3] >> 12) << 8);
  61. + else
  62. + sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
  63. +
  64. + sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
  65. /*
  66. * Calibration data is CALIBRATE_DEFAULT - (calculated