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>
98 list_for_each_entry(pos, &common->head, list)
101 #define rcar_zone_to_priv(zone) ((zone)->devdata)
102 #define rcar_priv_to_dev(priv) ((priv)->common->dev)
103 #define rcar_has_irq_support(priv) ((priv)->common->base)
104 #define rcar_id_to_shift(priv) ((priv)->id * 8)
108 .compatible = "renesas,rcar-thermal",
112 .compatible = "renesas,rcar-gen2-thermal",
116 .compatible = "renesas,thermal-r8a77995",
131 return ioread32(common->base + reg); in _rcar_thermal_common_read()
139 iowrite32(data, common->base + reg); in _rcar_thermal_common_write()
149 val = ioread32(common->base + reg); in _rcar_thermal_common_bset()
152 iowrite32(val, common->base + reg); in _rcar_thermal_common_bset()
158 return ioread32(priv->base + reg); in _rcar_thermal_read()
165 iowrite32(data, priv->base + reg); in _rcar_thermal_write()
174 val = ioread32(priv->base + reg); in _rcar_thermal_bset()
177 iowrite32(val, priv->base + reg); in _rcar_thermal_bset()
188 int ret = -EINVAL; in rcar_thermal_update_temp()
190 mutex_lock(&priv->lock); in rcar_thermal_update_temp()
217 dev_err(dev, "thermal sensor was broken\n"); in rcar_thermal_update_temp()
225 if (priv->chip->has_filonoff) in rcar_thermal_update_temp()
230 rcar_thermal_write(priv, INTCTRL, (((ctemp - 0) << 8) | in rcar_thermal_update_temp()
231 ((ctemp - 1) << 0))); in rcar_thermal_update_temp()
234 dev_dbg(dev, "thermal%d %d -> %d\n", priv->id, priv->ctemp, ctemp); in rcar_thermal_update_temp()
236 priv->ctemp = ctemp; in rcar_thermal_update_temp()
239 mutex_unlock(&priv->lock); in rcar_thermal_update_temp()
253 mutex_lock(&priv->lock); in rcar_thermal_get_current_temp()
254 tmp = MCELSIUS((priv->ctemp * 5) - 65); in rcar_thermal_get_current_temp()
255 mutex_unlock(&priv->lock); in rcar_thermal_get_current_temp()
257 if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) { in rcar_thermal_get_current_temp()
261 return -EIO; in rcar_thermal_get_current_temp()
296 return -EINVAL; in rcar_thermal_get_trip_type()
315 return -EINVAL; in rcar_thermal_get_trip_temp()
330 dev_warn(dev, "Thermal reached to critical temperature\n"); in rcar_thermal_notify()
357 struct rcar_thermal_common *common = priv->common; in _rcar_thermal_irq_ctrl()
364 spin_lock_irqsave(&common->lock, flags); in _rcar_thermal_irq_ctrl()
368 spin_unlock_irqrestore(&common->lock, flags); in _rcar_thermal_irq_ctrl()
394 thermal_zone_device_update(priv->zone, in rcar_thermal_work()
405 dev_dbg(dev, "thermal%d %s%s\n", in rcar_thermal_had_changed()
406 priv->id, in rcar_thermal_had_changed()
421 spin_lock_irqsave(&common->lock, flags); in rcar_thermal_irq()
427 spin_unlock_irqrestore(&common->lock, flags); in rcar_thermal_irq()
437 queue_delayed_work(system_freezable_wq, &priv->work, in rcar_thermal_irq()
451 struct device *dev = &pdev->dev; in rcar_thermal_remove()
456 cancel_delayed_work_sync(&priv->work); in rcar_thermal_remove()
457 if (priv->chip->use_of_thermal) in rcar_thermal_remove()
458 thermal_remove_hwmon_sysfs(priv->zone); in rcar_thermal_remove()
460 thermal_zone_device_unregister(priv->zone); in rcar_thermal_remove()
473 struct device *dev = &pdev->dev; in rcar_thermal_probe()
478 int ret = -ENODEV; in rcar_thermal_probe()
479 int idle = IDLE_INTERVAL; in rcar_thermal_probe() local
484 return -ENOMEM; in rcar_thermal_probe()
488 INIT_LIST_HEAD(&common->head); in rcar_thermal_probe()
489 spin_lock_init(&common->lock); in rcar_thermal_probe()
490 common->dev = dev; in rcar_thermal_probe()
495 for (i = 0; i < chip->nirqs; i++) { in rcar_thermal_probe()
499 if (!common->base) { in rcar_thermal_probe()
507 common->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
508 if (IS_ERR(common->base)) { in rcar_thermal_probe()
509 ret = PTR_ERR(common->base); in rcar_thermal_probe()
513 idle = 0; /* polling delay is not needed */ in rcar_thermal_probe()
516 ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, in rcar_thermal_probe()
524 if (chip->irq_per_ch) in rcar_thermal_probe()
535 ret = -ENOMEM; in rcar_thermal_probe()
539 priv->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
540 if (IS_ERR(priv->base)) { in rcar_thermal_probe()
541 ret = PTR_ERR(priv->base); in rcar_thermal_probe()
545 priv->common = common; in rcar_thermal_probe()
546 priv->id = i; in rcar_thermal_probe()
547 priv->chip = chip; in rcar_thermal_probe()
548 mutex_init(&priv->lock); in rcar_thermal_probe()
549 INIT_LIST_HEAD(&priv->list); in rcar_thermal_probe()
550 INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); in rcar_thermal_probe()
555 if (chip->use_of_thermal) in rcar_thermal_probe()
556 priv->zone = devm_thermal_zone_of_sensor_register( in rcar_thermal_probe()
560 priv->zone = thermal_zone_device_register( in rcar_thermal_probe()
564 idle); in rcar_thermal_probe()
565 if (IS_ERR(priv->zone)) { in rcar_thermal_probe()
566 dev_err(dev, "can't register thermal zone\n"); in rcar_thermal_probe()
567 ret = PTR_ERR(priv->zone); in rcar_thermal_probe()
568 priv->zone = NULL; in rcar_thermal_probe()
572 if (chip->use_of_thermal) { in rcar_thermal_probe()
577 priv->zone->tzp->no_hwmon = false; in rcar_thermal_probe()
578 ret = thermal_add_hwmon_sysfs(priv->zone); in rcar_thermal_probe()
585 list_move_tail(&priv->list, &common->head); in rcar_thermal_probe()
588 if (!chip->irq_per_ch) in rcar_thermal_probe()
592 if (common->base && enr_bits) in rcar_thermal_probe()
609 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_suspend()
612 if (priv->chip->needs_suspend_resume) { in rcar_thermal_suspend()
624 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_resume()
628 if (priv->chip->needs_suspend_resume) { in rcar_thermal_resume()
655 MODULE_DESCRIPTION("R-Car THS/TSC thermal sensor driver");