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>
This commit is contained in:
parent
faa4b9de12
commit
a85fd2c8fd
1 changed files with 20 additions and 10 deletions
|
@ -38,6 +38,7 @@
|
||||||
/* common data structures */
|
/* common data structures */
|
||||||
struct ti_thermal_data {
|
struct ti_thermal_data {
|
||||||
struct thermal_zone_device *ti_thermal;
|
struct thermal_zone_device *ti_thermal;
|
||||||
|
struct thermal_zone_device *pcb_tz;
|
||||||
struct thermal_cooling_device *cool_dev;
|
struct thermal_cooling_device *cool_dev;
|
||||||
struct ti_bandgap *bgp;
|
struct ti_bandgap *bgp;
|
||||||
enum thermal_device_mode mode;
|
enum thermal_device_mode mode;
|
||||||
|
@ -77,10 +78,12 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)
|
||||||
static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
|
static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
|
||||||
unsigned long *temp)
|
unsigned long *temp)
|
||||||
{
|
{
|
||||||
|
struct thermal_zone_device *pcb_tz = NULL;
|
||||||
struct ti_thermal_data *data = thermal->devdata;
|
struct ti_thermal_data *data = thermal->devdata;
|
||||||
struct ti_bandgap *bgp;
|
struct ti_bandgap *bgp;
|
||||||
const struct ti_temp_sensor *s;
|
const struct ti_temp_sensor *s;
|
||||||
int ret, tmp, pcb_temp, slope, constant;
|
int ret, tmp, slope, constant;
|
||||||
|
unsigned long pcb_temp;
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -92,16 +95,22 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
pcb_temp = 0;
|
/* Default constants */
|
||||||
/* TODO: Introduce pcb temperature lookup */
|
slope = s->slope;
|
||||||
|
constant = s->constant;
|
||||||
|
|
||||||
|
pcb_tz = data->pcb_tz;
|
||||||
/* In case pcb zone is available, use the extrapolation rule with it */
|
/* In case pcb zone is available, use the extrapolation rule with it */
|
||||||
if (pcb_temp) {
|
if (!IS_ERR_OR_NULL(pcb_tz)) {
|
||||||
tmp -= pcb_temp;
|
ret = thermal_zone_get_temp(pcb_tz, &pcb_temp);
|
||||||
slope = s->slope_pcb;
|
if (!ret) {
|
||||||
constant = s->constant_pcb;
|
tmp -= pcb_temp; /* got a valid PCB temp */
|
||||||
} else {
|
slope = s->slope_pcb;
|
||||||
slope = s->slope;
|
constant = s->constant_pcb;
|
||||||
constant = s->constant;
|
} else {
|
||||||
|
dev_err(bgp->dev,
|
||||||
|
"Failed to read PCB state. Using defaults\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*temp = ti_thermal_hotspot_temperature(tmp, slope, constant);
|
*temp = ti_thermal_hotspot_temperature(tmp, slope, constant);
|
||||||
|
|
||||||
|
@ -273,6 +282,7 @@ static struct ti_thermal_data
|
||||||
data->sensor_id = id;
|
data->sensor_id = id;
|
||||||
data->bgp = bgp;
|
data->bgp = bgp;
|
||||||
data->mode = THERMAL_DEVICE_ENABLED;
|
data->mode = THERMAL_DEVICE_ENABLED;
|
||||||
|
data->pcb_tz = thermal_zone_get_zone_by_name("pcb");
|
||||||
INIT_WORK(&data->thermal_wq, ti_thermal_work);
|
INIT_WORK(&data->thermal_wq, ti_thermal_work);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Add table
Reference in a new issue