Lines Matching +full:thermal +full:- +full:sensor

1 // SPDX-License-Identifier: GPL-2.0-only
3 * SPEAr thermal driver.
5 * Copyright (C) 2011-2012 ST Microelectronics
17 #include <linux/thermal.h>
21 /* SPEAr Thermal Sensor Dev Structure */
23 /* pointer to base address of the thermal sensor */
27 /* pointer to thermal flags */
31 static inline int thermal_get_temp(struct thermal_zone_device *thermal, in thermal_get_temp() argument
34 struct spear_thermal_dev *stdev = thermal->devdata; in thermal_get_temp()
40 *temp = (readl_relaxed(stdev->thermal_base) & 0x7F) * MD_FACTOR; in thermal_get_temp()
51 struct spear_thermal_dev *stdev = spear_thermal->devdata; in spear_thermal_suspend()
54 /* Disable SPEAr Thermal Sensor */ in spear_thermal_suspend()
55 actual_mask = readl_relaxed(stdev->thermal_base); in spear_thermal_suspend()
56 writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base); in spear_thermal_suspend()
58 clk_disable(stdev->clk); in spear_thermal_suspend()
67 struct spear_thermal_dev *stdev = spear_thermal->devdata; in spear_thermal_resume()
71 ret = clk_enable(stdev->clk); in spear_thermal_resume()
77 /* Enable SPEAr Thermal Sensor */ in spear_thermal_resume()
78 actual_mask = readl_relaxed(stdev->thermal_base); in spear_thermal_resume()
79 writel_relaxed(actual_mask | stdev->flags, stdev->thermal_base); in spear_thermal_resume()
93 struct device_node *np = pdev->dev.of_node; in spear_thermal_probe()
97 if (!np || !of_property_read_u32(np, "st,thermal-flags", &val)) { in spear_thermal_probe()
98 dev_err(&pdev->dev, "Failed: DT Pdata not passed\n"); in spear_thermal_probe()
99 return -EINVAL; in spear_thermal_probe()
102 stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL); in spear_thermal_probe()
104 return -ENOMEM; in spear_thermal_probe()
106 /* Enable thermal sensor */ in spear_thermal_probe()
108 stdev->thermal_base = devm_ioremap_resource(&pdev->dev, res); in spear_thermal_probe()
109 if (IS_ERR(stdev->thermal_base)) in spear_thermal_probe()
110 return PTR_ERR(stdev->thermal_base); in spear_thermal_probe()
112 stdev->clk = devm_clk_get(&pdev->dev, NULL); in spear_thermal_probe()
113 if (IS_ERR(stdev->clk)) { in spear_thermal_probe()
114 dev_err(&pdev->dev, "Can't get clock\n"); in spear_thermal_probe()
115 return PTR_ERR(stdev->clk); in spear_thermal_probe()
118 ret = clk_enable(stdev->clk); in spear_thermal_probe()
120 dev_err(&pdev->dev, "Can't enable clock\n"); in spear_thermal_probe()
124 stdev->flags = val; in spear_thermal_probe()
125 writel_relaxed(stdev->flags, stdev->thermal_base); in spear_thermal_probe()
130 dev_err(&pdev->dev, "thermal zone device is NULL\n"); in spear_thermal_probe()
136 dev_err(&pdev->dev, "Cannot enable thermal zone\n"); in spear_thermal_probe()
142 dev_info(&spear_thermal->device, "Thermal Sensor Loaded at: 0x%p.\n", in spear_thermal_probe()
143 stdev->thermal_base); in spear_thermal_probe()
150 clk_disable(stdev->clk); in spear_thermal_probe()
159 struct spear_thermal_dev *stdev = spear_thermal->devdata; in spear_thermal_exit()
163 /* Disable SPEAr Thermal Sensor */ in spear_thermal_exit()
164 actual_mask = readl_relaxed(stdev->thermal_base); in spear_thermal_exit()
165 writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base); in spear_thermal_exit()
167 clk_disable(stdev->clk); in spear_thermal_exit()
173 { .compatible = "st,thermal-spear1340" },
191 MODULE_DESCRIPTION("SPEAr thermal driver");