Skip to content

Commit

Permalink
drivers/thermal/spear_thermal.c: add Device Tree probing capability
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Viresh Kumar authored and Len Brown committed Jun 2, 2012
1 parent 76e10d1 commit b9c7aff
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 36 deletions.
14 changes: 14 additions & 0 deletions Documentation/devicetree/bindings/thermal/spear-thermal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
* SPEAr Thermal

Required properties:
- compatible : "st,thermal-spear1340"
- reg : Address range of the thermal registers
- st,thermal-flags: flags used to enable thermal sensor

Example:

thermal@fc000000 {
compatible = "st,thermal-spear1340";
reg = <0xfc000000 0x1000>;
st,thermal-flags = <0x7000>;
};
1 change: 1 addition & 0 deletions drivers/thermal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ config SPEAR_THERMAL
bool "SPEAr thermal sensor driver"
depends on THERMAL
depends on PLAT_SPEAR
depends on OF
help
Enable this to plug the SPEAr thermal sensor driver into the Linux
thermal framework
26 changes: 16 additions & 10 deletions drivers/thermal/spear_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <linux/err.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/platform_data/spear_thermal.h>
#include <linux/thermal.h>

#define MD_FACTOR 1000
Expand Down Expand Up @@ -103,21 +103,20 @@ static int spear_thermal_probe(struct platform_device *pdev)
{
struct thermal_zone_device *spear_thermal = NULL;
struct spear_thermal_dev *stdev;
struct spear_thermal_pdata *pdata;
int ret = 0;
struct device_node *np = pdev->dev.of_node;
struct resource *stres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int ret = 0, val;

if (!np || !of_property_read_u32(np, "st,thermal-flags", &val)) {
dev_err(&pdev->dev, "Failed: DT Pdata not passed\n");
return -EINVAL;
}

if (!stres) {
dev_err(&pdev->dev, "memory resource missing\n");
return -ENODEV;
}

pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
dev_err(&pdev->dev, "platform data is NULL\n");
return -EINVAL;
}

stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL);
if (!stdev) {
dev_err(&pdev->dev, "kzalloc fail\n");
Expand All @@ -144,7 +143,7 @@ static int spear_thermal_probe(struct platform_device *pdev)
goto put_clk;
}

stdev->flags = pdata->thermal_flags;
stdev->flags = val;
writel_relaxed(stdev->flags, stdev->thermal_base);

spear_thermal = thermal_zone_device_register("spear_thermal", 0,
Expand Down Expand Up @@ -189,13 +188,20 @@ static int spear_thermal_exit(struct platform_device *pdev)
return 0;
}

static const struct of_device_id spear_thermal_id_table[] = {
{ .compatible = "st,thermal-spear1340" },
{}
};
MODULE_DEVICE_TABLE(of, spear_thermal_id_table);

static struct platform_driver spear_thermal_driver = {
.probe = spear_thermal_probe,
.remove = spear_thermal_exit,
.driver = {
.name = "spear_thermal",
.owner = THIS_MODULE,
.pm = &spear_thermal_pm_ops,
.of_match_table = of_match_ptr(spear_thermal_id_table),
},
};

Expand Down
26 changes: 0 additions & 26 deletions include/linux/platform_data/spear_thermal.h

This file was deleted.

0 comments on commit b9c7aff

Please sign in to comment.