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

1 // SPDX-License-Identifier: GPL-2.0
3 * R-Car THS/TSC thermal sensor driver
101 list_for_each_entry(pos, &common->head, list)
104 #define rcar_zone_to_priv(zone) ((zone)->devdata)
105 #define rcar_priv_to_dev(priv) ((priv)->common->dev)
106 #define rcar_has_irq_support(priv) ((priv)->common->base)
107 #define rcar_id_to_shift(priv) ((priv)->id * 8)
111 .compatible = "renesas,rcar-thermal",
115 .compatible = "renesas,rcar-gen2-thermal",
119 .compatible = "renesas,thermal-r8a774c0",
123 .compatible = "renesas,thermal-r8a77970",
127 .compatible = "renesas,thermal-r8a77990",
131 .compatible = "renesas,thermal-r8a77995",
146 return ioread32(common->base + reg); in _rcar_thermal_common_read()
154 iowrite32(data, common->base + reg); in _rcar_thermal_common_write()
164 val = ioread32(common->base + reg); in _rcar_thermal_common_bset()
167 iowrite32(val, common->base + reg); in _rcar_thermal_common_bset()
173 return ioread32(priv->base + reg); in _rcar_thermal_read()
180 iowrite32(data, priv->base + reg); in _rcar_thermal_write()
189 val = ioread32(priv->base + reg); in _rcar_thermal_bset()
192 iowrite32(val, priv->base + reg); in _rcar_thermal_bset()
201 int old, new, ctemp = -EINVAL; in rcar_thermal_update_temp()
204 mutex_lock(&priv->lock); in rcar_thermal_update_temp()
238 if (priv->chip->has_filonoff) in rcar_thermal_update_temp()
243 rcar_thermal_write(priv, INTCTRL, (((ctemp - 0) << 8) | in rcar_thermal_update_temp()
244 ((ctemp - 1) << 0))); in rcar_thermal_update_temp()
248 mutex_unlock(&priv->lock); in rcar_thermal_update_temp()
262 /* Guaranteed operating range is -45C to 125C. */ in rcar_thermal_get_current_temp()
264 if (priv->chip->ctemp_bands == 1) in rcar_thermal_get_current_temp()
265 *temp = MCELSIUS((ctemp * 5) - 65); in rcar_thermal_get_current_temp()
267 *temp = MCELSIUS(((ctemp * 55) - 720) / 10); in rcar_thermal_get_current_temp()
269 *temp = MCELSIUS((ctemp * 5) - 60); in rcar_thermal_get_current_temp()
293 dev_err(dev, "rcar driver trip error\n"); in rcar_thermal_get_trip_type()
294 return -EINVAL; in rcar_thermal_get_trip_type()
312 dev_err(dev, "rcar driver trip error\n"); in rcar_thermal_get_trip_temp()
313 return -EINVAL; in rcar_thermal_get_trip_temp()
336 struct rcar_thermal_common *common = priv->common; in _rcar_thermal_irq_ctrl()
343 spin_lock_irqsave(&common->lock, flags); in _rcar_thermal_irq_ctrl()
347 spin_unlock_irqrestore(&common->lock, flags); in _rcar_thermal_irq_ctrl()
363 thermal_zone_device_update(priv->zone, THERMAL_EVENT_UNSPECIFIED); in rcar_thermal_work()
374 priv->id, in rcar_thermal_had_changed()
388 spin_lock(&common->lock); in rcar_thermal_irq()
394 spin_unlock(&common->lock); in rcar_thermal_irq()
404 queue_delayed_work(system_freezable_wq, &priv->work, in rcar_thermal_irq()
418 struct device *dev = &pdev->dev; in rcar_thermal_remove()
423 cancel_delayed_work_sync(&priv->work); in rcar_thermal_remove()
424 if (priv->chip->use_of_thermal) in rcar_thermal_remove()
425 thermal_remove_hwmon_sysfs(priv->zone); in rcar_thermal_remove()
427 thermal_zone_device_unregister(priv->zone); in rcar_thermal_remove()
440 struct device *dev = &pdev->dev; in rcar_thermal_probe()
445 int ret = -ENODEV; in rcar_thermal_probe()
451 return -ENOMEM; in rcar_thermal_probe()
455 INIT_LIST_HEAD(&common->head); in rcar_thermal_probe()
456 spin_lock_init(&common->lock); in rcar_thermal_probe()
457 common->dev = dev; in rcar_thermal_probe()
462 for (i = 0; i < chip->nirqs; i++) { in rcar_thermal_probe()
466 if (ret < 0 && ret != -ENXIO) in rcar_thermal_probe()
473 if (!common->base) { in rcar_thermal_probe()
481 common->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
482 if (IS_ERR(common->base)) { in rcar_thermal_probe()
483 ret = PTR_ERR(common->base); in rcar_thermal_probe()
498 if (chip->irq_per_ch) in rcar_thermal_probe()
509 ret = -ENOMEM; in rcar_thermal_probe()
513 priv->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
514 if (IS_ERR(priv->base)) { in rcar_thermal_probe()
515 ret = PTR_ERR(priv->base); in rcar_thermal_probe()
519 priv->common = common; in rcar_thermal_probe()
520 priv->id = i; in rcar_thermal_probe()
521 priv->chip = chip; in rcar_thermal_probe()
522 mutex_init(&priv->lock); in rcar_thermal_probe()
523 INIT_LIST_HEAD(&priv->list); in rcar_thermal_probe()
524 INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); in rcar_thermal_probe()
529 if (chip->use_of_thermal) { in rcar_thermal_probe()
530 priv->zone = devm_thermal_of_zone_register( in rcar_thermal_probe()
534 priv->zone = thermal_zone_device_register( in rcar_thermal_probe()
540 ret = thermal_zone_device_enable(priv->zone); in rcar_thermal_probe()
542 thermal_zone_device_unregister(priv->zone); in rcar_thermal_probe()
543 priv->zone = ERR_PTR(ret); in rcar_thermal_probe()
546 if (IS_ERR(priv->zone)) { in rcar_thermal_probe()
547 dev_err(dev, "can't register thermal zone\n"); in rcar_thermal_probe()
548 ret = PTR_ERR(priv->zone); in rcar_thermal_probe()
549 priv->zone = NULL; in rcar_thermal_probe()
553 if (chip->use_of_thermal) { in rcar_thermal_probe()
558 priv->zone->tzp->no_hwmon = false; in rcar_thermal_probe()
559 ret = thermal_add_hwmon_sysfs(priv->zone); in rcar_thermal_probe()
566 list_move_tail(&priv->list, &common->head); in rcar_thermal_probe()
569 if (!chip->irq_per_ch) in rcar_thermal_probe()
573 if (common->base && enr_bits) in rcar_thermal_probe()
590 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_suspend()
593 if (priv->chip->needs_suspend_resume) { in rcar_thermal_suspend()
605 struct rcar_thermal_priv *priv = list_first_entry(&common->head, in rcar_thermal_resume()
609 if (priv->chip->needs_suspend_resume) { in rcar_thermal_resume()
636 MODULE_DESCRIPTION("R-Car THS/TSC thermal sensor driver");