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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull thermal updates from Zhang Rui:

- use int instead of unsigned long to represent temperature to avoid
bogus overheat detection when negative temperature reported. From
Sascha Hauer.

- export available thermal governors information to user space via
sysfs. From Wei Ni.

- introduce new thermal driver for Wildcat Point platform controller
hub, which uses PCH thermal sensor and associated critical and hot
trip points. From Tushar Dave.

- add suuport for Intel Skylake and Denlow platforms in powerclamp
driver.

- some small cleanups in thermal core.

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
thermal: Add Intel PCH thermal driver
thermal: Add comment explaining test for critical temperature
thermal: Use IS_ENABLED instead of #ifdef
thermal: remove unnecessary call to thermal_zone_device_set_polling
thermal: trivial: fix typo in comment
thermal: consistently use int for temperatures
thermal: add available policies sysfs attribute
thermal/powerclamp: add cpu id for denlow platform
thermal/powerclamp: add cpu id for Skylake u/y
thermal/powerclamp: add cpu id for skylake h/s

+508 -196
+6
Documentation/thermal/sysfs-api.txt
··· 180 180 |---temp: Current temperature 181 181 |---mode: Working mode of the thermal zone 182 182 |---policy: Thermal governor used for this zone 183 + |---available_policies: Available thermal governors for this zone 183 184 |---trip_point_[0-*]_temp: Trip point temperature 184 185 |---trip_point_[0-*]_type: Trip point type 185 186 |---trip_point_[0-*]_hyst: Hysteresis value for this trip point ··· 256 255 policy 257 256 One of the various thermal governors used for a particular zone. 258 257 RW, Required 258 + 259 + available_policies 260 + Available thermal governors which can be used for a particular zone. 261 + RO, Required 259 262 260 263 trip_point_[0-*]_temp 261 264 The temperature above which trip point will be fired. ··· 422 417 |---temp: 37000 423 418 |---mode: enabled 424 419 |---policy: step_wise 420 + |---available_policies: step_wise fair_share 425 421 |---trip_point_0_temp: 100000 426 422 |---trip_point_0_type: critical 427 423 |---trip_point_1_temp: 80000
+6 -6
drivers/acpi/thermal.c
··· 525 525 526 526 /* sys I/F for generic thermal sysfs support */ 527 527 528 - static int thermal_get_temp(struct thermal_zone_device *thermal, 529 - unsigned long *temp) 528 + static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) 530 529 { 531 530 struct acpi_thermal *tz = thermal->devdata; 532 531 int result; ··· 632 633 } 633 634 634 635 static int thermal_get_trip_temp(struct thermal_zone_device *thermal, 635 - int trip, unsigned long *temp) 636 + int trip, int *temp) 636 637 { 637 638 struct acpi_thermal *tz = thermal->devdata; 638 639 int i; ··· 685 686 } 686 687 687 688 static int thermal_get_crit_temp(struct thermal_zone_device *thermal, 688 - unsigned long *temperature) { 689 + int *temperature) 690 + { 689 691 struct acpi_thermal *tz = thermal->devdata; 690 692 691 693 if (tz->trips.critical.flags.valid) { ··· 709 709 return -EINVAL; 710 710 711 711 if (type == THERMAL_TRIP_ACTIVE) { 712 - unsigned long trip_temp; 713 - unsigned long temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( 712 + int trip_temp; 713 + int temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( 714 714 tz->temperature, tz->kelvin_offset); 715 715 if (thermal_get_trip_temp(thermal, trip, &trip_temp)) 716 716 return -EINVAL;
+1 -1
drivers/hwmon/lm75.c
··· 104 104 105 105 /* sysfs attributes for hwmon */ 106 106 107 - static int lm75_read_temp(void *dev, long *temp) 107 + static int lm75_read_temp(void *dev, int *temp) 108 108 { 109 109 struct lm75_data *data = lm75_update_device(dev); 110 110
+1 -1
drivers/hwmon/ntc_thermistor.c
··· 477 477 return -EINVAL; 478 478 } 479 479 480 - static int ntc_read_temp(void *dev, long *temp) 480 + static int ntc_read_temp(void *dev, int *temp) 481 481 { 482 482 struct ntc_data *data = dev_get_drvdata(dev); 483 483 int ohm;
+1 -1
drivers/hwmon/tmp102.c
··· 98 98 return tmp102; 99 99 } 100 100 101 - static int tmp102_read_temp(void *dev, long *temp) 101 + static int tmp102_read_temp(void *dev, int *temp) 102 102 { 103 103 struct tmp102 *tmp102 = tmp102_update_device(dev); 104 104
+4 -4
drivers/input/touchscreen/sun4i-ts.c
··· 191 191 writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC); 192 192 } 193 193 194 - static int sun4i_get_temp(const struct sun4i_ts_data *ts, long *temp) 194 + static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp) 195 195 { 196 196 /* No temp_data until the first irq */ 197 197 if (ts->temp_data == -1) ··· 202 202 return 0; 203 203 } 204 204 205 - static int sun4i_get_tz_temp(void *data, long *temp) 205 + static int sun4i_get_tz_temp(void *data, int *temp) 206 206 { 207 207 return sun4i_get_temp(data, temp); 208 208 } ··· 215 215 char *buf) 216 216 { 217 217 struct sun4i_ts_data *ts = dev_get_drvdata(dev); 218 - long temp; 218 + int temp; 219 219 int error; 220 220 221 221 error = sun4i_get_temp(ts, &temp); 222 222 if (error) 223 223 return error; 224 224 225 - return sprintf(buf, "%ld\n", temp); 225 + return sprintf(buf, "%d\n", temp); 226 226 } 227 227 228 228 static ssize_t show_temp_label(struct device *dev,
+4 -5
drivers/platform/x86/acerhdf.c
··· 346 346 * as late as the polling interval is since we can't do that in the respective 347 347 * accessors of the module parameters. 348 348 */ 349 - static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal, 350 - unsigned long *t) 349 + static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal, int *t) 351 350 { 352 351 int temp, err = 0; 353 352 ··· 452 453 } 453 454 454 455 static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip, 455 - unsigned long *temp) 456 + int *temp) 456 457 { 457 458 if (trip != 0) 458 459 return -EINVAL; ··· 463 464 } 464 465 465 466 static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip, 466 - unsigned long *temp) 467 + int *temp) 467 468 { 468 469 if (trip == 0) 469 470 *temp = fanon; ··· 476 477 } 477 478 478 479 static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal, 479 - unsigned long *temperature) 480 + int *temperature) 480 481 { 481 482 *temperature = ACERHDF_TEMP_CRIT; 482 483 return 0;
+4 -5
drivers/platform/x86/intel_mid_thermal.c
··· 132 132 * to achieve very close approximate temp value with less than 133 133 * 0.5C error 134 134 */ 135 - static int adc_to_temp(int direct, uint16_t adc_val, unsigned long *tp) 135 + static int adc_to_temp(int direct, uint16_t adc_val, int *tp) 136 136 { 137 137 int temp; 138 138 ··· 174 174 * 175 175 * Can sleep 176 176 */ 177 - static int mid_read_temp(struct thermal_zone_device *tzd, unsigned long *temp) 177 + static int mid_read_temp(struct thermal_zone_device *tzd, int *temp) 178 178 { 179 179 struct thermal_device_info *td_info = tzd->devdata; 180 180 uint16_t adc_val, addr; 181 181 uint8_t data = 0; 182 182 int ret; 183 - unsigned long curr_temp; 184 - 183 + int curr_temp; 185 184 186 185 addr = td_info->chnl_addr; 187 186 ··· 452 453 * 453 454 * Can sleep 454 455 */ 455 - static int read_curr_temp(struct thermal_zone_device *tzd, unsigned long *temp) 456 + static int read_curr_temp(struct thermal_zone_device *tzd, int *temp) 456 457 { 457 458 WARN_ON(tzd == NULL); 458 459 return mid_read_temp(tzd, temp);
+1 -1
drivers/power/charger-manager.c
··· 619 619 620 620 #ifdef CONFIG_THERMAL 621 621 if (cm->tzd_batt) { 622 - ret = thermal_zone_get_temp(cm->tzd_batt, (unsigned long *)temp); 622 + ret = thermal_zone_get_temp(cm->tzd_batt, temp); 623 623 if (!ret) 624 624 /* Calibrate temperature unit */ 625 625 *temp /= 100;
+1 -1
drivers/power/power_supply_core.c
··· 557 557 558 558 #ifdef CONFIG_THERMAL 559 559 static int power_supply_read_temp(struct thermal_zone_device *tzd, 560 - unsigned long *temp) 560 + int *temp) 561 561 { 562 562 struct power_supply *psy; 563 563 union power_supply_propval val;
+8
drivers/thermal/Kconfig
··· 340 340 tristate 341 341 depends on ACPI 342 342 343 + config INTEL_PCH_THERMAL 344 + tristate "Intel PCH Thermal Reporting Driver" 345 + depends on X86 && PCI 346 + help 347 + Enable this to support thermal reporting on certain intel PCHs. 348 + Thermal reporting device will provide temperature reading, 349 + programmable trip points and other information. 350 + 343 351 menu "Texas Instruments thermal drivers" 344 352 source "drivers/thermal/ti-soc-thermal/Kconfig" 345 353 endmenu
+1
drivers/thermal/Makefile
··· 41 41 obj-$(CONFIG_INTEL_QUARK_DTS_THERMAL) += intel_quark_dts_thermal.o 42 42 obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/ 43 43 obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal/ 44 + obj-$(CONFIG_INTEL_PCH_THERMAL) += intel_pch_thermal.o 44 45 obj-$(CONFIG_ST_THERMAL) += st/ 45 46 obj-$(CONFIG_TEGRA_SOCTHERM) += tegra_soctherm.o 46 47 obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
+1 -1
drivers/thermal/armada_thermal.c
··· 155 155 } 156 156 157 157 static int armada_get_temp(struct thermal_zone_device *thermal, 158 - unsigned long *temp) 158 + int *temp) 159 159 { 160 160 struct armada_thermal_priv *priv = thermal->devdata; 161 161 unsigned long reg;
+3 -4
drivers/thermal/db8500_thermal.c
··· 107 107 } 108 108 109 109 /* Callback to get current temperature */ 110 - static int db8500_sys_get_temp(struct thermal_zone_device *thermal, 111 - unsigned long *temp) 110 + static int db8500_sys_get_temp(struct thermal_zone_device *thermal, int *temp) 112 111 { 113 112 struct db8500_thermal_zone *pzone = thermal->devdata; 114 113 ··· 179 180 180 181 /* Callback to get trip point temperature */ 181 182 static int db8500_sys_get_trip_temp(struct thermal_zone_device *thermal, 182 - int trip, unsigned long *temp) 183 + int trip, int *temp) 183 184 { 184 185 struct db8500_thermal_zone *pzone = thermal->devdata; 185 186 struct db8500_thsens_platform_data *ptrips = pzone->trip_tab; ··· 194 195 195 196 /* Callback to get critical trip point temperature */ 196 197 static int db8500_sys_get_crit_temp(struct thermal_zone_device *thermal, 197 - unsigned long *temp) 198 + int *temp) 198 199 { 199 200 struct db8500_thermal_zone *pzone = thermal->devdata; 200 201 struct db8500_thsens_platform_data *ptrips = pzone->trip_tab;
+1 -1
drivers/thermal/dove_thermal.c
··· 93 93 } 94 94 95 95 static int dove_get_temp(struct thermal_zone_device *thermal, 96 - unsigned long *temp) 96 + int *temp) 97 97 { 98 98 unsigned long reg; 99 99 struct dove_thermal_priv *priv = thermal->devdata;
+1 -1
drivers/thermal/fair_share.c
··· 34 34 static int get_trip_level(struct thermal_zone_device *tz) 35 35 { 36 36 int count = 0; 37 - unsigned long trip_temp; 37 + int trip_temp; 38 38 enum thermal_trip_type trip_type; 39 39 40 40 if (tz->trips == 0 || !tz->ops->get_trip_temp)
+2 -3
drivers/thermal/gov_bang_bang.c
··· 25 25 26 26 static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) 27 27 { 28 - long trip_temp; 29 - unsigned long trip_hyst; 28 + int trip_temp, trip_hyst; 30 29 struct thermal_instance *instance; 31 30 32 31 tz->ops->get_trip_temp(tz, trip, &trip_temp); 33 32 tz->ops->get_trip_hyst(tz, trip, &trip_hyst); 34 33 35 - dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n", 34 + dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n", 36 35 trip, trip_temp, tz->temperature, 37 36 trip_hyst); 38 37
+2 -2
drivers/thermal/hisi_thermal.c
··· 155 155 mutex_unlock(&data->thermal_lock); 156 156 } 157 157 158 - static int hisi_thermal_get_temp(void *_sensor, long *temp) 158 + static int hisi_thermal_get_temp(void *_sensor, int *temp) 159 159 { 160 160 struct hisi_thermal_sensor *sensor = _sensor; 161 161 struct hisi_thermal_data *data = sensor->thermal; ··· 178 178 data->irq_bind_sensor = sensor_id; 179 179 mutex_unlock(&data->thermal_lock); 180 180 181 - dev_dbg(&data->pdev->dev, "id=%d, irq=%d, temp=%ld, thres=%d\n", 181 + dev_dbg(&data->pdev->dev, "id=%d, irq=%d, temp=%d, thres=%d\n", 182 182 sensor->id, data->irq_enabled, *temp, sensor->thres_temp); 183 183 /* 184 184 * Bind irq to sensor for two cases:
+13 -14
drivers/thermal/imx_thermal.c
··· 98 98 enum thermal_device_mode mode; 99 99 struct regmap *tempmon; 100 100 u32 c1, c2; /* See formula in imx_get_sensor_data() */ 101 - unsigned long temp_passive; 102 - unsigned long temp_critical; 103 - unsigned long alarm_temp; 104 - unsigned long last_temp; 101 + int temp_passive; 102 + int temp_critical; 103 + int alarm_temp; 104 + int last_temp; 105 105 bool irq_enabled; 106 106 int irq; 107 107 struct clk *thermal_clk; ··· 109 109 }; 110 110 111 111 static void imx_set_panic_temp(struct imx_thermal_data *data, 112 - signed long panic_temp) 112 + int panic_temp) 113 113 { 114 114 struct regmap *map = data->tempmon; 115 115 int critical_value; ··· 121 121 } 122 122 123 123 static void imx_set_alarm_temp(struct imx_thermal_data *data, 124 - signed long alarm_temp) 124 + int alarm_temp) 125 125 { 126 126 struct regmap *map = data->tempmon; 127 127 int alarm_value; ··· 133 133 TEMPSENSE0_ALARM_VALUE_SHIFT); 134 134 } 135 135 136 - static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp) 136 + static int imx_get_temp(struct thermal_zone_device *tz, int *temp) 137 137 { 138 138 struct imx_thermal_data *data = tz->devdata; 139 139 struct regmap *map = data->tempmon; ··· 189 189 if (data->alarm_temp == data->temp_critical && 190 190 *temp < data->temp_passive) { 191 191 imx_set_alarm_temp(data, data->temp_passive); 192 - dev_dbg(&tz->device, "thermal alarm off: T < %lu\n", 192 + dev_dbg(&tz->device, "thermal alarm off: T < %d\n", 193 193 data->alarm_temp / 1000); 194 194 } 195 195 } 196 196 197 197 if (*temp != data->last_temp) { 198 - dev_dbg(&tz->device, "millicelsius: %ld\n", *temp); 198 + dev_dbg(&tz->device, "millicelsius: %d\n", *temp); 199 199 data->last_temp = *temp; 200 200 } 201 201 ··· 262 262 return 0; 263 263 } 264 264 265 - static int imx_get_crit_temp(struct thermal_zone_device *tz, 266 - unsigned long *temp) 265 + static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) 267 266 { 268 267 struct imx_thermal_data *data = tz->devdata; 269 268 ··· 271 272 } 272 273 273 274 static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, 274 - unsigned long *temp) 275 + int *temp) 275 276 { 276 277 struct imx_thermal_data *data = tz->devdata; 277 278 ··· 281 282 } 282 283 283 284 static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, 284 - unsigned long temp) 285 + int temp) 285 286 { 286 287 struct imx_thermal_data *data = tz->devdata; 287 288 ··· 433 434 { 434 435 struct imx_thermal_data *data = dev; 435 436 436 - dev_dbg(&data->tz->device, "THERMAL ALARM: T > %lu\n", 437 + dev_dbg(&data->tz->device, "THERMAL ALARM: T > %d\n", 437 438 data->alarm_temp / 1000); 438 439 439 440 thermal_zone_device_update(data->tz);
+1 -1
drivers/thermal/int340x_thermal/int3400_thermal.c
··· 186 186 } 187 187 188 188 static int int3400_thermal_get_temp(struct thermal_zone_device *thermal, 189 - unsigned long *temp) 189 + int *temp) 190 190 { 191 191 *temp = 20 * 1000; /* faked temp sensor with 20C */ 192 192 return 0;
+5 -5
drivers/thermal/int340x_thermal/int340x_thermal_zone.c
··· 20 20 #include "int340x_thermal_zone.h" 21 21 22 22 static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, 23 - unsigned long *temp) 23 + int *temp) 24 24 { 25 25 struct int34x_thermal_zone *d = zone->devdata; 26 26 unsigned long long tmp; ··· 49 49 } 50 50 51 51 static int int340x_thermal_get_trip_temp(struct thermal_zone_device *zone, 52 - int trip, unsigned long *temp) 52 + int trip, int *temp) 53 53 { 54 54 struct int34x_thermal_zone *d = zone->devdata; 55 55 int i; ··· 114 114 } 115 115 116 116 static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, 117 - int trip, unsigned long temp) 117 + int trip, int temp) 118 118 { 119 119 struct int34x_thermal_zone *d = zone->devdata; 120 120 acpi_status status; ··· 136 136 137 137 138 138 static int int340x_thermal_get_trip_hyst(struct thermal_zone_device *zone, 139 - int trip, unsigned long *temp) 139 + int trip, int *temp) 140 140 { 141 141 struct int34x_thermal_zone *d = zone->devdata; 142 142 acpi_status status; ··· 163 163 }; 164 164 165 165 static int int340x_thermal_get_trip_config(acpi_handle handle, char *name, 166 - unsigned long *temp) 166 + int *temp) 167 167 { 168 168 unsigned long long r; 169 169 acpi_status status;
+4 -4
drivers/thermal/int340x_thermal/int340x_thermal_zone.h
··· 21 21 #define INT340X_THERMAL_MAX_ACT_TRIP_COUNT 10 22 22 23 23 struct active_trip { 24 - unsigned long temp; 24 + int temp; 25 25 int id; 26 26 bool valid; 27 27 }; ··· 31 31 struct active_trip act_trips[INT340X_THERMAL_MAX_ACT_TRIP_COUNT]; 32 32 unsigned long *aux_trips; 33 33 int aux_trip_nr; 34 - unsigned long psv_temp; 34 + int psv_temp; 35 35 int psv_trip_id; 36 - unsigned long crt_temp; 36 + int crt_temp; 37 37 int crt_trip_id; 38 - unsigned long hot_temp; 38 + int hot_temp; 39 39 int hot_trip_id; 40 40 struct thermal_zone_device *zone; 41 41 struct thermal_zone_device_ops *override_ops;
+2 -2
drivers/thermal/int340x_thermal/processor_thermal_device.c
··· 145 145 return -EINVAL; 146 146 } 147 147 148 - static int read_temp_msr(unsigned long *temp) 148 + static int read_temp_msr(int *temp) 149 149 { 150 150 int cpu; 151 151 u32 eax, edx; ··· 177 177 } 178 178 179 179 static int proc_thermal_get_zone_temp(struct thermal_zone_device *zone, 180 - unsigned long *temp) 180 + int *temp) 181 181 { 182 182 int ret; 183 183
+286
drivers/thermal/intel_pch_thermal.c
··· 1 + /* intel_pch_thermal.c - Intel PCH Thermal driver 2 + * 3 + * Copyright (c) 2015, Intel Corporation. 4 + * 5 + * Authors: 6 + * Tushar Dave <tushar.n.dave@intel.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms and conditions of the GNU General Public License, 10 + * version 2, as published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope it will be useful, but WITHOUT 13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 + * more details. 16 + * 17 + */ 18 + 19 + #include <linux/module.h> 20 + #include <linux/types.h> 21 + #include <linux/init.h> 22 + #include <linux/pci.h> 23 + #include <linux/thermal.h> 24 + 25 + /* Intel PCH thermal Device IDs */ 26 + #define PCH_THERMAL_DID_WPT 0x9CA4 /* Wildcat Point */ 27 + 28 + /* Wildcat Point-LP PCH Thermal registers */ 29 + #define WPT_TEMP 0x0000 /* Temperature */ 30 + #define WPT_TSC 0x04 /* Thermal Sensor Control */ 31 + #define WPT_TSS 0x06 /* Thermal Sensor Status */ 32 + #define WPT_TSEL 0x08 /* Thermal Sensor Enable and Lock */ 33 + #define WPT_TSREL 0x0A /* Thermal Sensor Report Enable and Lock */ 34 + #define WPT_TSMIC 0x0C /* Thermal Sensor SMI Control */ 35 + #define WPT_CTT 0x0010 /* Catastrophic Trip Point */ 36 + #define WPT_TAHV 0x0014 /* Thermal Alert High Value */ 37 + #define WPT_TALV 0x0018 /* Thermal Alert Low Value */ 38 + #define WPT_TL 0x00000040 /* Throttle Value */ 39 + #define WPT_PHL 0x0060 /* PCH Hot Level */ 40 + #define WPT_PHLC 0x62 /* PHL Control */ 41 + #define WPT_TAS 0x80 /* Thermal Alert Status */ 42 + #define WPT_TSPIEN 0x82 /* PCI Interrupt Event Enables */ 43 + #define WPT_TSGPEN 0x84 /* General Purpose Event Enables */ 44 + 45 + /* Wildcat Point-LP PCH Thermal Register bit definitions */ 46 + #define WPT_TEMP_TSR 0x00ff /* Temp TS Reading */ 47 + #define WPT_TSC_CPDE 0x01 /* Catastrophic Power-Down Enable */ 48 + #define WPT_TSS_TSDSS 0x10 /* Thermal Sensor Dynamic Shutdown Status */ 49 + #define WPT_TSS_GPES 0x08 /* GPE status */ 50 + #define WPT_TSEL_ETS 0x01 /* Enable TS */ 51 + #define WPT_TSEL_PLDB 0x80 /* TSEL Policy Lock-Down Bit */ 52 + #define WPT_TL_TOL 0x000001FF /* T0 Level */ 53 + #define WPT_TL_T1L 0x1ff00000 /* T1 Level */ 54 + #define WPT_TL_TTEN 0x20000000 /* TT Enable */ 55 + 56 + static char driver_name[] = "Intel PCH thermal driver"; 57 + 58 + struct pch_thermal_device { 59 + void __iomem *hw_base; 60 + const struct pch_dev_ops *ops; 61 + struct pci_dev *pdev; 62 + struct thermal_zone_device *tzd; 63 + int crt_trip_id; 64 + unsigned long crt_temp; 65 + int hot_trip_id; 66 + unsigned long hot_temp; 67 + }; 68 + 69 + static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) 70 + { 71 + u8 tsel; 72 + u16 trip_temp; 73 + 74 + *nr_trips = 0; 75 + 76 + /* Check if BIOS has already enabled thermal sensor */ 77 + if (WPT_TSS_TSDSS & readb(ptd->hw_base + WPT_TSS)) 78 + goto read_trips; 79 + 80 + tsel = readb(ptd->hw_base + WPT_TSEL); 81 + /* 82 + * When TSEL's Policy Lock-Down bit is 1, TSEL become RO. 83 + * If so, thermal sensor cannot enable. Bail out. 84 + */ 85 + if (tsel & WPT_TSEL_PLDB) { 86 + dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); 87 + return -ENODEV; 88 + } 89 + 90 + writeb(tsel|WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); 91 + if (!(WPT_TSS_TSDSS & readb(ptd->hw_base + WPT_TSS))) { 92 + dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); 93 + return -ENODEV; 94 + } 95 + 96 + read_trips: 97 + ptd->crt_trip_id = -1; 98 + trip_temp = readw(ptd->hw_base + WPT_CTT); 99 + trip_temp &= 0x1FF; 100 + if (trip_temp) { 101 + /* Resolution of 1/2 degree C and an offset of -50C */ 102 + ptd->crt_temp = trip_temp * 1000 / 2 - 50000; 103 + ptd->crt_trip_id = 0; 104 + ++(*nr_trips); 105 + } 106 + 107 + ptd->hot_trip_id = -1; 108 + trip_temp = readw(ptd->hw_base + WPT_PHL); 109 + trip_temp &= 0x1FF; 110 + if (trip_temp) { 111 + /* Resolution of 1/2 degree C and an offset of -50C */ 112 + ptd->hot_temp = trip_temp * 1000 / 2 - 50000; 113 + ptd->hot_trip_id = *nr_trips; 114 + ++(*nr_trips); 115 + } 116 + 117 + return 0; 118 + } 119 + 120 + static int pch_wpt_get_temp(struct pch_thermal_device *ptd, 121 + unsigned long *temp) 122 + { 123 + u8 wpt_temp; 124 + 125 + wpt_temp = WPT_TEMP_TSR & readl(ptd->hw_base + WPT_TEMP); 126 + 127 + /* Resolution of 1/2 degree C and an offset of -50C */ 128 + *temp = (wpt_temp * 1000 / 2 - 50000); 129 + 130 + return 0; 131 + } 132 + 133 + struct pch_dev_ops { 134 + int (*hw_init)(struct pch_thermal_device *ptd, int *nr_trips); 135 + int (*get_temp)(struct pch_thermal_device *ptd, unsigned long *temp); 136 + }; 137 + 138 + 139 + /* dev ops for Wildcat Point */ 140 + static struct pch_dev_ops pch_dev_ops_wpt = { 141 + .hw_init = pch_wpt_init, 142 + .get_temp = pch_wpt_get_temp, 143 + }; 144 + 145 + static int pch_thermal_get_temp(struct thermal_zone_device *tzd, 146 + unsigned long *temp) 147 + { 148 + struct pch_thermal_device *ptd = tzd->devdata; 149 + 150 + return ptd->ops->get_temp(ptd, temp); 151 + } 152 + 153 + static int pch_get_trip_type(struct thermal_zone_device *tzd, int trip, 154 + enum thermal_trip_type *type) 155 + { 156 + struct pch_thermal_device *ptd = tzd->devdata; 157 + 158 + if (ptd->crt_trip_id == trip) 159 + *type = THERMAL_TRIP_CRITICAL; 160 + else if (ptd->hot_trip_id == trip) 161 + *type = THERMAL_TRIP_HOT; 162 + else 163 + return -EINVAL; 164 + 165 + return 0; 166 + } 167 + 168 + static int pch_get_trip_temp(struct thermal_zone_device *tzd, int trip, 169 + unsigned long *temp) 170 + { 171 + struct pch_thermal_device *ptd = tzd->devdata; 172 + 173 + if (ptd->crt_trip_id == trip) 174 + *temp = ptd->crt_temp; 175 + else if (ptd->hot_trip_id == trip) 176 + *temp = ptd->hot_temp; 177 + else 178 + return -EINVAL; 179 + 180 + return 0; 181 + } 182 + 183 + static struct thermal_zone_device_ops tzd_ops = { 184 + .get_temp = pch_thermal_get_temp, 185 + .get_trip_type = pch_get_trip_type, 186 + .get_trip_temp = pch_get_trip_temp, 187 + }; 188 + 189 + 190 + static int intel_pch_thermal_probe(struct pci_dev *pdev, 191 + const struct pci_device_id *id) 192 + { 193 + struct pch_thermal_device *ptd; 194 + int err; 195 + int nr_trips; 196 + char *dev_name; 197 + 198 + ptd = devm_kzalloc(&pdev->dev, sizeof(*ptd), GFP_KERNEL); 199 + if (!ptd) 200 + return -ENOMEM; 201 + 202 + switch (pdev->device) { 203 + case PCH_THERMAL_DID_WPT: 204 + ptd->ops = &pch_dev_ops_wpt; 205 + dev_name = "pch_wildcat_point"; 206 + break; 207 + default: 208 + dev_err(&pdev->dev, "unknown pch thermal device\n"); 209 + return -ENODEV; 210 + } 211 + 212 + pci_set_drvdata(pdev, ptd); 213 + ptd->pdev = pdev; 214 + 215 + err = pci_enable_device(pdev); 216 + if (err) { 217 + dev_err(&pdev->dev, "failed to enable pci device\n"); 218 + return err; 219 + } 220 + 221 + err = pci_request_regions(pdev, driver_name); 222 + if (err) { 223 + dev_err(&pdev->dev, "failed to request pci region\n"); 224 + goto error_disable; 225 + } 226 + 227 + ptd->hw_base = pci_ioremap_bar(pdev, 0); 228 + if (!ptd->hw_base) { 229 + err = -ENOMEM; 230 + dev_err(&pdev->dev, "failed to map mem base\n"); 231 + goto error_release; 232 + } 233 + 234 + err = ptd->ops->hw_init(ptd, &nr_trips); 235 + if (err) 236 + goto error_cleanup; 237 + 238 + ptd->tzd = thermal_zone_device_register(dev_name, nr_trips, 0, ptd, 239 + &tzd_ops, NULL, 0, 0); 240 + if (IS_ERR(ptd->tzd)) { 241 + dev_err(&pdev->dev, "Failed to register thermal zone %s\n", 242 + dev_name); 243 + err = PTR_ERR(ptd->tzd); 244 + goto error_cleanup; 245 + } 246 + 247 + return 0; 248 + 249 + error_cleanup: 250 + iounmap(ptd->hw_base); 251 + error_release: 252 + pci_release_regions(pdev); 253 + error_disable: 254 + pci_disable_device(pdev); 255 + dev_err(&pdev->dev, "pci device failed to probe\n"); 256 + return err; 257 + } 258 + 259 + static void intel_pch_thermal_remove(struct pci_dev *pdev) 260 + { 261 + struct pch_thermal_device *ptd = pci_get_drvdata(pdev); 262 + 263 + thermal_zone_device_unregister(ptd->tzd); 264 + iounmap(ptd->hw_base); 265 + pci_set_drvdata(pdev, NULL); 266 + pci_release_region(pdev, 0); 267 + pci_disable_device(pdev); 268 + } 269 + 270 + static struct pci_device_id intel_pch_thermal_id[] = { 271 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_WPT) }, 272 + { 0, }, 273 + }; 274 + MODULE_DEVICE_TABLE(pci, intel_pch_thermal_id); 275 + 276 + static struct pci_driver intel_pch_thermal_driver = { 277 + .name = "intel_pch_thermal", 278 + .id_table = intel_pch_thermal_id, 279 + .probe = intel_pch_thermal_probe, 280 + .remove = intel_pch_thermal_remove, 281 + }; 282 + 283 + module_pci_driver(intel_pch_thermal_driver); 284 + 285 + MODULE_LICENSE("GPL v2"); 286 + MODULE_DESCRIPTION("Intel PCH Thermal driver");
+3
drivers/thermal/intel_powerclamp.c
··· 693 693 { X86_VENDOR_INTEL, 6, 0x3f}, 694 694 { X86_VENDOR_INTEL, 6, 0x45}, 695 695 { X86_VENDOR_INTEL, 6, 0x46}, 696 + { X86_VENDOR_INTEL, 6, 0x47}, 696 697 { X86_VENDOR_INTEL, 6, 0x4c}, 697 698 { X86_VENDOR_INTEL, 6, 0x4d}, 699 + { X86_VENDOR_INTEL, 6, 0x4e}, 698 700 { X86_VENDOR_INTEL, 6, 0x4f}, 699 701 { X86_VENDOR_INTEL, 6, 0x56}, 700 702 { X86_VENDOR_INTEL, 6, 0x57}, 703 + { X86_VENDOR_INTEL, 6, 0x5e}, 701 704 {} 702 705 }; 703 706 MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids);
+6 -7
drivers/thermal/intel_quark_dts_thermal.c
··· 186 186 return ret; 187 187 } 188 188 189 - static int _get_trip_temp(int trip, unsigned long *temp) 189 + static int _get_trip_temp(int trip, int *temp) 190 190 { 191 191 int status; 192 192 u32 out; ··· 212 212 } 213 213 214 214 static inline int sys_get_trip_temp(struct thermal_zone_device *tzd, 215 - int trip, unsigned long *temp) 215 + int trip, int *temp) 216 216 { 217 217 return _get_trip_temp(trip, temp); 218 218 } 219 219 220 - static inline int sys_get_crit_temp(struct thermal_zone_device *tzd, 221 - unsigned long *temp) 220 + static inline int sys_get_crit_temp(struct thermal_zone_device *tzd, int *temp) 222 221 { 223 222 return _get_trip_temp(QRK_DTS_ID_TP_CRITICAL, temp); 224 223 } 225 224 226 225 static int update_trip_temp(struct soc_sensor_entry *aux_entry, 227 - int trip, unsigned long temp) 226 + int trip, int temp) 228 227 { 229 228 u32 out; 230 229 u32 temp_out; ··· 271 272 } 272 273 273 274 static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, 274 - unsigned long temp) 275 + int temp) 275 276 { 276 277 return update_trip_temp(tzd->devdata, trip, temp); 277 278 } ··· 288 289 } 289 290 290 291 static int sys_get_curr_temp(struct thermal_zone_device *tzd, 291 - unsigned long *temp) 292 + int *temp) 292 293 { 293 294 u32 out; 294 295 int ret;
+4 -4
drivers/thermal/intel_soc_dts_iosf.c
··· 80 80 } 81 81 82 82 static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip, 83 - unsigned long *temp) 83 + int *temp) 84 84 { 85 85 int status; 86 86 u32 out; ··· 106 106 } 107 107 108 108 static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts, 109 - int thres_index, unsigned long temp, 109 + int thres_index, int temp, 110 110 enum thermal_trip_type trip_type) 111 111 { 112 112 int status; ··· 196 196 } 197 197 198 198 static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, 199 - unsigned long temp) 199 + int temp) 200 200 { 201 201 struct intel_soc_dts_sensor_entry *dts = tzd->devdata; 202 202 struct intel_soc_dts_sensors *sensors = dts->sensors; ··· 226 226 } 227 227 228 228 static int sys_get_curr_temp(struct thermal_zone_device *tzd, 229 - unsigned long *temp) 229 + int *temp) 230 230 { 231 231 int status; 232 232 u32 out;
+1 -1
drivers/thermal/kirkwood_thermal.c
··· 33 33 }; 34 34 35 35 static int kirkwood_get_temp(struct thermal_zone_device *thermal, 36 - unsigned long *temp) 36 + int *temp) 37 37 { 38 38 unsigned long reg; 39 39 struct kirkwood_thermal_priv *priv = thermal->devdata;
+7 -7
drivers/thermal/of-thermal.c
··· 91 91 /*** DT thermal zone device callbacks ***/ 92 92 93 93 static int of_thermal_get_temp(struct thermal_zone_device *tz, 94 - unsigned long *temp) 94 + int *temp) 95 95 { 96 96 struct __thermal_zone *data = tz->devdata; 97 97 ··· 177 177 * Return: zero on success, error code otherwise 178 178 */ 179 179 static int of_thermal_set_emul_temp(struct thermal_zone_device *tz, 180 - unsigned long temp) 180 + int temp) 181 181 { 182 182 struct __thermal_zone *data = tz->devdata; 183 183 ··· 311 311 } 312 312 313 313 static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip, 314 - unsigned long *temp) 314 + int *temp) 315 315 { 316 316 struct __thermal_zone *data = tz->devdata; 317 317 ··· 324 324 } 325 325 326 326 static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip, 327 - unsigned long temp) 327 + int temp) 328 328 { 329 329 struct __thermal_zone *data = tz->devdata; 330 330 ··· 338 338 } 339 339 340 340 static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip, 341 - unsigned long *hyst) 341 + int *hyst) 342 342 { 343 343 struct __thermal_zone *data = tz->devdata; 344 344 ··· 351 351 } 352 352 353 353 static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, 354 - unsigned long hyst) 354 + int hyst) 355 355 { 356 356 struct __thermal_zone *data = tz->devdata; 357 357 ··· 365 365 } 366 366 367 367 static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, 368 - unsigned long *temp) 368 + int *temp) 369 369 { 370 370 struct __thermal_zone *data = tz->devdata; 371 371 int i;
+8 -8
drivers/thermal/power_allocator.c
··· 92 92 * Return: The power budget for the next period. 93 93 */ 94 94 static u32 pid_controller(struct thermal_zone_device *tz, 95 - unsigned long current_temp, 96 - unsigned long control_temp, 95 + int current_temp, 96 + int control_temp, 97 97 u32 max_allocatable_power) 98 98 { 99 99 s64 p, i, d, power_range; ··· 102 102 103 103 max_power_frac = int_to_frac(max_allocatable_power); 104 104 105 - err = ((s32)control_temp - (s32)current_temp); 105 + err = control_temp - current_temp; 106 106 err = int_to_frac(err); 107 107 108 108 /* Calculate the proportional term */ ··· 223 223 } 224 224 225 225 static int allocate_power(struct thermal_zone_device *tz, 226 - unsigned long current_temp, 227 - unsigned long control_temp) 226 + int current_temp, 227 + int control_temp) 228 228 { 229 229 struct thermal_instance *instance; 230 230 struct power_allocator_params *params = tz->governor_data; ··· 331 331 granted_power, total_granted_power, 332 332 num_actors, power_range, 333 333 max_allocatable_power, current_temp, 334 - (s32)control_temp - (s32)current_temp); 334 + control_temp - current_temp); 335 335 336 336 kfree(req_power); 337 337 unlock: ··· 416 416 { 417 417 int ret; 418 418 struct power_allocator_params *params; 419 - unsigned long switch_on_temp, control_temp; 419 + int switch_on_temp, control_temp; 420 420 u32 temperature_threshold; 421 421 422 422 if (!tz->tzp || !tz->tzp->sustainable_power) { ··· 481 481 static int power_allocator_throttle(struct thermal_zone_device *tz, int trip) 482 482 { 483 483 int ret; 484 - unsigned long switch_on_temp, control_temp, current_temp; 484 + int switch_on_temp, control_temp, current_temp; 485 485 struct power_allocator_params *params = tz->governor_data; 486 486 487 487 /*
+1 -1
drivers/thermal/qcom-spmi-temp-alarm.c
··· 117 117 return 0; 118 118 } 119 119 120 - static int qpnp_tm_get_temp(void *data, long *temp) 120 + static int qpnp_tm_get_temp(void *data, int *temp) 121 121 { 122 122 struct qpnp_tm_chip *chip = data; 123 123 int ret, mili_celsius;
+3 -4
drivers/thermal/rcar_thermal.c
··· 200 200 return ret; 201 201 } 202 202 203 - static int rcar_thermal_get_temp(struct thermal_zone_device *zone, 204 - unsigned long *temp) 203 + static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) 205 204 { 206 205 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); 207 206 ··· 234 235 } 235 236 236 237 static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone, 237 - int trip, unsigned long *temp) 238 + int trip, int *temp) 238 239 { 239 240 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); 240 241 struct device *dev = rcar_priv_to_dev(priv); ··· 298 299 static void rcar_thermal_work(struct work_struct *work) 299 300 { 300 301 struct rcar_thermal_priv *priv; 301 - unsigned long cctemp, nctemp; 302 + int cctemp, nctemp; 302 303 303 304 priv = container_of(work, struct rcar_thermal_priv, work.work); 304 305
+5 -5
drivers/thermal/rockchip_thermal.c
··· 64 64 void (*control)(void __iomem *reg, bool on); 65 65 66 66 /* Per-sensor methods */ 67 - int (*get_temp)(int chn, void __iomem *reg, long *temp); 67 + int (*get_temp)(int chn, void __iomem *reg, int *temp); 68 68 void (*set_tshut_temp)(int chn, void __iomem *reg, long temp); 69 69 void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m); 70 70 }; ··· 191 191 return 0; 192 192 } 193 193 194 - static long rk_tsadcv2_code_to_temp(u32 code) 194 + static int rk_tsadcv2_code_to_temp(u32 code) 195 195 { 196 196 unsigned int low = 0; 197 197 unsigned int high = ARRAY_SIZE(v2_code_table) - 1; ··· 277 277 writel_relaxed(val, regs + TSADCV2_AUTO_CON); 278 278 } 279 279 280 - static int rk_tsadcv2_get_temp(int chn, void __iomem *regs, long *temp) 280 + static int rk_tsadcv2_get_temp(int chn, void __iomem *regs, int *temp) 281 281 { 282 282 u32 val; 283 283 ··· 366 366 return IRQ_HANDLED; 367 367 } 368 368 369 - static int rockchip_thermal_get_temp(void *_sensor, long *out_temp) 369 + static int rockchip_thermal_get_temp(void *_sensor, int *out_temp) 370 370 { 371 371 struct rockchip_thermal_sensor *sensor = _sensor; 372 372 struct rockchip_thermal_data *thermal = sensor->thermal; ··· 374 374 int retval; 375 375 376 376 retval = tsadc->get_temp(sensor->id, thermal->regs, out_temp); 377 - dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %ld, retval: %d\n", 377 + dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n", 378 378 sensor->id, *out_temp, retval); 379 379 380 380 return retval;
+11 -12
drivers/thermal/samsung/exynos_tmu.c
··· 207 207 int (*tmu_initialize)(struct platform_device *pdev); 208 208 void (*tmu_control)(struct platform_device *pdev, bool on); 209 209 int (*tmu_read)(struct exynos_tmu_data *data); 210 - void (*tmu_set_emulation)(struct exynos_tmu_data *data, 211 - unsigned long temp); 210 + void (*tmu_set_emulation)(struct exynos_tmu_data *data, int temp); 212 211 void (*tmu_clear_irqs)(struct exynos_tmu_data *data); 213 212 }; 214 213 ··· 215 216 { 216 217 char data[10], *envp[] = { data, NULL }; 217 218 struct thermal_zone_device *tz = p->tzd; 218 - unsigned long temp; 219 + int temp; 219 220 unsigned int i; 220 221 221 222 if (!tz) { ··· 516 517 struct thermal_zone_device *tz = data->tzd; 517 518 unsigned int status, trim_info; 518 519 unsigned int rising_threshold = 0, falling_threshold = 0; 519 - unsigned long temp, temp_hist; 520 + int temp, temp_hist; 520 521 int ret = 0, threshold_code, i, sensor_id, cal_type; 521 522 522 523 status = readb(data->base + EXYNOS_TMU_REG_STATUS); ··· 609 610 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 610 611 unsigned int trim_info = 0, con, rising_threshold; 611 612 int ret = 0, threshold_code; 612 - unsigned long crit_temp = 0; 613 + int crit_temp = 0; 613 614 614 615 /* 615 616 * For exynos5440 soc triminfo value is swapped between TMU0 and ··· 662 663 unsigned int status, trim_info; 663 664 unsigned int rising_threshold = 0, falling_threshold = 0; 664 665 int ret = 0, threshold_code, i; 665 - unsigned long temp, temp_hist; 666 + int temp, temp_hist; 666 667 unsigned int reg_off, bit_off; 667 668 668 669 status = readb(data->base + EXYNOS_TMU_REG_STATUS); ··· 875 876 writel(con, data->base + EXYNOS_TMU_REG_CONTROL); 876 877 } 877 878 878 - static int exynos_get_temp(void *p, long *temp) 879 + static int exynos_get_temp(void *p, int *temp) 879 880 { 880 881 struct exynos_tmu_data *data = p; 881 882 ··· 895 896 896 897 #ifdef CONFIG_THERMAL_EMULATION 897 898 static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val, 898 - unsigned long temp) 899 + int temp) 899 900 { 900 901 if (temp) { 901 902 temp /= MCELSIUS; ··· 925 926 } 926 927 927 928 static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data, 928 - unsigned long temp) 929 + int temp) 929 930 { 930 931 unsigned int val; 931 932 u32 emul_con; ··· 945 946 } 946 947 947 948 static void exynos5440_tmu_set_emulation(struct exynos_tmu_data *data, 948 - unsigned long temp) 949 + int temp) 949 950 { 950 951 unsigned int val; 951 952 ··· 954 955 writel(val, data->base + EXYNOS5440_TMU_S0_7_DEBUG); 955 956 } 956 957 957 - static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) 958 + static int exynos_tmu_set_emulation(void *drv_data, int temp) 958 959 { 959 960 struct exynos_tmu_data *data = drv_data; 960 961 int ret = -EINVAL; ··· 977 978 #else 978 979 #define exynos4412_tmu_set_emulation NULL 979 980 #define exynos5440_tmu_set_emulation NULL 980 - static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) 981 + static int exynos_tmu_set_emulation(void *drv_data, int temp) 981 982 { return -EINVAL; } 982 983 #endif /* CONFIG_THERMAL_EMULATION */ 983 984
+1 -1
drivers/thermal/spear_thermal.c
··· 38 38 }; 39 39 40 40 static inline int thermal_get_temp(struct thermal_zone_device *thermal, 41 - unsigned long *temp) 41 + int *temp) 42 42 { 43 43 struct spear_thermal_dev *stdev = thermal->devdata; 44 44
+2 -3
drivers/thermal/st/st_thermal.c
··· 111 111 } 112 112 113 113 /* Callback to get temperature from HW*/ 114 - static int st_thermal_get_temp(struct thermal_zone_device *th, 115 - unsigned long *temperature) 114 + static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature) 116 115 { 117 116 struct st_thermal_sensor *sensor = th->devdata; 118 117 struct device *dev = sensor->dev; ··· 158 159 } 159 160 160 161 static int st_thermal_get_trip_temp(struct thermal_zone_device *th, 161 - int trip, unsigned long *temp) 162 + int trip, int *temp) 162 163 { 163 164 struct st_thermal_sensor *sensor = th->devdata; 164 165 struct device *dev = sensor->dev;
+2 -2
drivers/thermal/step_wise.c
··· 113 113 114 114 static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) 115 115 { 116 - long trip_temp; 116 + int trip_temp; 117 117 enum thermal_trip_type trip_type; 118 118 enum thermal_trend trend; 119 119 struct thermal_instance *instance; ··· 135 135 trace_thermal_zone_trip(tz, trip, trip_type); 136 136 } 137 137 138 - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%ld]:trend=%d,throttle=%d\n", 138 + dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n", 139 139 trip, trip_type, trip_temp, trend, throttle); 140 140 141 141 mutex_lock(&tz->lock);
+2 -2
drivers/thermal/tegra_soctherm.c
··· 293 293 * H denotes an addition of 0.5 Celsius and N denotes negation 294 294 * of the final value. 295 295 */ 296 - static long translate_temp(u16 val) 296 + static int translate_temp(u16 val) 297 297 { 298 298 long t; 299 299 ··· 306 306 return t; 307 307 } 308 308 309 - static int tegra_thermctl_get_temp(void *data, long *out_temp) 309 + static int tegra_thermctl_get_temp(void *data, int *out_temp) 310 310 { 311 311 struct tegra_thermctl_zone *zone = data; 312 312 u32 val;
+64 -43
drivers/thermal/thermal_core.c
··· 426 426 static void handle_critical_trips(struct thermal_zone_device *tz, 427 427 int trip, enum thermal_trip_type trip_type) 428 428 { 429 - long trip_temp; 429 + int trip_temp; 430 430 431 431 tz->ops->get_trip_temp(tz, trip, &trip_temp); 432 432 ··· 465 465 } 466 466 467 467 /** 468 - * thermal_zone_get_temp() - returns its the temperature of thermal zone 468 + * thermal_zone_get_temp() - returns the temperature of a thermal zone 469 469 * @tz: a valid pointer to a struct thermal_zone_device 470 470 * @temp: a valid pointer to where to store the resulting temperature. 471 471 * ··· 474 474 * 475 475 * Return: On success returns 0, an error code otherwise 476 476 */ 477 - int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp) 477 + int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) 478 478 { 479 479 int ret = -EINVAL; 480 - #ifdef CONFIG_THERMAL_EMULATION 481 480 int count; 482 - unsigned long crit_temp = -1UL; 481 + int crit_temp = INT_MAX; 483 482 enum thermal_trip_type type; 484 - #endif 485 483 486 484 if (!tz || IS_ERR(tz) || !tz->ops->get_temp) 487 485 goto exit; ··· 487 489 mutex_lock(&tz->lock); 488 490 489 491 ret = tz->ops->get_temp(tz, temp); 490 - #ifdef CONFIG_THERMAL_EMULATION 491 - if (!tz->emul_temperature) 492 - goto skip_emul; 493 492 494 - for (count = 0; count < tz->trips; count++) { 495 - ret = tz->ops->get_trip_type(tz, count, &type); 496 - if (!ret && type == THERMAL_TRIP_CRITICAL) { 497 - ret = tz->ops->get_trip_temp(tz, count, &crit_temp); 498 - break; 493 + if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { 494 + for (count = 0; count < tz->trips; count++) { 495 + ret = tz->ops->get_trip_type(tz, count, &type); 496 + if (!ret && type == THERMAL_TRIP_CRITICAL) { 497 + ret = tz->ops->get_trip_temp(tz, count, 498 + &crit_temp); 499 + break; 500 + } 499 501 } 502 + 503 + /* 504 + * Only allow emulating a temperature when the real temperature 505 + * is below the critical temperature so that the emulation code 506 + * cannot hide critical conditions. 507 + */ 508 + if (!ret && *temp < crit_temp) 509 + *temp = tz->emul_temperature; 500 510 } 501 - 502 - if (ret) 503 - goto skip_emul; 504 - 505 - if (*temp < crit_temp) 506 - *temp = tz->emul_temperature; 507 - skip_emul: 508 - #endif 511 + 509 512 mutex_unlock(&tz->lock); 510 513 exit: 511 514 return ret; ··· 515 516 516 517 static void update_temperature(struct thermal_zone_device *tz) 517 518 { 518 - long temp; 519 - int ret; 519 + int temp, ret; 520 520 521 521 ret = thermal_zone_get_temp(tz, &temp); 522 522 if (ret) { ··· 575 577 temp_show(struct device *dev, struct device_attribute *attr, char *buf) 576 578 { 577 579 struct thermal_zone_device *tz = to_thermal_zone(dev); 578 - long temperature; 579 - int ret; 580 + int temperature, ret; 580 581 581 582 ret = thermal_zone_get_temp(tz, &temperature); 582 583 583 584 if (ret) 584 585 return ret; 585 586 586 - return sprintf(buf, "%ld\n", temperature); 587 + return sprintf(buf, "%d\n", temperature); 587 588 } 588 589 589 590 static ssize_t ··· 686 689 { 687 690 struct thermal_zone_device *tz = to_thermal_zone(dev); 688 691 int trip, ret; 689 - long temperature; 692 + int temperature; 690 693 691 694 if (!tz->ops->get_trip_temp) 692 695 return -EPERM; ··· 699 702 if (ret) 700 703 return ret; 701 704 702 - return sprintf(buf, "%ld\n", temperature); 705 + return sprintf(buf, "%d\n", temperature); 703 706 } 704 707 705 708 static ssize_t ··· 708 711 { 709 712 struct thermal_zone_device *tz = to_thermal_zone(dev); 710 713 int trip, ret; 711 - unsigned long temperature; 714 + int temperature; 712 715 713 716 if (!tz->ops->set_trip_hyst) 714 717 return -EPERM; ··· 716 719 if (!sscanf(attr->attr.name, "trip_point_%d_hyst", &trip)) 717 720 return -EINVAL; 718 721 719 - if (kstrtoul(buf, 10, &temperature)) 722 + if (kstrtoint(buf, 10, &temperature)) 720 723 return -EINVAL; 721 724 722 725 /* ··· 735 738 { 736 739 struct thermal_zone_device *tz = to_thermal_zone(dev); 737 740 int trip, ret; 738 - unsigned long temperature; 741 + int temperature; 739 742 740 743 if (!tz->ops->get_trip_hyst) 741 744 return -EPERM; ··· 745 748 746 749 ret = tz->ops->get_trip_hyst(tz, trip, &temperature); 747 750 748 - return ret ? ret : sprintf(buf, "%ld\n", temperature); 751 + return ret ? ret : sprintf(buf, "%d\n", temperature); 749 752 } 750 753 751 754 static ssize_t ··· 844 847 return sprintf(buf, "%s\n", tz->governor->name); 845 848 } 846 849 847 - #ifdef CONFIG_THERMAL_EMULATION 850 + static ssize_t 851 + available_policies_show(struct device *dev, struct device_attribute *devattr, 852 + char *buf) 853 + { 854 + struct thermal_governor *pos; 855 + ssize_t count = 0; 856 + ssize_t size = PAGE_SIZE; 857 + 858 + mutex_lock(&thermal_governor_lock); 859 + 860 + list_for_each_entry(pos, &thermal_governor_list, governor_list) { 861 + size = PAGE_SIZE - count; 862 + count += scnprintf(buf + count, size, "%s ", pos->name); 863 + } 864 + count += scnprintf(buf + count, size, "\n"); 865 + 866 + mutex_unlock(&thermal_governor_lock); 867 + 868 + return count; 869 + } 870 + 848 871 static ssize_t 849 872 emul_temp_store(struct device *dev, struct device_attribute *attr, 850 873 const char *buf, size_t count) ··· 890 873 return ret ? ret : count; 891 874 } 892 875 static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store); 893 - #endif/*CONFIG_THERMAL_EMULATION*/ 894 876 895 877 static ssize_t 896 878 sustainable_power_show(struct device *dev, struct device_attribute *devattr, ··· 1048 1032 static DEVICE_ATTR(mode, 0644, mode_show, mode_store); 1049 1033 static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); 1050 1034 static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); 1035 + static DEVICE_ATTR(available_policies, S_IRUGO, available_policies_show, NULL); 1051 1036 1052 1037 /* sys I/F for cooling device */ 1053 1038 #define to_cooling_device(_dev) \ ··· 1820 1803 goto unregister; 1821 1804 } 1822 1805 1823 - #ifdef CONFIG_THERMAL_EMULATION 1824 - result = device_create_file(&tz->device, &dev_attr_emul_temp); 1825 - if (result) 1826 - goto unregister; 1827 - #endif 1806 + if (IS_ENABLED(CONFIG_THERMAL_EMULATION)) { 1807 + result = device_create_file(&tz->device, &dev_attr_emul_temp); 1808 + if (result) 1809 + goto unregister; 1810 + } 1811 + 1828 1812 /* Create policy attribute */ 1829 1813 result = device_create_file(&tz->device, &dev_attr_policy); 1830 1814 if (result) ··· 1833 1815 1834 1816 /* Add thermal zone params */ 1835 1817 result = create_tzp_attrs(&tz->device); 1818 + if (result) 1819 + goto unregister; 1820 + 1821 + /* Create available_policies attribute */ 1822 + result = device_create_file(&tz->device, &dev_attr_available_policies); 1836 1823 if (result) 1837 1824 goto unregister; 1838 1825 ··· 1871 1848 bind_tz(tz); 1872 1849 1873 1850 INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); 1874 - 1875 - if (!tz->ops->get_temp) 1876 - thermal_zone_device_set_polling(tz, 0); 1877 1851 1878 1852 thermal_zone_device_update(tz); 1879 1853 ··· 1938 1918 if (tz->ops->get_mode) 1939 1919 device_remove_file(&tz->device, &dev_attr_mode); 1940 1920 device_remove_file(&tz->device, &dev_attr_policy); 1921 + device_remove_file(&tz->device, &dev_attr_available_policies); 1941 1922 remove_trip_attrs(tz); 1942 1923 thermal_set_governor(tz, NULL); 1943 1924
+5 -5
drivers/thermal/thermal_hwmon.c
··· 69 69 static ssize_t 70 70 temp_input_show(struct device *dev, struct device_attribute *attr, char *buf) 71 71 { 72 - long temperature; 72 + int temperature; 73 73 int ret; 74 74 struct thermal_hwmon_attr *hwmon_attr 75 75 = container_of(attr, struct thermal_hwmon_attr, attr); ··· 83 83 if (ret) 84 84 return ret; 85 85 86 - return sprintf(buf, "%ld\n", temperature); 86 + return sprintf(buf, "%d\n", temperature); 87 87 } 88 88 89 89 static ssize_t ··· 95 95 = container_of(hwmon_attr, struct thermal_hwmon_temp, 96 96 temp_crit); 97 97 struct thermal_zone_device *tz = temp->tz; 98 - long temperature; 98 + int temperature; 99 99 int ret; 100 100 101 101 ret = tz->ops->get_trip_temp(tz, 0, &temperature); 102 102 if (ret) 103 103 return ret; 104 104 105 - return sprintf(buf, "%ld\n", temperature); 105 + return sprintf(buf, "%d\n", temperature); 106 106 } 107 107 108 108 ··· 142 142 143 143 static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz) 144 144 { 145 - unsigned long temp; 145 + int temp; 146 146 return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp); 147 147 } 148 148
+5 -5
drivers/thermal/ti-soc-thermal/ti-thermal-common.c
··· 76 76 77 77 /* thermal zone ops */ 78 78 /* Get temperature callback function for thermal zone */ 79 - static inline int __ti_thermal_get_temp(void *devdata, long *temp) 79 + static inline int __ti_thermal_get_temp(void *devdata, int *temp) 80 80 { 81 81 struct thermal_zone_device *pcb_tz = NULL; 82 82 struct ti_thermal_data *data = devdata; 83 83 struct ti_bandgap *bgp; 84 84 const struct ti_temp_sensor *s; 85 85 int ret, tmp, slope, constant; 86 - unsigned long pcb_temp; 86 + int pcb_temp; 87 87 88 88 if (!data) 89 89 return 0; ··· 119 119 } 120 120 121 121 static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal, 122 - unsigned long *temp) 122 + int *temp) 123 123 { 124 124 struct ti_thermal_data *data = thermal->devdata; 125 125 ··· 229 229 230 230 /* Get trip temperature callback functions for thermal zone */ 231 231 static int ti_thermal_get_trip_temp(struct thermal_zone_device *thermal, 232 - int trip, unsigned long *temp) 232 + int trip, int *temp) 233 233 { 234 234 if (!ti_thermal_is_valid_trip(trip)) 235 235 return -EINVAL; ··· 280 280 281 281 /* Get critical temperature callback functions for thermal zone */ 282 282 static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal, 283 - unsigned long *temp) 283 + int *temp) 284 284 { 285 285 /* shutdown zone */ 286 286 return ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp);
+5 -5
drivers/thermal/x86_pkg_temp_thermal.c
··· 164 164 return err; 165 165 } 166 166 167 - static int sys_get_curr_temp(struct thermal_zone_device *tzd, unsigned long *temp) 167 + static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) 168 168 { 169 169 u32 eax, edx; 170 170 struct phy_dev_entry *phy_dev_entry; ··· 175 175 if (eax & 0x80000000) { 176 176 *temp = phy_dev_entry->tj_max - 177 177 ((eax >> 16) & 0x7f) * 1000; 178 - pr_debug("sys_get_curr_temp %ld\n", *temp); 178 + pr_debug("sys_get_curr_temp %d\n", *temp); 179 179 return 0; 180 180 } 181 181 ··· 183 183 } 184 184 185 185 static int sys_get_trip_temp(struct thermal_zone_device *tzd, 186 - int trip, unsigned long *temp) 186 + int trip, int *temp) 187 187 { 188 188 u32 eax, edx; 189 189 struct phy_dev_entry *phy_dev_entry; ··· 214 214 *temp = phy_dev_entry->tj_max - thres_reg_value * 1000; 215 215 else 216 216 *temp = 0; 217 - pr_debug("sys_get_trip_temp %ld\n", *temp); 217 + pr_debug("sys_get_trip_temp %d\n", *temp); 218 218 219 219 return 0; 220 220 } 221 221 222 222 static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, 223 - unsigned long temp) 223 + int temp) 224 224 { 225 225 u32 l, h; 226 226 struct phy_dev_entry *phy_dev_entry;
+11 -15
include/linux/thermal.h
··· 92 92 struct thermal_cooling_device *); 93 93 int (*unbind) (struct thermal_zone_device *, 94 94 struct thermal_cooling_device *); 95 - int (*get_temp) (struct thermal_zone_device *, unsigned long *); 95 + int (*get_temp) (struct thermal_zone_device *, int *); 96 96 int (*get_mode) (struct thermal_zone_device *, 97 97 enum thermal_device_mode *); 98 98 int (*set_mode) (struct thermal_zone_device *, 99 99 enum thermal_device_mode); 100 100 int (*get_trip_type) (struct thermal_zone_device *, int, 101 101 enum thermal_trip_type *); 102 - int (*get_trip_temp) (struct thermal_zone_device *, int, 103 - unsigned long *); 104 - int (*set_trip_temp) (struct thermal_zone_device *, int, 105 - unsigned long); 106 - int (*get_trip_hyst) (struct thermal_zone_device *, int, 107 - unsigned long *); 108 - int (*set_trip_hyst) (struct thermal_zone_device *, int, 109 - unsigned long); 110 - int (*get_crit_temp) (struct thermal_zone_device *, unsigned long *); 111 - int (*set_emul_temp) (struct thermal_zone_device *, unsigned long); 102 + int (*get_trip_temp) (struct thermal_zone_device *, int, int *); 103 + int (*set_trip_temp) (struct thermal_zone_device *, int, int); 104 + int (*get_trip_hyst) (struct thermal_zone_device *, int, int *); 105 + int (*set_trip_hyst) (struct thermal_zone_device *, int, int); 106 + int (*get_crit_temp) (struct thermal_zone_device *, int *); 107 + int (*set_emul_temp) (struct thermal_zone_device *, int); 112 108 int (*get_trend) (struct thermal_zone_device *, int, 113 109 enum thermal_trend *); 114 110 int (*notify) (struct thermal_zone_device *, int, ··· 328 332 * temperature. 329 333 */ 330 334 struct thermal_zone_of_device_ops { 331 - int (*get_temp)(void *, long *); 335 + int (*get_temp)(void *, int *); 332 336 int (*get_trend)(void *, long *); 333 - int (*set_emul_temp)(void *, unsigned long); 337 + int (*set_emul_temp)(void *, int); 334 338 }; 335 339 336 340 /** ··· 402 406 const struct thermal_cooling_device_ops *); 403 407 void thermal_cooling_device_unregister(struct thermal_cooling_device *); 404 408 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name); 405 - int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp); 409 + int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp); 406 410 407 411 int get_tz_trend(struct thermal_zone_device *, int); 408 412 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, ··· 453 457 const char *name) 454 458 { return ERR_PTR(-ENODEV); } 455 459 static inline int thermal_zone_get_temp( 456 - struct thermal_zone_device *tz, unsigned long *temp) 460 + struct thermal_zone_device *tz, int *temp) 457 461 { return -ENODEV; } 458 462 static inline int get_tz_trend(struct thermal_zone_device *tz, int trip) 459 463 { return -ENODEV; }
+3 -3
include/trace/events/thermal_power_allocator.h
··· 11 11 u32 total_req_power, u32 *granted_power, 12 12 u32 total_granted_power, size_t num_actors, 13 13 u32 power_range, u32 max_allocatable_power, 14 - unsigned long current_temp, s32 delta_temp), 14 + int current_temp, s32 delta_temp), 15 15 TP_ARGS(tz, req_power, total_req_power, granted_power, 16 16 total_granted_power, num_actors, power_range, 17 17 max_allocatable_power, current_temp, delta_temp), ··· 24 24 __field(size_t, num_actors ) 25 25 __field(u32, power_range ) 26 26 __field(u32, max_allocatable_power ) 27 - __field(unsigned long, current_temp ) 27 + __field(int, current_temp ) 28 28 __field(s32, delta_temp ) 29 29 ), 30 30 TP_fast_assign( ··· 42 42 __entry->delta_temp = delta_temp; 43 43 ), 44 44 45 - TP_printk("thermal_zone_id=%d req_power={%s} total_req_power=%u granted_power={%s} total_granted_power=%u power_range=%u max_allocatable_power=%u current_temperature=%lu delta_temperature=%d", 45 + TP_printk("thermal_zone_id=%d req_power={%s} total_req_power=%u granted_power={%s} total_granted_power=%u power_range=%u max_allocatable_power=%u current_temperature=%d delta_temperature=%d", 46 46 __entry->tz_id, 47 47 __print_array(__get_dynamic_array(req_power), 48 48 __entry->num_actors, 4),