Lines Matching +full:rcar +full:- +full:gen2 +full:- +full:thermal

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()
397 struct device *dev = &pdev->dev; in rcar_thermal_probe()
402 int ret = -ENODEV; in rcar_thermal_probe()
408 return -ENOMEM; in rcar_thermal_probe()
412 INIT_LIST_HEAD(&common->head); in rcar_thermal_probe()
413 spin_lock_init(&common->lock); in rcar_thermal_probe()
414 common->dev = dev; in rcar_thermal_probe()
419 for (i = 0; i < chip->nirqs; i++) { in rcar_thermal_probe()
423 if (ret < 0 && ret != -ENXIO) in rcar_thermal_probe()
430 if (!common->base) { in rcar_thermal_probe()
438 common->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
439 if (IS_ERR(common->base)) { in rcar_thermal_probe()
440 ret = PTR_ERR(common->base); in rcar_thermal_probe()
455 if (chip->irq_per_ch) in rcar_thermal_probe()
466 ret = -ENOMEM; in rcar_thermal_probe()
470 priv->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
471 if (IS_ERR(priv->base)) { in rcar_thermal_probe()
472 ret = PTR_ERR(priv->base); in rcar_thermal_probe()
476 priv->common = common; in rcar_thermal_probe()
477 priv->id = i; in rcar_thermal_probe()
478 priv->chip = chip; in rcar_thermal_probe()
479 mutex_init(&priv->lock); in rcar_thermal_probe()
480 INIT_LIST_HEAD(&priv->list); in rcar_thermal_probe()
481 INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); in rcar_thermal_probe()
486 if (chip->use_of_thermal) { in rcar_thermal_probe()
487 priv->zone = devm_thermal_of_zone_register( in rcar_thermal_probe()
491 priv->zone = thermal_zone_device_register_with_trips( in rcar_thermal_probe()
496 ret = thermal_zone_device_enable(priv->zone); in rcar_thermal_probe()
498 thermal_zone_device_unregister(priv->zone); in rcar_thermal_probe()
499 priv->zone = ERR_PTR(ret); in rcar_thermal_probe()
502 if (IS_ERR(priv->zone)) { in rcar_thermal_probe()
503 dev_err(dev, "can't register thermal zone\n"); in rcar_thermal_probe()
504 ret = PTR_ERR(priv->zone); in rcar_thermal_probe()
505 priv->zone = NULL; in rcar_thermal_probe()
509 if (chip->use_of_thermal) { in rcar_thermal_probe()
510 ret = thermal_add_hwmon_sysfs(priv->zone); in rcar_thermal_probe()
517 list_move_tail(&priv->list, &common->head); in rcar_thermal_probe()
520 if (!chip->irq_per_ch) in rcar_thermal_probe()
524 if (common->base && enr_bits) in rcar_thermal_probe()
541 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_suspend()
544 if (priv->chip->needs_suspend_resume) { in rcar_thermal_suspend()
556 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_resume()
560 if (priv->chip->needs_suspend_resume) { in rcar_thermal_resume()
587 MODULE_DESCRIPTION("R-Car THS/TSC thermal sensor driver");