Lines Matching +full:thermal +full:- +full:sensor
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Kirkwood thermal sensor driver
14 #include <linux/thermal.h>
21 /* Kirkwood Thermal Sensor Dev Structure */
23 void __iomem *sensor; member
26 static int kirkwood_get_temp(struct thermal_zone_device *thermal, in kirkwood_get_temp() argument
30 struct kirkwood_thermal_priv *priv = thermal->devdata; in kirkwood_get_temp()
32 reg = readl_relaxed(priv->sensor); in kirkwood_get_temp()
37 dev_err(&thermal->device, in kirkwood_get_temp()
38 "Temperature sensor reading not valid\n"); in kirkwood_get_temp()
39 return -EIO; in kirkwood_get_temp()
45 * Celsius = (322-reg)/1.3625 in kirkwood_get_temp()
49 *temp = ((3220000000UL - (10000000UL * reg)) / 13625); in kirkwood_get_temp()
59 { .compatible = "marvell,kirkwood-thermal" },
65 struct thermal_zone_device *thermal = NULL; in kirkwood_thermal_probe() local
70 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in kirkwood_thermal_probe()
72 return -ENOMEM; in kirkwood_thermal_probe()
75 priv->sensor = devm_ioremap_resource(&pdev->dev, res); in kirkwood_thermal_probe()
76 if (IS_ERR(priv->sensor)) in kirkwood_thermal_probe()
77 return PTR_ERR(priv->sensor); in kirkwood_thermal_probe()
79 thermal = thermal_zone_device_register("kirkwood_thermal", 0, 0, in kirkwood_thermal_probe()
81 if (IS_ERR(thermal)) { in kirkwood_thermal_probe()
82 dev_err(&pdev->dev, in kirkwood_thermal_probe()
83 "Failed to register thermal zone device\n"); in kirkwood_thermal_probe()
84 return PTR_ERR(thermal); in kirkwood_thermal_probe()
86 ret = thermal_zone_device_enable(thermal); in kirkwood_thermal_probe()
88 thermal_zone_device_unregister(thermal); in kirkwood_thermal_probe()
89 dev_err(&pdev->dev, "Failed to enable thermal zone device\n"); in kirkwood_thermal_probe()
93 platform_set_drvdata(pdev, thermal); in kirkwood_thermal_probe()
122 MODULE_DESCRIPTION("kirkwood thermal driver");