Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux

Pull thermal management updates from Zhang Rui:
"The top merge commit was re-generated yesterday because two topic
branches were dropped from this pull request in the last minute due to
some unaddressed comments. All the other material has been in
linux-next for quite a while.

Specifics:

- Enhance thermal core to handle unexpected device cooling states
after fresh boot and system resume. From Zhang Rui and Chen Yu.

- Several fixes and cleanups on Rockchip and RCAR thermal drivers.
From Caesar Wang and Kuninori Morimoto.

- Add Broxton support for Intel processor thermal reporting device
driver. From Amy Wiles"

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
thermal: trip_point_temp_store() calls thermal_zone_device_update()
thermal: rcar: rcar_thermal_get_temp() return error if strange temp
thermal: rcar: check irq possibility in rcar_thermal_irq_xxx()
thermal: rcar: check every rcar_thermal_update_temp() return value
thermal: rcar: move rcar_thermal_dt_ids to upside
thermal: rockchip: Support the RK3399 SoCs in thermal driver
thermal: rockchip: Support the RK3228 SoCs in thermal driver
dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible
thermal: rockchip: fix a trivial typo
Thermal: Enable Broxton SoC thermal reporting device
thermal: constify pch_dev_ops structure
Thermal: do thermal zone update after a cooling device registered
Thermal: handle thermal zone device properly during system sleep
Thermal: initialize thermal zone device correctly

