Lines Matching +full:sensor +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0
3 * of-thermal.c - Generic Thermal Management device tree support.
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()
112 return ERR_PTR(-ENOMEM); in thermal_of_trips_init()
126 static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id) in of_thermal_zone_find() argument
130 struct device_node *np __free(device_node) = of_find_node_by_name(NULL, "thermal-zones"); in of_thermal_zone_find()
133 return ERR_PTR(-ENODEV); in of_thermal_zone_find()
137 * Search for each thermal zone, a defined sensor in of_thermal_zone_find()
144 count = of_count_phandle_with_args(child, "thermal-sensors", in of_thermal_zone_find()
145 "#thermal-sensor-cells"); in of_thermal_zone_find()
147 pr_err("%pOFn: missing thermal sensor\n", child); in of_thermal_zone_find()
148 return ERR_PTR(-EINVAL); in of_thermal_zone_find()
155 ret = of_parse_phandle_with_args(child, "thermal-sensors", in of_thermal_zone_find()
156 "#thermal-sensor-cells", in of_thermal_zone_find()
159 pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", child, ret); in of_thermal_zone_find()
164 if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? in of_thermal_zone_find()
166 pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, child); in of_thermal_zone_find()
172 return ERR_PTR(-ENODEV); in of_thermal_zone_find()
179 ret = of_property_read_u32(np, "polling-delay-passive", pdelay); in thermal_of_monitor_init()
180 if (ret == -EINVAL) { in thermal_of_monitor_init()
183 pr_err("%pOFn: Couldn't get polling-delay-passive: %d\n", np, ret); in thermal_of_monitor_init()
187 ret = of_property_read_u32(np, "polling-delay", delay); in thermal_of_monitor_init()
188 if (ret == -EINVAL) { in thermal_of_monitor_init()
191 pr_err("%pOFn: Couldn't get polling-delay: %d\n", np, ret); in thermal_of_monitor_init()
205 tzp->no_hwmon = true; in thermal_of_parameters_init()
207 if (!of_property_read_u32(np, "sustainable-power", &prop)) in thermal_of_parameters_init()
208 tzp->sustainable_power = prop; in thermal_of_parameters_init()
211 * For now, the thermal framework supports only one sensor per in thermal_of_parameters_init()
221 tzp->slope = coef[0]; in thermal_of_parameters_init()
222 tzp->offset = coef[1]; in thermal_of_parameters_init()
229 np = of_find_node_by_name(NULL, "thermal-zones"); in thermal_of_zone_get_by_name()
231 return ERR_PTR(-ENODEV); in thermal_of_zone_get_by_name()
233 tz_np = of_get_child_by_name(np, tz->type); in thermal_of_zone_get_by_name()
238 return ERR_PTR(-ENODEV); in thermal_of_zone_get_by_name()
252 ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells", in thermal_of_get_cooling_spec()
256 pr_err("Invalid cooling-device entry\n"); in thermal_of_get_cooling_spec()
267 if (cooling_spec.np != cdev->np) in thermal_of_get_cooling_spec()
270 c->lower = cooling_spec.args[0]; in thermal_of_get_cooling_spec()
271 c->upper = cooling_spec.args[1]; in thermal_of_get_cooling_spec()
272 c->weight = weight; in thermal_of_get_cooling_spec()
287 if (tr_np != trip->priv) in thermal_of_cm_lookup()
291 count = of_count_phandle_with_args(child, "cooling-device", in thermal_of_cm_lookup()
292 "#cooling-cells"); in thermal_of_cm_lookup()
315 pr_err("Failed to get node tz by name\n"); in thermal_of_should_bind()
319 cm_np = of_get_child_by_name(tz_np, "cooling-maps"); in thermal_of_should_bind()
334 * thermal_of_zone_unregister - Cleanup the specific allocated ressources
348 * thermal_of_zone_register - Register a thermal zone with device node
349 * sensor
352 * node sensor and identifier. It searches for the thermal zone
353 * associated to the couple sensor/id and retrieves all the thermal
357 * @sensor: A device node pointer corresponding to the sensor in the device tree
358 * @id: An integer as sensor identifier
360 * @ops: A set of thermal sensor ops
363 * - EINVAL: if the device tree thermal description is malformed
364 * - ENOMEM: if one structure can not be allocated
365 * - Other negative errors are returned by the underlying called functions
367 static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, voi… in thermal_of_zone_register() argument
380 np = of_thermal_zone_find(sensor, id); in thermal_of_zone_register()
382 if (PTR_ERR(np) != -ENODEV) in thermal_of_zone_register()
383 pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id); in thermal_of_zone_register()
389 pr_err("Failed to parse trip points for %pOFn id=%d\n", sensor, id); in thermal_of_zone_register()
395 pr_info("No trip points found for %pOFn id=%d\n", sensor, id); in thermal_of_zone_register()
407 ret = of_property_read_string(np, "critical-action", &action); in thermal_of_zone_register()
412 tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, in thermal_of_zone_register()
427 tz->type, tz->id, ret); in thermal_of_zone_register()
459 * devm_thermal_of_zone_register - register a thermal tied with the sensor life cycle
463 * @dev: a device structure pointer to sensor to be tied with the thermal zone OF life cycle
464 * @sensor_id: the sensor identifier
466 * @ops: a pointer to the ops structure associated with the sensor
476 return ERR_PTR(-ENOMEM); in devm_thermal_of_zone_register()
478 tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops); in devm_thermal_of_zone_register()
492 * devm_thermal_of_zone_unregister - Resource managed version of
495 * @tz: a pointer to struct thermal_zone where the sensor is registered.
497 * This function removes the sensor callbacks and private data from the