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

Merge tag 'thermal-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control updates from Rafael Wysocki:
"These mostly continue to prepare the thermal control subsystem for
using unified representation of trip points, which includes cleanups,
code refactoring and similar and update several drivers (for other
reasons), which includes new hardware support.

Specifics:

- Add a thermal zone 'devdata' accessor and modify several drivers to
use it (Daniel Lezcano)

- Prevent drivers from using the 'device' internal thermal zone
structure field directly (Daniel Lezcano)

- Clean up the hwmon thermal driver (Daniel Lezcano)

- Add thermal zone id accessor and thermal zone type accessor and
prevent drivers from using thermal zone fields directly (Daniel
Lezcano)

- Clean up the acerhdf and tegra thermal drivers (Daniel Lezcano)

- Add lower bound check for sysfs input to the x86_pkg_temp_thermal
Intel thermal driver (Zhang Rui)

- Add more thermal zone device encapsulation: prevent setting
structure field directly, access the sensor device instead the
thermal zone's device for trace, relocate the traces in
drivers/thermal (Daniel Lezcano)

- Use the generic trip point for the i.MX and remove the
get_trip_temp ops (Daniel Lezcano)

- Use the devm_platform_ioremap_resource() in the Hisilicon driver
(Yang Li)

- Remove R-Car H3 ES1.* handling as public has only access to the ES2
version and the upstream support for the ES1 has been shutdown
(Wolfram Sang)

- Add a delay after initializing the bank in order to let the time to
the hardware to initialze itself before reading the temperature
(Amjad Ouled-Ameur)

- Add MT8365 support (Amjad Ouled-Ameur)

- Preparational cleanup and DT bindings for RK3588 support (Sebastian
Reichel)

- Add driver support for RK3588 (Finley Xiao)

- Use devm_reset_control_array_get_exclusive() for the Rockchip
driver (Ye Xingchen)

- Detect power gated thermal zones and return -EAGAIN when reading
the temperature (Mikko Perttunen)

- Remove thermal_bind_params structure as it is unused (Zhang Rui)

- Drop unneeded quotes in DT bindings allowing to run yamllint (Rob
Herring)

- Update the power allocator documentation according to the thermal
trace relocation (Lukas Bulwahn)

- Fix sensor 1 interrupt status bitmask for the Mediatek LVTS sensor
(Chen-Yu Tsai)

- Use the dev_err_probe() helper in the Amlogic driver (Ye Xingchen)

- Add AP domain support to LVTS thermal controllers for mt8195
(Balsam CHIHI)

- Remove buggy call to thermal_of_zone_unregister() (Daniel Lezcano)

- Make thermal_of_zone_[un]register() private to the thermal OF code
(Daniel Lezcano)

- Create a private copy of the thermal zone device parameters
structure when registering a thermal zone (Daniel Lezcano)

- Fix a kernel NULL pointer dereference in thermal_hwmon (Zhang Rui)

- Revert recent message adjustment in thermal_hwmon (Rafael Wysocki)

- Use of_property_present() for testing DT property presence in
thermal control code (Rob Herring)

- Clean up thermal_list_lock locking in the thermal core (Rafael
Wysocki)

- Add DLVR support for RFIM control in the int340x Intel thermal
driver (Srinivas Pandruvada)"

* tag 'thermal-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (55 commits)
thermal: intel: int340x: Add DLVR support for RFIM control
thermal/core: Alloc-copy-free the thermal zone parameters structure
thermal/of: Unexport unused OF functions
thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister
thermal/drivers/mediatek/lvts_thermal: Add AP domain for mt8195
dt-bindings: thermal: mediatek: Add AP domain to LVTS thermal controllers for mt8195
thermal: amlogic: Use dev_err_probe()
thermal/drivers/mediatek/lvts_thermal: Fix sensor 1 interrupt status bitmask
MAINTAINERS: adjust entry in THERMAL/POWER_ALLOCATOR after header movement
dt-bindings: thermal: Drop unneeded quotes
thermal/core: Remove thermal_bind_params structure
thermal/drivers/tegra-bpmp: Handle offline zones
thermal/drivers/rockchip: use devm_reset_control_array_get_exclusive()
dt-bindings: rockchip-thermal: Support the RK3588 SoC compatible
thermal/drivers/rockchip: Support RK3588 SoC in the thermal driver
thermal/drivers/rockchip: Support dynamic sized sensor array
thermal/drivers/rockchip: Simplify channel id logic
thermal/drivers/rockchip: Use dev_err_probe
thermal/drivers/rockchip: Simplify clock logic
thermal/drivers/rockchip: Simplify getting match data
...