Changed files
+304 -39
Documentation
devicetree
bindings
drivers
include
linux
+2
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
··· 2 2 3 3 Required properties: 4 4 - compatible : should be "rockchip,<name>-tsadc" 5 + "rockchip,rk3228-tsadc": found on RK3228 SoCs 5 6 "rockchip,rk3288-tsadc": found on RK3288 SoCs 6 7 "rockchip,rk3368-tsadc": found on RK3368 SoCs 8 + "rockchip,rk3399-tsadc": found on RK3399 SoCs 7 9 - reg : physical base address of the controller and length of memory mapped 8 10 region. 9 11 - interrupts : The interrupt number to the cpu. The interrupt specifier format
+10
drivers/thermal/int340x_thermal/processor_thermal_device.c
··· 33 33 /* Braswell thermal reporting device */ 34 34 #define PCI_DEVICE_ID_PROC_BSW_THERMAL 0x22DC 35 35 36 + /* Broxton thermal reporting device */ 37 + #define PCI_DEVICE_ID_PROC_BXT0_THERMAL 0x0A8C 38 + #define PCI_DEVICE_ID_PROC_BXT1_THERMAL 0x1A8C 39 + #define PCI_DEVICE_ID_PROC_BXTX_THERMAL 0x4A8C 40 + #define PCI_DEVICE_ID_PROC_BXTP_THERMAL 0x5A8C 41 + 36 42 struct power_config { 37 43 u32 index; 38 44 u32 min_uw; ··· 410 404 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_HSB_THERMAL)}, 411 405 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_SKL_THERMAL)}, 412 406 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BSW_THERMAL)}, 407 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXT0_THERMAL)}, 408 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXT1_THERMAL)}, 409 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXTX_THERMAL)}, 410 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXTP_THERMAL)}, 413 411 { 0, }, 414 412 }; 415 413
+1 -1
drivers/thermal/intel_pch_thermal.c
··· 136 136 137 137 138 138 /* dev ops for Wildcat Point */ 139 - static struct pch_dev_ops pch_dev_ops_wpt = { 139 + static const struct pch_dev_ops pch_dev_ops_wpt = { 140 140 .hw_init = pch_wpt_init, 141 141 .get_temp = pch_wpt_get_temp, 142 142 };
+33 -20
drivers/thermal/rcar_thermal.c
··· 75 75 #define rcar_has_irq_support(priv) ((priv)->common->base) 76 76 #define rcar_id_to_shift(priv) ((priv)->id * 8) 77 77 78 - #ifdef DEBUG 79 - # define rcar_force_update_temp(priv) 1 80 - #else 81 - # define rcar_force_update_temp(priv) 0 82 - #endif 78 + static const struct of_device_id rcar_thermal_dt_ids[] = { 79 + { .compatible = "renesas,rcar-thermal", }, 80 + {}, 81 + }; 82 + MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids); 83 83 84 84 /* 85 85 * basic functions ··· 203 203 static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) 204 204 { 205 205 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); 206 + int tmp; 207 + int ret; 206 208 207 - if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) 208 - rcar_thermal_update_temp(priv); 209 + ret = rcar_thermal_update_temp(priv); 210 + if (ret < 0) 211 + return ret; 209 212 210 213 mutex_lock(&priv->lock); 211 - *temp = MCELSIUS((priv->ctemp * 5) - 65); 214 + tmp = MCELSIUS((priv->ctemp * 5) - 65); 212 215 mutex_unlock(&priv->lock); 216 + 217 + if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) { 218 + struct device *dev = rcar_priv_to_dev(priv); 219 + 220 + dev_err(dev, "it couldn't measure temperature correctly\n"); 221 + return -EIO; 222 + } 223 + 224 + *temp = tmp; 213 225 214 226 return 0; 215 227 } ··· 300 288 unsigned long flags; 301 289 u32 mask = 0x3 << rcar_id_to_shift(priv); /* enable Rising/Falling */ 302 290 291 + if (!rcar_has_irq_support(priv)) 292 + return; 293 + 303 294 spin_lock_irqsave(&common->lock, flags); 304 295 305 296 rcar_thermal_common_bset(common, INTMSK, mask, enable ? 0 : mask); ··· 314 299 { 315 300 struct rcar_thermal_priv *priv; 316 301 int cctemp, nctemp; 302 + int ret; 317 303 318 304 priv = container_of(work, struct rcar_thermal_priv, work.work); 319 305 320 306 rcar_thermal_get_temp(priv->zone, &cctemp); 321 - rcar_thermal_update_temp(priv); 307 + ret = rcar_thermal_update_temp(priv); 308 + if (ret < 0) 309 + return; 310 + 322 311 rcar_thermal_irq_enable(priv); 323 312 324 313 rcar_thermal_get_temp(priv->zone, &nctemp); ··· 387 368 struct rcar_thermal_priv *priv; 388 369 389 370 rcar_thermal_for_each_priv(priv, common) { 390 - if (rcar_has_irq_support(priv)) 391 - rcar_thermal_irq_disable(priv); 371 + rcar_thermal_irq_disable(priv); 392 372 thermal_zone_device_unregister(priv->zone); 393 373 } 394 374 ··· 459 441 mutex_init(&priv->lock); 460 442 INIT_LIST_HEAD(&priv->list); 461 443 INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); 462 - rcar_thermal_update_temp(priv); 444 + ret = rcar_thermal_update_temp(priv); 445 + if (ret < 0) 446 + goto error_unregister; 463 447 464 448 priv->zone = thermal_zone_device_register("rcar_thermal", 465 449 1, 0, priv, ··· 473 453 goto error_unregister; 474 454 } 475 455 476 - if (rcar_has_irq_support(priv)) 477 - rcar_thermal_irq_enable(priv); 456 + rcar_thermal_irq_enable(priv); 478 457 479 458 list_move_tail(&priv->list, &common->head); 480 459 ··· 502 483 503 484 return ret; 504 485 } 505 - 506 - static const struct of_device_id rcar_thermal_dt_ids[] = { 507 - { .compatible = "renesas,rcar-thermal", }, 508 - {}, 509 - }; 510 - MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids); 511 486 512 487 static struct platform_driver rcar_thermal_driver = { 513 488 .driver = {
+160 -12
drivers/thermal/rockchip_thermal.c
··· 38 38 }; 39 39 40 40 /** 41 - * the system Temperature Sensors tshut(tshut) polarity 41 + * The system Temperature Sensors tshut(tshut) polarity 42 42 * the bit 8 is tshut polarity. 43 43 * 0: low active, 1: high active 44 44 */ ··· 57 57 }; 58 58 59 59 /** 60 - * The conversion table has the adc value and temperature. 61 - * ADC_DECREMENT is the adc value decremnet.(e.g. v2_code_table) 62 - * ADC_INCREMNET is the adc value incremnet.(e.g. v3_code_table) 63 - */ 60 + * The conversion table has the adc value and temperature. 61 + * ADC_DECREMENT: the adc value is of diminishing.(e.g. v2_code_table) 62 + * ADC_INCREMENT: the adc value is incremental.(e.g. v3_code_table) 63 + */ 64 64 enum adc_sort_mode { 65 65 ADC_DECREMENT = 0, 66 66 ADC_INCREMENT, ··· 72 72 */ 73 73 #define SOC_MAX_SENSORS 2 74 74 75 + /** 76 + * struct chip_tsadc_table: hold information about chip-specific differences 77 + * @id: conversion table 78 + * @length: size of conversion table 79 + * @data_mask: mask to apply on data inputs 80 + * @mode: sort mode of this adc variant (incrementing or decrementing) 81 + */ 75 82 struct chip_tsadc_table { 76 83 const struct tsadc_table *id; 77 - 78 - /* the array table size*/ 79 84 unsigned int length; 80 - 81 - /* that analogic mask data */ 82 85 u32 data_mask; 83 - 84 - /* the sort mode is adc value that increment or decrement in table */ 85 86 enum adc_sort_mode mode; 86 87 }; 87 88 ··· 154 153 #define TSADCV2_SHUT_2GPIO_SRC_EN(chn) BIT(4 + (chn)) 155 154 #define TSADCV2_SHUT_2CRU_SRC_EN(chn) BIT(8 + (chn)) 156 155 156 + #define TSADCV1_INT_PD_CLEAR_MASK ~BIT(16) 157 157 #define TSADCV2_INT_PD_CLEAR_MASK ~BIT(8) 158 158 159 159 #define TSADCV2_DATA_MASK 0xfff ··· 168 166 struct tsadc_table { 169 167 u32 code; 170 168 int temp; 169 + }; 170 + 171 + /** 172 + * Note: 173 + * Code to Temperature mapping of the Temperature sensor is a piece wise linear 174 + * curve.Any temperature, code faling between to 2 give temperatures can be 175 + * linearly interpolated. 176 + * Code to Temperature mapping should be updated based on sillcon results. 177 + */ 178 + static const struct tsadc_table v1_code_table[] = { 179 + {TSADCV3_DATA_MASK, -40000}, 180 + {436, -40000}, 181 + {431, -35000}, 182 + {426, -30000}, 183 + {421, -25000}, 184 + {416, -20000}, 185 + {411, -15000}, 186 + {406, -10000}, 187 + {401, -5000}, 188 + {395, 0}, 189 + {390, 5000}, 190 + {385, 10000}, 191 + {380, 15000}, 192 + {375, 20000}, 193 + {370, 25000}, 194 + {364, 30000}, 195 + {359, 35000}, 196 + {354, 40000}, 197 + {349, 45000}, 198 + {343, 50000}, 199 + {338, 55000}, 200 + {333, 60000}, 201 + {328, 65000}, 202 + {322, 70000}, 203 + {317, 75000}, 204 + {312, 80000}, 205 + {307, 85000}, 206 + {301, 90000}, 207 + {296, 95000}, 208 + {291, 100000}, 209 + {286, 105000}, 210 + {280, 110000}, 211 + {275, 115000}, 212 + {270, 120000}, 213 + {264, 125000}, 171 214 }; 172 215 173 216 static const struct tsadc_table v2_code_table[] = { ··· 290 243 {169, 120000}, 291 244 {171, 125000}, 292 245 {TSADCV3_DATA_MASK, 125000}, 246 + }; 247 + 248 + static const struct tsadc_table v4_code_table[] = { 249 + {TSADCV3_DATA_MASK, -40000}, 250 + {431, -40000}, 251 + {426, -35000}, 252 + {421, -30000}, 253 + {415, -25000}, 254 + {410, -20000}, 255 + {405, -15000}, 256 + {399, -10000}, 257 + {394, -5000}, 258 + {389, 0}, 259 + {383, 5000}, 260 + {378, 10000}, 261 + {373, 15000}, 262 + {367, 20000}, 263 + {362, 25000}, 264 + {357, 30000}, 265 + {351, 35000}, 266 + {346, 40000}, 267 + {340, 45000}, 268 + {335, 50000}, 269 + {330, 55000}, 270 + {324, 60000}, 271 + {319, 65000}, 272 + {313, 70000}, 273 + {308, 75000}, 274 + {302, 80000}, 275 + {297, 85000}, 276 + {291, 90000}, 277 + {286, 95000}, 278 + {281, 100000}, 279 + {275, 105000}, 280 + {270, 110000}, 281 + {264, 115000}, 282 + {259, 120000}, 283 + {253, 125000}, 293 284 }; 294 285 295 286 static u32 rk_tsadcv2_temp_to_code(struct chip_tsadc_table table, ··· 453 368 regs + TSADCV2_HIGHT_TSHUT_DEBOUNCE); 454 369 } 455 370 371 + static void rk_tsadcv1_irq_ack(void __iomem *regs) 372 + { 373 + u32 val; 374 + 375 + val = readl_relaxed(regs + TSADCV2_INT_PD); 376 + writel_relaxed(val & TSADCV1_INT_PD_CLEAR_MASK, regs + TSADCV2_INT_PD); 377 + } 378 + 456 379 static void rk_tsadcv2_irq_ack(void __iomem *regs) 457 380 { 458 381 u32 val; ··· 522 429 writel_relaxed(val, regs + TSADCV2_INT_EN); 523 430 } 524 431 432 + static const struct rockchip_tsadc_chip rk3228_tsadc_data = { 433 + .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 434 + .chn_num = 1, /* one channel for tsadc */ 435 + 436 + .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ 437 + .tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */ 438 + .tshut_temp = 95000, 439 + 440 + .initialize = rk_tsadcv2_initialize, 441 + .irq_ack = rk_tsadcv1_irq_ack, 442 + .control = rk_tsadcv2_control, 443 + .get_temp = rk_tsadcv2_get_temp, 444 + .set_tshut_temp = rk_tsadcv2_tshut_temp, 445 + .set_tshut_mode = rk_tsadcv2_tshut_mode, 446 + 447 + .table = { 448 + .id = v1_code_table, 449 + .length = ARRAY_SIZE(v1_code_table), 450 + .data_mask = TSADCV3_DATA_MASK, 451 + .mode = ADC_DECREMENT, 452 + }, 453 + }; 454 + 525 455 static const struct rockchip_tsadc_chip rk3288_tsadc_data = { 526 456 .chn_id[SENSOR_CPU] = 1, /* cpu sensor is channel 1 */ 527 457 .chn_id[SENSOR_GPU] = 2, /* gpu sensor is channel 2 */ ··· 593 477 }, 594 478 }; 595 479 480 + static const struct rockchip_tsadc_chip rk3399_tsadc_data = { 481 + .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 482 + .chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */ 483 + .chn_num = 2, /* two channels for tsadc */ 484 + 485 + .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ 486 + .tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */ 487 + .tshut_temp = 95000, 488 + 489 + .initialize = rk_tsadcv2_initialize, 490 + .irq_ack = rk_tsadcv1_irq_ack, 491 + .control = rk_tsadcv2_control, 492 + .get_temp = rk_tsadcv2_get_temp, 493 + .set_tshut_temp = rk_tsadcv2_tshut_temp, 494 + .set_tshut_mode = rk_tsadcv2_tshut_mode, 495 + 496 + .table = { 497 + .id = v4_code_table, 498 + .length = ARRAY_SIZE(v4_code_table), 499 + .data_mask = TSADCV3_DATA_MASK, 500 + .mode = ADC_DECREMENT, 501 + }, 502 + }; 503 + 596 504 static const struct of_device_id of_rockchip_thermal_match[] = { 505 + { 506 + .compatible = "rockchip,rk3228-tsadc", 507 + .data = (void *)&rk3228_tsadc_data, 508 + }, 597 509 { 598 510 .compatible = "rockchip,rk3288-tsadc", 599 511 .data = (void *)&rk3288_tsadc_data, ··· 629 485 { 630 486 .compatible = "rockchip,rk3368-tsadc", 631 487 .data = (void *)&rk3368_tsadc_data, 488 + }, 489 + { 490 + .compatible = "rockchip,rk3399-tsadc", 491 + .data = (void *)&rk3399_tsadc_data, 632 492 }, 633 493 { /* end */ }, 634 494 }; ··· 765 617 return 0; 766 618 } 767 619 768 - /* 620 + /** 769 621 * Reset TSADC Controller, reset all tsadc registers. 770 622 */ 771 623 static void rockchip_thermal_reset_controller(struct reset_control *reset)
+15 -2
drivers/thermal/step_wise.c
··· 63 63 next_target = instance->target; 64 64 dev_dbg(&cdev->device, "cur_state=%ld\n", cur_state); 65 65 66 + if (!instance->initialized) { 67 + if (throttle) { 68 + next_target = (cur_state + 1) >= instance->upper ? 69 + instance->upper : 70 + ((cur_state + 1) < instance->lower ? 71 + instance->lower : (cur_state + 1)); 72 + } else { 73 + next_target = THERMAL_NO_TARGET; 74 + } 75 + 76 + return next_target; 77 + } 78 + 66 79 switch (trend) { 67 80 case THERMAL_TREND_RAISING: 68 81 if (throttle) { ··· 162 149 dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", 163 150 old_target, (int)instance->target); 164 151 165 - if (old_target == instance->target) 152 + if (instance->initialized && old_target == instance->target) 166 153 continue; 167 154 168 155 /* Activate a passive thermal instance */ ··· 174 161 instance->target == THERMAL_NO_TARGET) 175 162 update_passive_instance(tz, trip_type, -1); 176 163 177 - 164 + instance->initialized = true; 178 165 instance->cdev->updated = false; /* cdev needs update */ 179 166 } 180 167
+77 -4
drivers/thermal/thermal_core.c
··· 37 37 #include <linux/of.h> 38 38 #include <net/netlink.h> 39 39 #include <net/genetlink.h> 40 + #include <linux/suspend.h> 40 41 41 42 #define CREATE_TRACE_POINTS 42 43 #include <trace/events/thermal.h> ··· 59 58 60 59 static DEFINE_MUTEX(thermal_list_lock); 61 60 static DEFINE_MUTEX(thermal_governor_lock); 61 + 62 + static atomic_t in_suspend; 62 63 63 64 static struct thermal_governor *def_governor; 64 65 ··· 535 532 mutex_unlock(&tz->lock); 536 533 537 534 trace_thermal_temperature(tz); 538 - dev_dbg(&tz->device, "last_temperature=%d, current_temperature=%d\n", 539 - tz->last_temperature, tz->temperature); 535 + if (tz->last_temperature == THERMAL_TEMP_INVALID) 536 + dev_dbg(&tz->device, "last_temperature N/A, current_temperature=%d\n", 537 + tz->temperature); 538 + else 539 + dev_dbg(&tz->device, "last_temperature=%d, current_temperature=%d\n", 540 + tz->last_temperature, tz->temperature); 541 + } 542 + 543 + static void thermal_zone_device_reset(struct thermal_zone_device *tz) 544 + { 545 + struct thermal_instance *pos; 546 + 547 + tz->temperature = THERMAL_TEMP_INVALID; 548 + tz->passive = 0; 549 + list_for_each_entry(pos, &tz->thermal_instances, tz_node) 550 + pos->initialized = false; 540 551 } 541 552 542 553 void thermal_zone_device_update(struct thermal_zone_device *tz) 543 554 { 544 555 int count; 556 + 557 + if (atomic_read(&in_suspend)) 558 + return; 545 559 546 560 if (!tz->ops->get_temp) 547 561 return; ··· 696 676 return -EINVAL; 697 677 698 678 ret = tz->ops->set_trip_temp(tz, trip, temperature); 679 + if (ret) 680 + return ret; 699 681 700 - return ret ? ret : count; 682 + thermal_zone_device_update(tz); 683 + 684 + return count; 701 685 } 702 686 703 687 static ssize_t ··· 1345 1321 if (!result) { 1346 1322 list_add_tail(&dev->tz_node, &tz->thermal_instances); 1347 1323 list_add_tail(&dev->cdev_node, &cdev->thermal_instances); 1324 + atomic_set(&tz->need_update, 1); 1348 1325 } 1349 1326 mutex_unlock(&cdev->lock); 1350 1327 mutex_unlock(&tz->lock); ··· 1455 1430 const struct thermal_cooling_device_ops *ops) 1456 1431 { 1457 1432 struct thermal_cooling_device *cdev; 1433 + struct thermal_zone_device *pos = NULL; 1458 1434 int result; 1459 1435 1460 1436 if (type && strlen(type) >= THERMAL_NAME_LENGTH) ··· 1499 1473 1500 1474 /* Update binding information for 'this' new cdev */ 1501 1475 bind_cdev(cdev); 1476 + 1477 + mutex_lock(&thermal_list_lock); 1478 + list_for_each_entry(pos, &thermal_tz_list, node) 1479 + if (atomic_cmpxchg(&pos->need_update, 1, 0)) 1480 + thermal_zone_device_update(pos); 1481 + mutex_unlock(&thermal_list_lock); 1502 1482 1503 1483 return cdev; 1504 1484 } ··· 1838 1806 tz->trips = trips; 1839 1807 tz->passive_delay = passive_delay; 1840 1808 tz->polling_delay = polling_delay; 1809 + /* A new thermal zone needs to be updated anyway. */ 1810 + atomic_set(&tz->need_update, 1); 1841 1811 1842 1812 dev_set_name(&tz->device, "thermal_zone%d", tz->id); 1843 1813 result = device_register(&tz->device); ··· 1934 1900 1935 1901 INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); 1936 1902 1937 - thermal_zone_device_update(tz); 1903 + thermal_zone_device_reset(tz); 1904 + /* Update the new thermal zone and mark it as already updated. */ 1905 + if (atomic_cmpxchg(&tz->need_update, 1, 0)) 1906 + thermal_zone_device_update(tz); 1938 1907 1939 1908 return tz; 1940 1909 ··· 2177 2140 thermal_gov_power_allocator_unregister(); 2178 2141 } 2179 2142 2143 + static int thermal_pm_notify(struct notifier_block *nb, 2144 + unsigned long mode, void *_unused) 2145 + { 2146 + struct thermal_zone_device *tz; 2147 + 2148 + switch (mode) { 2149 + case PM_HIBERNATION_PREPARE: 2150 + case PM_RESTORE_PREPARE: 2151 + case PM_SUSPEND_PREPARE: 2152 + atomic_set(&in_suspend, 1); 2153 + break; 2154 + case PM_POST_HIBERNATION: 2155 + case PM_POST_RESTORE: 2156 + case PM_POST_SUSPEND: 2157 + atomic_set(&in_suspend, 0); 2158 + list_for_each_entry(tz, &thermal_tz_list, node) { 2159 + thermal_zone_device_reset(tz); 2160 + thermal_zone_device_update(tz); 2161 + } 2162 + break; 2163 + default: 2164 + break; 2165 + } 2166 + return 0; 2167 + } 2168 + 2169 + static struct notifier_block thermal_pm_nb = { 2170 + .notifier_call = thermal_pm_notify, 2171 + }; 2172 + 2180 2173 static int __init thermal_init(void) 2181 2174 { 2182 2175 int result; ··· 2227 2160 if (result) 2228 2161 goto exit_netlink; 2229 2162 2163 + result = register_pm_notifier(&thermal_pm_nb); 2164 + if (result) 2165 + pr_warn("Thermal: Can not register suspend notifier, return %d\n", 2166 + result); 2167 + 2230 2168 return 0; 2231 2169 2232 2170 exit_netlink: ··· 2251 2179 2252 2180 static void __exit thermal_exit(void) 2253 2181 { 2182 + unregister_pm_notifier(&thermal_pm_nb); 2254 2183 of_thermal_destroy_zones(); 2255 2184 genetlink_exit(); 2256 2185 class_unregister(&thermal_class);
+1
drivers/thermal/thermal_core.h
··· 41 41 struct thermal_zone_device *tz; 42 42 struct thermal_cooling_device *cdev; 43 43 int trip; 44 + bool initialized; 44 45 unsigned long upper; /* Highest cooling state for this trip point */ 45 46 unsigned long lower; /* Lowest cooling state for this trip point */ 46 47 unsigned long target; /* expected cooling state */
+5
include/linux/thermal.h
··· 43 43 /* Default weight of a bound cooling device */ 44 44 #define THERMAL_WEIGHT_DEFAULT 0 45 45 46 + /* use value, which < 0K, to indicate an invalid/uninitialized temperature */ 47 + #define THERMAL_TEMP_INVALID -274000 48 + 46 49 /* Unit conversion macros */ 47 50 #define DECI_KELVIN_TO_CELSIUS(t) ({ \ 48 51 long _t = (t); \ ··· 170 167 * @forced_passive: If > 0, temperature at which to switch on all ACPI 171 168 * processor cooling devices. Currently only used by the 172 169 * step-wise governor. 170 + * @need_update: if equals 1, thermal_zone_device_update needs to be invoked. 173 171 * @ops: operations this &thermal_zone_device supports 174 172 * @tzp: thermal zone parameters 175 173 * @governor: pointer to the governor for this thermal zone ··· 198 194 int emul_temperature; 199 195 int passive; 200 196 unsigned int forced_passive; 197 + atomic_t need_update; 201 198 struct thermal_zone_device_ops *ops; 202 199 struct thermal_zone_params *tzp; 203 200 struct thermal_governor *governor;