Lines Matching +full:thermal +full:- +full:zones
1 // SPDX-License-Identifier: GPL-2.0
3 * of-thermal.c - Generic Thermal Management device tree support.
15 #include <linux/thermal.h>
24 * It maps 'enum thermal_trip_type' found in include/linux/thermal.h
35 * thermal_of_get_trip_type - Get phy mode for given device_node
60 return -ENODEV; in thermal_of_get_trip_type()
74 trip->temperature = prop; in thermal_of_populate_trip()
81 trip->hysteresis = prop; in thermal_of_populate_trip()
83 ret = thermal_of_get_trip_type(np, &trip->type); in thermal_of_populate_trip()
89 trip->flags = THERMAL_TRIP_FLAG_RW_TEMP; in thermal_of_populate_trip()
91 trip->priv = np; in thermal_of_populate_trip()
105 return ERR_PTR(-EINVAL); in thermal_of_trips_init()
111 ret = -EINVAL; in thermal_of_trips_init()
117 ret = -ENOMEM; in thermal_of_trips_init()
148 np = of_find_node_by_name(NULL, "thermal-zones"); in of_thermal_zone_find()
150 pr_debug("No thermal zones description\n"); in of_thermal_zone_find()
151 return ERR_PTR(-ENODEV); in of_thermal_zone_find()
155 * Search for each thermal zone, a defined sensor in of_thermal_zone_find()
162 count = of_count_phandle_with_args(child, "thermal-sensors", in of_thermal_zone_find()
163 "#thermal-sensor-cells"); in of_thermal_zone_find()
165 pr_err("%pOFn: missing thermal sensor\n", child); in of_thermal_zone_find()
166 tz = ERR_PTR(-EINVAL); in of_thermal_zone_find()
174 ret = of_parse_phandle_with_args(child, "thermal-sensors", in of_thermal_zone_find()
175 "#thermal-sensor-cells", in of_thermal_zone_find()
178 pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", child, ret); in of_thermal_zone_find()
191 tz = ERR_PTR(-ENODEV); in of_thermal_zone_find()
201 ret = of_property_read_u32(np, "polling-delay-passive", pdelay); in thermal_of_monitor_init()
202 if (ret == -EINVAL) { in thermal_of_monitor_init()
205 pr_err("%pOFn: Couldn't get polling-delay-passive: %d\n", np, ret); in thermal_of_monitor_init()
209 ret = of_property_read_u32(np, "polling-delay", delay); in thermal_of_monitor_init()
210 if (ret == -EINVAL) { in thermal_of_monitor_init()
213 pr_err("%pOFn: Couldn't get polling-delay: %d\n", np, ret); in thermal_of_monitor_init()
227 tzp->no_hwmon = true; in thermal_of_parameters_init()
229 if (!of_property_read_u32(np, "sustainable-power", &prop)) in thermal_of_parameters_init()
230 tzp->sustainable_power = prop; in thermal_of_parameters_init()
233 * For now, the thermal framework supports only one sensor per in thermal_of_parameters_init()
234 * thermal zone. Thus, we are considering only the first two in thermal_of_parameters_init()
243 tzp->slope = coef[0]; in thermal_of_parameters_init()
244 tzp->offset = coef[1]; in thermal_of_parameters_init()
251 np = of_find_node_by_name(NULL, "thermal-zones"); in thermal_of_zone_get_by_name()
253 return ERR_PTR(-ENODEV); in thermal_of_zone_get_by_name()
255 tz_np = of_get_child_by_name(np, tz->type); in thermal_of_zone_get_by_name()
260 return ERR_PTR(-ENODEV); in thermal_of_zone_get_by_name()
274 ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells", in thermal_of_get_cooling_spec()
278 pr_err("Invalid cooling-device entry\n"); in thermal_of_get_cooling_spec()
289 if (cooling_spec.np != cdev->np) in thermal_of_get_cooling_spec()
292 c->lower = cooling_spec.args[0]; in thermal_of_get_cooling_spec()
293 c->upper = cooling_spec.args[1]; in thermal_of_get_cooling_spec()
294 c->weight = weight; in thermal_of_get_cooling_spec()
313 cm_np = of_get_child_by_name(tz_np, "cooling-maps"); in thermal_of_should_bind()
323 if (tr_np != trip->priv) in thermal_of_should_bind()
327 count = of_count_phandle_with_args(child, "cooling-device", "#cooling-cells"); in thermal_of_should_bind()
349 * thermal_of_zone_unregister - Cleanup the specific allocated ressources
351 * This function disables the thermal zone and frees the different
352 * ressources allocated specific to the thermal OF.
354 * @tz: a pointer to the thermal zone structure
363 * thermal_of_zone_register - Register a thermal zone with device node
367 * node sensor and identifier. It searches for the thermal zone
368 * associated to the couple sensor/id and retrieves all the thermal
369 * zone properties and registers new thermal zone with those
374 * @data: A private data to be stored in the thermal zone dedicated private area
375 * @ops: A set of thermal sensor ops
377 * Return: a valid thermal zone structure pointer on success.
378 * - EINVAL: if the device tree thermal description is malformed
379 * - ENOMEM: if one structure can not be allocated
380 * - Other negative errors are returned by the underlying called functions
397 if (PTR_ERR(np) != -ENODEV) in thermal_of_zone_register()
398 pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id); in thermal_of_zone_register()
419 ret = of_property_read_string(np, "critical-action", &action); in thermal_of_zone_register()
424 tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, in thermal_of_zone_register()
429 pr_err("Failed to register thermal zone %pOFn: %d\n", np, ret); in thermal_of_zone_register()
438 pr_err("Failed to enabled thermal zone '%s', id=%d: %d\n", in thermal_of_zone_register()
439 tz->type, tz->id, ret); in thermal_of_zone_register()
471 * devm_thermal_of_zone_register - register a thermal tied with the sensor life cycle
475 * @dev: a device structure pointer to sensor to be tied with the thermal zone OF life cycle
477 * @data: a pointer to a private data to be stored in the thermal zone 'devdata' field
488 return ERR_PTR(-ENOMEM); in devm_thermal_of_zone_register()
490 tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops); in devm_thermal_of_zone_register()
504 * devm_thermal_of_zone_unregister - Resource managed version of
510 * thermal zone device registered with devm_thermal_zone_of_sensor_register()
512 * thermal zone device callbacks.