diff options
| -rw-r--r-- | Documentation/devicetree/bindings/thermal/spear-thermal.txt | 14 | ||||
| -rw-r--r-- | drivers/thermal/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/thermal/spear_thermal.c | 26 | ||||
| -rw-r--r-- | include/linux/platform_data/spear_thermal.h | 26 |
4 files changed, 31 insertions, 36 deletions
diff --git a/Documentation/devicetree/bindings/thermal/spear-thermal.txt b/Documentation/devicetree/bindings/thermal/spear-thermal.txt new file mode 100644 index 000000000000..93e3b67c102d --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/spear-thermal.txt | |||
| @@ -0,0 +1,14 @@ | |||
| 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 | }; | ||
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 514a691abea0..3ab2bd540b54 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 c2e32df3b164..ca40d36d0ba8 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 | ||
| 191 | static const struct of_device_id spear_thermal_id_table[] = { | ||
| 192 | { .compatible = "st,thermal-spear1340" }, | ||
| 193 | {} | ||
| 194 | }; | ||
| 195 | MODULE_DEVICE_TABLE(of, spear_thermal_id_table); | ||
| 196 | |||
| 192 | static struct platform_driver spear_thermal_driver = { | 197 | static 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 | ||
diff --git a/include/linux/platform_data/spear_thermal.h b/include/linux/platform_data/spear_thermal.h deleted file mode 100644 index 724f2e1cbbcb..000000000000 --- a/include/linux/platform_data/spear_thermal.h +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 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 */ | ||
