Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: ti-soc-thermal: remove external heat while extrapolating hotspot

For boards that provide a PCB sensor close to SoC junction
temperature, it is possible to remove the cumulative heat
reported by the SoC temperature sensor.

This patch changes the extrapolation computation to consider
an external sensor in the extrapolation equations.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Eduardo Valentin and committed by
Greg Kroah-Hartman
a85fd2c8 faa4b9de

+20 -10
+20 -10
drivers/staging/ti-soc-thermal/ti-thermal-common.c
··· 38 38 /* common data structures */ 39 39 struct ti_thermal_data { 40 40 struct thermal_zone_device *ti_thermal; 41 + struct thermal_zone_device *pcb_tz; 41 42 struct thermal_cooling_device *cool_dev; 42 43 struct ti_bandgap *bgp; 43 44 enum thermal_device_mode mode; ··· 78 77 static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal, 79 78 unsigned long *temp) 80 79 { 80 + struct thermal_zone_device *pcb_tz = NULL; 81 81 struct ti_thermal_data *data = thermal->devdata; 82 82 struct ti_bandgap *bgp; 83 83 const struct ti_temp_sensor *s; 84 - int ret, tmp, pcb_temp, slope, constant; 84 + int ret, tmp, slope, constant; 85 + unsigned long pcb_temp; 85 86 86 87 if (!data) 87 88 return 0; ··· 95 92 if (ret) 96 93 return ret; 97 94 98 - pcb_temp = 0; 99 - /* TODO: Introduce pcb temperature lookup */ 95 + /* Default constants */ 96 + slope = s->slope; 97 + constant = s->constant; 98 + 99 + pcb_tz = data->pcb_tz; 100 100 /* In case pcb zone is available, use the extrapolation rule with it */ 101 - if (pcb_temp) { 102 - tmp -= pcb_temp; 103 - slope = s->slope_pcb; 104 - constant = s->constant_pcb; 105 - } else { 106 - slope = s->slope; 107 - constant = s->constant; 101 + if (!IS_ERR_OR_NULL(pcb_tz)) { 102 + ret = thermal_zone_get_temp(pcb_tz, &pcb_temp); 103 + if (!ret) { 104 + tmp -= pcb_temp; /* got a valid PCB temp */ 105 + slope = s->slope_pcb; 106 + constant = s->constant_pcb; 107 + } else { 108 + dev_err(bgp->dev, 109 + "Failed to read PCB state. Using defaults\n"); 110 + } 108 111 } 109 112 *temp = ti_thermal_hotspot_temperature(tmp, slope, constant); 110 113 ··· 282 273 data->sensor_id = id; 283 274 data->bgp = bgp; 284 275 data->mode = THERMAL_DEVICE_ENABLED; 276 + data->pcb_tz = thermal_zone_get_zone_by_name("pcb"); 285 277 INIT_WORK(&data->thermal_wq, ti_thermal_work); 286 278 287 279 return data;