aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorViresh Kumar <viresh.linux@gmail.com>2012-05-29 14:18:51 -0400
committerLen Brown <len.brown@intel.com>2012-06-02 01:49:38 -0400
commitb9c7aff481f19dd655ae3ce6513817d625e2d47c (patch)
treed84338cd776c68891522e60e7faa30ac7ad09a91 /drivers/thermal
parent76e10d158efb6d4516018846f60c2ab5501900bc (diff)
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>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/Kconfig1
-rw-r--r--drivers/thermal/spear_thermal.c26
2 files changed, 17 insertions, 10 deletions
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 514a691abea..3ab2bd540b5 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -23,6 +23,7 @@ config SPEAR_THERMAL
23 bool "SPEAr thermal sensor driver" 23 bool "SPEAr thermal sensor driver"
24 depends on THERMAL 24 depends on THERMAL
25 depends on PLAT_SPEAR 25 depends on PLAT_SPEAR
26 depends on OF
26 help 27 help
27 Enable this to plug the SPEAr thermal sensor driver into the Linux 28 Enable this to plug the SPEAr thermal sensor driver into the Linux
28 thermal framework 29 thermal framework
diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
index c2e32df3b16..ca40d36d0ba 100644
--- a/drivers/thermal/spear_thermal.c
+++ b/drivers/thermal/spear_thermal.c
@@ -20,9 +20,9 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/of.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/platform_device.h> 25#include <linux/platform_device.h>
25#include <linux/platform_data/spear_thermal.h>
26#include <linux/thermal.h> 26#include <linux/thermal.h>
27 27
28#define MD_FACTOR 1000 28#define MD_FACTOR 1000
@@ -103,21 +103,20 @@ static int spear_thermal_probe(struct platform_device *pdev)
103{ 103{
104 struct thermal_zone_device *spear_thermal = NULL; 104 struct thermal_zone_device *spear_thermal = NULL;
105 struct spear_thermal_dev *stdev; 105 struct spear_thermal_dev *stdev;
106 struct spear_thermal_pdata *pdata; 106 struct device_node *np = pdev->dev.of_node;
107 int ret = 0;
108 struct resource *stres = platform_get_resource(pdev, IORESOURCE_MEM, 0); 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 if (!stres) { 115 if (!stres) {
111 dev_err(&pdev->dev, "memory resource missing\n"); 116 dev_err(&pdev->dev, "memory resource missing\n");
112 return -ENODEV; 117 return -ENODEV;
113 } 118 }
114 119
115 pdata = dev_get_platdata(&pdev->dev);
116 if (!pdata) {
117 dev_err(&pdev->dev, "platform data is NULL\n");
118 return -EINVAL;
119 }
120
121 stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL); 120 stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL);
122 if (!stdev) { 121 if (!stdev) {
123 dev_err(&pdev->dev, "kzalloc fail\n"); 122 dev_err(&pdev->dev, "kzalloc fail\n");
@@ -144,7 +143,7 @@ static int spear_thermal_probe(struct platform_device *pdev)
144 goto put_clk; 143 goto put_clk;
145 } 144 }
146 145
147 stdev->flags = pdata->thermal_flags; 146 stdev->flags = val;
148 writel_relaxed(stdev->flags, stdev->thermal_base); 147 writel_relaxed(stdev->flags, stdev->thermal_base);
149 148
150 spear_thermal = thermal_zone_device_register("spear_thermal", 0, 149 spear_thermal = thermal_zone_device_register("spear_thermal", 0,
@@ -189,6 +188,12 @@ static int spear_thermal_exit(struct platform_device *pdev)
189 return 0; 188 return 0;
190} 189}
191 190
191static const struct of_device_id spear_thermal_id_table[] = {
192 { .compatible = "st,thermal-spear1340" },
193 {}
194};
195MODULE_DEVICE_TABLE(of, spear_thermal_id_table);
196
192static struct platform_driver spear_thermal_driver = { 197static struct platform_driver spear_thermal_driver = {
193 .probe = spear_thermal_probe, 198 .probe = spear_thermal_probe,
194 .remove = spear_thermal_exit, 199 .remove = spear_thermal_exit,
@@ -196,6 +201,7 @@ static struct platform_driver spear_thermal_driver = {
196 .name = "spear_thermal", 201 .name = "spear_thermal",
197 .owner = THIS_MODULE, 202 .owner = THIS_MODULE,
198 .pm = &spear_thermal_pm_ops, 203 .pm = &spear_thermal_pm_ops,
204 .of_match_table = of_match_ptr(spear_thermal_id_table),
199 }, 205 },
200}; 206};
201 207