aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2016-08-26 19:21:16 -0400
committerZhang Rui <rui.zhang@intel.com>2016-09-27 02:35:21 -0400
commit0e70f466fb910ae54c4c71243b99385129e93feb (patch)
treebe1535a5675f7afa8a09cd09a119fddaeb24d662 /drivers/thermal
parent040a3eadf00b4993fb215fba1d788c91712401ba (diff)
thermal: Enhance thermal_zone_device_update for events
Added one additional parameter to thermal_zone_device_update() to provide caller with an optional capability to specify reason. Currently this event is used by user space governor to trigger different processing based on event code. Also it saves an additional call to read temperature when the event is received. The following events are cuurently defined: - Unspecified event - New temperature sample - Trip point violated - Trip point changed - thermal device up and down - thermal device power capability changed Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/db8500_thermal.c2
-rw-r--r--drivers/thermal/hisi_thermal.c3
-rw-r--r--drivers/thermal/imx_thermal.c4
-rw-r--r--drivers/thermal/int340x_thermal/int340x_thermal_zone.h2
-rw-r--r--drivers/thermal/intel_bxt_pmic_thermal.c3
-rw-r--r--drivers/thermal/intel_soc_dts_iosf.c3
-rw-r--r--drivers/thermal/max77620_thermal.c3
-rw-r--r--drivers/thermal/of-thermal.c2
-rw-r--r--drivers/thermal/qcom-spmi-temp-alarm.c2
-rw-r--r--drivers/thermal/rcar_thermal.c3
-rw-r--r--drivers/thermal/rockchip_thermal.c3
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c2
-rw-r--r--drivers/thermal/st/st_thermal_memmap.c3
-rw-r--r--drivers/thermal/thermal_core.c21
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-thermal-common.c4
-rw-r--r--drivers/thermal/x86_pkg_temp_thermal.c3
16 files changed, 38 insertions, 25 deletions
diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
index 652acd8fbe48..e776cea80cfc 100644
--- a/drivers/thermal/db8500_thermal.c
+++ b/drivers/thermal/db8500_thermal.c
@@ -306,7 +306,7 @@ static void db8500_thermal_work(struct work_struct *work)
306 if (cur_mode == THERMAL_DEVICE_DISABLED) 306 if (cur_mode == THERMAL_DEVICE_DISABLED)
307 return; 307 return;
308 308
309 thermal_zone_device_update(pzone->therm_dev); 309 thermal_zone_device_update(pzone->therm_dev, THERMAL_EVENT_UNSPECIFIED);
310 dev_dbg(&pzone->therm_dev->device, "thermal work finished.\n"); 310 dev_dbg(&pzone->therm_dev->device, "thermal work finished.\n");
311} 311}
312 312
diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 97fad8f51e1c..f6429666a1cf 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -237,7 +237,8 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
237 if (!data->sensors[i].tzd) 237 if (!data->sensors[i].tzd)
238 continue; 238 continue;
239 239
240 thermal_zone_device_update(data->sensors[i].tzd); 240 thermal_zone_device_update(data->sensors[i].tzd,
241 THERMAL_EVENT_UNSPECIFIED);
241 } 242 }
242 243
243 return IRQ_HANDLED; 244 return IRQ_HANDLED;
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index e473548b5d28..06912f0602b7 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -246,7 +246,7 @@ static int imx_set_mode(struct thermal_zone_device *tz,
246 } 246 }
247 247
248 data->mode = mode; 248 data->mode = mode;
249 thermal_zone_device_update(tz); 249 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
250 250
251 return 0; 251 return 0;
252} 252}
@@ -457,7 +457,7 @@ static irqreturn_t imx_thermal_alarm_irq_thread(int irq, void *dev)
457 dev_dbg(&data->tz->device, "THERMAL ALARM: T > %d\n", 457 dev_dbg(&data->tz->device, "THERMAL ALARM: T > %d\n",
458 data->alarm_temp / 1000); 458 data->alarm_temp / 1000);
459 459
460 thermal_zone_device_update(data->tz); 460 thermal_zone_device_update(data->tz, THERMAL_EVENT_UNSPECIFIED);
461 461
462 return IRQ_HANDLED; 462 return IRQ_HANDLED;
463} 463}
diff --git a/drivers/thermal/int340x_thermal/int340x_thermal_zone.h b/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
index aaadf724ff2e..65116b1f19f1 100644
--- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
+++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
@@ -62,7 +62,7 @@ static inline void *int340x_thermal_zone_get_priv_data(
62static inline void int340x_thermal_zone_device_update( 62static inline void int340x_thermal_zone_device_update(
63 struct int34x_thermal_zone *tzone) 63 struct int34x_thermal_zone *tzone)
64{ 64{
65 thermal_zone_device_update(tzone->zone); 65 thermal_zone_device_update(tzone->zone, THERMAL_EVENT_UNSPECIFIED);
66} 66}
67 67
68#endif 68#endif
diff --git a/drivers/thermal/intel_bxt_pmic_thermal.c b/drivers/thermal/intel_bxt_pmic_thermal.c
index 4ae3e0c1576a..0f19a393ddd8 100644
--- a/drivers/thermal/intel_bxt_pmic_thermal.c
+++ b/drivers/thermal/intel_bxt_pmic_thermal.c
@@ -204,7 +204,8 @@ static irqreturn_t pmic_thermal_irq_handler(int irq, void *data)
204 trip = td->maps[i].trip_config[j].trip_num; 204 trip = td->maps[i].trip_config[j].trip_num;
205 tzd = thermal_zone_get_zone_by_name(td->maps[i].handle); 205 tzd = thermal_zone_get_zone_by_name(td->maps[i].handle);
206 if (!IS_ERR(tzd)) 206 if (!IS_ERR(tzd))
207 thermal_zone_device_update(tzd); 207 thermal_zone_device_update(tzd,
208 THERMAL_EVENT_UNSPECIFIED);
208 209
209 /* Clear the appropriate irq */ 210 /* Clear the appropriate irq */
210 regmap_write(regmap, reg, reg_val & mask); 211 regmap_write(regmap, reg, reg_val & mask);
diff --git a/drivers/thermal/intel_soc_dts_iosf.c b/drivers/thermal/intel_soc_dts_iosf.c
index f72e1db3216f..e0813dfaa278 100644
--- a/drivers/thermal/intel_soc_dts_iosf.c
+++ b/drivers/thermal/intel_soc_dts_iosf.c
@@ -391,7 +391,8 @@ void intel_soc_dts_iosf_interrupt_handler(struct intel_soc_dts_sensors *sensors)
391 391
392 for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { 392 for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
393 pr_debug("TZD update for zone %d\n", i); 393 pr_debug("TZD update for zone %d\n", i);
394 thermal_zone_device_update(sensors->soc_dts[i].tzone); 394 thermal_zone_device_update(sensors->soc_dts[i].tzone,
395 THERMAL_EVENT_UNSPECIFIED);
395 } 396 }
396 } else 397 } else
397 spin_unlock_irqrestore(&sensors->intr_notify_lock, flags); 398 spin_unlock_irqrestore(&sensors->intr_notify_lock, flags);
diff --git a/drivers/thermal/max77620_thermal.c b/drivers/thermal/max77620_thermal.c
index 8d6162676f68..83905ff46e40 100644
--- a/drivers/thermal/max77620_thermal.c
+++ b/drivers/thermal/max77620_thermal.c
@@ -82,7 +82,8 @@ static irqreturn_t max77620_thermal_irq(int irq, void *data)
82 else if (irq == mtherm->irq_tjalarm2) 82 else if (irq == mtherm->irq_tjalarm2)
83 dev_crit(mtherm->dev, "Junction Temp Alarm2(140C) occurred\n"); 83 dev_crit(mtherm->dev, "Junction Temp Alarm2(140C) occurred\n");
84 84
85 thermal_zone_device_update(mtherm->tz_device); 85 thermal_zone_device_update(mtherm->tz_device,
86 THERMAL_EVENT_UNSPECIFIED);
86 87
87 return IRQ_HANDLED; 88 return IRQ_HANDLED;
88} 89}
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index ab6e5260a901..d04ec3b9e5ff 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -286,7 +286,7 @@ static int of_thermal_set_mode(struct thermal_zone_device *tz,
286 mutex_unlock(&tz->lock); 286 mutex_unlock(&tz->lock);
287 287
288 data->mode = mode; 288 data->mode = mode;
289 thermal_zone_device_update(tz); 289 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
290 290
291 return 0; 291 return 0;
292} 292}
diff --git a/drivers/thermal/qcom-spmi-temp-alarm.c b/drivers/thermal/qcom-spmi-temp-alarm.c
index f8a3c60bef94..819c6d5d7aa7 100644
--- a/drivers/thermal/qcom-spmi-temp-alarm.c
+++ b/drivers/thermal/qcom-spmi-temp-alarm.c
@@ -150,7 +150,7 @@ static irqreturn_t qpnp_tm_isr(int irq, void *data)
150{ 150{
151 struct qpnp_tm_chip *chip = data; 151 struct qpnp_tm_chip *chip = data;
152 152
153 thermal_zone_device_update(chip->tz_dev); 153 thermal_zone_device_update(chip->tz_dev, THERMAL_EVENT_UNSPECIFIED);
154 154
155 return IRQ_HANDLED; 155 return IRQ_HANDLED;
156} 156}
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index b5c6442d82d6..6c73d3ecf33b 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -358,7 +358,8 @@ static void rcar_thermal_work(struct work_struct *work)
358 return; 358 return;
359 359
360 if (nctemp != cctemp) 360 if (nctemp != cctemp)
361 thermal_zone_device_update(priv->zone); 361 thermal_zone_device_update(priv->zone,
362 THERMAL_EVENT_UNSPECIFIED);
362} 363}
363 364
364static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status) 365static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 1f165c990c85..e227a9f0acf7 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -873,7 +873,8 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev)
873 thermal->chip->irq_ack(thermal->regs); 873 thermal->chip->irq_ack(thermal->regs);
874 874
875 for (i = 0; i < thermal->chip->chn_num; i++) 875 for (i = 0; i < thermal->chip->chn_num; i++)
876 thermal_zone_device_update(thermal->sensors[i].tzd); 876 thermal_zone_device_update(thermal->sensors[i].tzd,
877 THERMAL_EVENT_UNSPECIFIED);
877 878
878 return IRQ_HANDLED; 879 return IRQ_HANDLED;
879} 880}
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index f3ce94ec73b5..ad1186dd6132 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -225,7 +225,7 @@ static void exynos_report_trigger(struct exynos_tmu_data *p)
225 return; 225 return;
226 } 226 }
227 227
228 thermal_zone_device_update(tz); 228 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
229 229
230 mutex_lock(&tz->lock); 230 mutex_lock(&tz->lock);
231 /* Find the level for which trip happened */ 231 /* Find the level for which trip happened */
diff --git a/drivers/thermal/st/st_thermal_memmap.c b/drivers/thermal/st/st_thermal_memmap.c
index fc0c9e198710..91d42319de27 100644
--- a/drivers/thermal/st/st_thermal_memmap.c
+++ b/drivers/thermal/st/st_thermal_memmap.c
@@ -42,7 +42,8 @@ static irqreturn_t st_mmap_thermal_trip_handler(int irq, void *sdata)
42{ 42{
43 struct st_thermal_sensor *sensor = sdata; 43 struct st_thermal_sensor *sensor = sdata;
44 44
45 thermal_zone_device_update(sensor->thermal_dev); 45 thermal_zone_device_update(sensor->thermal_dev,
46 THERMAL_EVENT_UNSPECIFIED);
46 47
47 return IRQ_HANDLED; 48 return IRQ_HANDLED;
48} 49}
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index f2d55e478b2a..226b0b4aced6 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -607,7 +607,8 @@ static void thermal_zone_device_reset(struct thermal_zone_device *tz)
607 pos->initialized = false; 607 pos->initialized = false;
608} 608}
609 609
610void thermal_zone_device_update(struct thermal_zone_device *tz) 610void thermal_zone_device_update(struct thermal_zone_device *tz,
611 enum thermal_notify_event event)
611{ 612{
612 int count; 613 int count;
613 614
@@ -621,6 +622,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
621 622
622 thermal_zone_set_trips(tz); 623 thermal_zone_set_trips(tz);
623 624
625 tz->notify_event = event;
626
624 for (count = 0; count < tz->trips; count++) 627 for (count = 0; count < tz->trips; count++)
625 handle_thermal_trip(tz, count); 628 handle_thermal_trip(tz, count);
626} 629}
@@ -631,7 +634,7 @@ static void thermal_zone_device_check(struct work_struct *work)
631 struct thermal_zone_device *tz = container_of(work, struct 634 struct thermal_zone_device *tz = container_of(work, struct
632 thermal_zone_device, 635 thermal_zone_device,
633 poll_queue.work); 636 poll_queue.work);
634 thermal_zone_device_update(tz); 637 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
635} 638}
636 639
637/* sys I/F for thermal zone */ 640/* sys I/F for thermal zone */
@@ -755,7 +758,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
755 if (ret) 758 if (ret)
756 return ret; 759 return ret;
757 760
758 thermal_zone_device_update(tz); 761 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
759 762
760 return count; 763 return count;
761} 764}
@@ -877,7 +880,7 @@ passive_store(struct device *dev, struct device_attribute *attr,
877 880
878 tz->forced_passive = state; 881 tz->forced_passive = state;
879 882
880 thermal_zone_device_update(tz); 883 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
881 884
882 return count; 885 return count;
883} 886}
@@ -968,7 +971,7 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
968 } 971 }
969 972
970 if (!ret) 973 if (!ret)
971 thermal_zone_device_update(tz); 974 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
972 975
973 return ret ? ret : count; 976 return ret ? ret : count;
974} 977}
@@ -1564,7 +1567,8 @@ __thermal_cooling_device_register(struct device_node *np,
1564 mutex_lock(&thermal_list_lock); 1567 mutex_lock(&thermal_list_lock);
1565 list_for_each_entry(pos, &thermal_tz_list, node) 1568 list_for_each_entry(pos, &thermal_tz_list, node)
1566 if (atomic_cmpxchg(&pos->need_update, 1, 0)) 1569 if (atomic_cmpxchg(&pos->need_update, 1, 0))
1567 thermal_zone_device_update(pos); 1570 thermal_zone_device_update(pos,
1571 THERMAL_EVENT_UNSPECIFIED);
1568 mutex_unlock(&thermal_list_lock); 1572 mutex_unlock(&thermal_list_lock);
1569 1573
1570 return cdev; 1574 return cdev;
@@ -2007,7 +2011,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
2007 thermal_zone_device_reset(tz); 2011 thermal_zone_device_reset(tz);
2008 /* Update the new thermal zone and mark it as already updated. */ 2012 /* Update the new thermal zone and mark it as already updated. */
2009 if (atomic_cmpxchg(&tz->need_update, 1, 0)) 2013 if (atomic_cmpxchg(&tz->need_update, 1, 0))
2010 thermal_zone_device_update(tz); 2014 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
2011 2015
2012 return tz; 2016 return tz;
2013 2017
@@ -2294,7 +2298,8 @@ static int thermal_pm_notify(struct notifier_block *nb,
2294 atomic_set(&in_suspend, 0); 2298 atomic_set(&in_suspend, 0);
2295 list_for_each_entry(tz, &thermal_tz_list, node) { 2299 list_for_each_entry(tz, &thermal_tz_list, node) {
2296 thermal_zone_device_reset(tz); 2300 thermal_zone_device_reset(tz);
2297 thermal_zone_device_update(tz); 2301 thermal_zone_device_update(tz,
2302 THERMAL_EVENT_UNSPECIFIED);
2298 } 2303 }
2299 break; 2304 break;
2300 default: 2305 default:
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 4a6757ca78f0..0586bd0f2bab 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -52,7 +52,7 @@ static void ti_thermal_work(struct work_struct *work)
52 struct ti_thermal_data *data = container_of(work, 52 struct ti_thermal_data *data = container_of(work,
53 struct ti_thermal_data, thermal_wq); 53 struct ti_thermal_data, thermal_wq);
54 54
55 thermal_zone_device_update(data->ti_thermal); 55 thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED);
56 56
57 dev_dbg(&data->ti_thermal->device, "updated thermal zone %s\n", 57 dev_dbg(&data->ti_thermal->device, "updated thermal zone %s\n",
58 data->ti_thermal->type); 58 data->ti_thermal->type);
@@ -205,7 +205,7 @@ static int ti_thermal_set_mode(struct thermal_zone_device *thermal,
205 data->mode = mode; 205 data->mode = mode;
206 ti_bandgap_write_update_interval(bgp, data->sensor_id, 206 ti_bandgap_write_update_interval(bgp, data->sensor_id,
207 data->ti_thermal->polling_delay); 207 data->ti_thermal->polling_delay);
208 thermal_zone_device_update(data->ti_thermal); 208 thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED);
209 dev_dbg(&thermal->device, "thermal polling set for duration=%d msec\n", 209 dev_dbg(&thermal->device, "thermal polling set for duration=%d msec\n",
210 data->ti_thermal->polling_delay); 210 data->ti_thermal->polling_delay);
211 211
diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
index 97f0a2bd93ed..95f4c1bcdb4c 100644
--- a/drivers/thermal/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/x86_pkg_temp_thermal.c
@@ -348,7 +348,8 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work)
348 } 348 }
349 if (notify) { 349 if (notify) {
350 pr_debug("thermal_zone_device_update\n"); 350 pr_debug("thermal_zone_device_update\n");
351 thermal_zone_device_update(phdev->tzone); 351 thermal_zone_device_update(phdev->tzone,
352 THERMAL_EVENT_UNSPECIFIED);
352 } 353 }
353} 354}
354 355