Lines Matching +full:r8a7795 +full:- +full:thermal

1 // SPDX-License-Identifier: GPL-2.0
3 * R-Car Gen3 THS thermal sensor driver
18 #include <linux/thermal.h>
72 /* Structure for thermal temperature calculation */
85 int id; /* thermal channel id */
97 return ioread32(tsc->base + reg); in rcar_gen3_thermal_read()
103 iowrite32(data, tsc->base + reg); in rcar_gen3_thermal_write()
109 * [reg] = [temp] * a + b => [temp] = ([reg] - b) / a
132 #define TJ_3 -41
144 tsc->tj_t = (FIXPT_INT((ptat[1] - ptat[2]) * 157) in rcar_gen3_thermal_calc_coefs()
145 / (ptat[0] - ptat[2])) + FIXPT_INT(TJ_3); in rcar_gen3_thermal_calc_coefs()
147 tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]), in rcar_gen3_thermal_calc_coefs()
148 tsc->tj_t - FIXPT_INT(TJ_3)); in rcar_gen3_thermal_calc_coefs()
149 tsc->coef.b1 = FIXPT_INT(thcode[2]) - tsc->coef.a1 * TJ_3; in rcar_gen3_thermal_calc_coefs()
151 tsc->coef.a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]), in rcar_gen3_thermal_calc_coefs()
152 tsc->tj_t - FIXPT_INT(ths_tj_1)); in rcar_gen3_thermal_calc_coefs()
153 tsc->coef.b2 = FIXPT_INT(thcode[0]) - tsc->coef.a2 * ths_tj_1; in rcar_gen3_thermal_calc_coefs()
161 -RCAR3_THERMAL_GRAN / 2; in rcar_gen3_thermal_round()
175 if (reg <= thcodes[tsc->id][1]) in rcar_gen3_thermal_get_temp()
176 val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1, in rcar_gen3_thermal_get_temp()
177 tsc->coef.a1); in rcar_gen3_thermal_get_temp()
179 val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2, in rcar_gen3_thermal_get_temp()
180 tsc->coef.a2); in rcar_gen3_thermal_get_temp()
183 /* Guaranteed operating range is -40C to 125C. */ in rcar_gen3_thermal_get_temp()
197 if (celsius <= INT_FIXPT(tsc->tj_t)) in rcar_gen3_thermal_mcelsius_to_temp()
198 val = celsius * tsc->coef.a1 + tsc->coef.b1; in rcar_gen3_thermal_mcelsius_to_temp()
200 val = celsius * tsc->coef.a2 + tsc->coef.b2; in rcar_gen3_thermal_mcelsius_to_temp()
211 low = temperature - MCELSIUS(1); in rcar_gen3_thermal_update_range()
232 for (i = 0; i < priv->num_tscs; i++) in rcar_thermal_irq_set()
233 rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_IRQMSK, val); in rcar_thermal_irq_set()
242 for (i = 0; i < priv->num_tscs; i++) { in rcar_gen3_thermal_irq()
243 status = rcar_gen3_thermal_read(priv->tscs[i], REG_GEN3_IRQSTR); in rcar_gen3_thermal_irq()
244 rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_IRQSTR, 0); in rcar_gen3_thermal_irq()
246 rcar_gen3_thermal_update_range(priv->tscs[i]); in rcar_gen3_thermal_irq()
247 thermal_zone_device_update(priv->tscs[i]->zone, in rcar_gen3_thermal_irq()
256 { .soc_id = "r8a7795", .revision = "ES1.*" },
310 .compatible = "renesas,r8a774a1-thermal",
314 .compatible = "renesas,r8a774b1-thermal",
318 .compatible = "renesas,r8a774e1-thermal",
322 .compatible = "renesas,r8a7795-thermal",
326 .compatible = "renesas,r8a7796-thermal",
330 .compatible = "renesas,r8a77961-thermal",
334 .compatible = "renesas,r8a77965-thermal",
338 .compatible = "renesas,r8a77980-thermal",
347 struct device *dev = &pdev->dev; in rcar_gen3_thermal_remove()
368 struct device *dev = &pdev->dev; in rcar_gen3_thermal_probe()
381 return -ENOMEM; in rcar_gen3_thermal_probe()
383 priv->thermal_init = rcar_gen3_thermal_init; in rcar_gen3_thermal_probe()
385 priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1; in rcar_gen3_thermal_probe()
402 return -ENOMEM; in rcar_gen3_thermal_probe()
423 ret = -ENOMEM; in rcar_gen3_thermal_probe()
427 tsc->base = devm_ioremap_resource(dev, res); in rcar_gen3_thermal_probe()
428 if (IS_ERR(tsc->base)) { in rcar_gen3_thermal_probe()
429 ret = PTR_ERR(tsc->base); in rcar_gen3_thermal_probe()
432 tsc->id = i; in rcar_gen3_thermal_probe()
434 priv->tscs[i] = tsc; in rcar_gen3_thermal_probe()
436 priv->thermal_init(tsc); in rcar_gen3_thermal_probe()
443 dev_err(dev, "Can't register thermal zone\n"); in rcar_gen3_thermal_probe()
447 tsc->zone = zone; in rcar_gen3_thermal_probe()
449 tsc->zone->tzp->no_hwmon = false; in rcar_gen3_thermal_probe()
450 ret = thermal_add_hwmon_sysfs(tsc->zone); in rcar_gen3_thermal_probe()
458 ret = of_thermal_get_ntrips(tsc->zone); in rcar_gen3_thermal_probe()
467 priv->num_tscs = i; in rcar_gen3_thermal_probe()
469 if (!priv->num_tscs) { in rcar_gen3_thermal_probe()
470 ret = -ENODEV; in rcar_gen3_thermal_probe()
498 for (i = 0; i < priv->num_tscs; i++) { in rcar_gen3_thermal_resume()
499 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_resume()
501 priv->thermal_init(tsc); in rcar_gen3_thermal_resume()
525 MODULE_DESCRIPTION("R-Car Gen3 THS thermal sensor driver");
526 MODULE_AUTHOR("Wolfram Sang <wsa+renesas@sang-engineering.com>");