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_zone_device_priv(thermal); in thermal_get_temp()
40 *temp = (readl_relaxed(stdev->thermal_base) & 0x7F) * MD_FACTOR; in thermal_get_temp()
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()
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()
96 if (!np || !of_property_read_u32(np, "st,thermal-flags", &val)) { in spear_thermal_probe()
97 dev_err(&pdev->dev, "Failed: DT Pdata not passed\n"); in spear_thermal_probe()
98 return -EINVAL; in spear_thermal_probe()
101 stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL); in spear_thermal_probe()
103 return -ENOMEM; in spear_thermal_probe()
105 /* Enable thermal sensor */ in spear_thermal_probe()
106 stdev->thermal_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in spear_thermal_probe()
107 if (IS_ERR(stdev->thermal_base)) in spear_thermal_probe()
108 return PTR_ERR(stdev->thermal_base); in spear_thermal_probe()
110 stdev->clk = devm_clk_get(&pdev->dev, NULL); in spear_thermal_probe()
111 if (IS_ERR(stdev->clk)) { in spear_thermal_probe()
112 dev_err(&pdev->dev, "Can't get clock\n"); in spear_thermal_probe()
113 return PTR_ERR(stdev->clk); in spear_thermal_probe()
116 ret = clk_enable(stdev->clk); in spear_thermal_probe()
118 dev_err(&pdev->dev, "Can't enable clock\n"); in spear_thermal_probe()
122 stdev->flags = val; in spear_thermal_probe()
123 writel_relaxed(stdev->flags, stdev->thermal_base); in spear_thermal_probe()
128 dev_err(&pdev->dev, "thermal zone device is NULL\n"); in spear_thermal_probe()
134 dev_err(&pdev->dev, "Cannot enable thermal zone\n"); in spear_thermal_probe()
140 dev_info(&pdev->dev, "Thermal Sensor Loaded at: 0x%p.\n", in spear_thermal_probe()
141 stdev->thermal_base); in spear_thermal_probe()
148 clk_disable(stdev->clk); in spear_thermal_probe()
161 /* Disable SPEAr Thermal Sensor */ in spear_thermal_exit()
162 actual_mask = readl_relaxed(stdev->thermal_base); in spear_thermal_exit()
163 writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base); in spear_thermal_exit()
165 clk_disable(stdev->clk); in spear_thermal_exit()
169 { .compatible = "st,thermal-spear1340" },
187 MODULE_DESCRIPTION("SPEAr thermal driver");