0003-v6.2-thermal-drivers-tsens-Allow-configuring-min-and-max-.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From 7805365fee582056b32c69cf35aafbb94b14a8ca Mon Sep 17 00:00:00 2001
  2. From: Robert Marko <[email protected]>
  3. Date: Fri, 19 Aug 2022 00:02:43 +0200
  4. Subject: [PATCH] thermal/drivers/tsens: Allow configuring min and max trips
  5. IPQ8074 and IPQ6018 dont support negative trip temperatures and support
  6. up to 204 degrees C as the max trip temperature.
  7. So, instead of always setting the -40 as min and 120 degrees C as max
  8. allow it to be configured as part of the features.
  9. Signed-off-by: Robert Marko <[email protected]>
  10. Reviewed-by: Bjorn Andersson <[email protected]>
  11. Link: https://lore.kernel.org/r/[email protected]
  12. Signed-off-by: Daniel Lezcano <[email protected]>
  13. ---
  14. drivers/thermal/qcom/tsens-8960.c | 2 ++
  15. drivers/thermal/qcom/tsens-v0_1.c | 2 ++
  16. drivers/thermal/qcom/tsens-v1.c | 2 ++
  17. drivers/thermal/qcom/tsens-v2.c | 2 ++
  18. drivers/thermal/qcom/tsens.c | 4 ++--
  19. drivers/thermal/qcom/tsens.h | 4 ++++
  20. 6 files changed, 14 insertions(+), 2 deletions(-)
  21. --- a/drivers/thermal/qcom/tsens-8960.c
  22. +++ b/drivers/thermal/qcom/tsens-8960.c
  23. @@ -273,6 +273,8 @@ static struct tsens_features tsens_8960_
  24. .adc = 1,
  25. .srot_split = 0,
  26. .max_sensors = 11,
  27. + .trip_min_temp = -40000,
  28. + .trip_max_temp = 120000,
  29. };
  30. struct tsens_plat_data data_8960 = {
  31. --- a/drivers/thermal/qcom/tsens-v0_1.c
  32. +++ b/drivers/thermal/qcom/tsens-v0_1.c
  33. @@ -553,6 +553,8 @@ static struct tsens_features tsens_v0_1_
  34. .adc = 1,
  35. .srot_split = 1,
  36. .max_sensors = 11,
  37. + .trip_min_temp = -40000,
  38. + .trip_max_temp = 120000,
  39. };
  40. static const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = {
  41. --- a/drivers/thermal/qcom/tsens-v1.c
  42. +++ b/drivers/thermal/qcom/tsens-v1.c
  43. @@ -277,6 +277,8 @@ static struct tsens_features tsens_v1_fe
  44. .adc = 1,
  45. .srot_split = 1,
  46. .max_sensors = 11,
  47. + .trip_min_temp = -40000,
  48. + .trip_max_temp = 120000,
  49. };
  50. static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = {
  51. --- a/drivers/thermal/qcom/tsens-v2.c
  52. +++ b/drivers/thermal/qcom/tsens-v2.c
  53. @@ -35,6 +35,8 @@ static struct tsens_features tsens_v2_fe
  54. .adc = 0,
  55. .srot_split = 1,
  56. .max_sensors = 16,
  57. + .trip_min_temp = -40000,
  58. + .trip_max_temp = 120000,
  59. };
  60. static const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = {
  61. --- a/drivers/thermal/qcom/tsens.c
  62. +++ b/drivers/thermal/qcom/tsens.c
  63. @@ -573,8 +573,8 @@ static int tsens_set_trips(struct therma
  64. dev_dbg(dev, "[%u] %s: proposed thresholds: (%d:%d)\n",
  65. hw_id, __func__, low, high);
  66. - cl_high = clamp_val(high, -40000, 120000);
  67. - cl_low = clamp_val(low, -40000, 120000);
  68. + cl_high = clamp_val(high, priv->feat->trip_min_temp, priv->feat->trip_max_temp);
  69. + cl_low = clamp_val(low, priv->feat->trip_min_temp, priv->feat->trip_max_temp);
  70. high_val = tsens_mC_to_hw(s, cl_high);
  71. low_val = tsens_mC_to_hw(s, cl_low);
  72. --- a/drivers/thermal/qcom/tsens.h
  73. +++ b/drivers/thermal/qcom/tsens.h
  74. @@ -499,6 +499,8 @@ enum regfield_ids {
  75. * with SROT only being available to secure boot firmware?
  76. * @has_watchdog: does this IP support watchdog functionality?
  77. * @max_sensors: maximum sensors supported by this version of the IP
  78. + * @trip_min_temp: minimum trip temperature supported by this version of the IP
  79. + * @trip_max_temp: maximum trip temperature supported by this version of the IP
  80. */
  81. struct tsens_features {
  82. unsigned int ver_major;
  83. @@ -508,6 +510,8 @@ struct tsens_features {
  84. unsigned int srot_split:1;
  85. unsigned int has_watchdog:1;
  86. unsigned int max_sensors;
  87. + int trip_min_temp;
  88. + int trip_max_temp;
  89. };
  90. /**