Lines Matching +full:thermal +full:- +full:calibration
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Dove thermal sensor driver
14 #include <linux/thermal.h>
19 /* Dove Thermal Manager Control and Status Register */
32 /* Dove Thermal Diode Control 1 Register */
36 /* Dove Thermal Sensor Dev Structure */
48 reg = readl_relaxed(priv->control); in dove_init_sensor()
54 /* Reference calibration value */ in dove_init_sensor()
58 /* Set the high level reference for calibration */ in dove_init_sensor()
61 writel(reg, priv->control); in dove_init_sensor()
64 reg = readl_relaxed(priv->control); in dove_init_sensor()
65 writel((reg | PMU_TDC0_SW_RST_MASK), priv->control); in dove_init_sensor()
66 writel(reg, priv->control); in dove_init_sensor()
69 reg = readl_relaxed(priv->sensor); in dove_init_sensor()
71 writel(reg, priv->sensor); in dove_init_sensor()
75 reg = readl_relaxed(priv->sensor); in dove_init_sensor()
81 return -EIO; in dove_init_sensor()
86 static int dove_get_temp(struct thermal_zone_device *thermal, in dove_get_temp() argument
90 struct dove_thermal_priv *priv = thermal->devdata; in dove_get_temp()
93 reg = readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG); in dove_get_temp()
95 dev_err(&thermal->device, in dove_get_temp()
97 return -EIO; in dove_get_temp()
103 * Celsius = (322-reg)/1.3625 in dove_get_temp()
105 reg = readl_relaxed(priv->sensor); in dove_get_temp()
107 *temp = ((3220000000UL - (10000000UL * reg)) / 13625); in dove_get_temp()
117 { .compatible = "marvell,dove-thermal" },
123 struct thermal_zone_device *thermal = NULL; in dove_thermal_probe() local
128 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in dove_thermal_probe()
130 return -ENOMEM; in dove_thermal_probe()
133 priv->sensor = devm_ioremap_resource(&pdev->dev, res); in dove_thermal_probe()
134 if (IS_ERR(priv->sensor)) in dove_thermal_probe()
135 return PTR_ERR(priv->sensor); in dove_thermal_probe()
138 priv->control = devm_ioremap_resource(&pdev->dev, res); in dove_thermal_probe()
139 if (IS_ERR(priv->control)) in dove_thermal_probe()
140 return PTR_ERR(priv->control); in dove_thermal_probe()
144 dev_err(&pdev->dev, "Failed to initialize sensor\n"); in dove_thermal_probe()
148 thermal = thermal_zone_device_register("dove_thermal", 0, 0, in dove_thermal_probe()
150 if (IS_ERR(thermal)) { in dove_thermal_probe()
151 dev_err(&pdev->dev, in dove_thermal_probe()
152 "Failed to register thermal zone device\n"); in dove_thermal_probe()
153 return PTR_ERR(thermal); in dove_thermal_probe()
156 ret = thermal_zone_device_enable(thermal); in dove_thermal_probe()
158 thermal_zone_device_unregister(thermal); in dove_thermal_probe()
162 platform_set_drvdata(pdev, thermal); in dove_thermal_probe()
191 MODULE_DESCRIPTION("Dove thermal driver");