Lines Matching +full:- +full:thermal
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Thermal device driver for DA9062 and DA9061
7 /* When over-temperature is reached, an interrupt from the device will be
11 * implementation of the thermal driver will include a .notify() function
14 * These uevents are intended to indicate non-invasive temperature control
17 * the IRQ is re-enabled so the start of a new over-temperature event can
27 #include <linux/thermal.h>
61 struct da9062_thermal *thermal = container_of(work, in da9062_thermal_poll_on() local
69 ret = regmap_write(thermal->hw->regmap, in da9062_thermal_poll_on()
73 dev_err(thermal->dev, in da9062_thermal_poll_on()
79 * If over-temperature, then this status will be true. in da9062_thermal_poll_on()
80 * If not over-temperature, this status will be false. in da9062_thermal_poll_on()
82 ret = regmap_read(thermal->hw->regmap, in da9062_thermal_poll_on()
86 dev_err(thermal->dev, in da9062_thermal_poll_on()
92 mutex_lock(&thermal->lock); in da9062_thermal_poll_on()
93 thermal->temperature = DA9062_MILLI_CELSIUS(125); in da9062_thermal_poll_on()
94 mutex_unlock(&thermal->lock); in da9062_thermal_poll_on()
95 thermal_zone_device_update(thermal->zone, in da9062_thermal_poll_on()
98 delay = thermal->zone->passive_delay_jiffies; in da9062_thermal_poll_on()
99 queue_delayed_work(system_freezable_wq, &thermal->work, delay); in da9062_thermal_poll_on()
103 mutex_lock(&thermal->lock); in da9062_thermal_poll_on()
104 thermal->temperature = DA9062_MILLI_CELSIUS(0); in da9062_thermal_poll_on()
105 mutex_unlock(&thermal->lock); in da9062_thermal_poll_on()
106 thermal_zone_device_update(thermal->zone, in da9062_thermal_poll_on()
110 enable_irq(thermal->irq); in da9062_thermal_poll_on()
115 struct da9062_thermal *thermal = data; in da9062_thermal_irq_handler() local
117 disable_irq_nosync(thermal->irq); in da9062_thermal_irq_handler()
118 queue_delayed_work(system_freezable_wq, &thermal->work, 0); in da9062_thermal_irq_handler()
127 struct da9062_thermal *thermal = z->devdata; in da9062_thermal_get_trip_type() local
134 dev_err(thermal->dev, in da9062_thermal_get_trip_type()
135 "Driver does not support more than 1 trip-wire\n"); in da9062_thermal_get_trip_type()
136 return -EINVAL; in da9062_thermal_get_trip_type()
146 struct da9062_thermal *thermal = z->devdata; in da9062_thermal_get_trip_temp() local
153 dev_err(thermal->dev, in da9062_thermal_get_trip_temp()
154 "Driver does not support more than 1 trip-wire\n"); in da9062_thermal_get_trip_temp()
155 return -EINVAL; in da9062_thermal_get_trip_temp()
164 struct da9062_thermal *thermal = z->devdata; in da9062_thermal_get_temp() local
166 mutex_lock(&thermal->lock); in da9062_thermal_get_temp()
167 *temp = thermal->temperature; in da9062_thermal_get_temp()
168 mutex_unlock(&thermal->lock); in da9062_thermal_get_temp()
180 .name = "da9062-thermal",
184 { .compatible = "dlg,da9062-thermal", .data = &da9062_config },
192 struct da9062 *chip = dev_get_drvdata(pdev->dev.parent); in da9062_thermal_probe()
193 struct da9062_thermal *thermal; in da9062_thermal_probe() local
199 pdev->dev.of_node); in da9062_thermal_probe()
201 return -ENXIO; in da9062_thermal_probe()
203 if (pdev->dev.of_node) { in da9062_thermal_probe()
204 if (!of_property_read_u32(pdev->dev.of_node, in da9062_thermal_probe()
205 "polling-delay-passive", in da9062_thermal_probe()
209 dev_warn(&pdev->dev, in da9062_thermal_probe()
210 "Out-of-range polling period %d ms\n", in da9062_thermal_probe()
217 thermal = devm_kzalloc(&pdev->dev, sizeof(struct da9062_thermal), in da9062_thermal_probe()
219 if (!thermal) { in da9062_thermal_probe()
220 ret = -ENOMEM; in da9062_thermal_probe()
224 thermal->config = match->data; in da9062_thermal_probe()
225 thermal->hw = chip; in da9062_thermal_probe()
226 thermal->dev = &pdev->dev; in da9062_thermal_probe()
228 INIT_DELAYED_WORK(&thermal->work, da9062_thermal_poll_on); in da9062_thermal_probe()
229 mutex_init(&thermal->lock); in da9062_thermal_probe()
231 thermal->zone = thermal_zone_device_register(thermal->config->name, in da9062_thermal_probe()
232 1, 0, thermal, in da9062_thermal_probe()
235 if (IS_ERR(thermal->zone)) { in da9062_thermal_probe()
236 dev_err(&pdev->dev, "Cannot register thermal zone device\n"); in da9062_thermal_probe()
237 ret = PTR_ERR(thermal->zone); in da9062_thermal_probe()
240 ret = thermal_zone_device_enable(thermal->zone); in da9062_thermal_probe()
242 dev_err(&pdev->dev, "Cannot enable thermal zone device\n"); in da9062_thermal_probe()
246 dev_dbg(&pdev->dev, in da9062_thermal_probe()
248 jiffies_to_msecs(thermal->zone->passive_delay_jiffies)); in da9062_thermal_probe()
250 ret = platform_get_irq_byname(pdev, "THERMAL"); in da9062_thermal_probe()
254 thermal->irq = ret; in da9062_thermal_probe()
256 ret = request_threaded_irq(thermal->irq, NULL, in da9062_thermal_probe()
259 "THERMAL", thermal); in da9062_thermal_probe()
261 dev_err(&pdev->dev, in da9062_thermal_probe()
262 "Failed to request thermal device IRQ.\n"); in da9062_thermal_probe()
266 platform_set_drvdata(pdev, thermal); in da9062_thermal_probe()
270 thermal_zone_device_unregister(thermal->zone); in da9062_thermal_probe()
277 struct da9062_thermal *thermal = platform_get_drvdata(pdev); in da9062_thermal_remove() local
279 free_irq(thermal->irq, thermal); in da9062_thermal_remove()
280 cancel_delayed_work_sync(&thermal->work); in da9062_thermal_remove()
281 thermal_zone_device_unregister(thermal->zone); in da9062_thermal_remove()
289 .name = "da9062-thermal",
297 MODULE_DESCRIPTION("Thermal TJUNC device driver for Dialog DA9062 and DA9061");
299 MODULE_ALIAS("platform:da9062-thermal");