Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/thermal/spear_thermal.c: add Device Tree probing capability

SPEAr platforms now support DT and so must convert all drivers to support
DT. This patch adds DT probing support for SPEAr thermal sensor driver
and updates its documentation too.

Also, as SPEAr is the only user of this driver and is only available with
DT, make this an only DT driver. So, platform_data is completely removed
and passed via DT now.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@st.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by

Viresh Kumar and committed by
Len Brown
b9c7aff4 76e10d15

+31 -36
+14
Documentation/devicetree/bindings/thermal/spear-thermal.txt
··· 1 + * SPEAr Thermal 2 + 3 + Required properties: 4 + - compatible : "st,thermal-spear1340" 5 + - reg : Address range of the thermal registers 6 + - st,thermal-flags: flags used to enable thermal sensor 7 + 8 + Example: 9 + 10 + thermal@fc000000 { 11 + compatible = "st,thermal-spear1340"; 12 + reg = <0xfc000000 0x1000>; 13 + st,thermal-flags = <0x7000>; 14 + };
+1
drivers/thermal/Kconfig
··· 23 23 bool "SPEAr thermal sensor driver" 24 24 depends on THERMAL 25 25 depends on PLAT_SPEAR 26 + depends on OF 26 27 help 27 28 Enable this to plug the SPEAr thermal sensor driver into the Linux 28 29 thermal framework
+16 -10
drivers/thermal/spear_thermal.c
··· 20 20 #include <linux/err.h> 21 21 #include <linux/io.h> 22 22 #include <linux/kernel.h> 23 + #include <linux/of.h> 23 24 #include <linux/module.h> 24 25 #include <linux/platform_device.h> 25 - #include <linux/platform_data/spear_thermal.h> 26 26 #include <linux/thermal.h> 27 27 28 28 #define MD_FACTOR 1000 ··· 103 103 { 104 104 struct thermal_zone_device *spear_thermal = NULL; 105 105 struct spear_thermal_dev *stdev; 106 - struct spear_thermal_pdata *pdata; 107 - int ret = 0; 106 + struct device_node *np = pdev->dev.of_node; 108 107 struct resource *stres = platform_get_resource(pdev, IORESOURCE_MEM, 0); 108 + int ret = 0, val; 109 + 110 + if (!np || !of_property_read_u32(np, "st,thermal-flags", &val)) { 111 + dev_err(&pdev->dev, "Failed: DT Pdata not passed\n"); 112 + return -EINVAL; 113 + } 109 114 110 115 if (!stres) { 111 116 dev_err(&pdev->dev, "memory resource missing\n"); 112 117 return -ENODEV; 113 - } 114 - 115 - pdata = dev_get_platdata(&pdev->dev); 116 - if (!pdata) { 117 - dev_err(&pdev->dev, "platform data is NULL\n"); 118 - return -EINVAL; 119 118 } 120 119 121 120 stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL); ··· 143 144 goto put_clk; 144 145 } 145 146 146 - stdev->flags = pdata->thermal_flags; 147 + stdev->flags = val; 147 148 writel_relaxed(stdev->flags, stdev->thermal_base); 148 149 149 150 spear_thermal = thermal_zone_device_register("spear_thermal", 0, ··· 188 189 return 0; 189 190 } 190 191 192 + static const struct of_device_id spear_thermal_id_table[] = { 193 + { .compatible = "st,thermal-spear1340" }, 194 + {} 195 + }; 196 + MODULE_DEVICE_TABLE(of, spear_thermal_id_table); 197 + 191 198 static struct platform_driver spear_thermal_driver = { 192 199 .probe = spear_thermal_probe, 193 200 .remove = spear_thermal_exit, ··· 201 196 .name = "spear_thermal", 202 197 .owner = THIS_MODULE, 203 198 .pm = &spear_thermal_pm_ops, 199 + .of_match_table = of_match_ptr(spear_thermal_id_table), 204 200 }, 205 201 }; 206 202
-26
include/linux/platform_data/spear_thermal.h
··· 1 - /* 2 - * SPEAr thermal driver platform data. 3 - * 4 - * Copyright (C) 2011-2012 ST Microelectronics 5 - * Author: Vincenzo Frascino <vincenzo.frascino@st.com> 6 - * 7 - * This software is licensed under the terms of the GNU General Public 8 - * License version 2, as published by the Free Software Foundation, and 9 - * may be copied, distributed, and modified under those terms. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - * 16 - */ 17 - #ifndef SPEAR_THERMAL_H 18 - #define SPEAR_THERMAL_H 19 - 20 - /* SPEAr Thermal Sensor Platform Data */ 21 - struct spear_thermal_pdata { 22 - /* flags used to enable thermal sensor */ 23 - unsigned int thermal_flags; 24 - }; 25 - 26 - #endif /* SPEAR_THERMAL_H */