Lines Matching +full:thermal +full:- +full:idle
1 // SPDX-License-Identifier: GPL-2.0
3 * R-Car THS/TSC thermal sensor driver
20 #include <linux/thermal.h>
101 list_for_each_entry(pos, &common->head, list)
104 #define rcar_priv_to_dev(priv) ((priv)->common->dev)
105 #define rcar_has_irq_support(priv) ((priv)->common->base)
106 #define rcar_id_to_shift(priv) ((priv)->id * 8)
110 .compatible = "renesas,rcar-thermal",
114 .compatible = "renesas,rcar-gen2-thermal",
118 .compatible = "renesas,thermal-r8a774c0",
122 .compatible = "renesas,thermal-r8a77970",
126 .compatible = "renesas,thermal-r8a77990",
130 .compatible = "renesas,thermal-r8a77995",
145 return ioread32(common->base + reg); in _rcar_thermal_common_read()
153 iowrite32(data, common->base + reg); in _rcar_thermal_common_write()
163 val = ioread32(common->base + reg); in _rcar_thermal_common_bset()
166 iowrite32(val, common->base + reg); in _rcar_thermal_common_bset()
172 return ioread32(priv->base + reg); in _rcar_thermal_read()
179 iowrite32(data, priv->base + reg); in _rcar_thermal_write()
188 val = ioread32(priv->base + reg); in _rcar_thermal_bset()
191 iowrite32(val, priv->base + reg); in _rcar_thermal_bset()
200 int old, new, ctemp = -EINVAL; in rcar_thermal_update_temp()
203 mutex_lock(&priv->lock); in rcar_thermal_update_temp()
229 dev_err(dev, "thermal sensor was broken\n"); in rcar_thermal_update_temp()
237 if (priv->chip->has_filonoff) in rcar_thermal_update_temp()
242 rcar_thermal_write(priv, INTCTRL, (((ctemp - 0) << 8) | in rcar_thermal_update_temp()
243 ((ctemp - 1) << 0))); in rcar_thermal_update_temp()
247 mutex_unlock(&priv->lock); in rcar_thermal_update_temp()
261 /* Guaranteed operating range is -45C to 125C. */ in rcar_thermal_get_current_temp()
263 if (priv->chip->ctemp_bands == 1) in rcar_thermal_get_current_temp()
264 *temp = MCELSIUS((ctemp * 5) - 65); in rcar_thermal_get_current_temp()
266 *temp = MCELSIUS(((ctemp * 55) - 720) / 10); in rcar_thermal_get_current_temp()
268 *temp = MCELSIUS((ctemp * 5) - 60); in rcar_thermal_get_current_temp()
295 struct rcar_thermal_common *common = priv->common; in _rcar_thermal_irq_ctrl()
302 spin_lock_irqsave(&common->lock, flags); in _rcar_thermal_irq_ctrl()
306 spin_unlock_irqrestore(&common->lock, flags); in _rcar_thermal_irq_ctrl()
322 thermal_zone_device_update(priv->zone, THERMAL_EVENT_UNSPECIFIED); in rcar_thermal_work()
332 dev_dbg(dev, "thermal%d %s%s\n", in rcar_thermal_had_changed()
333 priv->id, in rcar_thermal_had_changed()
347 spin_lock(&common->lock); in rcar_thermal_irq()
353 spin_unlock(&common->lock); in rcar_thermal_irq()
363 queue_delayed_work(system_freezable_wq, &priv->work, in rcar_thermal_irq()
377 struct device *dev = &pdev->dev; in rcar_thermal_remove()
382 cancel_delayed_work_sync(&priv->work); in rcar_thermal_remove()
383 if (priv->chip->use_of_thermal) in rcar_thermal_remove()
384 thermal_remove_hwmon_sysfs(priv->zone); in rcar_thermal_remove()
386 thermal_zone_device_unregister(priv->zone); in rcar_thermal_remove()
399 struct device *dev = &pdev->dev; in rcar_thermal_probe()
404 int ret = -ENODEV; in rcar_thermal_probe()
405 int idle = IDLE_INTERVAL; in rcar_thermal_probe() local
410 return -ENOMEM; in rcar_thermal_probe()
414 INIT_LIST_HEAD(&common->head); in rcar_thermal_probe()
415 spin_lock_init(&common->lock); in rcar_thermal_probe()
416 common->dev = dev; in rcar_thermal_probe()
421 for (i = 0; i < chip->nirqs; i++) { in rcar_thermal_probe()
425 if (ret < 0 && ret != -ENXIO) in rcar_thermal_probe()
432 if (!common->base) { in rcar_thermal_probe()
440 common->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
441 if (IS_ERR(common->base)) { in rcar_thermal_probe()
442 ret = PTR_ERR(common->base); in rcar_thermal_probe()
446 idle = 0; /* polling delay is not needed */ in rcar_thermal_probe()
457 if (chip->irq_per_ch) in rcar_thermal_probe()
468 ret = -ENOMEM; in rcar_thermal_probe()
472 priv->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
473 if (IS_ERR(priv->base)) { in rcar_thermal_probe()
474 ret = PTR_ERR(priv->base); in rcar_thermal_probe()
478 priv->common = common; in rcar_thermal_probe()
479 priv->id = i; in rcar_thermal_probe()
480 priv->chip = chip; in rcar_thermal_probe()
481 mutex_init(&priv->lock); in rcar_thermal_probe()
482 INIT_LIST_HEAD(&priv->list); in rcar_thermal_probe()
483 INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); in rcar_thermal_probe()
488 if (chip->use_of_thermal) { in rcar_thermal_probe()
489 priv->zone = devm_thermal_of_zone_register( in rcar_thermal_probe()
493 priv->zone = thermal_zone_device_register_with_trips( in rcar_thermal_probe()
496 idle); in rcar_thermal_probe()
498 ret = thermal_zone_device_enable(priv->zone); in rcar_thermal_probe()
500 thermal_zone_device_unregister(priv->zone); in rcar_thermal_probe()
501 priv->zone = ERR_PTR(ret); in rcar_thermal_probe()
504 if (IS_ERR(priv->zone)) { in rcar_thermal_probe()
505 dev_err(dev, "can't register thermal zone\n"); in rcar_thermal_probe()
506 ret = PTR_ERR(priv->zone); in rcar_thermal_probe()
507 priv->zone = NULL; in rcar_thermal_probe()
511 if (chip->use_of_thermal) { in rcar_thermal_probe()
512 ret = thermal_add_hwmon_sysfs(priv->zone); in rcar_thermal_probe()
519 list_move_tail(&priv->list, &common->head); in rcar_thermal_probe()
522 if (!chip->irq_per_ch) in rcar_thermal_probe()
526 if (common->base && enr_bits) in rcar_thermal_probe()
543 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_suspend()
546 if (priv->chip->needs_suspend_resume) { in rcar_thermal_suspend()
558 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_resume()
562 if (priv->chip->needs_suspend_resume) { in rcar_thermal_resume()
589 MODULE_DESCRIPTION("R-Car THS/TSC thermal sensor driver");