+852 -721
+1 -1
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
··· 30 30 31 31 amlogic,ao-secure: 32 32 description: phandle to the ao-secure syscon 33 - $ref: '/schemas/types.yaml#/definitions/phandle' 33 + $ref: /schemas/types.yaml#/definitions/phandle 34 34 35 35 '#thermal-sensor-cells': 36 36 const: 0
+2 -2
Documentation/devicetree/bindings/thermal/imx-thermal.yaml
··· 40 40 - const: temp_grade 41 41 42 42 fsl,tempmon: 43 - $ref: '/schemas/types.yaml#/definitions/phandle' 43 + $ref: /schemas/types.yaml#/definitions/phandle 44 44 description: Phandle to anatop system controller node. 45 45 46 46 fsl,tempmon-data: 47 - $ref: '/schemas/types.yaml#/definitions/phandle' 47 + $ref: /schemas/types.yaml#/definitions/phandle 48 48 description: | 49 49 Deprecated property, phandle pointer to fuse controller that contains 50 50 TEMPMON calibration data, e.g. OCOTP on imx6q. The details about
+1
Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
··· 16 16 - "mediatek,mt7981-thermal", "mediatek,mt7986-thermal" : For MT7981 SoC 17 17 - "mediatek,mt7986-thermal" : For MT7986 SoC 18 18 - "mediatek,mt8183-thermal" : For MT8183 family of SoCs 19 + - "mediatek,mt8365-thermal" : For MT8365 family of SoCs 19 20 - "mediatek,mt8516-thermal", "mediatek,mt2701-thermal : For MT8516 family of SoCs 20 21 - reg: Address range of the thermal controller 21 22 - interrupts: IRQ for the thermal controller
+2 -2
Documentation/devicetree/bindings/thermal/qoriq-thermal.yaml
··· 29 29 maxItems: 1 30 30 31 31 fsl,tmu-range: 32 - $ref: '/schemas/types.yaml#/definitions/uint32-array' 32 + $ref: /schemas/types.yaml#/definitions/uint32-array 33 33 description: | 34 34 The values to be programmed into TTRnCR, as specified by the SoC 35 35 reference manual. The first cell is TTR0CR, the second is TTR1CR, etc. 36 36 maxItems: 4 37 37 38 38 fsl,tmu-calibration: 39 - $ref: '/schemas/types.yaml#/definitions/uint32-matrix' 39 + $ref: /schemas/types.yaml#/definitions/uint32-matrix 40 40 description: | 41 41 A list of cell pairs containing temperature calibration data, as 42 42 specified by the SoC reference manual. The first cell of each pair
+1
Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml
··· 19 19 - rockchip,rk3368-tsadc 20 20 - rockchip,rk3399-tsadc 21 21 - rockchip,rk3568-tsadc 22 + - rockchip,rk3588-tsadc 22 23 - rockchip,rv1108-tsadc 23 24 24 25 reg:
+44 -2
Documentation/driver-api/thermal/intel_dptf.rst
··· 184 184 DPTF Processor thermal RFIM interface 185 185 -------------------------------------------- 186 186 187 - RFIM interface allows adjustment of FIVR (Fully Integrated Voltage Regulator) 188 - and DDR (Double Data Rate)frequencies to avoid RF interference with WiFi and 5G. 187 + RFIM interface allows adjustment of FIVR (Fully Integrated Voltage Regulator), 188 + DDR (Double Data Rate) and DLVR (Digital Linear Voltage Regulator) 189 + frequencies to avoid RF interference with WiFi and 5G. 189 190 190 191 Switching voltage regulators (VR) generate radiated EMI or RFI at the 191 192 fundamental frequency and its harmonics. Some harmonics may interfere ··· 196 195 small % and shift away the switching noise harmonic interference from 197 196 radio channels. OEM or ODMs can use the driver to control SOC IVR 198 197 operation within the range where it does not impact IVR performance. 198 + 199 + Some products use DLVR instead of FIVR as switching voltage regulator. 200 + In this case attributes of DLVR must be adjusted instead of FIVR. 201 + 202 + While shifting the frequencies additional clock noise can be introduced, 203 + which is compensated by adjusting Spread spectrum percent. This helps 204 + to reduce the clock noise to meet regulatory compliance. This spreading 205 + % increases bandwidth of signal transmission and hence reduces the 206 + effects of interference, noise and signal fading. 199 207 200 208 DRAM devices of DDR IO interface and their power plane can generate EMI 201 209 at the data rates. Similar to IVR control mechanism, Intel offers a ··· 273 263 274 264 ``rfi_disable (RW)`` 275 265 Disable DDR rate change feature 266 + 267 + DLVR attributes 268 + 269 + :file:`/sys/bus/pci/devices/0000\:00\:04.0/dlvr/` 270 + 271 + ``dlvr_hardware_rev`` (RO) 272 + DLVR hardware revision. 273 + 274 + ``dlvr_freq_mhz`` (RO) 275 + Current DLVR PLL frequency in MHz. 276 + 277 + ``dlvr_freq_select`` (RW) 278 + Sets DLVR PLL clock frequency. Once set, and enabled via 279 + dlvr_rfim_enable, the dlvr_freq_mhz will show the current 280 + DLVR PLL frequency. 281 + 282 + ``dlvr_pll_busy`` (RO) 283 + PLL can't accept frequency change when set. 284 + 285 + ``dlvr_rfim_enable`` (RW) 286 + 0: Disable RF frequency hopping, 1: Enable RF frequency hopping. 287 + 288 + ``dlvr_spread_spectrum_pct`` (RW) 289 + Sets DLVR spread spectrum percent value. 290 + 291 + ``dlvr_control_mode`` (RW) 292 + Specifies how frequencies are spread using spread spectrum. 293 + 0: Down spread, 294 + 1: Spread in the Center. 295 + 296 + ``dlvr_control_lock`` (RW) 297 + 1: future writes are ignored. 276 298 277 299 DPTF Power supply and Battery Interface 278 300 ----------------------------------------
-40
Documentation/driver-api/thermal/sysfs-api.rst
··· 306 306 307 307 :: 308 308 309 - struct thermal_bind_params 310 - 311 - This structure defines the following parameters that are used to bind 312 - a zone with a cooling device for a particular trip point. 313 - 314 - .cdev: 315 - The cooling device pointer 316 - .weight: 317 - The 'influence' of a particular cooling device on this 318 - zone. This is relative to the rest of the cooling 319 - devices. For example, if all cooling devices have a 320 - weight of 1, then they all contribute the same. You can 321 - use percentages if you want, but it's not mandatory. A 322 - weight of 0 means that this cooling device doesn't 323 - contribute to the cooling of this zone unless all cooling 324 - devices have a weight of 0. If all weights are 0, then 325 - they all contribute the same. 326 - .trip_mask: 327 - This is a bit mask that gives the binding relation between 328 - this thermal zone and cdev, for a particular trip point. 329 - If nth bit is set, then the cdev and thermal zone are bound 330 - for trip point n. 331 - .binding_limits: 332 - This is an array of cooling state limits. Must have 333 - exactly 2 * thermal_zone.number_of_trip_points. It is an 334 - array consisting of tuples <lower-state upper-state> of 335 - state limits. Each trip will be associated with one state 336 - limit tuple when binding. A NULL pointer means 337 - <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> on all trips. 338 - These limits are used when binding a cdev to a trip point. 339 - .match: 340 - This call back returns success(0) if the 'tz and cdev' need to 341 - be bound, as per platform data. 342 - 343 - :: 344 - 345 309 struct thermal_zone_params 346 310 347 311 This structure defines the platform level parameters for a thermal zone. ··· 321 357 will be created. when no_hwmon == true, nothing will be done. 322 358 In case the thermal_zone_params is NULL, the hwmon interface 323 359 will be created (for backward compatibility). 324 - .num_tbps: 325 - Number of thermal_bind_params entries for this zone 326 - .tbp: 327 - thermal_bind_params entries 328 360 329 361 2. sysfs attributes structure 330 362 =============================
+1 -1
MAINTAINERS
··· 20816 20816 S: Maintained 20817 20817 F: Documentation/driver-api/thermal/power_allocator.rst 20818 20818 F: drivers/thermal/gov_power_allocator.c 20819 - F: include/trace/events/thermal_power_allocator.h 20819 + F: drivers/thermal/thermal_trace_ipa.h 20820 20820 20821 20821 THINKPAD ACPI EXTRAS DRIVER 20822 20822 M: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
+9 -9
drivers/acpi/thermal.c
··· 498 498 499 499 static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) 500 500 { 501 - struct acpi_thermal *tz = thermal->devdata; 501 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 502 502 int result; 503 503 504 504 if (!tz) ··· 516 516 static int thermal_get_trip_type(struct thermal_zone_device *thermal, 517 517 int trip, enum thermal_trip_type *type) 518 518 { 519 - struct acpi_thermal *tz = thermal->devdata; 519 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 520 520 int i; 521 521 522 522 if (!tz || trip < 0) ··· 560 560 static int thermal_get_trip_temp(struct thermal_zone_device *thermal, 561 561 int trip, int *temp) 562 562 { 563 - struct acpi_thermal *tz = thermal->devdata; 563 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 564 564 int i; 565 565 566 566 if (!tz || trip < 0) ··· 613 613 static int thermal_get_crit_temp(struct thermal_zone_device *thermal, 614 614 int *temperature) 615 615 { 616 - struct acpi_thermal *tz = thermal->devdata; 616 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 617 617 618 618 if (tz->trips.critical.flags.valid) { 619 619 *temperature = deci_kelvin_to_millicelsius_with_offset( ··· 628 628 static int thermal_get_trend(struct thermal_zone_device *thermal, 629 629 int trip, enum thermal_trend *trend) 630 630 { 631 - struct acpi_thermal *tz = thermal->devdata; 631 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 632 632 enum thermal_trip_type type; 633 633 int i; 634 634 ··· 670 670 671 671 static void acpi_thermal_zone_device_hot(struct thermal_zone_device *thermal) 672 672 { 673 - struct acpi_thermal *tz = thermal->devdata; 673 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 674 674 675 675 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, 676 676 dev_name(&tz->device->dev), ··· 679 679 680 680 static void acpi_thermal_zone_device_critical(struct thermal_zone_device *thermal) 681 681 { 682 - struct acpi_thermal *tz = thermal->devdata; 682 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 683 683 684 684 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, 685 685 dev_name(&tz->device->dev), ··· 693 693 bool bind) 694 694 { 695 695 struct acpi_device *device = cdev->devdata; 696 - struct acpi_thermal *tz = thermal->devdata; 696 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 697 697 struct acpi_device *dev; 698 698 acpi_handle handle; 699 699 int i; ··· 842 842 goto acpi_bus_detach; 843 843 844 844 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", 845 - tz->thermal_zone->id); 845 + thermal_zone_device_id(tz->thermal_zone)); 846 846 847 847 return 0; 848 848
+1 -1
drivers/ata/ahci_imx.c
··· 418 418 419 419 static int sata_ahci_read_temperature(struct thermal_zone_device *tz, int *temp) 420 420 { 421 - return __sata_ahci_read_temperature(tz->devdata, temp); 421 + return __sata_ahci_read_temperature(thermal_zone_device_priv(tz), temp); 422 422 } 423 423 424 424 static ssize_t sata_ahci_show_temp(struct device *dev,
+2 -2
drivers/hwmon/hwmon.c
··· 154 154 #ifdef CONFIG_THERMAL_OF 155 155 static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 156 156 { 157 - struct hwmon_thermal_data *tdata = tz->devdata; 157 + struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz); 158 158 struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); 159 159 int ret; 160 160 long t; ··· 171 171 172 172 static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low, int high) 173 173 { 174 - struct hwmon_thermal_data *tdata = tz->devdata; 174 + struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz); 175 175 struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); 176 176 const struct hwmon_chip_info *chip = hwdev->chip; 177 177 const struct hwmon_channel_info * const *info = chip->info;
+1 -1
drivers/hwmon/pmbus/pmbus_core.c
··· 1273 1273 1274 1274 static int pmbus_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 1275 1275 { 1276 - struct pmbus_thermal_data *tdata = tz->devdata; 1276 + struct pmbus_thermal_data *tdata = thermal_zone_device_priv(tz); 1277 1277 struct pmbus_sensor *sensor = tdata->sensor; 1278 1278 struct pmbus_data *pmbus_data = tdata->pmbus_data; 1279 1279 struct i2c_client *client = to_i2c_client(pmbus_data->dev);
+2 -2
drivers/hwmon/scmi-hwmon.c
··· 141 141 { 142 142 int ret; 143 143 long value; 144 - struct scmi_thermal_sensor *th_sensor = tz->devdata; 144 + struct scmi_thermal_sensor *th_sensor = thermal_zone_device_priv(tz); 145 145 146 146 ret = scmi_hwmon_read_scaled_value(th_sensor->ph, th_sensor->info, 147 147 &value); ··· 220 220 sensor->name); 221 221 } else { 222 222 dev_dbg(dev, "Sensor '%s' attached to thermal zone ID:%d\n", 223 - sensor->name, tzd->id); 223 + sensor->name, thermal_zone_device_id(tzd)); 224 224 } 225 225 226 226 return 0;
+1 -1
drivers/hwmon/scpi-hwmon.c
··· 64 64 65 65 static int scpi_read_temp(struct thermal_zone_device *tz, int *temp) 66 66 { 67 - struct scpi_thermal_zone *zone = tz->devdata; 67 + struct scpi_thermal_zone *zone = thermal_zone_device_priv(tz); 68 68 struct scpi_sensors *scpi_sensors = zone->scpi_sensors; 69 69 struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops; 70 70 struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];
+1 -1
drivers/iio/adc/sun4i-gpadc-iio.c
··· 414 414 415 415 static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp) 416 416 { 417 - struct sun4i_gpadc_iio *info = tz->devdata; 417 + struct sun4i_gpadc_iio *info = thermal_zone_device_priv(tz); 418 418 int val, scale, offset; 419 419 420 420 if (sun4i_gpadc_temp_read(info->indio_dev, &val))
+1 -1
drivers/input/touchscreen/sun4i-ts.c
··· 194 194 195 195 static int sun4i_get_tz_temp(struct thermal_zone_device *tz, int *temp) 196 196 { 197 - return sun4i_get_temp(tz->devdata, temp); 197 + return sun4i_get_temp(thermal_zone_device_priv(tz), temp); 198 198 } 199 199 200 200 static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
+1 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
··· 12 12 static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev, 13 13 int *temp) 14 14 { 15 - struct adapter *adap = tzdev->devdata; 15 + struct adapter *adap = thermal_zone_device_priv(tzdev); 16 16 u32 param, val; 17 17 int ret; 18 18
+8 -8
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
··· 176 176 177 177 if (crit_temp > emerg_temp) { 178 178 dev_warn(dev, "%s : Critical threshold %d is above emergency threshold %d\n", 179 - tz->tzdev->type, crit_temp, emerg_temp); 179 + thermal_zone_device_type(tz->tzdev), crit_temp, emerg_temp); 180 180 return 0; 181 181 } 182 182 ··· 200 200 static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev, 201 201 struct thermal_cooling_device *cdev) 202 202 { 203 - struct mlxsw_thermal *thermal = tzdev->devdata; 203 + struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev); 204 204 struct device *dev = thermal->bus_info->dev; 205 205 int i, err; 206 206 ··· 226 226 static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev, 227 227 struct thermal_cooling_device *cdev) 228 228 { 229 - struct mlxsw_thermal *thermal = tzdev->devdata; 229 + struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev); 230 230 struct device *dev = thermal->bus_info->dev; 231 231 int i; 232 232 int err; ··· 248 248 static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev, 249 249 int *p_temp) 250 250 { 251 - struct mlxsw_thermal *thermal = tzdev->devdata; 251 + struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev); 252 252 struct device *dev = thermal->bus_info->dev; 253 253 char mtmp_pl[MLXSW_REG_MTMP_LEN]; 254 254 int temp; ··· 280 280 static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev, 281 281 struct thermal_cooling_device *cdev) 282 282 { 283 - struct mlxsw_thermal_module *tz = tzdev->devdata; 283 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 284 284 struct mlxsw_thermal *thermal = tz->parent; 285 285 int i, j, err; 286 286 ··· 309 309 static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev, 310 310 struct thermal_cooling_device *cdev) 311 311 { 312 - struct mlxsw_thermal_module *tz = tzdev->devdata; 312 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 313 313 struct mlxsw_thermal *thermal = tz->parent; 314 314 int i; 315 315 int err; ··· 355 355 static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev, 356 356 int *p_temp) 357 357 { 358 - struct mlxsw_thermal_module *tz = tzdev->devdata; 358 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 359 359 struct mlxsw_thermal *thermal = tz->parent; 360 360 int temp, crit_temp, emerg_temp; 361 361 struct device *dev; ··· 390 390 static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, 391 391 int *p_temp) 392 392 { 393 - struct mlxsw_thermal_module *tz = tzdev->devdata; 393 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 394 394 struct mlxsw_thermal *thermal = tz->parent; 395 395 char mtmp_pl[MLXSW_REG_MTMP_LEN]; 396 396 u16 index;
+2 -2
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
··· 615 615 static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, 616 616 int *temperature) 617 617 { 618 - struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; 618 + struct iwl_mvm *mvm = thermal_zone_device_priv(device); 619 619 int ret; 620 620 int temp; 621 621 ··· 641 641 static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, 642 642 int trip, int temp) 643 643 { 644 - struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; 644 + struct iwl_mvm *mvm = thermal_zone_device_priv(device); 645 645 struct iwl_mvm_thermal_device *tzone; 646 646 int ret; 647 647
+3 -16
drivers/platform/x86/acerhdf.c
··· 79 79 static unsigned int fanstate = ACERHDF_FAN_AUTO; 80 80 static char force_bios[16]; 81 81 static char force_product[16]; 82 - static unsigned int prev_interval; 83 82 static struct thermal_zone_device *thz_dev; 84 83 static struct thermal_cooling_device *cl_dev; 85 84 static struct platform_device *acerhdf_dev; ··· 345 346 trips[0].temperature = fanon; 346 347 trips[0].hysteresis = fanon - fanoff; 347 348 348 - if (kernelmode && prev_interval != interval) { 349 + if (kernelmode) { 349 350 if (interval > ACERHDF_MAX_INTERVAL) { 350 351 pr_err("interval too high, set to %d\n", 351 352 ACERHDF_MAX_INTERVAL); 352 353 interval = ACERHDF_MAX_INTERVAL; 353 354 } 355 + 354 356 if (verbose) 355 357 pr_notice("interval changed to: %d\n", interval); 356 - 357 - if (thermal) 358 - thermal->polling_delay_jiffies = 359 - round_jiffies(msecs_to_jiffies(interval * 1000)); 360 - 361 - prev_interval = interval; 362 358 } 363 359 } 364 360 ··· 691 697 if (ret) 692 698 return ret; 693 699 694 - if (strcmp(thz_dev->governor->name, 695 - acerhdf_zone_params.governor_name)) { 696 - pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n", 697 - acerhdf_zone_params.governor_name); 698 - return -EINVAL; 699 - } 700 - 701 700 return 0; 702 701 } 703 702 ··· 788 801 .get = param_get_uint, 789 802 }; 790 803 791 - module_param_cb(interval, &interval_ops, &interval, 0600); 804 + module_param_cb(interval, &interval_ops, &interval, 0000); 792 805 MODULE_PARM_DESC(interval, "Polling interval of temperature check");
+1 -1
drivers/power/supply/power_supply_core.c
··· 1142 1142 int ret; 1143 1143 1144 1144 WARN_ON(tzd == NULL); 1145 - psy = tzd->devdata; 1145 + psy = thermal_zone_device_priv(tzd); 1146 1146 ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); 1147 1147 if (ret) 1148 1148 return ret;
+1 -1
drivers/regulator/max8973-regulator.c
··· 436 436 437 437 static int max8973_thermal_read_temp(struct thermal_zone_device *tz, int *temp) 438 438 { 439 - struct max8973_chip *mchip = tz->devdata; 439 + struct max8973_chip *mchip = thermal_zone_device_priv(tz); 440 440 unsigned int val; 441 441 int ret; 442 442
+2 -1
drivers/thermal/Makefile
··· 2 2 # 3 3 # Makefile for sensor chip drivers. 4 4 # 5 - 5 + CFLAGS_thermal_core.o := -I$(src) 6 6 obj-$(CONFIG_THERMAL) += thermal_sys.o 7 7 thermal_sys-y += thermal_core.o thermal_sysfs.o 8 8 thermal_sys-y += thermal_trip.o thermal_helpers.o ··· 16 16 thermal_sys-$(CONFIG_THERMAL_ACPI) += thermal_acpi.o 17 17 18 18 # governors 19 + CFLAGS_gov_power_allocator.o := -I$(src) 19 20 thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += gov_fair_share.o 20 21 thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o 21 22 thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += gov_step_wise.o
+4 -7
drivers/thermal/amlogic_thermal.c
··· 181 181 static int amlogic_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 182 182 { 183 183 unsigned int tval; 184 - struct amlogic_thermal *pdata = tz->devdata; 184 + struct amlogic_thermal *pdata = thermal_zone_device_priv(tz); 185 185 186 186 if (!pdata) 187 187 return -EINVAL; ··· 262 262 return PTR_ERR(pdata->regmap); 263 263 264 264 pdata->clk = devm_clk_get(dev, NULL); 265 - if (IS_ERR(pdata->clk)) { 266 - if (PTR_ERR(pdata->clk) != -EPROBE_DEFER) 267 - dev_err(dev, "failed to get clock\n"); 268 - return PTR_ERR(pdata->clk); 269 - } 265 + if (IS_ERR(pdata->clk)) 266 + return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get clock\n"); 270 267 271 268 pdata->sec_ao_map = syscon_regmap_lookup_by_phandle 272 269 (pdev->dev.of_node, "amlogic,ao-secure"); ··· 282 285 return ret; 283 286 } 284 287 285 - if (devm_thermal_add_hwmon_sysfs(pdata->tzd)) 288 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd)) 286 289 dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n"); 287 290 288 291 ret = amlogic_thermal_initialize(pdata);
+4 -10
drivers/thermal/armada_thermal.c
··· 360 360 * we must absolutely wait for the sensor validity bit to ensure we read 361 361 * actual data. 362 362 */ 363 - if (armada_wait_sensor_validity(priv)) { 364 - dev_err(priv->dev, 365 - "Temperature sensor reading not valid\n"); 363 + if (armada_wait_sensor_validity(priv)) 366 364 return -EIO; 367 - } 368 365 369 366 return 0; 370 367 } ··· 395 398 static int armada_get_temp_legacy(struct thermal_zone_device *thermal, 396 399 int *temp) 397 400 { 398 - struct armada_thermal_priv *priv = thermal->devdata; 401 + struct armada_thermal_priv *priv = thermal_zone_device_priv(thermal); 399 402 int ret; 400 403 401 404 /* Valid check */ 402 - if (!armada_is_valid(priv)) { 403 - dev_err(priv->dev, 404 - "Temperature sensor reading not valid\n"); 405 + if (!armada_is_valid(priv)) 405 406 return -EIO; 406 - } 407 407 408 408 /* Do the actual reading */ 409 409 ret = armada_read_sensor(priv, temp); ··· 414 420 415 421 static int armada_get_temp(struct thermal_zone_device *tz, int *temp) 416 422 { 417 - struct armada_thermal_sensor *sensor = tz->devdata; 423 + struct armada_thermal_sensor *sensor = thermal_zone_device_priv(tz); 418 424 struct armada_thermal_priv *priv = sensor->priv; 419 425 int ret; 420 426
+1 -2
drivers/thermal/broadcom/bcm2711_thermal.c
··· 33 33 34 34 static int bcm2711_get_temp(struct thermal_zone_device *tz, int *temp) 35 35 { 36 - struct bcm2711_thermal_priv *priv = tz->devdata; 36 + struct bcm2711_thermal_priv *priv = thermal_zone_device_priv(tz); 37 37 int slope = thermal_zone_get_slope(tz); 38 38 int offset = thermal_zone_get_offset(tz); 39 39 u32 val; ··· 98 98 99 99 priv->thermal = thermal; 100 100 101 - thermal->tzp->no_hwmon = false; 102 101 return thermal_add_hwmon_sysfs(thermal); 103 102 } 104 103
+2 -5
drivers/thermal/broadcom/bcm2835_thermal.c
··· 90 90 91 91 static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 92 92 { 93 - struct bcm2835_thermal_data *data = tz->devdata; 93 + struct bcm2835_thermal_data *data = thermal_zone_device_priv(tz); 94 94 u32 val = readl(data->regs + BCM2835_TS_TSENSSTAT); 95 95 96 96 if (!(val & BCM2835_TS_TSENSSTAT_VALID)) ··· 267 267 * Thermal_zone doesn't enable hwmon as default, 268 268 * enable it here 269 269 */ 270 - tz->tzp->no_hwmon = false; 271 270 err = thermal_add_hwmon_sysfs(tz); 272 271 if (err) 273 272 goto err_tz; ··· 275 276 276 277 return 0; 277 278 err_tz: 278 - thermal_of_zone_unregister(tz); 279 + devm_thermal_of_zone_unregister(&pdev->dev, tz); 279 280 err_clk: 280 281 clk_disable_unprepare(data->clk); 281 282 ··· 285 286 static int bcm2835_thermal_remove(struct platform_device *pdev) 286 287 { 287 288 struct bcm2835_thermal_data *data = platform_get_drvdata(pdev); 288 - struct thermal_zone_device *tz = data->tz; 289 289 290 290 debugfs_remove_recursive(data->debugfsdir); 291 - thermal_of_zone_unregister(tz); 292 291 clk_disable_unprepare(data->clk); 293 292 294 293 return 0;
+3 -5
drivers/thermal/broadcom/brcmstb_thermal.c
··· 152 152 153 153 static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp) 154 154 { 155 - struct brcmstb_thermal_priv *priv = tz->devdata; 155 + struct brcmstb_thermal_priv *priv = thermal_zone_device_priv(tz); 156 156 u32 val; 157 157 long t; 158 158 159 159 val = __raw_readl(priv->tmon_base + AVS_TMON_STATUS); 160 160 161 - if (!(val & AVS_TMON_STATUS_valid_msk)) { 162 - dev_err(priv->dev, "reading not valid\n"); 161 + if (!(val & AVS_TMON_STATUS_valid_msk)) 163 162 return -EIO; 164 - } 165 163 166 164 val = (val & AVS_TMON_STATUS_data_msk) >> AVS_TMON_STATUS_data_shift; 167 165 ··· 260 262 261 263 static int brcmstb_set_trips(struct thermal_zone_device *tz, int low, int high) 262 264 { 263 - struct brcmstb_thermal_priv *priv = tz->devdata; 265 + struct brcmstb_thermal_priv *priv = thermal_zone_device_priv(tz); 264 266 265 267 dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high); 266 268
+1 -1
drivers/thermal/broadcom/ns-thermal.c
··· 16 16 17 17 static int ns_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 18 18 { 19 - void __iomem *pvtmon = tz->devdata; 19 + void __iomem *pvtmon = thermal_zone_device_priv(tz); 20 20 int offset = thermal_zone_get_offset(tz); 21 21 int slope = thermal_zone_get_slope(tz); 22 22 u32 val;
+1 -1
drivers/thermal/broadcom/sr-thermal.c
··· 32 32 33 33 static int sr_get_temp(struct thermal_zone_device *tz, int *temp) 34 34 { 35 - struct sr_tmon *tmon = tz->devdata; 35 + struct sr_tmon *tmon = thermal_zone_device_priv(tz); 36 36 struct sr_thermal *sr_thermal = tmon->priv; 37 37 38 38 *temp = readl(sr_thermal->regs + SR_TMON_TEMP_BASE(tmon->tmon_id));
+2 -2
drivers/thermal/cpufreq_cooling.c
··· 23 23 #include <linux/thermal.h> 24 24 #include <linux/units.h> 25 25 26 - #include <trace/events/thermal.h> 26 + #include "thermal_trace.h" 27 27 28 28 /* 29 29 * Cooling state <-> CPUFreq frequency ··· 633 633 return NULL; 634 634 } 635 635 636 - if (of_find_property(np, "#cooling-cells", NULL)) { 636 + if (of_property_present(np, "#cooling-cells")) { 637 637 struct em_perf_domain *em = em_cpu_get(policy->cpu); 638 638 639 639 cdev = __cpufreq_cooling_register(np, policy, em);
+8 -5
drivers/thermal/da9062-thermal.c
··· 41 41 42 42 #define DA9062_MILLI_CELSIUS(t) ((t) * 1000) 43 43 44 + static unsigned int pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD; 45 + 44 46 struct da9062_thermal_config { 45 47 const char *name; 46 48 }; ··· 97 95 thermal_zone_device_update(thermal->zone, 98 96 THERMAL_EVENT_UNSPECIFIED); 99 97 100 - delay = thermal->zone->passive_delay_jiffies; 98 + /* 99 + * pp_tmp is between 1s and 10s, so we can round the jiffies 100 + */ 101 + delay = round_jiffies(msecs_to_jiffies(pp_tmp)); 101 102 queue_delayed_work(system_freezable_wq, &thermal->work, delay); 102 103 return; 103 104 } ··· 128 123 static int da9062_thermal_get_temp(struct thermal_zone_device *z, 129 124 int *temp) 130 125 { 131 - struct da9062_thermal *thermal = z->devdata; 126 + struct da9062_thermal *thermal = thermal_zone_device_priv(z); 132 127 133 128 mutex_lock(&thermal->lock); 134 129 *temp = thermal->temperature; ··· 160 155 { 161 156 struct da9062 *chip = dev_get_drvdata(pdev->dev.parent); 162 157 struct da9062_thermal *thermal; 163 - unsigned int pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD; 164 158 const struct of_device_id *match; 165 159 int ret = 0; 166 160 ··· 212 208 } 213 209 214 210 dev_dbg(&pdev->dev, 215 - "TJUNC temperature polling period set at %d ms\n", 216 - jiffies_to_msecs(thermal->zone->passive_delay_jiffies)); 211 + "TJUNC temperature polling period set at %d ms\n", pp_tmp); 217 212 218 213 ret = platform_get_irq_byname(pdev, "THERMAL"); 219 214 if (ret < 0)
+6 -3
drivers/thermal/db8500_thermal.c
··· 53 53 54 54 struct db8500_thermal_zone { 55 55 struct thermal_zone_device *tz; 56 + struct device *dev; 56 57 unsigned long interpolated_temp; 57 58 unsigned int cur_index; 58 59 }; ··· 61 60 /* Callback to get current temperature */ 62 61 static int db8500_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 63 62 { 64 - struct db8500_thermal_zone *th = tz->devdata; 63 + struct db8500_thermal_zone *th = thermal_zone_device_priv(tz); 65 64 66 65 /* 67 66 * TODO: There is no PRCMU interface to get temperature data currently, ··· 115 114 idx -= 1; 116 115 117 116 db8500_thermal_update_config(th, idx, next_low, next_high); 118 - dev_dbg(&th->tz->device, 117 + dev_dbg(th->dev, 119 118 "PRCMU set max %ld, min %ld\n", next_high, next_low); 120 119 121 120 thermal_zone_device_update(th->tz, THERMAL_EVENT_UNSPECIFIED); ··· 137 136 138 137 db8500_thermal_update_config(th, idx, next_low, next_high); 139 138 140 - dev_dbg(&th->tz->device, 139 + dev_dbg(th->dev, 141 140 "PRCMU set max %ld, min %ld\n", next_high, next_low); 142 141 } else if (idx == num_points - 1) 143 142 /* So we roof out 1 degree over the max point */ ··· 157 156 th = devm_kzalloc(dev, sizeof(*th), GFP_KERNEL); 158 157 if (!th) 159 158 return -ENOMEM; 159 + 160 + th->dev = dev; 160 161 161 162 low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW"); 162 163 if (low_irq < 0)
+1 -1
drivers/thermal/devfreq_cooling.c
··· 20 20 #include <linux/thermal.h> 21 21 #include <linux/units.h> 22 22 23 - #include <trace/events/thermal.h> 23 + #include "thermal_trace.h" 24 24 25 25 #define SCALE_ERROR_MITIGATION 100 26 26
+2 -5
drivers/thermal/dove_thermal.c
··· 87 87 int *temp) 88 88 { 89 89 unsigned long reg; 90 - struct dove_thermal_priv *priv = thermal->devdata; 90 + struct dove_thermal_priv *priv = thermal_zone_device_priv(thermal); 91 91 92 92 /* Valid check */ 93 93 reg = readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG); 94 - if ((reg & PMU_TDC1_TEMP_VALID_MASK) == 0x0) { 95 - dev_err(&thermal->device, 96 - "Temperature sensor reading not valid\n"); 94 + if ((reg & PMU_TDC1_TEMP_VALID_MASK) == 0x0) 97 95 return -EIO; 98 - } 99 96 100 97 /* 101 98 * Calculate temperature. According to Marvell internal
+1 -1
drivers/thermal/gov_fair_share.c
··· 11 11 */ 12 12 13 13 #include <linux/thermal.h> 14 - #include <trace/events/thermal.h> 14 + #include "thermal_trace.h" 15 15 16 16 #include "thermal_core.h" 17 17
+1 -1
drivers/thermal/gov_power_allocator.c
··· 12 12 #include <linux/thermal.h> 13 13 14 14 #define CREATE_TRACE_POINTS 15 - #include <trace/events/thermal_power_allocator.h> 15 + #include "thermal_trace_ipa.h" 16 16 17 17 #include "thermal_core.h" 18 18
+1 -1
drivers/thermal/gov_step_wise.c
··· 12 12 13 13 #include <linux/thermal.h> 14 14 #include <linux/minmax.h> 15 - #include <trace/events/thermal.h> 15 + #include "thermal_trace.h" 16 16 17 17 #include "thermal_core.h" 18 18
+2 -7
drivers/thermal/hisi_thermal.c
··· 431 431 432 432 static int hisi_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 433 433 { 434 - struct hisi_thermal_sensor *sensor = tz->devdata; 434 + struct hisi_thermal_sensor *sensor = thermal_zone_device_priv(tz); 435 435 struct hisi_thermal_data *data = sensor->data; 436 436 437 437 *temp = data->ops->get_temp(sensor); 438 - 439 - dev_dbg(&data->pdev->dev, "tzd=%p, id=%d, temp=%d, thres=%d\n", 440 - sensor->tzd, sensor->id, *temp, sensor->thres_temp); 441 438 442 439 return 0; 443 440 } ··· 544 547 { 545 548 struct hisi_thermal_data *data; 546 549 struct device *dev = &pdev->dev; 547 - struct resource *res; 548 550 int i, ret; 549 551 550 552 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); ··· 554 558 platform_set_drvdata(pdev, data); 555 559 data->ops = of_device_get_match_data(dev); 556 560 557 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 558 - data->regs = devm_ioremap_resource(dev, res); 561 + data->regs = devm_platform_ioremap_resource(pdev, 0); 559 562 if (IS_ERR(data->regs)) 560 563 return PTR_ERR(data->regs); 561 564
+3 -3
drivers/thermal/imx8mm_thermal.c
··· 141 141 142 142 static int tmu_get_temp(struct thermal_zone_device *tz, int *temp) 143 143 { 144 - struct tmu_sensor *sensor = tz->devdata; 144 + struct tmu_sensor *sensor = thermal_zone_device_priv(tz); 145 145 struct imx8mm_tmu *tmu = sensor->priv; 146 146 147 147 return tmu->socdata->get_temp(sensor, temp); ··· 282 282 * strongly recommended to update such old DTs to get correct 283 283 * temperature compensation values for each SoC. 284 284 */ 285 - if (!of_find_property(pdev->dev.of_node, "nvmem-cells", NULL)) { 285 + if (!of_property_present(pdev->dev.of_node, "nvmem-cells")) { 286 286 dev_warn(dev, 287 287 "No OCOTP nvmem reference found, SoC-specific calibration not loaded. Please update your DT.\n"); 288 288 return 0; ··· 343 343 } 344 344 tmu->sensors[i].hw_id = i; 345 345 346 - if (devm_thermal_add_hwmon_sysfs(tmu->sensors[i].tzd)) 346 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, tmu->sensors[i].tzd)) 347 347 dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n"); 348 348 } 349 349
+3 -6
drivers/thermal/imx_sc_thermal.c
··· 46 46 { 47 47 struct imx_sc_msg_misc_get_temp msg; 48 48 struct imx_sc_rpc_msg *hdr = &msg.hdr; 49 - struct imx_sc_sensor *sensor = tz->devdata; 49 + struct imx_sc_sensor *sensor = thermal_zone_device_priv(tz); 50 50 int ret; 51 51 52 52 msg.data.req.resource_id = sensor->resource_id; ··· 58 58 hdr->size = 2; 59 59 60 60 ret = imx_scu_call_rpc(thermal_ipc_handle, &msg, true); 61 - if (ret) { 62 - dev_err(&sensor->tzd->device, "read temp sensor %d failed, ret %d\n", 63 - sensor->resource_id, ret); 61 + if (ret) 64 62 return ret; 65 - } 66 63 67 64 *temp = msg.data.resp.celsius * 1000 + msg.data.resp.tenths * 100; 68 65 ··· 116 119 return ret; 117 120 } 118 121 119 - if (devm_thermal_add_hwmon_sysfs(sensor->tzd)) 122 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, sensor->tzd)) 120 123 dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n"); 121 124 } 122 125
+21 -49
drivers/thermal/imx_thermal.c
··· 252 252 253 253 static int imx_get_temp(struct thermal_zone_device *tz, int *temp) 254 254 { 255 - struct imx_thermal_data *data = tz->devdata; 255 + struct imx_thermal_data *data = thermal_zone_device_priv(tz); 256 256 const struct thermal_soc_data *soc_data = data->socdata; 257 257 struct regmap *map = data->tempmon; 258 258 unsigned int n_meas; ··· 265 265 266 266 regmap_read(map, soc_data->temp_data, &val); 267 267 268 - if ((val & soc_data->temp_valid_mask) == 0) { 269 - dev_dbg(&tz->device, "temp measurement never finished\n"); 268 + if ((val & soc_data->temp_valid_mask) == 0) 270 269 return -EAGAIN; 271 - } 272 270 273 271 n_meas = (val & soc_data->temp_value_mask) 274 272 >> soc_data->temp_value_shift; ··· 285 287 if (data->alarm_temp == trips[IMX_TRIP_CRITICAL].temperature && 286 288 *temp < trips[IMX_TRIP_PASSIVE].temperature) { 287 289 imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); 288 - dev_dbg(&tz->device, "thermal alarm off: T < %d\n", 290 + dev_dbg(data->dev, "thermal alarm off: T < %d\n", 289 291 data->alarm_temp / 1000); 290 292 } 291 293 } 292 294 293 295 if (*temp != data->last_temp) { 294 - dev_dbg(&tz->device, "millicelsius: %d\n", *temp); 296 + dev_dbg(data->dev, "millicelsius: %d\n", *temp); 295 297 data->last_temp = *temp; 296 298 } 297 299 ··· 309 311 static int imx_change_mode(struct thermal_zone_device *tz, 310 312 enum thermal_device_mode mode) 311 313 { 312 - struct imx_thermal_data *data = tz->devdata; 314 + struct imx_thermal_data *data = thermal_zone_device_priv(tz); 313 315 314 316 if (mode == THERMAL_DEVICE_ENABLED) { 315 317 pm_runtime_get(data->dev); ··· 330 332 return 0; 331 333 } 332 334 333 - static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) 334 - { 335 - *temp = trips[IMX_TRIP_CRITICAL].temperature; 336 - 337 - return 0; 338 - } 339 - 340 - static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, 335 + static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id, 341 336 int temp) 342 337 { 343 - struct imx_thermal_data *data = tz->devdata; 338 + struct imx_thermal_data *data = thermal_zone_device_priv(tz); 339 + struct thermal_trip trip; 344 340 int ret; 345 341 346 342 ret = pm_runtime_resume_and_get(data->dev); 347 343 if (ret < 0) 348 344 return ret; 349 345 346 + ret = __thermal_zone_get_trip(tz, trip_id, &trip); 347 + if (ret) 348 + return ret; 349 + 350 350 /* do not allow changing critical threshold */ 351 - if (trip == IMX_TRIP_CRITICAL) 351 + if (trip.type == THERMAL_TRIP_CRITICAL) 352 352 return -EPERM; 353 353 354 354 /* do not allow passive to be set higher than critical */ 355 355 if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) 356 356 return -EINVAL; 357 - 358 - trips[IMX_TRIP_PASSIVE].temperature = temp; 359 357 360 358 imx_set_alarm_temp(data, temp); 361 359 ··· 363 369 static int imx_bind(struct thermal_zone_device *tz, 364 370 struct thermal_cooling_device *cdev) 365 371 { 366 - int ret; 367 - 368 - ret = thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev, 369 - THERMAL_NO_LIMIT, 370 - THERMAL_NO_LIMIT, 371 - THERMAL_WEIGHT_DEFAULT); 372 - if (ret) { 373 - dev_err(&tz->device, 374 - "binding zone %s with cdev %s failed:%d\n", 375 - tz->type, cdev->type, ret); 376 - return ret; 377 - } 378 - 379 - return 0; 372 + return thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev, 373 + THERMAL_NO_LIMIT, 374 + THERMAL_NO_LIMIT, 375 + THERMAL_WEIGHT_DEFAULT); 380 376 } 381 377 382 378 static int imx_unbind(struct thermal_zone_device *tz, 383 379 struct thermal_cooling_device *cdev) 384 380 { 385 - int ret; 386 - 387 - ret = thermal_zone_unbind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev); 388 - if (ret) { 389 - dev_err(&tz->device, 390 - "unbinding zone %s with cdev %s failed:%d\n", 391 - tz->type, cdev->type, ret); 392 - return ret; 393 - } 394 - 395 - return 0; 381 + return thermal_zone_unbind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev); 396 382 } 397 383 398 384 static struct thermal_zone_device_ops imx_tz_ops = { ··· 380 406 .unbind = imx_unbind, 381 407 .get_temp = imx_get_temp, 382 408 .change_mode = imx_change_mode, 383 - .get_crit_temp = imx_get_crit_temp, 384 409 .set_trip_temp = imx_set_trip_temp, 385 410 }; 386 411 ··· 533 560 { 534 561 struct imx_thermal_data *data = dev; 535 562 536 - dev_dbg(&data->tz->device, "THERMAL ALARM: T > %d\n", 537 - data->alarm_temp / 1000); 563 + dev_dbg(data->dev, "THERMAL ALARM: T > %d\n", data->alarm_temp / 1000); 538 564 539 565 thermal_zone_device_update(data->tz, THERMAL_EVENT_UNSPECIFIED); 540 566 ··· 566 594 567 595 np = of_get_cpu_node(data->policy->cpu, NULL); 568 596 569 - if (!np || !of_find_property(np, "#cooling-cells", NULL)) { 597 + if (!np || !of_property_present(np, "#cooling-cells")) { 570 598 data->cdev = cpufreq_cooling_register(data->policy); 571 599 if (IS_ERR(data->cdev)) { 572 600 ret = PTR_ERR(data->cdev); ··· 643 671 644 672 platform_set_drvdata(pdev, data); 645 673 646 - if (of_find_property(pdev->dev.of_node, "nvmem-cells", NULL)) { 674 + if (of_property_present(pdev->dev.of_node, "nvmem-cells")) { 647 675 ret = imx_init_from_nvmem_cells(pdev); 648 676 if (ret) 649 677 return dev_err_probe(&pdev->dev, ret,
+1 -1
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
··· 497 497 static int int3400_thermal_change_mode(struct thermal_zone_device *thermal, 498 498 enum thermal_device_mode mode) 499 499 { 500 - struct int3400_thermal_priv *priv = thermal->devdata; 500 + struct int3400_thermal_priv *priv = thermal_zone_device_priv(thermal); 501 501 int result = 0; 502 502 503 503 if (!priv)
+2 -2
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
··· 14 14 static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, 15 15 int *temp) 16 16 { 17 - struct int34x_thermal_zone *d = zone->devdata; 17 + struct int34x_thermal_zone *d = thermal_zone_device_priv(zone); 18 18 unsigned long long tmp; 19 19 acpi_status status; 20 20 ··· 41 41 static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, 42 42 int trip, int temp) 43 43 { 44 - struct int34x_thermal_zone *d = zone->devdata; 44 + struct int34x_thermal_zone *d = thermal_zone_device_priv(zone); 45 45 char name[] = {'P', 'A', 'T', '0' + trip, '\0'}; 46 46 acpi_status status; 47 47
+2 -1
drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
··· 337 337 } 338 338 339 339 if (feature_mask & PROC_THERMAL_FEATURE_FIVR || 340 - feature_mask & PROC_THERMAL_FEATURE_DVFS) { 340 + feature_mask & PROC_THERMAL_FEATURE_DVFS || 341 + feature_mask & PROC_THERMAL_FEATURE_DLVR) { 341 342 ret = proc_thermal_rfim_add(pdev, proc_priv); 342 343 if (ret) { 343 344 dev_err(&pdev->dev, "failed to add RFIM interface\n");
+1
drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
··· 60 60 #define PROC_THERMAL_FEATURE_FIVR 0x02 61 61 #define PROC_THERMAL_FEATURE_DVFS 0x04 62 62 #define PROC_THERMAL_FEATURE_MBOX 0x08 63 + #define PROC_THERMAL_FEATURE_DLVR 0x10 63 64 64 65 #if IS_ENABLED(CONFIG_PROC_THERMAL_MMIO_RAPL) 65 66 int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
+3 -3
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
··· 135 135 136 136 static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) 137 137 { 138 - struct proc_thermal_pci *pci_info = tzd->devdata; 138 + struct proc_thermal_pci *pci_info = thermal_zone_device_priv(tzd); 139 139 u32 _temp; 140 140 141 141 proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_PKG_TEMP, &_temp); ··· 146 146 147 147 static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) 148 148 { 149 - struct proc_thermal_pci *pci_info = tzd->devdata; 149 + struct proc_thermal_pci *pci_info = thermal_zone_device_priv(tzd); 150 150 int tjmax, _temp; 151 151 152 152 if (temp <= 0) { ··· 351 351 352 352 static const struct pci_device_id proc_thermal_pci_ids[] = { 353 353 { PCI_DEVICE_DATA(INTEL, ADL_THERMAL, PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_MBOX) }, 354 - { PCI_DEVICE_DATA(INTEL, MTLP_THERMAL, PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_MBOX) }, 354 + { PCI_DEVICE_DATA(INTEL, MTLP_THERMAL, PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_MBOX | PROC_THERMAL_FEATURE_DLVR) }, 355 355 { PCI_DEVICE_DATA(INTEL, RPL_THERMAL, PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_MBOX) }, 356 356 { }, 357 357 };
+87 -5
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
··· 39 39 { 1, 0x5A14, 2, 0x3, 1}, /* fivr_fffc_rev */ 40 40 }; 41 41 42 + static const char * const dlvr_strings[] = { 43 + "dlvr_spread_spectrum_pct", 44 + "dlvr_control_mode", 45 + "dlvr_control_lock", 46 + "dlvr_rfim_enable", 47 + "dlvr_freq_select", 48 + "dlvr_hardware_rev", 49 + "dlvr_freq_mhz", 50 + "dlvr_pll_busy", 51 + NULL 52 + }; 53 + 54 + static const struct mmio_reg dlvr_mmio_regs[] = { 55 + { 0, 0x15A08, 5, 0x1F, 0}, /* dlvr_spread_spectrum_pct */ 56 + { 0, 0x15A08, 1, 0x1, 5}, /* dlvr_control_mode */ 57 + { 0, 0x15A08, 1, 0x1, 6}, /* dlvr_control_lock */ 58 + { 0, 0x15A08, 1, 0x1, 7}, /* dlvr_rfim_enable */ 59 + { 0, 0x15A08, 12, 0xFFF, 8}, /* dlvr_freq_select */ 60 + { 1, 0x15A10, 2, 0x3, 30}, /* dlvr_hardware_rev */ 61 + { 1, 0x15A10, 16, 0xFFFF, 0}, /* dlvr_freq_mhz */ 62 + { 1, 0x15A10, 1, 0x1, 16}, /* dlvr_pll_busy */ 63 + }; 64 + 42 65 /* These will represent sysfs attribute names */ 43 66 static const char * const dvfs_strings[] = { 44 67 "rfi_restriction_run_busy", ··· 101 78 int ret;\ 102 79 \ 103 80 proc_priv = pci_get_drvdata(pdev);\ 104 - if (table) {\ 81 + if (table == 1) {\ 105 82 match_strs = (const char **)dvfs_strings;\ 106 83 mmio_regs = adl_dvfs_mmio_regs;\ 107 - } else { \ 84 + } else if (table == 2) { \ 85 + match_strs = (const char **)dlvr_strings;\ 86 + mmio_regs = dlvr_mmio_regs;\ 87 + } else {\ 108 88 match_strs = (const char **)fivr_strings;\ 109 89 mmio_regs = tgl_fivr_mmio_regs;\ 110 90 } \ 111 - \ 112 91 ret = match_string(match_strs, -1, attr->attr.name);\ 113 92 if (ret < 0)\ 114 93 return ret;\ ··· 134 109 u32 mask;\ 135 110 \ 136 111 proc_priv = pci_get_drvdata(pdev);\ 137 - if (table) {\ 112 + if (table == 1) {\ 138 113 match_strs = (const char **)dvfs_strings;\ 139 114 mmio_regs = adl_dvfs_mmio_regs;\ 140 - } else { \ 115 + } else if (table == 2) { \ 116 + match_strs = (const char **)dlvr_strings;\ 117 + mmio_regs = dlvr_mmio_regs;\ 118 + } else {\ 141 119 match_strs = (const char **)fivr_strings;\ 142 120 mmio_regs = tgl_fivr_mmio_regs;\ 143 121 } \ ··· 174 146 RFIM_STORE(spread_spectrum_clk_enable, 0) 175 147 RFIM_STORE(rfi_vco_ref_code, 0) 176 148 RFIM_STORE(fivr_fffc_rev, 0) 149 + 150 + RFIM_SHOW(dlvr_spread_spectrum_pct, 2) 151 + RFIM_SHOW(dlvr_control_mode, 2) 152 + RFIM_SHOW(dlvr_control_lock, 2) 153 + RFIM_SHOW(dlvr_hardware_rev, 2) 154 + RFIM_SHOW(dlvr_freq_mhz, 2) 155 + RFIM_SHOW(dlvr_pll_busy, 2) 156 + RFIM_SHOW(dlvr_freq_select, 2) 157 + RFIM_SHOW(dlvr_rfim_enable, 2) 158 + 159 + RFIM_STORE(dlvr_spread_spectrum_pct, 2) 160 + RFIM_STORE(dlvr_rfim_enable, 2) 161 + RFIM_STORE(dlvr_freq_select, 2) 162 + RFIM_STORE(dlvr_control_mode, 2) 163 + RFIM_STORE(dlvr_control_lock, 2) 164 + 165 + static DEVICE_ATTR_RW(dlvr_spread_spectrum_pct); 166 + static DEVICE_ATTR_RW(dlvr_control_mode); 167 + static DEVICE_ATTR_RW(dlvr_control_lock); 168 + static DEVICE_ATTR_RW(dlvr_freq_select); 169 + static DEVICE_ATTR_RO(dlvr_hardware_rev); 170 + static DEVICE_ATTR_RO(dlvr_freq_mhz); 171 + static DEVICE_ATTR_RO(dlvr_pll_busy); 172 + static DEVICE_ATTR_RW(dlvr_rfim_enable); 173 + 174 + static struct attribute *dlvr_attrs[] = { 175 + &dev_attr_dlvr_spread_spectrum_pct.attr, 176 + &dev_attr_dlvr_control_mode.attr, 177 + &dev_attr_dlvr_control_lock.attr, 178 + &dev_attr_dlvr_freq_select.attr, 179 + &dev_attr_dlvr_hardware_rev.attr, 180 + &dev_attr_dlvr_freq_mhz.attr, 181 + &dev_attr_dlvr_pll_busy.attr, 182 + &dev_attr_dlvr_rfim_enable.attr, 183 + NULL 184 + }; 185 + 186 + static const struct attribute_group dlvr_attribute_group = { 187 + .attrs = dlvr_attrs, 188 + .name = "dlvr" 189 + }; 177 190 178 191 static DEVICE_ATTR_RW(vco_ref_code_lo); 179 192 static DEVICE_ATTR_RW(vco_ref_code_hi); ··· 346 277 return ret; 347 278 } 348 279 280 + if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR) { 281 + ret = sysfs_create_group(&pdev->dev.kobj, &dlvr_attribute_group); 282 + if (ret) 283 + return ret; 284 + } 285 + 349 286 if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DVFS) { 350 287 ret = sysfs_create_group(&pdev->dev.kobj, &dvfs_attribute_group); 351 288 if (ret && proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_FIVR) { 352 289 sysfs_remove_group(&pdev->dev.kobj, &fivr_attribute_group); 290 + return ret; 291 + } 292 + if (ret && proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR) { 293 + sysfs_remove_group(&pdev->dev.kobj, &dlvr_attribute_group); 353 294 return ret; 354 295 } 355 296 } ··· 374 295 375 296 if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_FIVR) 376 297 sysfs_remove_group(&pdev->dev.kobj, &fivr_attribute_group); 298 + 299 + if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR) 300 + sysfs_remove_group(&pdev->dev.kobj, &dlvr_attribute_group); 377 301 378 302 if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DVFS) 379 303 sysfs_remove_group(&pdev->dev.kobj, &dvfs_attribute_group);
+1 -1
drivers/thermal/intel/intel_pch_thermal.c
··· 119 119 120 120 static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp) 121 121 { 122 - struct pch_thermal_device *ptd = tzd->devdata; 122 + struct pch_thermal_device *ptd = thermal_zone_device_priv(tzd); 123 123 124 124 *temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); 125 125 return 0;
+3 -3
drivers/thermal/intel/intel_quark_dts_thermal.c
··· 120 120 static int soc_dts_enable(struct thermal_zone_device *tzd) 121 121 { 122 122 u32 out; 123 - struct soc_sensor_entry *aux_entry = tzd->devdata; 123 + struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd); 124 124 int ret; 125 125 126 126 ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ, ··· 148 148 static int soc_dts_disable(struct thermal_zone_device *tzd) 149 149 { 150 150 u32 out; 151 - struct soc_sensor_entry *aux_entry = tzd->devdata; 151 + struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd); 152 152 int ret; 153 153 154 154 ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ, ··· 250 250 static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, 251 251 int temp) 252 252 { 253 - return update_trip_temp(tzd->devdata, trip, temp); 253 + return update_trip_temp(thermal_zone_device_priv(tzd), trip, temp); 254 254 } 255 255 256 256 static int sys_get_curr_temp(struct thermal_zone_device *tzd,
+5 -8
drivers/thermal/intel/intel_soc_dts_iosf.c
··· 54 54 struct intel_soc_dts_sensor_entry *dts; 55 55 struct intel_soc_dts_sensors *sensors; 56 56 57 - dts = tzd->devdata; 57 + dts = thermal_zone_device_priv(tzd); 58 58 sensors = dts->sensors; 59 59 mutex_lock(&sensors->dts_update_lock); 60 60 status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ··· 168 168 static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, 169 169 int temp) 170 170 { 171 - struct intel_soc_dts_sensor_entry *dts = tzd->devdata; 171 + struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd); 172 172 struct intel_soc_dts_sensors *sensors = dts->sensors; 173 173 int status; 174 174 ··· 176 176 return -EINVAL; 177 177 178 178 mutex_lock(&sensors->dts_update_lock); 179 - status = update_trip_temp(tzd->devdata, trip, temp, 179 + status = update_trip_temp(dts, trip, temp, 180 180 dts->trip_types[trip]); 181 181 mutex_unlock(&sensors->dts_update_lock); 182 182 ··· 186 186 static int sys_get_trip_type(struct thermal_zone_device *tzd, 187 187 int trip, enum thermal_trip_type *type) 188 188 { 189 - struct intel_soc_dts_sensor_entry *dts; 190 - 191 - dts = tzd->devdata; 189 + struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd); 192 190 193 191 *type = dts->trip_types[trip]; 194 192 ··· 198 200 { 199 201 int status; 200 202 u32 out; 201 - struct intel_soc_dts_sensor_entry *dts; 203 + struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd); 202 204 struct intel_soc_dts_sensors *sensors; 203 205 unsigned long raw; 204 206 205 - dts = tzd->devdata; 206 207 sensors = dts->sensors; 207 208 status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, 208 209 SOC_DTS_OFFSET_TEMP, &out);
+7 -5
drivers/thermal/intel/x86_pkg_temp_thermal.c
··· 107 107 108 108 static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) 109 109 { 110 - struct zone_device *zonedev = tzd->devdata; 110 + struct zone_device *zonedev = thermal_zone_device_priv(tzd); 111 111 int val; 112 112 113 113 val = intel_tcc_get_temp(zonedev->cpu, true); ··· 122 122 static int 123 123 sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) 124 124 { 125 - struct zone_device *zonedev = tzd->devdata; 125 + struct zone_device *zonedev = thermal_zone_device_priv(tzd); 126 126 u32 l, h, mask, shift, intr; 127 - int tj_max, ret; 127 + int tj_max, val, ret; 128 128 129 129 tj_max = intel_tcc_get_tjmax(zonedev->cpu); 130 130 if (tj_max < 0) 131 131 return tj_max; 132 132 tj_max *= 1000; 133 133 134 - if (trip >= MAX_NUMBER_OF_TRIPS || temp >= tj_max) 134 + val = (tj_max - temp)/1000; 135 + 136 + if (trip >= MAX_NUMBER_OF_TRIPS || val < 0 || val > 0x7f) 135 137 return -EINVAL; 136 138 137 139 ret = rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, ··· 158 156 if (!temp) { 159 157 l &= ~intr; 160 158 } else { 161 - l |= (tj_max - temp)/1000 << shift; 159 + l |= val << shift; 162 160 l |= intr; 163 161 } 164 162
+2 -2
drivers/thermal/k3_bandgap.c
··· 141 141 142 142 static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 143 143 { 144 - struct k3_thermal_data *data = tz->devdata; 144 + struct k3_thermal_data *data = thermal_zone_device_priv(tz); 145 145 int ret = 0; 146 146 147 147 ret = k3_bgp_read_temp(data, temp); ··· 222 222 goto err_alloc; 223 223 } 224 224 225 - if (devm_thermal_add_hwmon_sysfs(data[id].tzd)) 225 + if (devm_thermal_add_hwmon_sysfs(dev, data[id].tzd)) 226 226 dev_warn(dev, "Failed to add hwmon sysfs attributes\n"); 227 227 } 228 228
+1 -1
drivers/thermal/k3_j72xx_bandgap.c
··· 248 248 /* Get temperature callback function for thermal zone */ 249 249 static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 250 250 { 251 - return k3_bgp_read_temp(tz->devdata, temp); 251 + return k3_bgp_read_temp(thermal_zone_device_priv(tz), temp); 252 252 } 253 253 254 254 static const struct thermal_zone_device_ops k3_of_thermal_ops = {
+2 -5
drivers/thermal/kirkwood_thermal.c
··· 27 27 int *temp) 28 28 { 29 29 unsigned long reg; 30 - struct kirkwood_thermal_priv *priv = thermal->devdata; 30 + struct kirkwood_thermal_priv *priv = thermal_zone_device_priv(thermal); 31 31 32 32 reg = readl_relaxed(priv->sensor); 33 33 34 34 /* Valid check */ 35 35 if (!((reg >> KIRKWOOD_THERMAL_VALID_OFFSET) & 36 - KIRKWOOD_THERMAL_VALID_MASK)) { 37 - dev_err(&thermal->device, 38 - "Temperature sensor reading not valid\n"); 36 + KIRKWOOD_THERMAL_VALID_MASK)) 39 37 return -EIO; 40 - } 41 38 42 39 /* 43 40 * Calculate temperature. According to Marvell internal
+2 -4
drivers/thermal/max77620_thermal.c
··· 46 46 47 47 static int max77620_thermal_read_temp(struct thermal_zone_device *tz, int *temp) 48 48 { 49 - struct max77620_therm_info *mtherm = tz->devdata; 49 + struct max77620_therm_info *mtherm = thermal_zone_device_priv(tz); 50 50 unsigned int val; 51 51 int ret; 52 52 53 53 ret = regmap_read(mtherm->rmap, MAX77620_REG_STATLBT, &val); 54 - if (ret < 0) { 55 - dev_err(mtherm->dev, "Failed to read STATLBT: %d\n", ret); 54 + if (ret < 0) 56 55 return ret; 57 - } 58 56 59 57 if (val & MAX77620_IRQ_TJALRM2_MASK) 60 58 *temp = MAX77620_TJALARM2_TEMP;
+92 -19
drivers/thermal/mediatek/auxadc_thermal.c
··· 31 31 #define AUXADC_CON2_V 0x010 32 32 #define AUXADC_DATA(channel) (0x14 + (channel) * 4) 33 33 34 + #define APMIXED_SYS_TS_CON0 0x600 34 35 #define APMIXED_SYS_TS_CON1 0x604 35 36 36 37 /* Thermal Controller Registers */ ··· 282 281 /* The calibration coefficient of sensor */ 283 282 #define MT7986_CALIBRATION 165 284 283 284 + /* MT8365 */ 285 + #define MT8365_TEMP_AUXADC_CHANNEL 11 286 + #define MT8365_CALIBRATION 164 287 + #define MT8365_NUM_CONTROLLER 1 288 + #define MT8365_NUM_BANKS 1 289 + #define MT8365_NUM_SENSORS 3 290 + #define MT8365_NUM_SENSORS_PER_ZONE 3 291 + #define MT8365_TS1 0 292 + #define MT8365_TS2 1 293 + #define MT8365_TS3 2 294 + 285 295 struct mtk_thermal; 286 296 287 297 struct thermal_bank_cfg { ··· 319 307 bool need_switch_bank; 320 308 struct thermal_bank_cfg bank_data[MAX_NUM_ZONES]; 321 309 enum mtk_thermal_version version; 310 + u32 apmixed_buffer_ctl_reg; 311 + u32 apmixed_buffer_ctl_mask; 312 + u32 apmixed_buffer_ctl_set; 322 313 }; 323 314 324 315 struct mtk_thermal { ··· 447 432 static const int mt7986_vts_index[MT7986_NUM_SENSORS] = { VTS1 }; 448 433 static const int mt7986_tc_offset[MT7986_NUM_CONTROLLER] = { 0x0, }; 449 434 435 + /* MT8365 thermal sensor data */ 436 + static const int mt8365_bank_data[MT8365_NUM_SENSORS] = { 437 + MT8365_TS1, MT8365_TS2, MT8365_TS3 438 + }; 439 + 440 + static const int mt8365_msr[MT8365_NUM_SENSORS_PER_ZONE] = { 441 + TEMP_MSR0, TEMP_MSR1, TEMP_MSR2 442 + }; 443 + 444 + static const int mt8365_adcpnp[MT8365_NUM_SENSORS_PER_ZONE] = { 445 + TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2 446 + }; 447 + 448 + static const int mt8365_mux_values[MT8365_NUM_SENSORS] = { 0, 1, 2 }; 449 + static const int mt8365_tc_offset[MT8365_NUM_CONTROLLER] = { 0 }; 450 + 451 + static const int mt8365_vts_index[MT8365_NUM_SENSORS] = { VTS1, VTS2, VTS3 }; 452 + 450 453 /* 451 454 * The MT8173 thermal controller has four banks. Each bank can read up to 452 455 * four temperature sensors simultaneously. The MT8173 has a total of 5 ··· 540 507 }; 541 508 542 509 /* 510 + * The MT8365 thermal controller has one bank, which can read up to 511 + * four temperature sensors simultaneously. The MT8365 has a total of 3 512 + * temperature sensors. 513 + * 514 + * The thermal core only gets the maximum temperature of this one bank, 515 + * so the bank concept wouldn't be necessary here. However, the SVS (Smart 516 + * Voltage Scaling) unit makes its decisions based on the same bank 517 + * data. 518 + */ 519 + static const struct mtk_thermal_data mt8365_thermal_data = { 520 + .auxadc_channel = MT8365_TEMP_AUXADC_CHANNEL, 521 + .num_banks = MT8365_NUM_BANKS, 522 + .num_sensors = MT8365_NUM_SENSORS, 523 + .vts_index = mt8365_vts_index, 524 + .cali_val = MT8365_CALIBRATION, 525 + .num_controller = MT8365_NUM_CONTROLLER, 526 + .controller_offset = mt8365_tc_offset, 527 + .need_switch_bank = false, 528 + .bank_data = { 529 + { 530 + .num_sensors = MT8365_NUM_SENSORS, 531 + .sensors = mt8365_bank_data 532 + }, 533 + }, 534 + .msr = mt8365_msr, 535 + .adcpnp = mt8365_adcpnp, 536 + .sensor_mux_values = mt8365_mux_values, 537 + .version = MTK_THERMAL_V1, 538 + .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON0, 539 + .apmixed_buffer_ctl_mask = (u32) ~GENMASK(29, 28), 540 + .apmixed_buffer_ctl_set = 0, 541 + }; 542 + 543 + /* 543 544 * The MT2712 thermal controller has one bank, which can read up to 544 545 * four temperature sensors simultaneously. The MT2712 has a total of 4 545 546 * temperature sensors. ··· 627 560 .adcpnp = mt7622_adcpnp, 628 561 .sensor_mux_values = mt7622_mux_values, 629 562 .version = MTK_THERMAL_V2, 563 + .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1, 564 + .apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3), 565 + .apmixed_buffer_ctl_set = BIT(0), 630 566 }; 631 567 632 568 /* ··· 816 746 mt, conf->bank_data[bank->id].sensors[i], raw); 817 747 818 748 819 - /* 820 - * The first read of a sensor often contains very high bogus 821 - * temperature value. Filter these out so that the system does 822 - * not immediately shut down. 823 - */ 824 - if (temp > 200000) 825 - temp = 0; 826 - 827 749 if (temp > max) 828 750 max = temp; 829 751 } ··· 825 763 826 764 static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature) 827 765 { 828 - struct mtk_thermal *mt = tz->devdata; 766 + struct mtk_thermal *mt = thermal_zone_device_priv(tz); 829 767 int i; 830 768 int tempmax = INT_MIN; 831 769 ··· 1136 1074 { 1137 1075 .compatible = "mediatek,mt8183-thermal", 1138 1076 .data = (void *)&mt8183_thermal_data, 1077 + }, 1078 + { 1079 + .compatible = "mediatek,mt8365-thermal", 1080 + .data = (void *)&mt8365_thermal_data, 1139 1081 }, { 1140 1082 }, 1141 1083 }; 1142 1084 MODULE_DEVICE_TABLE(of, mtk_thermal_of_match); 1143 1085 1144 - static void mtk_thermal_turn_on_buffer(void __iomem *apmixed_base) 1086 + static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt, 1087 + void __iomem *apmixed_base) 1145 1088 { 1146 - int tmp; 1089 + u32 tmp; 1147 1090 1148 - tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1); 1149 - tmp &= ~(0x37); 1150 - tmp |= 0x1; 1151 - writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1); 1091 + if (!mt->conf->apmixed_buffer_ctl_reg) 1092 + return; 1093 + 1094 + tmp = readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg); 1095 + tmp &= mt->conf->apmixed_buffer_ctl_mask; 1096 + tmp |= mt->conf->apmixed_buffer_ctl_set; 1097 + writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg); 1152 1098 udelay(200); 1153 1099 } 1154 1100 ··· 1254 1184 goto err_disable_clk_auxadc; 1255 1185 } 1256 1186 1257 - if (mt->conf->version != MTK_THERMAL_V1) { 1258 - mtk_thermal_turn_on_buffer(apmixed_base); 1187 + mtk_thermal_turn_on_buffer(mt, apmixed_base); 1188 + 1189 + if (mt->conf->version != MTK_THERMAL_V2) 1259 1190 mtk_thermal_release_periodic_ts(mt, auxadc_base); 1260 - } 1261 1191 1262 1192 if (mt->conf->version == MTK_THERMAL_V1) 1263 1193 mt->raw_to_mcelsius = raw_to_mcelsius_v1; ··· 1273 1203 1274 1204 platform_set_drvdata(pdev, mt); 1275 1205 1206 + /* Delay for thermal banks to be ready */ 1207 + msleep(30); 1208 + 1276 1209 tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt, 1277 1210 &mtk_thermal_ops); 1278 1211 if (IS_ERR(tzdev)) { ··· 1283 1210 goto err_disable_clk_peri_therm; 1284 1211 } 1285 1212 1286 - ret = devm_thermal_add_hwmon_sysfs(tzdev); 1213 + ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev); 1287 1214 if (ret) 1288 1215 dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs"); 1289 1216
+83 -27
drivers/thermal/mediatek/lvts_thermal.c
··· 66 66 #define LVTS_MONINT_CONF 0x9FBF7BDE 67 67 68 68 #define LVTS_INT_SENSOR0 0x0009001F 69 - #define LVTS_INT_SENSOR1 0X000881F0 69 + #define LVTS_INT_SENSOR1 0x001203E0 70 70 #define LVTS_INT_SENSOR2 0x00247C00 71 71 #define LVTS_INT_SENSOR3 0x1FC00000 72 72 ··· 252 252 253 253 static int lvts_get_temp(struct thermal_zone_device *tz, int *temp) 254 254 { 255 - struct lvts_sensor *lvts_sensor = tz->devdata; 255 + struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz); 256 256 void __iomem *msr = lvts_sensor->msr; 257 257 u32 value; 258 258 ··· 290 290 291 291 static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high) 292 292 { 293 - struct lvts_sensor *lvts_sensor = tz->devdata; 293 + struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz); 294 294 void __iomem *base = lvts_sensor->base; 295 295 u32 raw_low = lvts_temp_to_raw(low); 296 296 u32 raw_high = lvts_temp_to_raw(high); ··· 305 305 * 14-0 : Raw temperature for threshold 306 306 */ 307 307 if (low != -INT_MAX) { 308 - dev_dbg(&tz->device, "Setting low limit temperature interrupt: %d\n", low); 308 + pr_debug("%s: Setting low limit temperature interrupt: %d\n", 309 + thermal_zone_device_type(tz), low); 309 310 writel(raw_low, LVTS_H2NTHRE(base)); 310 311 } 311 312 ··· 319 318 * 320 319 * 14-0 : Raw temperature for threshold 321 320 */ 322 - dev_dbg(&tz->device, "Setting high limit temperature interrupt: %d\n", high); 321 + pr_debug("%s: Setting high limit temperature interrupt: %d\n", 322 + thermal_zone_device_type(tz), high); 323 323 writel(raw_high, LVTS_HTHRE(base)); 324 324 325 325 return 0; ··· 395 393 * => 0x1FC00000 396 394 * sensor 2 interrupt: 0000 0000 0010 0100 0111 1100 0000 0000 397 395 * => 0x00247C00 398 - * sensor 1 interrupt: 0000 0000 0001 0001 0000 0011 1110 0000 399 - * => 0X000881F0 396 + * sensor 1 interrupt: 0000 0000 0001 0010 0000 0011 1110 0000 397 + * => 0X001203E0 400 398 * sensor 0 interrupt: 0000 0000 0000 1001 0000 0000 0001 1111 401 399 * => 0x0009001F 402 400 */ ··· 530 528 * The efuse blob values follows the sensor enumeration per thermal 531 529 * controller. The decoding of the stream is as follow: 532 530 * 533 - * <--?-> <----big0 ???---> <-sensor0-> <-0-> 534 - * ------------------------------------------ 535 - * index in the stream: : | 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 536 - * ------------------------------------------ 531 + * stream index map for MCU Domain : 537 532 * 538 - * <--sensor1--><-0-> <----big1 ???---> <-sen 539 - * ------------------------------------------ 540 - * | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD | 541 - * ------------------------------------------ 533 + * <-----mcu-tc#0-----> <-----sensor#0-----> <-----sensor#1-----> 534 + * 0x01 | 0x02 | 0x03 | 0x04 | 0x05 | 0x06 | 0x07 | 0x08 | 0x09 542 535 * 543 - * sor0-> <-0-> <-sensor1-> <-0-> .......... 544 - * ------------------------------------------ 545 - * | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD | 546 - * ------------------------------------------ 536 + * <-----mcu-tc#1-----> <-----sensor#2-----> <-----sensor#3-----> 537 + * 0x0A | 0x0B | 0x0C | 0x0D | 0x0E | 0x0F | 0x10 | 0x11 | 0x12 547 538 * 548 - * And so on ... 539 + * <-----mcu-tc#2-----> <-----sensor#4-----> <-----sensor#5-----> <-----sensor#6-----> <-----sensor#7-----> 540 + * 0x13 | 0x14 | 0x15 | 0x16 | 0x17 | 0x18 | 0x19 | 0x1A | 0x1B | 0x1C | 0x1D | 0x1E | 0x1F | 0x20 | 0x21 541 + * 542 + * stream index map for AP Domain : 543 + * 544 + * <-----ap--tc#0-----> <-----sensor#0-----> <-----sensor#1-----> 545 + * 0x22 | 0x23 | 0x24 | 0x25 | 0x26 | 0x27 | 0x28 | 0x29 | 0x2A 546 + * 547 + * <-----ap--tc#1-----> <-----sensor#2-----> <-----sensor#3-----> 548 + * 0x2B | 0x2C | 0x2D | 0x2E | 0x2F | 0x30 | 0x31 | 0x32 | 0x33 549 + * 550 + * <-----ap--tc#2-----> <-----sensor#4-----> <-----sensor#5-----> <-----sensor#6-----> 551 + * 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39 | 0x3A | 0x3B | 0x3C | 0x3D | 0x3E | 0x3F 552 + * 553 + * <-----ap--tc#3-----> <-----sensor#7-----> <-----sensor#8-----> 554 + * 0x40 | 0x41 | 0x42 | 0x43 | 0x44 | 0x45 | 0x46 | 0x47 | 0x48 549 555 * 550 556 * The data description gives the offset of the calibration data in 551 557 * this bytes stream for each sensor. 552 - * 553 - * Each thermal controller can handle up to 4 sensors max, we don't 554 - * care if there are less as the array of calibration is sized to 4 555 - * anyway. The unused sensor slot will be zeroed. 556 558 */ 557 559 static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl, 558 560 const struct lvts_ctrl_data *lvts_ctrl_data, ··· 1169 1163 return 0; 1170 1164 } 1171 1165 1172 - static const struct lvts_ctrl_data mt8195_lvts_data_ctrl[] = { 1166 + static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = { 1173 1167 { 1174 1168 .cal_offset = { 0x04, 0x07 }, 1175 1169 .lvts_sensor = { ··· 1204 1198 } 1205 1199 }; 1206 1200 1201 + static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = { 1202 + { 1203 + .cal_offset = { 0x25, 0x28 }, 1204 + .lvts_sensor = { 1205 + { .dt_id = MT8195_AP_VPU0 }, 1206 + { .dt_id = MT8195_AP_VPU1 } 1207 + }, 1208 + .num_lvts_sensor = 2, 1209 + .offset = 0x0, 1210 + .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195, 1211 + }, 1212 + { 1213 + .cal_offset = { 0x2e, 0x31 }, 1214 + .lvts_sensor = { 1215 + { .dt_id = MT8195_AP_GPU0 }, 1216 + { .dt_id = MT8195_AP_GPU1 } 1217 + }, 1218 + .num_lvts_sensor = 2, 1219 + .offset = 0x100, 1220 + .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195, 1221 + }, 1222 + { 1223 + .cal_offset = { 0x37, 0x3a, 0x3d }, 1224 + .lvts_sensor = { 1225 + { .dt_id = MT8195_AP_VDEC }, 1226 + { .dt_id = MT8195_AP_IMG }, 1227 + { .dt_id = MT8195_AP_INFRA }, 1228 + }, 1229 + .num_lvts_sensor = 3, 1230 + .offset = 0x200, 1231 + .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195, 1232 + }, 1233 + { 1234 + .cal_offset = { 0x43, 0x46 }, 1235 + .lvts_sensor = { 1236 + { .dt_id = MT8195_AP_CAM0 }, 1237 + { .dt_id = MT8195_AP_CAM1 } 1238 + }, 1239 + .num_lvts_sensor = 2, 1240 + .offset = 0x300, 1241 + .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195, 1242 + } 1243 + }; 1244 + 1207 1245 static const struct lvts_data mt8195_lvts_mcu_data = { 1208 - .lvts_ctrl = mt8195_lvts_data_ctrl, 1209 - .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_data_ctrl), 1246 + .lvts_ctrl = mt8195_lvts_mcu_data_ctrl, 1247 + .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_mcu_data_ctrl), 1248 + }; 1249 + 1250 + static const struct lvts_data mt8195_lvts_ap_data = { 1251 + .lvts_ctrl = mt8195_lvts_ap_data_ctrl, 1252 + .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_ap_data_ctrl), 1210 1253 }; 1211 1254 1212 1255 static const struct of_device_id lvts_of_match[] = { 1213 1256 { .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data }, 1257 + { .compatible = "mediatek,mt8195-lvts-ap", .data = &mt8195_lvts_ap_data }, 1214 1258 {}, 1215 1259 }; 1216 1260 MODULE_DEVICE_TABLE(of, lvts_of_match);
+3 -3
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
··· 360 360 361 361 static int adc_tm5_get_temp(struct thermal_zone_device *tz, int *temp) 362 362 { 363 - struct adc_tm5_channel *channel = tz->devdata; 363 + struct adc_tm5_channel *channel = thermal_zone_device_priv(tz); 364 364 int ret; 365 365 366 366 if (!channel || !channel->iio) ··· 642 642 643 643 static int adc_tm5_set_trips(struct thermal_zone_device *tz, int low, int high) 644 644 { 645 - struct adc_tm5_channel *channel = tz->devdata; 645 + struct adc_tm5_channel *channel = thermal_zone_device_priv(tz); 646 646 struct adc_tm5_chip *chip; 647 647 int ret; 648 648 ··· 689 689 return PTR_ERR(tzd); 690 690 } 691 691 adc_tm->channels[i].tzd = tzd; 692 - if (devm_thermal_add_hwmon_sysfs(tzd)) 692 + if (devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd)) 693 693 dev_warn(adc_tm->dev, 694 694 "Failed to add hwmon sysfs attributes\n"); 695 695 }
+3 -3
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
··· 187 187 188 188 static int qpnp_tm_get_temp(struct thermal_zone_device *tz, int *temp) 189 189 { 190 - struct qpnp_tm_chip *chip = tz->devdata; 190 + struct qpnp_tm_chip *chip = thermal_zone_device_priv(tz); 191 191 int ret, mili_celsius; 192 192 193 193 if (!temp) ··· 265 265 266 266 static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp) 267 267 { 268 - struct qpnp_tm_chip *chip = tz->devdata; 268 + struct qpnp_tm_chip *chip = thermal_zone_device_priv(tz); 269 269 struct thermal_trip trip; 270 270 int ret; 271 271 ··· 459 459 return ret; 460 460 } 461 461 462 - if (devm_thermal_add_hwmon_sysfs(chip->tz_dev)) 462 + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev)) 463 463 dev_warn(&pdev->dev, 464 464 "Failed to add hwmon sysfs attributes\n"); 465 465
+3 -3
drivers/thermal/qcom/tsens.c
··· 673 673 674 674 static int tsens_set_trips(struct thermal_zone_device *tz, int low, int high) 675 675 { 676 - struct tsens_sensor *s = tz->devdata; 676 + struct tsens_sensor *s = thermal_zone_device_priv(tz); 677 677 struct tsens_priv *priv = s->priv; 678 678 struct device *dev = priv->dev; 679 679 struct tsens_irq_data d; ··· 1057 1057 1058 1058 static int tsens_get_temp(struct thermal_zone_device *tz, int *temp) 1059 1059 { 1060 - struct tsens_sensor *s = tz->devdata; 1060 + struct tsens_sensor *s = thermal_zone_device_priv(tz); 1061 1061 struct tsens_priv *priv = s->priv; 1062 1062 1063 1063 return priv->ops->get_temp(s, temp); ··· 1189 1189 if (priv->ops->enable) 1190 1190 priv->ops->enable(priv, i); 1191 1191 1192 - if (devm_thermal_add_hwmon_sysfs(tzd)) 1192 + if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd)) 1193 1193 dev_warn(priv->dev, 1194 1194 "Failed to add hwmon sysfs attributes\n"); 1195 1195 }
+2 -2
drivers/thermal/qoriq_thermal.c
··· 83 83 84 84 static int tmu_get_temp(struct thermal_zone_device *tz, int *temp) 85 85 { 86 - struct qoriq_sensor *qsensor = tz->devdata; 86 + struct qoriq_sensor *qsensor = thermal_zone_device_priv(tz); 87 87 struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor); 88 88 u32 val; 89 89 /* ··· 157 157 return ret; 158 158 } 159 159 160 - if (devm_thermal_add_hwmon_sysfs(tzd)) 160 + if (devm_thermal_add_hwmon_sysfs(dev, tzd)) 161 161 dev_warn(dev, 162 162 "Failed to add hwmon sysfs attributes\n"); 163 163
+4 -53
drivers/thermal/rcar_gen3_thermal.c
··· 14 14 #include <linux/of_device.h> 15 15 #include <linux/platform_device.h> 16 16 #include <linux/pm_runtime.h> 17 - #include <linux/sys_soc.h> 18 17 #include <linux/thermal.h> 19 18 20 19 #include "thermal_hwmon.h" ··· 26 27 #define REG_GEN3_IRQTEMP1 0x14 27 28 #define REG_GEN3_IRQTEMP2 0x18 28 29 #define REG_GEN3_IRQTEMP3 0x1C 29 - #define REG_GEN3_CTSR 0x20 30 30 #define REG_GEN3_THCTR 0x20 31 31 #define REG_GEN3_TEMP 0x28 32 32 #define REG_GEN3_THCODE1 0x50 ··· 43 45 #define IRQ_TEMPD1 BIT(3) 44 46 #define IRQ_TEMPD2 BIT(4) 45 47 #define IRQ_TEMPD3 BIT(5) 46 - 47 - /* CTSR bits */ 48 - #define CTSR_PONM BIT(8) 49 - #define CTSR_AOUT BIT(7) 50 - #define CTSR_THBGR BIT(5) 51 - #define CTSR_VMEN BIT(4) 52 - #define CTSR_VMST BIT(1) 53 - #define CTSR_THSST BIT(0) 54 48 55 49 /* THCTR bits */ 56 50 #define THCTR_PONM BIT(6) ··· 78 88 struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; 79 89 struct thermal_zone_device_ops ops; 80 90 unsigned int num_tscs; 81 - void (*thermal_init)(struct rcar_gen3_thermal_priv *priv, 82 - struct rcar_gen3_thermal_tsc *tsc); 83 91 int ptat[3]; 84 92 }; 85 93 ··· 155 167 156 168 static int rcar_gen3_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 157 169 { 158 - struct rcar_gen3_thermal_tsc *tsc = tz->devdata; 170 + struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_priv(tz); 159 171 int mcelsius, val; 160 172 int reg; 161 173 ··· 194 206 195 207 static int rcar_gen3_thermal_set_trips(struct thermal_zone_device *tz, int low, int high) 196 208 { 197 - struct rcar_gen3_thermal_tsc *tsc = tz->devdata; 209 + struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_priv(tz); 198 210 u32 irqmsk = 0; 199 211 200 212 if (low != -INT_MAX) { ··· 235 247 236 248 return IRQ_HANDLED; 237 249 } 238 - 239 - static const struct soc_device_attribute r8a7795es1[] = { 240 - { .soc_id = "r8a7795", .revision = "ES1.*" }, 241 - { /* sentinel */ } 242 - }; 243 250 244 251 static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) 245 252 { ··· 292 309 } 293 310 294 311 return true; 295 - } 296 - 297 - static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_priv *priv, 298 - struct rcar_gen3_thermal_tsc *tsc) 299 - { 300 - rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR); 301 - rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0); 302 - 303 - usleep_range(1000, 2000); 304 - 305 - rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_PONM); 306 - 307 - rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F); 308 - rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); 309 - if (priv->ops.set_trips) 310 - rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, 311 - IRQ_TEMPD1 | IRQ_TEMP2); 312 - 313 - rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 314 - CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN); 315 - 316 - usleep_range(100, 200); 317 - 318 - rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 319 - CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN | 320 - CTSR_VMST | CTSR_THSST); 321 - 322 - usleep_range(1000, 2000); 323 312 } 324 313 325 314 static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_priv *priv, ··· 429 474 return -ENOMEM; 430 475 431 476 priv->ops = rcar_gen3_tz_of_ops; 432 - priv->thermal_init = rcar_gen3_thermal_init; 433 - if (soc_device_match(r8a7795es1)) 434 - priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1; 435 477 436 478 platform_set_drvdata(pdev, priv); 437 479 ··· 468 516 for (i = 0; i < priv->num_tscs; i++) { 469 517 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; 470 518 471 - priv->thermal_init(priv, tsc); 519 + rcar_gen3_thermal_init(priv, tsc); 472 520 rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1); 473 521 474 522 zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops); ··· 479 527 } 480 528 tsc->zone = zone; 481 529 482 - tsc->zone->tzp->no_hwmon = false; 483 530 ret = thermal_add_hwmon_sysfs(tsc->zone); 484 531 if (ret) 485 532 goto error_unregister; ··· 515 564 for (i = 0; i < priv->num_tscs; i++) { 516 565 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; 517 566 518 - priv->thermal_init(priv, tsc); 567 + rcar_gen3_thermal_init(priv, tsc); 519 568 } 520 569 521 570 return 0;
+1 -7
drivers/thermal/rcar_thermal.c
··· 101 101 list_for_each_entry(pos, &common->head, list) 102 102 103 103 #define MCELSIUS(temp) ((temp) * 1000) 104 - #define rcar_zone_to_priv(zone) ((zone)->devdata) 105 104 #define rcar_priv_to_dev(priv) ((priv)->common->dev) 106 105 #define rcar_has_irq_support(priv) ((priv)->common->base) 107 106 #define rcar_id_to_shift(priv) ((priv)->id * 8) ··· 272 273 273 274 static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) 274 275 { 275 - struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); 276 + struct rcar_thermal_priv *priv = thermal_zone_device_priv(zone); 276 277 277 278 return rcar_thermal_get_current_temp(priv, temp); 278 279 } ··· 509 510 } 510 511 511 512 if (chip->use_of_thermal) { 512 - /* 513 - * thermal_zone doesn't enable hwmon as default, 514 - * but, enable it here to keep compatible 515 - */ 516 - priv->zone->tzp->no_hwmon = false; 517 513 ret = thermal_add_hwmon_sysfs(priv->zone); 518 514 if (ret) 519 515 goto error_unregister;
+228 -104
drivers/thermal/rockchip_thermal.c
··· 40 40 }; 41 41 42 42 /* 43 - * The system has two Temperature Sensors. 44 - * sensor0 is for CPU, and sensor1 is for GPU. 45 - */ 46 - enum sensor_id { 47 - SENSOR_CPU = 0, 48 - SENSOR_GPU, 49 - }; 50 - 51 - /* 52 43 * The conversion table has the adc value and temperature. 53 44 * ADC_DECREMENT: the adc value is of diminishing.(e.g. rk3288_code_table) 54 45 * ADC_INCREMENT: the adc value is incremental.(e.g. rk3368_code_table) ··· 50 59 }; 51 60 52 61 #include "thermal_hwmon.h" 53 - 54 - /* 55 - * The max sensors is two in rockchip SoCs. 56 - * Two sensors: CPU and GPU sensor. 57 - */ 58 - #define SOC_MAX_SENSORS 2 59 62 60 63 /** 61 64 * struct chip_tsadc_table - hold information about chip-specific differences ··· 67 82 68 83 /** 69 84 * struct rockchip_tsadc_chip - hold the private data of tsadc chip 70 - * @chn_id: array of sensor ids of chip corresponding to the channel 85 + * @chn_offset: the channel offset of the first channel 71 86 * @chn_num: the channel number of tsadc chip 72 87 * @tshut_temp: the hardware-controlled shutdown temperature value 73 88 * @tshut_mode: the hardware-controlled shutdown mode (0:CRU 1:GPIO) ··· 83 98 */ 84 99 struct rockchip_tsadc_chip { 85 100 /* The sensor id of chip correspond to the ADC channel */ 86 - int chn_id[SOC_MAX_SENSORS]; 101 + int chn_offset; 87 102 int chn_num; 88 103 89 104 /* The hardware-controlled tshut property */ ··· 141 156 struct platform_device *pdev; 142 157 struct reset_control *reset; 143 158 144 - struct rockchip_thermal_sensor sensors[SOC_MAX_SENSORS]; 159 + struct rockchip_thermal_sensor *sensors; 145 160 146 161 struct clk *clk; 147 162 struct clk *pclk; ··· 165 180 #define TSADCV2_AUTO_CON 0x04 166 181 #define TSADCV2_INT_EN 0x08 167 182 #define TSADCV2_INT_PD 0x0c 183 + #define TSADCV3_AUTO_SRC_CON 0x0c 184 + #define TSADCV3_HT_INT_EN 0x14 185 + #define TSADCV3_HSHUT_GPIO_INT_EN 0x18 186 + #define TSADCV3_HSHUT_CRU_INT_EN 0x1c 187 + #define TSADCV3_INT_PD 0x24 188 + #define TSADCV3_HSHUT_PD 0x28 168 189 #define TSADCV2_DATA(chn) (0x20 + (chn) * 0x04) 169 190 #define TSADCV2_COMP_INT(chn) (0x30 + (chn) * 0x04) 170 191 #define TSADCV2_COMP_SHUT(chn) (0x40 + (chn) * 0x04) 192 + #define TSADCV3_DATA(chn) (0x2c + (chn) * 0x04) 193 + #define TSADCV3_COMP_INT(chn) (0x6c + (chn) * 0x04) 194 + #define TSADCV3_COMP_SHUT(chn) (0x10c + (chn) * 0x04) 171 195 #define TSADCV2_HIGHT_INT_DEBOUNCE 0x60 172 196 #define TSADCV2_HIGHT_TSHUT_DEBOUNCE 0x64 197 + #define TSADCV3_HIGHT_INT_DEBOUNCE 0x14c 198 + #define TSADCV3_HIGHT_TSHUT_DEBOUNCE 0x150 173 199 #define TSADCV2_AUTO_PERIOD 0x68 174 200 #define TSADCV2_AUTO_PERIOD_HT 0x6c 201 + #define TSADCV3_AUTO_PERIOD 0x154 202 + #define TSADCV3_AUTO_PERIOD_HT 0x158 175 203 176 204 #define TSADCV2_AUTO_EN BIT(0) 205 + #define TSADCV2_AUTO_EN_MASK BIT(16) 177 206 #define TSADCV2_AUTO_SRC_EN(chn) BIT(4 + (chn)) 207 + #define TSADCV3_AUTO_SRC_EN(chn) BIT(chn) 208 + #define TSADCV3_AUTO_SRC_EN_MASK(chn) BIT(16 + chn) 178 209 #define TSADCV2_AUTO_TSHUT_POLARITY_HIGH BIT(8) 210 + #define TSADCV2_AUTO_TSHUT_POLARITY_MASK BIT(24) 179 211 180 212 #define TSADCV3_AUTO_Q_SEL_EN BIT(1) 181 213 182 214 #define TSADCV2_INT_SRC_EN(chn) BIT(chn) 215 + #define TSADCV2_INT_SRC_EN_MASK(chn) BIT(16 + (chn)) 183 216 #define TSADCV2_SHUT_2GPIO_SRC_EN(chn) BIT(4 + (chn)) 184 217 #define TSADCV2_SHUT_2CRU_SRC_EN(chn) BIT(8 + (chn)) 185 218 186 219 #define TSADCV2_INT_PD_CLEAR_MASK ~BIT(8) 187 220 #define TSADCV3_INT_PD_CLEAR_MASK ~BIT(16) 221 + #define TSADCV4_INT_PD_CLEAR_MASK 0xffffffff 188 222 189 223 #define TSADCV2_DATA_MASK 0xfff 190 224 #define TSADCV3_DATA_MASK 0x3ff 225 + #define TSADCV4_DATA_MASK 0x1ff 191 226 192 227 #define TSADCV2_HIGHT_INT_DEBOUNCE_COUNT 4 193 228 #define TSADCV2_HIGHT_TSHUT_DEBOUNCE_COUNT 4 ··· 218 213 219 214 #define TSADCV5_AUTO_PERIOD_TIME 1622 /* 2.5ms */ 220 215 #define TSADCV5_AUTO_PERIOD_HT_TIME 1622 /* 2.5ms */ 216 + #define TSADCV6_AUTO_PERIOD_TIME 5000 /* 2.5ms */ 217 + #define TSADCV6_AUTO_PERIOD_HT_TIME 5000 /* 2.5ms */ 221 218 222 219 #define TSADCV2_USER_INTER_PD_SOC 0x340 /* 13 clocks */ 223 220 #define TSADCV5_USER_INTER_PD_SOC 0xfc0 /* 97us, at least 90us */ ··· 235 228 #define RK3568_GRF_TSADC_ANA_REG1 (0x10001 << 1) 236 229 #define RK3568_GRF_TSADC_ANA_REG2 (0x10001 << 2) 237 230 #define RK3568_GRF_TSADC_TSEN (0x10001 << 8) 231 + 232 + #define RK3588_GRF0_TSADC_CON 0x0100 233 + 234 + #define RK3588_GRF0_TSADC_TRM (0xff0077 << 0) 235 + #define RK3588_GRF0_TSADC_SHUT_2CRU (0x30003 << 10) 236 + #define RK3588_GRF0_TSADC_SHUT_2GPIO (0x70007 << 12) 238 237 239 238 #define GRF_SARADC_TESTBIT_ON (0x10001 << 2) 240 239 #define GRF_TSADC_TESTBIT_H_ON (0x10001 << 2) ··· 536 523 {TSADCV2_DATA_MASK, 125000}, 537 524 }; 538 525 526 + static const struct tsadc_table rk3588_code_table[] = { 527 + {0, -40000}, 528 + {215, -40000}, 529 + {285, 25000}, 530 + {350, 85000}, 531 + {395, 125000}, 532 + {TSADCV4_DATA_MASK, 125000}, 533 + }; 534 + 539 535 static u32 rk_tsadcv2_temp_to_code(const struct chip_tsadc_table *table, 540 536 int temp) 541 537 { ··· 815 793 } 816 794 } 817 795 796 + static void rk_tsadcv8_initialize(struct regmap *grf, void __iomem *regs, 797 + enum tshut_polarity tshut_polarity) 798 + { 799 + writel_relaxed(TSADCV6_AUTO_PERIOD_TIME, regs + TSADCV3_AUTO_PERIOD); 800 + writel_relaxed(TSADCV6_AUTO_PERIOD_HT_TIME, 801 + regs + TSADCV3_AUTO_PERIOD_HT); 802 + writel_relaxed(TSADCV2_HIGHT_INT_DEBOUNCE_COUNT, 803 + regs + TSADCV3_HIGHT_INT_DEBOUNCE); 804 + writel_relaxed(TSADCV2_HIGHT_TSHUT_DEBOUNCE_COUNT, 805 + regs + TSADCV3_HIGHT_TSHUT_DEBOUNCE); 806 + if (tshut_polarity == TSHUT_HIGH_ACTIVE) 807 + writel_relaxed(TSADCV2_AUTO_TSHUT_POLARITY_HIGH | 808 + TSADCV2_AUTO_TSHUT_POLARITY_MASK, 809 + regs + TSADCV2_AUTO_CON); 810 + else 811 + writel_relaxed(TSADCV2_AUTO_TSHUT_POLARITY_MASK, 812 + regs + TSADCV2_AUTO_CON); 813 + } 814 + 818 815 static void rk_tsadcv2_irq_ack(void __iomem *regs) 819 816 { 820 817 u32 val; ··· 848 807 849 808 val = readl_relaxed(regs + TSADCV2_INT_PD); 850 809 writel_relaxed(val & TSADCV3_INT_PD_CLEAR_MASK, regs + TSADCV2_INT_PD); 810 + } 811 + 812 + static void rk_tsadcv4_irq_ack(void __iomem *regs) 813 + { 814 + u32 val; 815 + 816 + val = readl_relaxed(regs + TSADCV3_INT_PD); 817 + writel_relaxed(val & TSADCV4_INT_PD_CLEAR_MASK, regs + TSADCV3_INT_PD); 818 + val = readl_relaxed(regs + TSADCV3_HSHUT_PD); 819 + writel_relaxed(val & TSADCV3_INT_PD_CLEAR_MASK, 820 + regs + TSADCV3_HSHUT_PD); 851 821 } 852 822 853 823 static void rk_tsadcv2_control(void __iomem *regs, bool enable) ··· 896 844 writel_relaxed(val, regs + TSADCV2_AUTO_CON); 897 845 } 898 846 847 + static void rk_tsadcv4_control(void __iomem *regs, bool enable) 848 + { 849 + u32 val; 850 + 851 + if (enable) 852 + val = TSADCV2_AUTO_EN | TSADCV2_AUTO_EN_MASK; 853 + else 854 + val = TSADCV2_AUTO_EN_MASK; 855 + 856 + writel_relaxed(val, regs + TSADCV2_AUTO_CON); 857 + } 858 + 899 859 static int rk_tsadcv2_get_temp(const struct chip_tsadc_table *table, 900 860 int chn, void __iomem *regs, int *temp) 901 861 { 902 862 u32 val; 903 863 904 864 val = readl_relaxed(regs + TSADCV2_DATA(chn)); 865 + 866 + return rk_tsadcv2_code_to_temp(table, val, temp); 867 + } 868 + 869 + static int rk_tsadcv4_get_temp(const struct chip_tsadc_table *table, 870 + int chn, void __iomem *regs, int *temp) 871 + { 872 + u32 val; 873 + 874 + val = readl_relaxed(regs + TSADCV3_DATA(chn)); 905 875 906 876 return rk_tsadcv2_code_to_temp(table, val, temp); 907 877 } ··· 962 888 return 0; 963 889 } 964 890 891 + static int rk_tsadcv3_alarm_temp(const struct chip_tsadc_table *table, 892 + int chn, void __iomem *regs, int temp) 893 + { 894 + u32 alarm_value; 895 + 896 + /* 897 + * In some cases, some sensors didn't need the trip points, the 898 + * set_trips will pass {-INT_MAX, INT_MAX} to trigger tsadc alarm 899 + * in the end, ignore this case and disable the high temperature 900 + * interrupt. 901 + */ 902 + if (temp == INT_MAX) { 903 + writel_relaxed(TSADCV2_INT_SRC_EN_MASK(chn), 904 + regs + TSADCV3_HT_INT_EN); 905 + return 0; 906 + } 907 + /* Make sure the value is valid */ 908 + alarm_value = rk_tsadcv2_temp_to_code(table, temp); 909 + if (alarm_value == table->data_mask) 910 + return -ERANGE; 911 + writel_relaxed(alarm_value & table->data_mask, 912 + regs + TSADCV3_COMP_INT(chn)); 913 + writel_relaxed(TSADCV2_INT_SRC_EN(chn) | TSADCV2_INT_SRC_EN_MASK(chn), 914 + regs + TSADCV3_HT_INT_EN); 915 + return 0; 916 + } 917 + 965 918 static int rk_tsadcv2_tshut_temp(const struct chip_tsadc_table *table, 966 919 int chn, void __iomem *regs, int temp) 967 920 { ··· 1004 903 /* TSHUT will be valid */ 1005 904 val = readl_relaxed(regs + TSADCV2_AUTO_CON); 1006 905 writel_relaxed(val | TSADCV2_AUTO_SRC_EN(chn), regs + TSADCV2_AUTO_CON); 906 + 907 + return 0; 908 + } 909 + 910 + static int rk_tsadcv3_tshut_temp(const struct chip_tsadc_table *table, 911 + int chn, void __iomem *regs, int temp) 912 + { 913 + u32 tshut_value; 914 + 915 + /* Make sure the value is valid */ 916 + tshut_value = rk_tsadcv2_temp_to_code(table, temp); 917 + if (tshut_value == table->data_mask) 918 + return -ERANGE; 919 + 920 + writel_relaxed(tshut_value, regs + TSADCV3_COMP_SHUT(chn)); 921 + 922 + /* TSHUT will be valid */ 923 + writel_relaxed(TSADCV3_AUTO_SRC_EN(chn) | TSADCV3_AUTO_SRC_EN_MASK(chn), 924 + regs + TSADCV3_AUTO_SRC_CON); 1007 925 1008 926 return 0; 1009 927 } ··· 1044 924 writel_relaxed(val, regs + TSADCV2_INT_EN); 1045 925 } 1046 926 927 + static void rk_tsadcv3_tshut_mode(int chn, void __iomem *regs, 928 + enum tshut_mode mode) 929 + { 930 + u32 val_gpio, val_cru; 931 + 932 + if (mode == TSHUT_MODE_GPIO) { 933 + val_gpio = TSADCV2_INT_SRC_EN(chn) | TSADCV2_INT_SRC_EN_MASK(chn); 934 + val_cru = TSADCV2_INT_SRC_EN_MASK(chn); 935 + } else { 936 + val_cru = TSADCV2_INT_SRC_EN(chn) | TSADCV2_INT_SRC_EN_MASK(chn); 937 + val_gpio = TSADCV2_INT_SRC_EN_MASK(chn); 938 + } 939 + writel_relaxed(val_gpio, regs + TSADCV3_HSHUT_GPIO_INT_EN); 940 + writel_relaxed(val_cru, regs + TSADCV3_HSHUT_CRU_INT_EN); 941 + } 942 + 1047 943 static const struct rockchip_tsadc_chip px30_tsadc_data = { 1048 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 1049 - .chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */ 944 + /* cpu, gpu */ 945 + .chn_offset = 0, 1050 946 .chn_num = 2, /* 2 channels for tsadc */ 1051 947 1052 948 .tshut_mode = TSHUT_MODE_CRU, /* default TSHUT via CRU */ ··· 1085 949 }; 1086 950 1087 951 static const struct rockchip_tsadc_chip rv1108_tsadc_data = { 1088 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 952 + /* cpu */ 953 + .chn_offset = 0, 1089 954 .chn_num = 1, /* one channel for tsadc */ 1090 955 1091 956 .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ ··· 1110 973 }; 1111 974 1112 975 static const struct rockchip_tsadc_chip rk3228_tsadc_data = { 1113 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 976 + /* cpu */ 977 + .chn_offset = 0, 1114 978 .chn_num = 1, /* one channel for tsadc */ 1115 979 1116 980 .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ ··· 1135 997 }; 1136 998 1137 999 static const struct rockchip_tsadc_chip rk3288_tsadc_data = { 1138 - .chn_id[SENSOR_CPU] = 1, /* cpu sensor is channel 1 */ 1139 - .chn_id[SENSOR_GPU] = 2, /* gpu sensor is channel 2 */ 1000 + /* cpu, gpu */ 1001 + .chn_offset = 1, 1140 1002 .chn_num = 2, /* two channels for tsadc */ 1141 1003 1142 1004 .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ ··· 1160 1022 }; 1161 1023 1162 1024 static const struct rockchip_tsadc_chip rk3328_tsadc_data = { 1163 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 1025 + /* cpu */ 1026 + .chn_offset = 0, 1164 1027 .chn_num = 1, /* one channels for tsadc */ 1165 1028 1166 1029 .tshut_mode = TSHUT_MODE_CRU, /* default TSHUT via CRU */ ··· 1184 1045 }; 1185 1046 1186 1047 static const struct rockchip_tsadc_chip rk3366_tsadc_data = { 1187 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 1188 - .chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */ 1048 + /* cpu, gpu */ 1049 + .chn_offset = 0, 1189 1050 .chn_num = 2, /* two channels for tsadc */ 1190 1051 1191 1052 .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ ··· 1209 1070 }; 1210 1071 1211 1072 static const struct rockchip_tsadc_chip rk3368_tsadc_data = { 1212 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 1213 - .chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */ 1073 + /* cpu, gpu */ 1074 + .chn_offset = 0, 1214 1075 .chn_num = 2, /* two channels for tsadc */ 1215 1076 1216 1077 .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ ··· 1234 1095 }; 1235 1096 1236 1097 static const struct rockchip_tsadc_chip rk3399_tsadc_data = { 1237 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 1238 - .chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */ 1098 + /* cpu, gpu */ 1099 + .chn_offset = 0, 1239 1100 .chn_num = 2, /* two channels for tsadc */ 1240 1101 1241 1102 .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ ··· 1259 1120 }; 1260 1121 1261 1122 static const struct rockchip_tsadc_chip rk3568_tsadc_data = { 1262 - .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ 1263 - .chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */ 1123 + /* cpu, gpu */ 1124 + .chn_offset = 0, 1264 1125 .chn_num = 2, /* two channels for tsadc */ 1265 1126 1266 1127 .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ ··· 1279 1140 .id = rk3568_code_table, 1280 1141 .length = ARRAY_SIZE(rk3568_code_table), 1281 1142 .data_mask = TSADCV2_DATA_MASK, 1143 + .mode = ADC_INCREMENT, 1144 + }, 1145 + }; 1146 + 1147 + static const struct rockchip_tsadc_chip rk3588_tsadc_data = { 1148 + /* top, big_core0, big_core1, little_core, center, gpu, npu */ 1149 + .chn_offset = 0, 1150 + .chn_num = 7, /* seven channels for tsadc */ 1151 + .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ 1152 + .tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */ 1153 + .tshut_temp = 95000, 1154 + .initialize = rk_tsadcv8_initialize, 1155 + .irq_ack = rk_tsadcv4_irq_ack, 1156 + .control = rk_tsadcv4_control, 1157 + .get_temp = rk_tsadcv4_get_temp, 1158 + .set_alarm_temp = rk_tsadcv3_alarm_temp, 1159 + .set_tshut_temp = rk_tsadcv3_tshut_temp, 1160 + .set_tshut_mode = rk_tsadcv3_tshut_mode, 1161 + .table = { 1162 + .id = rk3588_code_table, 1163 + .length = ARRAY_SIZE(rk3588_code_table), 1164 + .data_mask = TSADCV4_DATA_MASK, 1282 1165 .mode = ADC_INCREMENT, 1283 1166 }, 1284 1167 }; ··· 1341 1180 .compatible = "rockchip,rk3568-tsadc", 1342 1181 .data = (void *)&rk3568_tsadc_data, 1343 1182 }, 1183 + { 1184 + .compatible = "rockchip,rk3588-tsadc", 1185 + .data = (void *)&rk3588_tsadc_data, 1186 + }, 1344 1187 { /* end */ }, 1345 1188 }; 1346 1189 MODULE_DEVICE_TABLE(of, of_rockchip_thermal_match); ··· 1378 1213 1379 1214 static int rockchip_thermal_set_trips(struct thermal_zone_device *tz, int low, int high) 1380 1215 { 1381 - struct rockchip_thermal_sensor *sensor = tz->devdata; 1216 + struct rockchip_thermal_sensor *sensor = thermal_zone_device_priv(tz); 1382 1217 struct rockchip_thermal_data *thermal = sensor->thermal; 1383 1218 const struct rockchip_tsadc_chip *tsadc = thermal->chip; 1384 1219 ··· 1391 1226 1392 1227 static int rockchip_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp) 1393 1228 { 1394 - struct rockchip_thermal_sensor *sensor = tz->devdata; 1229 + struct rockchip_thermal_sensor *sensor = thermal_zone_device_priv(tz); 1395 1230 struct rockchip_thermal_data *thermal = sensor->thermal; 1396 1231 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip; 1397 1232 int retval; 1398 1233 1399 1234 retval = tsadc->get_temp(&tsadc->table, 1400 1235 sensor->id, thermal->regs, out_temp); 1401 - dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n", 1402 - sensor->id, *out_temp, retval); 1403 - 1404 1236 return retval; 1405 1237 } 1406 1238 ··· 1515 1353 { 1516 1354 struct device_node *np = pdev->dev.of_node; 1517 1355 struct rockchip_thermal_data *thermal; 1518 - const struct of_device_id *match; 1519 1356 int irq; 1520 1357 int i; 1521 1358 int error; 1522 - 1523 - match = of_match_node(of_rockchip_thermal_match, np); 1524 - if (!match) 1525 - return -ENXIO; 1526 1359 1527 1360 irq = platform_get_irq(pdev, 0); 1528 1361 if (irq < 0) ··· 1530 1373 1531 1374 thermal->pdev = pdev; 1532 1375 1533 - thermal->chip = (const struct rockchip_tsadc_chip *)match->data; 1376 + thermal->chip = device_get_match_data(&pdev->dev); 1534 1377 if (!thermal->chip) 1535 1378 return -EINVAL; 1379 + 1380 + thermal->sensors = devm_kcalloc(&pdev->dev, thermal->chip->chn_num, 1381 + sizeof(*thermal->sensors), GFP_KERNEL); 1382 + if (!thermal->sensors) 1383 + return -ENOMEM; 1536 1384 1537 1385 thermal->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 1538 1386 if (IS_ERR(thermal->regs)) 1539 1387 return PTR_ERR(thermal->regs); 1540 1388 1541 - thermal->reset = devm_reset_control_array_get(&pdev->dev, false, false); 1542 - if (IS_ERR(thermal->reset)) { 1543 - error = PTR_ERR(thermal->reset); 1544 - dev_err(&pdev->dev, "failed to get tsadc reset: %d\n", error); 1545 - return error; 1546 - } 1389 + thermal->reset = devm_reset_control_array_get_exclusive(&pdev->dev); 1390 + if (IS_ERR(thermal->reset)) 1391 + return dev_err_probe(&pdev->dev, PTR_ERR(thermal->reset), 1392 + "failed to get tsadc reset.\n"); 1547 1393 1548 - thermal->clk = devm_clk_get(&pdev->dev, "tsadc"); 1549 - if (IS_ERR(thermal->clk)) { 1550 - error = PTR_ERR(thermal->clk); 1551 - dev_err(&pdev->dev, "failed to get tsadc clock: %d\n", error); 1552 - return error; 1553 - } 1394 + thermal->clk = devm_clk_get_enabled(&pdev->dev, "tsadc"); 1395 + if (IS_ERR(thermal->clk)) 1396 + return dev_err_probe(&pdev->dev, PTR_ERR(thermal->clk), 1397 + "failed to get tsadc clock.\n"); 1554 1398 1555 - thermal->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); 1556 - if (IS_ERR(thermal->pclk)) { 1557 - error = PTR_ERR(thermal->pclk); 1558 - dev_err(&pdev->dev, "failed to get apb_pclk clock: %d\n", 1559 - error); 1560 - return error; 1561 - } 1562 - 1563 - error = clk_prepare_enable(thermal->clk); 1564 - if (error) { 1565 - dev_err(&pdev->dev, "failed to enable converter clock: %d\n", 1566 - error); 1567 - return error; 1568 - } 1569 - 1570 - error = clk_prepare_enable(thermal->pclk); 1571 - if (error) { 1572 - dev_err(&pdev->dev, "failed to enable pclk: %d\n", error); 1573 - goto err_disable_clk; 1574 - } 1399 + thermal->pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk"); 1400 + if (IS_ERR(thermal->pclk)) 1401 + return dev_err_probe(&pdev->dev, PTR_ERR(thermal->pclk), 1402 + "failed to get apb_pclk clock.\n"); 1575 1403 1576 1404 rockchip_thermal_reset_controller(thermal->reset); 1577 1405 1578 1406 error = rockchip_configure_from_dt(&pdev->dev, np, thermal); 1579 - if (error) { 1580 - dev_err(&pdev->dev, "failed to parse device tree data: %d\n", 1581 - error); 1582 - goto err_disable_pclk; 1583 - } 1407 + if (error) 1408 + return dev_err_probe(&pdev->dev, error, 1409 + "failed to parse device tree data\n"); 1584 1410 1585 1411 thermal->chip->initialize(thermal->grf, thermal->regs, 1586 1412 thermal->tshut_polarity); ··· 1571 1431 for (i = 0; i < thermal->chip->chn_num; i++) { 1572 1432 error = rockchip_thermal_register_sensor(pdev, thermal, 1573 1433 &thermal->sensors[i], 1574 - thermal->chip->chn_id[i]); 1575 - if (error) { 1576 - dev_err(&pdev->dev, 1577 - "failed to register sensor[%d] : error = %d\n", 1578 - i, error); 1579 - goto err_disable_pclk; 1580 - } 1434 + thermal->chip->chn_offset + i); 1435 + if (error) 1436 + return dev_err_probe(&pdev->dev, error, 1437 + "failed to register sensor[%d].\n", i); 1581 1438 } 1582 1439 1583 1440 error = devm_request_threaded_irq(&pdev->dev, irq, NULL, 1584 1441 &rockchip_thermal_alarm_irq_thread, 1585 1442 IRQF_ONESHOT, 1586 1443 "rockchip_thermal", thermal); 1587 - if (error) { 1588 - dev_err(&pdev->dev, 1589 - "failed to request tsadc irq: %d\n", error); 1590 - goto err_disable_pclk; 1591 - } 1444 + if (error) 1445 + return dev_err_probe(&pdev->dev, error, 1446 + "failed to request tsadc irq.\n"); 1592 1447 1593 1448 thermal->chip->control(thermal->regs, true); 1594 1449 1595 1450 for (i = 0; i < thermal->chip->chn_num; i++) { 1596 1451 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); 1597 - thermal->sensors[i].tzd->tzp->no_hwmon = false; 1598 1452 error = thermal_add_hwmon_sysfs(thermal->sensors[i].tzd); 1599 1453 if (error) 1600 1454 dev_warn(&pdev->dev, ··· 1599 1465 platform_set_drvdata(pdev, thermal); 1600 1466 1601 1467 return 0; 1602 - 1603 - err_disable_pclk: 1604 - clk_disable_unprepare(thermal->pclk); 1605 - err_disable_clk: 1606 - clk_disable_unprepare(thermal->clk); 1607 - 1608 - return error; 1609 1468 } 1610 1469 1611 1470 static int rockchip_thermal_remove(struct platform_device *pdev) ··· 1614 1487 } 1615 1488 1616 1489 thermal->chip->control(thermal->regs, false); 1617 - 1618 - clk_disable_unprepare(thermal->pclk); 1619 - clk_disable_unprepare(thermal->clk); 1620 1490 1621 1491 return 0; 1622 1492 }
+1 -2
drivers/thermal/rzg2l_thermal.c
··· 75 75 76 76 static int rzg2l_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 77 77 { 78 - struct rzg2l_thermal_priv *priv = tz->devdata; 78 + struct rzg2l_thermal_priv *priv = thermal_zone_device_priv(tz); 79 79 u32 result = 0, dsensor, ts_code_ave; 80 80 int val, i; 81 81 ··· 216 216 } 217 217 218 218 priv->zone = zone; 219 - priv->zone->tzp->no_hwmon = false; 220 219 ret = thermal_add_hwmon_sysfs(priv->zone); 221 220 if (ret) 222 221 goto err;
+2 -2
drivers/thermal/samsung/exynos_tmu.c
··· 645 645 646 646 static int exynos_get_temp(struct thermal_zone_device *tz, int *temp) 647 647 { 648 - struct exynos_tmu_data *data = tz->devdata; 648 + struct exynos_tmu_data *data = thermal_zone_device_priv(tz); 649 649 int value, ret = 0; 650 650 651 651 if (!data || !data->tmu_read) ··· 723 723 724 724 static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp) 725 725 { 726 - struct exynos_tmu_data *data = tz->devdata; 726 + struct exynos_tmu_data *data = thermal_zone_device_priv(tz); 727 727 int ret = -EINVAL; 728 728 729 729 if (data->soc == SOC_ARCH_EXYNOS4210)
+5 -5
drivers/thermal/spear_thermal.c
··· 31 31 static inline int thermal_get_temp(struct thermal_zone_device *thermal, 32 32 int *temp) 33 33 { 34 - struct spear_thermal_dev *stdev = thermal->devdata; 34 + struct spear_thermal_dev *stdev = thermal_zone_device_priv(thermal); 35 35 36 36 /* 37 37 * Data are ready to be read after 628 usec from POWERDOWN signal ··· 48 48 static int __maybe_unused spear_thermal_suspend(struct device *dev) 49 49 { 50 50 struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev); 51 - struct spear_thermal_dev *stdev = spear_thermal->devdata; 51 + struct spear_thermal_dev *stdev = thermal_zone_device_priv(spear_thermal); 52 52 unsigned int actual_mask = 0; 53 53 54 54 /* Disable SPEAr Thermal Sensor */ ··· 64 64 static int __maybe_unused spear_thermal_resume(struct device *dev) 65 65 { 66 66 struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev); 67 - struct spear_thermal_dev *stdev = spear_thermal->devdata; 67 + struct spear_thermal_dev *stdev = thermal_zone_device_priv(spear_thermal); 68 68 unsigned int actual_mask = 0; 69 69 int ret = 0; 70 70 ··· 137 137 138 138 platform_set_drvdata(pdev, spear_thermal); 139 139 140 - dev_info(&spear_thermal->device, "Thermal Sensor Loaded at: 0x%p.\n", 140 + dev_info(&pdev->dev, "Thermal Sensor Loaded at: 0x%p.\n", 141 141 stdev->thermal_base); 142 142 143 143 return 0; ··· 154 154 { 155 155 unsigned int actual_mask = 0; 156 156 struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev); 157 - struct spear_thermal_dev *stdev = spear_thermal->devdata; 157 + struct spear_thermal_dev *stdev = thermal_zone_device_priv(spear_thermal); 158 158 159 159 thermal_zone_device_unregister(spear_thermal); 160 160
+1 -1
drivers/thermal/sprd_thermal.c
··· 206 206 207 207 static int sprd_thm_read_temp(struct thermal_zone_device *tz, int *temp) 208 208 { 209 - struct sprd_thermal_sensor *sen = tz->devdata; 209 + struct sprd_thermal_sensor *sen = thermal_zone_device_priv(tz); 210 210 u32 data; 211 211 212 212 data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
+1 -4
drivers/thermal/st/st_thermal.c
··· 108 108 /* Callback to get temperature from HW*/ 109 109 static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature) 110 110 { 111 - struct st_thermal_sensor *sensor = th->devdata; 112 - struct device *dev = sensor->dev; 111 + struct st_thermal_sensor *sensor = thermal_zone_device_priv(th); 113 112 unsigned int temp; 114 113 unsigned int overflow; 115 114 int ret; ··· 125 126 126 127 temp += sensor->cdata->temp_adjust_val; 127 128 temp = mcelsius(temp); 128 - 129 - dev_dbg(dev, "temperature: %d\n", temp); 130 129 131 130 *temperature = temp; 132 131
+2 -3
drivers/thermal/st/stm_thermal.c
··· 303 303 304 304 static int stm_thermal_set_trips(struct thermal_zone_device *tz, int low, int high) 305 305 { 306 - struct stm_thermal_sensor *sensor = tz->devdata; 306 + struct stm_thermal_sensor *sensor = thermal_zone_device_priv(tz); 307 307 u32 itr1, th; 308 308 int ret; 309 309 ··· 351 351 /* Callback to get temperature from HW */ 352 352 static int stm_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 353 353 { 354 - struct stm_thermal_sensor *sensor = tz->devdata; 354 + struct stm_thermal_sensor *sensor = thermal_zone_device_priv(tz); 355 355 u32 periods; 356 356 int freqM, ret; 357 357 ··· 558 558 * Thermal_zone doesn't enable hwmon as default, 559 559 * enable it here 560 560 */ 561 - sensor->th_dev->tzp->no_hwmon = false; 562 561 ret = thermal_add_hwmon_sysfs(sensor->th_dev); 563 562 if (ret) 564 563 goto err_tz;
+2 -2
drivers/thermal/sun8i_thermal.c
··· 110 110 111 111 static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp) 112 112 { 113 - struct tsensor *s = tz->devdata; 113 + struct tsensor *s = thermal_zone_device_priv(tz); 114 114 struct ths_device *tmdev = s->tmdev; 115 115 int val = 0; 116 116 ··· 475 475 if (IS_ERR(tmdev->sensor[i].tzd)) 476 476 return PTR_ERR(tmdev->sensor[i].tzd); 477 477 478 - if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd)) 478 + if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd)) 479 479 dev_warn(tmdev->dev, 480 480 "Failed to add hwmon sysfs attributes\n"); 481 481 }
+3 -3
drivers/thermal/tegra/soctherm.c
··· 423 423 424 424 static int tegra_thermctl_get_temp(struct thermal_zone_device *tz, int *out_temp) 425 425 { 426 - struct tegra_thermctl_zone *zone = tz->devdata; 426 + struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz); 427 427 u32 val; 428 428 429 429 val = readl(zone->reg); ··· 584 584 585 585 static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp) 586 586 { 587 - struct tegra_thermctl_zone *zone = tz->devdata; 587 + struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz); 588 588 struct tegra_soctherm *ts = zone->ts; 589 589 struct thermal_trip trip; 590 590 const struct tegra_tsensor_group *sg = zone->sg; ··· 658 658 659 659 static int tegra_thermctl_set_trips(struct thermal_zone_device *tz, int lo, int hi) 660 660 { 661 - struct tegra_thermctl_zone *zone = tz->devdata; 661 + struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz); 662 662 u32 r; 663 663 664 664 thermal_irq_disable(zone);
+12 -3
drivers/thermal/tegra/tegra-bpmp-thermal.c
··· 52 52 err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg); 53 53 if (err) 54 54 return err; 55 + if (msg.rx.ret == -BPMP_EFAULT) 56 + return -EAGAIN; 55 57 if (msg.rx.ret) 56 58 return -EINVAL; 57 59 ··· 64 62 65 63 static int tegra_bpmp_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp) 66 64 { 67 - return __tegra_bpmp_thermal_get_temp(tz->devdata, out_temp); 65 + struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_priv(tz); 66 + 67 + return __tegra_bpmp_thermal_get_temp(zone, out_temp); 68 68 } 69 69 70 70 static int tegra_bpmp_thermal_set_trips(struct thermal_zone_device *tz, int low, int high) 71 71 { 72 - struct tegra_bpmp_thermal_zone *zone = tz->devdata; 72 + struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_priv(tz); 73 73 struct mrq_thermal_host_to_bpmp_request req; 74 74 struct tegra_bpmp_message msg; 75 75 int err; ··· 211 207 zone->tegra = tegra; 212 208 213 209 err = __tegra_bpmp_thermal_get_temp(zone, &temp); 214 - if (err < 0) { 210 + 211 + /* 212 + * Sensors in powergated domains may temporarily fail to be read 213 + * (-EAGAIN), but will become accessible when the domain is powered on. 214 + */ 215 + if (err < 0 && err != -EAGAIN) { 215 216 devm_kfree(&pdev->dev, zone); 216 217 continue; 217 218 }
+17 -14
drivers/thermal/tegra/tegra30-tsensor.c
··· 160 160 161 161 static int tegra_tsensor_get_temp(struct thermal_zone_device *tz, int *temp) 162 162 { 163 - const struct tegra_tsensor_channel *tsc = tz->devdata; 163 + const struct tegra_tsensor_channel *tsc = thermal_zone_device_priv(tz); 164 164 const struct tegra_tsensor *ts = tsc->ts; 165 165 int err, c1, c2, c3, c4, counter; 166 166 u32 val; ··· 218 218 219 219 static int tegra_tsensor_set_trips(struct thermal_zone_device *tz, int low, int high) 220 220 { 221 - const struct tegra_tsensor_channel *tsc = tz->devdata; 221 + const struct tegra_tsensor_channel *tsc = thermal_zone_device_priv(tz); 222 222 const struct tegra_tsensor *ts = tsc->ts; 223 223 u32 val; 224 224 ··· 359 359 360 360 tegra_tsensor_get_hw_channel_trips(tzd, &hot_trip, &crit_trip); 361 361 362 - /* prevent potential racing with tegra_tsensor_set_trips() */ 363 - mutex_lock(&tzd->lock); 364 - 365 362 dev_info_once(ts->dev, "ch%u: PMC emergency shutdown trip set to %dC\n", 366 363 id, DIV_ROUND_CLOSEST(crit_trip, 1000)); 367 364 ··· 400 403 val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG0_INTR_HW_FREQ_DIV_EN, 1); 401 404 val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG0_INTR_THERMAL_RST_EN, 1); 402 405 writel_relaxed(val, tsc->regs + TSENSOR_SENSOR0_CONFIG0); 403 - 404 - mutex_unlock(&tzd->lock); 405 406 406 407 err = thermal_zone_device_enable(tzd); 407 408 if (err) { ··· 523 528 return 0; 524 529 } 525 530 526 - if (devm_thermal_add_hwmon_sysfs(tsc->tzd)) 531 + if (devm_thermal_add_hwmon_sysfs(ts->dev, tsc->tzd)) 527 532 dev_warn(ts->dev, "failed to add hwmon sysfs attributes\n"); 528 533 529 534 return 0; ··· 580 585 return err; 581 586 } 582 587 588 + /* 589 + * Enable the channels before setting the interrupt so 590 + * set_trips() can not be called while we are setting up the 591 + * register TSENSOR_SENSOR0_CONFIG1. With this we close a 592 + * potential race window where we are setting up the TH2 and 593 + * the temperature hits TH1 resulting to an update of the 594 + * TSENSOR_SENSOR0_CONFIG1 register in the ISR. 595 + */ 596 + for (i = 0; i < ARRAY_SIZE(ts->ch); i++) { 597 + err = tegra_tsensor_enable_hw_channel(ts, i); 598 + if (err) 599 + return err; 600 + } 601 + 583 602 err = devm_request_threaded_irq(&pdev->dev, irq, NULL, 584 603 tegra_tsensor_isr, IRQF_ONESHOT, 585 604 "tegra_tsensor", ts); 586 605 if (err) 587 606 return dev_err_probe(&pdev->dev, err, 588 607 "failed to request interrupt\n"); 589 - 590 - for (i = 0; i < ARRAY_SIZE(ts->ch); i++) { 591 - err = tegra_tsensor_enable_hw_channel(ts, i); 592 - if (err) 593 - return err; 594 - } 595 608 596 609 return 0; 597 610 }
+3 -4
drivers/thermal/thermal-generic-adc.c
··· 54 54 55 55 static int gadc_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 56 56 { 57 - struct gadc_thermal_info *gti = tz->devdata; 57 + struct gadc_thermal_info *gti = thermal_zone_device_priv(tz); 58 58 int val; 59 59 int ret; 60 60 61 61 ret = iio_read_channel_processed(gti->channel, &val); 62 - if (ret < 0) { 63 - dev_err(gti->dev, "IIO channel read failed %d\n", ret); 62 + if (ret < 0) 64 63 return ret; 65 - } 64 + 66 65 *temp = gadc_thermal_adc_to_temp(gti, val); 67 66 68 67 return 0;
+45 -127
drivers/thermal/thermal_core.c
··· 22 22 #include <linux/suspend.h> 23 23 24 24 #define CREATE_TRACE_POINTS 25 - #include <trace/events/thermal.h> 25 + #include "thermal_trace.h" 26 26 27 27 #include "thermal_core.h" 28 28 #include "thermal_hwmon.h" ··· 794 794 tz->type, cdev->type, ret); 795 795 } 796 796 797 - static void __bind(struct thermal_zone_device *tz, int mask, 798 - struct thermal_cooling_device *cdev, 799 - unsigned long *limits, 800 - unsigned int weight) 801 - { 802 - int i, ret; 803 - 804 - for (i = 0; i < tz->num_trips; i++) { 805 - if (mask & (1 << i)) { 806 - unsigned long upper, lower; 807 - 808 - upper = THERMAL_NO_LIMIT; 809 - lower = THERMAL_NO_LIMIT; 810 - if (limits) { 811 - lower = limits[i * 2]; 812 - upper = limits[i * 2 + 1]; 813 - } 814 - ret = thermal_zone_bind_cooling_device(tz, i, cdev, 815 - upper, lower, 816 - weight); 817 - if (ret) 818 - print_bind_err_msg(tz, cdev, ret); 819 - } 820 - } 821 - } 822 - 823 797 static void bind_cdev(struct thermal_cooling_device *cdev) 824 798 { 825 - int i, ret; 826 - const struct thermal_zone_params *tzp; 799 + int ret; 827 800 struct thermal_zone_device *pos = NULL; 828 801 829 - mutex_lock(&thermal_list_lock); 830 - 831 802 list_for_each_entry(pos, &thermal_tz_list, node) { 832 - if (!pos->tzp && !pos->ops->bind) 833 - continue; 834 - 835 803 if (pos->ops->bind) { 836 804 ret = pos->ops->bind(pos, cdev); 837 805 if (ret) 838 806 print_bind_err_msg(pos, cdev, ret); 839 - continue; 840 - } 841 - 842 - tzp = pos->tzp; 843 - if (!tzp || !tzp->tbp) 844 - continue; 845 - 846 - for (i = 0; i < tzp->num_tbps; i++) { 847 - if (tzp->tbp[i].cdev || !tzp->tbp[i].match) 848 - continue; 849 - if (tzp->tbp[i].match(pos, cdev)) 850 - continue; 851 - tzp->tbp[i].cdev = cdev; 852 - __bind(pos, tzp->tbp[i].trip_mask, cdev, 853 - tzp->tbp[i].binding_limits, 854 - tzp->tbp[i].weight); 855 807 } 856 808 } 857 - 858 - mutex_unlock(&thermal_list_lock); 859 809 } 860 810 861 811 /** ··· 883 933 884 934 /* Add 'this' new cdev to the global cdev list */ 885 935 mutex_lock(&thermal_list_lock); 936 + 886 937 list_add(&cdev->node, &thermal_cdev_list); 887 - mutex_unlock(&thermal_list_lock); 888 938 889 939 /* Update binding information for 'this' new cdev */ 890 940 bind_cdev(cdev); 891 941 892 - mutex_lock(&thermal_list_lock); 893 942 list_for_each_entry(pos, &thermal_tz_list, node) 894 943 if (atomic_cmpxchg(&pos->need_update, 1, 0)) 895 944 thermal_zone_device_update(pos, 896 945 THERMAL_EVENT_UNSPECIFIED); 946 + 897 947 mutex_unlock(&thermal_list_lock); 898 948 899 949 return cdev; ··· 1088 1138 } 1089 1139 EXPORT_SYMBOL_GPL(thermal_cooling_device_update); 1090 1140 1091 - static void __unbind(struct thermal_zone_device *tz, int mask, 1092 - struct thermal_cooling_device *cdev) 1093 - { 1094 - int i; 1095 - 1096 - for (i = 0; i < tz->num_trips; i++) 1097 - if (mask & (1 << i)) 1098 - thermal_zone_unbind_cooling_device(tz, i, cdev); 1099 - } 1100 - 1101 1141 /** 1102 1142 * thermal_cooling_device_unregister - removes a thermal cooling device 1103 1143 * @cdev: the thermal cooling device to remove. ··· 1097 1157 */ 1098 1158 void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) 1099 1159 { 1100 - int i; 1101 - const struct thermal_zone_params *tzp; 1102 1160 struct thermal_zone_device *tz; 1103 1161 1104 1162 if (!cdev) ··· 1113 1175 1114 1176 /* Unbind all thermal zones associated with 'this' cdev */ 1115 1177 list_for_each_entry(tz, &thermal_tz_list, node) { 1116 - if (tz->ops->unbind) { 1178 + if (tz->ops->unbind) 1117 1179 tz->ops->unbind(tz, cdev); 1118 - continue; 1119 - } 1120 - 1121 - if (!tz->tzp || !tz->tzp->tbp) 1122 - continue; 1123 - 1124 - tzp = tz->tzp; 1125 - for (i = 0; i < tzp->num_tbps; i++) { 1126 - if (tzp->tbp[i].cdev == cdev) { 1127 - __unbind(tz, tzp->tbp[i].trip_mask, cdev); 1128 - tzp->tbp[i].cdev = NULL; 1129 - } 1130 - } 1131 1180 } 1132 1181 1133 1182 mutex_unlock(&thermal_list_lock); ··· 1125 1200 1126 1201 static void bind_tz(struct thermal_zone_device *tz) 1127 1202 { 1128 - int i, ret; 1203 + int ret; 1129 1204 struct thermal_cooling_device *pos = NULL; 1130 - const struct thermal_zone_params *tzp = tz->tzp; 1131 1205 1132 - if (!tzp && !tz->ops->bind) 1206 + if (!tz->ops->bind) 1133 1207 return; 1134 1208 1135 1209 mutex_lock(&thermal_list_lock); 1136 1210 1137 - /* If there is ops->bind, try to use ops->bind */ 1138 - if (tz->ops->bind) { 1139 - list_for_each_entry(pos, &thermal_cdev_list, node) { 1140 - ret = tz->ops->bind(tz, pos); 1141 - if (ret) 1142 - print_bind_err_msg(tz, pos, ret); 1143 - } 1144 - goto exit; 1145 - } 1146 - 1147 - if (!tzp || !tzp->tbp) 1148 - goto exit; 1149 - 1150 1211 list_for_each_entry(pos, &thermal_cdev_list, node) { 1151 - for (i = 0; i < tzp->num_tbps; i++) { 1152 - if (tzp->tbp[i].cdev || !tzp->tbp[i].match) 1153 - continue; 1154 - if (tzp->tbp[i].match(tz, pos)) 1155 - continue; 1156 - tzp->tbp[i].cdev = pos; 1157 - __bind(tz, tzp->tbp[i].trip_mask, pos, 1158 - tzp->tbp[i].binding_limits, 1159 - tzp->tbp[i].weight); 1160 - } 1212 + ret = tz->ops->bind(tz, pos); 1213 + if (ret) 1214 + print_bind_err_msg(tz, pos, ret); 1161 1215 } 1162 - exit: 1216 + 1163 1217 mutex_unlock(&thermal_list_lock); 1164 1218 } 1165 1219 ··· 1256 1352 if (!tz) 1257 1353 return ERR_PTR(-ENOMEM); 1258 1354 1355 + if (tzp) { 1356 + tz->tzp = kmemdup(tzp, sizeof(*tzp), GFP_KERNEL); 1357 + if (!tz->tzp) { 1358 + result = -ENOMEM; 1359 + goto free_tz; 1360 + } 1361 + } 1362 + 1259 1363 INIT_LIST_HEAD(&tz->thermal_instances); 1260 1364 ida_init(&tz->ida); 1261 1365 mutex_init(&tz->lock); 1262 1366 id = ida_alloc(&thermal_tz_ida, GFP_KERNEL); 1263 1367 if (id < 0) { 1264 1368 result = id; 1265 - goto free_tz; 1369 + goto free_tzp; 1266 1370 } 1267 1371 1268 1372 tz->id = id; ··· 1280 1368 ops->critical = thermal_zone_device_critical; 1281 1369 1282 1370 tz->ops = ops; 1283 - tz->tzp = tzp; 1284 1371 tz->device.class = thermal_class; 1285 1372 tz->devdata = devdata; 1286 1373 tz->trips = trips; ··· 1361 1450 tz = NULL; 1362 1451 remove_id: 1363 1452 ida_free(&thermal_tz_ida, id); 1453 + free_tzp: 1454 + kfree(tz->tzp); 1364 1455 free_tz: 1365 1456 kfree(tz); 1366 1457 return ERR_PTR(result); ··· 1380 1467 } 1381 1468 EXPORT_SYMBOL_GPL(thermal_zone_device_register); 1382 1469 1470 + void *thermal_zone_device_priv(struct thermal_zone_device *tzd) 1471 + { 1472 + return tzd->devdata; 1473 + } 1474 + EXPORT_SYMBOL_GPL(thermal_zone_device_priv); 1475 + 1476 + const char *thermal_zone_device_type(struct thermal_zone_device *tzd) 1477 + { 1478 + return tzd->type; 1479 + } 1480 + EXPORT_SYMBOL_GPL(thermal_zone_device_type); 1481 + 1482 + int thermal_zone_device_id(struct thermal_zone_device *tzd) 1483 + { 1484 + return tzd->id; 1485 + } 1486 + EXPORT_SYMBOL_GPL(thermal_zone_device_id); 1487 + 1383 1488 /** 1384 1489 * thermal_zone_device_unregister - removes the registered thermal zone device 1385 1490 * @tz: the thermal zone device to remove 1386 1491 */ 1387 1492 void thermal_zone_device_unregister(struct thermal_zone_device *tz) 1388 1493 { 1389 - int i, tz_id; 1390 - const struct thermal_zone_params *tzp; 1494 + int tz_id; 1391 1495 struct thermal_cooling_device *cdev; 1392 1496 struct thermal_zone_device *pos = NULL; 1393 1497 1394 1498 if (!tz) 1395 1499 return; 1396 1500 1397 - tzp = tz->tzp; 1398 1501 tz_id = tz->id; 1399 1502 1400 1503 mutex_lock(&thermal_list_lock); ··· 1425 1496 list_del(&tz->node); 1426 1497 1427 1498 /* Unbind all cdevs associated with 'this' thermal zone */ 1428 - list_for_each_entry(cdev, &thermal_cdev_list, node) { 1429 - if (tz->ops->unbind) { 1499 + list_for_each_entry(cdev, &thermal_cdev_list, node) 1500 + if (tz->ops->unbind) 1430 1501 tz->ops->unbind(tz, cdev); 1431 - continue; 1432 - } 1433 - 1434 - if (!tzp || !tzp->tbp) 1435 - break; 1436 - 1437 - for (i = 0; i < tzp->num_tbps; i++) { 1438 - if (tzp->tbp[i].cdev == cdev) { 1439 - __unbind(tz, tzp->tbp[i].trip_mask, cdev); 1440 - tzp->tbp[i].cdev = NULL; 1441 - } 1442 - } 1443 - } 1444 1502 1445 1503 mutex_unlock(&thermal_list_lock); 1446 1504 ··· 1442 1526 mutex_lock(&tz->lock); 1443 1527 device_del(&tz->device); 1444 1528 mutex_unlock(&tz->lock); 1529 + 1530 + kfree(tz->tzp); 1445 1531 1446 1532 put_device(&tz->device); 1447 1533
+4 -2
drivers/thermal/thermal_helpers.c
··· 19 19 #include <linux/string.h> 20 20 #include <linux/sysfs.h> 21 21 22 - #include <trace/events/thermal.h> 23 - 24 22 #include "thermal_core.h" 23 + #include "thermal_trace.h" 25 24 26 25 int get_tz_trend(struct thermal_zone_device *tz, int trip) 27 26 { ··· 105 106 if (!ret && *temp < crit_temp) 106 107 *temp = tz->emul_temperature; 107 108 } 109 + 110 + if (ret) 111 + dev_dbg(&tz->device, "Failed to get temperature: %d\n", ret); 108 112 109 113 return ret; 110 114 }
+3 -2
drivers/thermal/thermal_hwmon.c
··· 17 17 #include <linux/thermal.h> 18 18 19 19 #include "thermal_hwmon.h" 20 + #include "thermal_core.h" 20 21 21 22 /* hwmon sys I/F */ 22 23 /* thermal zone devices with the same type share one hwmon device */ ··· 264 263 thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res); 265 264 } 266 265 267 - int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) 266 + int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz) 268 267 { 269 268 struct thermal_zone_device **ptr; 270 269 int ret; ··· 281 280 } 282 281 283 282 *ptr = tz; 284 - devres_add(&tz->device, ptr); 283 + devres_add(dev, ptr); 285 284 286 285 return ret; 287 286 }
+2 -2
drivers/thermal/thermal_hwmon.h
··· 17 17 18 18 #ifdef CONFIG_THERMAL_HWMON 19 19 int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz); 20 - int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz); 20 + int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz); 21 21 void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz); 22 22 #else 23 23 static inline int ··· 27 27 } 28 28 29 29 static inline int 30 - devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) 30 + devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz) 31 31 { 32 32 return 0; 33 33 }
+1 -1
drivers/thermal/thermal_mmio.c
··· 23 23 static int thermal_mmio_get_temperature(struct thermal_zone_device *tz, int *temp) 24 24 { 25 25 int t; 26 - struct thermal_mmio *sensor = tz->devdata; 26 + struct thermal_mmio *sensor = thermal_zone_device_priv(tz); 27 27 28 28 t = sensor->read_mmio(sensor->mmio_base) & sensor->mask; 29 29 t *= sensor->factor;
+3 -5
drivers/thermal/thermal_of.c
··· 439 439 * 440 440 * @tz: a pointer to the thermal zone structure 441 441 */ 442 - void thermal_of_zone_unregister(struct thermal_zone_device *tz) 442 + static void thermal_of_zone_unregister(struct thermal_zone_device *tz) 443 443 { 444 444 struct thermal_trip *trips = tz->trips; 445 445 struct thermal_zone_params *tzp = tz->tzp; ··· 451 451 kfree(tzp); 452 452 kfree(ops); 453 453 } 454 - EXPORT_SYMBOL_GPL(thermal_of_zone_unregister); 455 454 456 455 /** 457 456 * thermal_of_zone_register - Register a thermal zone with device node ··· 472 473 * - ENOMEM: if one structure can not be allocated 473 474 * - Other negative errors are returned by the underlying called functions 474 475 */ 475 - struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, 476 - const struct thermal_zone_device_ops *ops) 476 + static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, 477 + const struct thermal_zone_device_ops *ops) 477 478 { 478 479 struct thermal_zone_device *tz; 479 480 struct thermal_trip *trips; ··· 549 550 550 551 return ERR_PTR(ret); 551 552 } 552 - EXPORT_SYMBOL_GPL(thermal_of_zone_register); 553 553 554 554 static void devm_thermal_of_zone_release(struct device *dev, void *res) 555 555 {
+10 -10
drivers/thermal/ti-soc-thermal/ti-thermal-common.c
··· 23 23 #include "ti-bandgap.h" 24 24 #include "../thermal_hwmon.h" 25 25 26 + #define TI_BANDGAP_UPDATE_INTERVAL_MS 250 27 + 26 28 /* common data structures */ 27 29 struct ti_thermal_data { 28 30 struct cpufreq_policy *policy; ··· 45 43 46 44 thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED); 47 45 48 - dev_dbg(&data->ti_thermal->device, "updated thermal zone %s\n", 49 - data->ti_thermal->type); 46 + dev_dbg(data->bgp->dev, "updated thermal zone %s\n", 47 + thermal_zone_device_type(data->ti_thermal)); 50 48 } 51 49 52 50 /** ··· 70 68 static inline int __ti_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 71 69 { 72 70 struct thermal_zone_device *pcb_tz = NULL; 73 - struct ti_thermal_data *data = tz->devdata; 71 + struct ti_thermal_data *data = thermal_zone_device_priv(tz); 74 72 struct ti_bandgap *bgp; 75 73 const struct ti_temp_sensor *s; 76 74 int ret, tmp, slope, constant; ··· 111 109 112 110 static int __ti_thermal_get_trend(struct thermal_zone_device *tz, int trip, enum thermal_trend *trend) 113 111 { 114 - struct ti_thermal_data *data = tz->devdata; 112 + struct ti_thermal_data *data = thermal_zone_device_priv(tz); 115 113 struct ti_bandgap *bgp; 116 114 int id, tr, ret = 0; 117 115 ··· 161 159 char *domain) 162 160 { 163 161 struct ti_thermal_data *data; 164 - int interval; 165 162 166 163 data = ti_bandgap_get_sensor_data(bgp, id); 167 164 ··· 178 177 return PTR_ERR(data->ti_thermal); 179 178 } 180 179 181 - interval = jiffies_to_msecs(data->ti_thermal->polling_delay_jiffies); 182 - 183 180 ti_bandgap_set_sensor_data(bgp, id, data); 184 - ti_bandgap_write_update_interval(bgp, data->sensor_id, interval); 181 + ti_bandgap_write_update_interval(bgp, data->sensor_id, 182 + TI_BANDGAP_UPDATE_INTERVAL_MS); 185 183 186 - if (devm_thermal_add_hwmon_sysfs(data->ti_thermal)) 184 + if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal)) 187 185 dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n"); 188 186 189 187 return 0; ··· 223 223 * using DT, then it must be aware that the cooling device 224 224 * loading has to happen via cpufreq driver. 225 225 */ 226 - if (of_find_property(np, "#thermal-sensor-cells", NULL)) 226 + if (of_property_present(np, "#thermal-sensor-cells")) 227 227 return 0; 228 228 229 229 data = ti_bandgap_get_sensor_data(bgp, id);
+1 -1
drivers/thermal/uniphier_thermal.c
··· 187 187 188 188 static int uniphier_tm_get_temp(struct thermal_zone_device *tz, int *out_temp) 189 189 { 190 - struct uniphier_tm_dev *tdev = tz->devdata; 190 + struct uniphier_tm_dev *tdev = thermal_zone_device_priv(tz); 191 191 struct regmap *map = tdev->regmap; 192 192 int ret; 193 193 u32 temp;
+10
include/dt-bindings/thermal/mediatek,lvts-thermal.h
··· 16 16 #define MT8195_MCU_LITTLE_CPU2 6 17 17 #define MT8195_MCU_LITTLE_CPU3 7 18 18 19 + #define MT8195_AP_VPU0 8 20 + #define MT8195_AP_VPU1 9 21 + #define MT8195_AP_GPU0 10 22 + #define MT8195_AP_GPU1 11 23 + #define MT8195_AP_VDEC 12 24 + #define MT8195_AP_IMG 13 25 + #define MT8195_AP_INFRA 14 26 + #define MT8195_AP_CAM0 15 27 + #define MT8195_AP_CAM1 16 28 + 19 29 #endif /* __MEDIATEK_LVTS_DT_H */
+19 -55
include/linux/thermal.h
··· 207 207 struct list_head governor_list; 208 208 }; 209 209 210 - /* Structure that holds binding parameters for a zone */ 211 - struct thermal_bind_params { 212 - struct thermal_cooling_device *cdev; 213 - 214 - /* 215 - * This is a measure of 'how effectively these devices can 216 - * cool 'this' thermal zone. It shall be determined by 217 - * platform characterization. This value is relative to the 218 - * rest of the weights so a cooling device whose weight is 219 - * double that of another cooling device is twice as 220 - * effective. See Documentation/driver-api/thermal/sysfs-api.rst for more 221 - * information. 222 - */ 223 - int weight; 224 - 225 - /* 226 - * This is a bit mask that gives the binding relation between this 227 - * thermal zone and cdev, for a particular trip point. 228 - * See Documentation/driver-api/thermal/sysfs-api.rst for more information. 229 - */ 230 - int trip_mask; 231 - 232 - /* 233 - * This is an array of cooling state limits. Must have exactly 234 - * 2 * thermal_zone.number_of_trip_points. It is an array consisting 235 - * of tuples <lower-state upper-state> of state limits. Each trip 236 - * will be associated with one state limit tuple when binding. 237 - * A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> 238 - * on all trips. 239 - */ 240 - unsigned long *binding_limits; 241 - int (*match) (struct thermal_zone_device *tz, 242 - struct thermal_cooling_device *cdev); 243 - }; 244 - 245 210 /* Structure to define Thermal Zone parameters */ 246 211 struct thermal_zone_params { 247 212 char governor_name[THERMAL_NAME_LENGTH]; ··· 217 252 * will be created. when no_hwmon == true, nothing will be done 218 253 */ 219 254 bool no_hwmon; 220 - 221 - int num_tbps; /* Number of tbp entries */ 222 - struct thermal_bind_params *tbp; 223 255 224 256 /* 225 257 * Sustainable power (heat) that this thermal zone can dissipate in ··· 259 297 260 298 /* Function declarations */ 261 299 #ifdef CONFIG_THERMAL_OF 262 - struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, 263 - const struct thermal_zone_device_ops *ops); 264 - 265 300 struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data, 266 301 const struct thermal_zone_device_ops *ops); 267 302 268 - void thermal_of_zone_unregister(struct thermal_zone_device *tz); 269 - 270 303 void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz); 271 304 272 - void thermal_of_zone_unregister(struct thermal_zone_device *tz); 273 - 274 305 #else 275 - static inline 276 - struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, 277 - const struct thermal_zone_device_ops *ops) 278 - { 279 - return ERR_PTR(-ENOTSUPP); 280 - } 281 306 282 307 static inline 283 308 struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data, 284 309 const struct thermal_zone_device_ops *ops) 285 310 { 286 311 return ERR_PTR(-ENOTSUPP); 287 - } 288 - 289 - static inline void thermal_of_zone_unregister(struct thermal_zone_device *tz) 290 - { 291 312 } 292 313 293 314 static inline void devm_thermal_of_zone_unregister(struct device *dev, ··· 309 364 thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int, int, 310 365 void *, struct thermal_zone_device_ops *, 311 366 struct thermal_zone_params *, int, int); 367 + 368 + void *thermal_zone_device_priv(struct thermal_zone_device *tzd); 369 + const char *thermal_zone_device_type(struct thermal_zone_device *tzd); 370 + int thermal_zone_device_id(struct thermal_zone_device *tzd); 312 371 313 372 int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, 314 373 struct thermal_cooling_device *, ··· 385 436 static inline int thermal_zone_get_offset( 386 437 struct thermal_zone_device *tz) 387 438 { return -ENODEV; } 439 + 440 + static inline void *thermal_zone_device_priv(struct thermal_zone_device *tz) 441 + { 442 + return NULL; 443 + } 444 + 445 + static inline const char *thermal_zone_device_type(struct thermal_zone_device *tzd) 446 + { 447 + return NULL; 448 + } 449 + 450 + static inline int thermal_zone_device_id(struct thermal_zone_device *tzd) 451 + { 452 + return -ENODEV; 453 + } 388 454 389 455 static inline int thermal_zone_device_enable(struct thermal_zone_device *tz) 390 456 { return -ENODEV; }
+6
include/trace/events/thermal.h drivers/thermal/thermal_trace.h
··· 195 195 #endif /* CONFIG_DEVFREQ_THERMAL */ 196 196 #endif /* _TRACE_THERMAL_H */ 197 197 198 + #undef TRACE_INCLUDE_PATH 199 + #define TRACE_INCLUDE_PATH . 200 + 201 + #undef TRACE_INCLUDE_FILE 202 + #define TRACE_INCLUDE_FILE thermal_trace 203 + 198 204 /* This part must be outside protection */ 199 205 #include <trace/define_trace.h>
+6
include/trace/events/thermal_power_allocator.h drivers/thermal/thermal_trace_ipa.h
··· 84 84 ); 85 85 #endif /* _TRACE_THERMAL_POWER_ALLOCATOR_H */ 86 86 87 + #undef TRACE_INCLUDE_PATH 88 + #define TRACE_INCLUDE_PATH . 89 + 90 + #undef TRACE_INCLUDE_FILE 91 + #define TRACE_INCLUDE_FILE thermal_trace_ipa 92 + 87 93 /* This part must be outside protection */ 88 94 #include <trace/define_trace.h>