diff options
author | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-05-29 11:07:41 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-06-12 22:12:22 -0400 |
commit | 359836e1de4d32a647bf2c1f99d84d2ff0a098bd (patch) | |
tree | aa9e1067d010db8645d3e493270339a9600d748e /drivers/thermal/ti-soc-thermal | |
parent | 0c1569590a6f14130b3660241580036176dba718 (diff) |
thermal: 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.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/ti-soc-thermal')
-rw-r--r-- | drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index e3c5e677eaa5..8e67ebf98404 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c | |||
@@ -38,6 +38,7 @@ | |||
38 | /* common data structures */ | 38 | /* common data structures */ |
39 | struct ti_thermal_data { | 39 | struct ti_thermal_data { |
40 | struct thermal_zone_device *ti_thermal; | 40 | struct thermal_zone_device *ti_thermal; |
41 | struct thermal_zone_device *pcb_tz; | ||
41 | struct thermal_cooling_device *cool_dev; | 42 | struct thermal_cooling_device *cool_dev; |
42 | struct ti_bandgap *bgp; | 43 | struct ti_bandgap *bgp; |
43 | enum thermal_device_mode mode; | 44 | enum thermal_device_mode mode; |
@@ -77,10 +78,12 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c) | |||
77 | static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal, | 78 | static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal, |
78 | unsigned long *temp) | 79 | unsigned long *temp) |
79 | { | 80 | { |
81 | struct thermal_zone_device *pcb_tz = NULL; | ||
80 | struct ti_thermal_data *data = thermal->devdata; | 82 | struct ti_thermal_data *data = thermal->devdata; |
81 | struct ti_bandgap *bgp; | 83 | struct ti_bandgap *bgp; |
82 | const struct ti_temp_sensor *s; | 84 | const struct ti_temp_sensor *s; |
83 | int ret, tmp, pcb_temp, slope, constant; | 85 | int ret, tmp, slope, constant; |
86 | unsigned long pcb_temp; | ||
84 | 87 | ||
85 | if (!data) | 88 | if (!data) |
86 | return 0; | 89 | return 0; |
@@ -92,16 +95,22 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal, | |||
92 | if (ret) | 95 | if (ret) |
93 | return ret; | 96 | return ret; |
94 | 97 | ||
95 | pcb_temp = 0; | 98 | /* Default constants */ |
96 | /* TODO: Introduce pcb temperature lookup */ | 99 | slope = s->slope; |
100 | constant = s->constant; | ||
101 | |||
102 | pcb_tz = data->pcb_tz; | ||
97 | /* In case pcb zone is available, use the extrapolation rule with it */ | 103 | /* In case pcb zone is available, use the extrapolation rule with it */ |
98 | if (pcb_temp) { | 104 | if (!IS_ERR_OR_NULL(pcb_tz)) { |
99 | tmp -= pcb_temp; | 105 | ret = thermal_zone_get_temp(pcb_tz, &pcb_temp); |
100 | slope = s->slope_pcb; | 106 | if (!ret) { |
101 | constant = s->constant_pcb; | 107 | tmp -= pcb_temp; /* got a valid PCB temp */ |
102 | } else { | 108 | slope = s->slope_pcb; |
103 | slope = s->slope; | 109 | constant = s->constant_pcb; |
104 | constant = s->constant; | 110 | } else { |
111 | dev_err(bgp->dev, | ||
112 | "Failed to read PCB state. Using defaults\n"); | ||
113 | } | ||
105 | } | 114 | } |
106 | *temp = ti_thermal_hotspot_temperature(tmp, slope, constant); | 115 | *temp = ti_thermal_hotspot_temperature(tmp, slope, constant); |
107 | 116 | ||
@@ -273,6 +282,7 @@ static struct ti_thermal_data | |||
273 | data->sensor_id = id; | 282 | data->sensor_id = id; |
274 | data->bgp = bgp; | 283 | data->bgp = bgp; |
275 | data->mode = THERMAL_DEVICE_ENABLED; | 284 | data->mode = THERMAL_DEVICE_ENABLED; |
285 | data->pcb_tz = thermal_zone_get_zone_by_name("pcb"); | ||
276 | INIT_WORK(&data->thermal_wq, ti_thermal_work); | 286 | INIT_WORK(&data->thermal_wq, ti_thermal_work); |
277 | 287 | ||
278 | return data; | 288 | return data; |