aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-24 20:13:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-24 20:13:49 -0500
commit91466574be1a3701fab4abf5ac1539b556575a81 (patch)
tree89373ef6b0c9e024a9688207b832552dfbcca666 /drivers/hwmon
parent09da8dfa98682d871987145ed11e3232accac860 (diff)
parentc698a4492f01127ca90fc28cd5157f3d616fe4ff (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal management updates from Zhang Rui: "This time, the biggest change is the work of representing hardware thermal properties in device tree infrastructure. This work includes the introduction of a device tree bindings for describing the hardware thermal behavior and limits, and also a parser to read and interpret the data, and build thermal zones and thermal binding parameters. It also contains three examples on how to use the new representation on sensor devices, using three different drivers to accomplish it. One driver is in thermal subsystem, the TI SoC thermal, and the other two drivers are in hwmon subsystem. Actually, this would be the first step of the complete work because we still need to check other potential drivers to be converted and then validate the proposed API. But the reason why I include it in this pull request is that, first, this change does not hurt any others without using this approach, second, the principle and concept of this change would not break after converting the remaining drivers. BTW, as you can see, there are several points in this change that do not belong to thermal subsystem. Because it has been suggested by Guenter R that in such cases, it is recommended to send the complete series via one single subsystem. Specifics: - representing hardware thermal properties in device tree infrastructure - fix a regression that the imx thermal driver breaks system suspend. - introduce ACPI INT3403 thermal driver to retrieve temperature data from the INT3403 ACPI device object present on some systems. - introduce debug statement for thermal core and step_wise governor. - assorted fixes and cleanups for thermal core, cpu cooling, exynos thrmal, intel powerclamp and imx thermal driver" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: (34 commits) thermal: remove const flag from .ops of imx thermal Thermal: update thermal zone device after setting emul_temp intel_powerclamp: Fix cstate counter detection. thermal: imx: add necessary clk operation Thermal cpu cooling: return error if no valid cpu frequency entry thermal: fix cpu_cooling max_level behavior thermal: rcar-thermal: Enable driver compilation with COMPILE_TEST thermal: debug: add debug statement for core and step_wise thermal: imx_thermal: add module device table drivers: thermal: Mark function as static in x86_pkg_temp_thermal.c thermal:samsung: fix compilation warning thermal: imx: correct suspend/resume flow thermal: exynos: fix error return code Thermal: ACPI INT3403 thermal driver MAINTAINERS: add thermal bindings entry in thermal domain arm: dts: make OMAP4460 bandgap node to belong to OCP arm: dts: make OMAP443x bandgap node to belong to OCP arm: dts: add cooling properties on omap5 cpu node arm: dts: add omap5 thermal data arm: dts: add omap5 CORE thermal data ...
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm75.c35
-rw-r--r--drivers/hwmon/tmp102.c19
2 files changed, 49 insertions, 5 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 7e3ef134f1d2..84a55eacd903 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -27,6 +27,8 @@
27#include <linux/hwmon-sysfs.h> 27#include <linux/hwmon-sysfs.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/of.h>
31#include <linux/thermal.h>
30#include "lm75.h" 32#include "lm75.h"
31 33
32 34
@@ -71,6 +73,7 @@ static const u8 LM75_REG_TEMP[3] = {
71/* Each client has this additional data */ 73/* Each client has this additional data */
72struct lm75_data { 74struct lm75_data {
73 struct device *hwmon_dev; 75 struct device *hwmon_dev;
76 struct thermal_zone_device *tz;
74 struct mutex update_lock; 77 struct mutex update_lock;
75 u8 orig_conf; 78 u8 orig_conf;
76 u8 resolution; /* In bits, between 9 and 12 */ 79 u8 resolution; /* In bits, between 9 and 12 */
@@ -91,22 +94,36 @@ static struct lm75_data *lm75_update_device(struct device *dev);
91 94
92/*-----------------------------------------------------------------------*/ 95/*-----------------------------------------------------------------------*/
93 96
97static inline long lm75_reg_to_mc(s16 temp, u8 resolution)
98{
99 return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8);
100}
101
94/* sysfs attributes for hwmon */ 102/* sysfs attributes for hwmon */
95 103
104static int lm75_read_temp(void *dev, long *temp)
105{
106 struct lm75_data *data = lm75_update_device(dev);
107
108 if (IS_ERR(data))
109 return PTR_ERR(data);
110
111 *temp = lm75_reg_to_mc(data->temp[0], data->resolution);
112
113 return 0;
114}
115
96static ssize_t show_temp(struct device *dev, struct device_attribute *da, 116static ssize_t show_temp(struct device *dev, struct device_attribute *da,
97 char *buf) 117 char *buf)
98{ 118{
99 struct sensor_device_attribute *attr = to_sensor_dev_attr(da); 119 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
100 struct lm75_data *data = lm75_update_device(dev); 120 struct lm75_data *data = lm75_update_device(dev);
101 long temp;
102 121
103 if (IS_ERR(data)) 122 if (IS_ERR(data))
104 return PTR_ERR(data); 123 return PTR_ERR(data);
105 124
106 temp = ((data->temp[attr->index] >> (16 - data->resolution)) * 1000) 125 return sprintf(buf, "%ld\n", lm75_reg_to_mc(data->temp[attr->index],
107 >> (data->resolution - 8); 126 data->resolution));
108
109 return sprintf(buf, "%ld\n", temp);
110} 127}
111 128
112static ssize_t set_temp(struct device *dev, struct device_attribute *da, 129static ssize_t set_temp(struct device *dev, struct device_attribute *da,
@@ -273,6 +290,13 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
273 goto exit_remove; 290 goto exit_remove;
274 } 291 }
275 292
293 data->tz = thermal_zone_of_sensor_register(&client->dev,
294 0,
295 &client->dev,
296 lm75_read_temp, NULL);
297 if (IS_ERR(data->tz))
298 data->tz = NULL;
299
276 dev_info(&client->dev, "%s: sensor '%s'\n", 300 dev_info(&client->dev, "%s: sensor '%s'\n",
277 dev_name(data->hwmon_dev), client->name); 301 dev_name(data->hwmon_dev), client->name);
278 302
@@ -287,6 +311,7 @@ static int lm75_remove(struct i2c_client *client)
287{ 311{
288 struct lm75_data *data = i2c_get_clientdata(client); 312 struct lm75_data *data = i2c_get_clientdata(client);
289 313
314 thermal_zone_of_sensor_unregister(&client->dev, data->tz);
290 hwmon_device_unregister(data->hwmon_dev); 315 hwmon_device_unregister(data->hwmon_dev);
291 sysfs_remove_group(&client->dev.kobj, &lm75_group); 316 sysfs_remove_group(&client->dev.kobj, &lm75_group);
292 lm75_write_value(client, LM75_REG_CONF, data->orig_conf); 317 lm75_write_value(client, LM75_REG_CONF, data->orig_conf);
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index d7b47abf37fe..6748b4583e7b 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -27,6 +27,8 @@
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/device.h> 28#include <linux/device.h>
29#include <linux/jiffies.h> 29#include <linux/jiffies.h>
30#include <linux/thermal.h>
31#include <linux/of.h>
30 32
31#define DRIVER_NAME "tmp102" 33#define DRIVER_NAME "tmp102"
32 34
@@ -50,6 +52,7 @@
50 52
51struct tmp102 { 53struct tmp102 {
52 struct device *hwmon_dev; 54 struct device *hwmon_dev;
55 struct thermal_zone_device *tz;
53 struct mutex lock; 56 struct mutex lock;
54 u16 config_orig; 57 u16 config_orig;
55 unsigned long last_update; 58 unsigned long last_update;
@@ -93,6 +96,15 @@ static struct tmp102 *tmp102_update_device(struct i2c_client *client)
93 return tmp102; 96 return tmp102;
94} 97}
95 98
99static int tmp102_read_temp(void *dev, long *temp)
100{
101 struct tmp102 *tmp102 = tmp102_update_device(to_i2c_client(dev));
102
103 *temp = tmp102->temp[0];
104
105 return 0;
106}
107
96static ssize_t tmp102_show_temp(struct device *dev, 108static ssize_t tmp102_show_temp(struct device *dev,
97 struct device_attribute *attr, 109 struct device_attribute *attr,
98 char *buf) 110 char *buf)
@@ -204,6 +216,12 @@ static int tmp102_probe(struct i2c_client *client,
204 goto fail_remove_sysfs; 216 goto fail_remove_sysfs;
205 } 217 }
206 218
219 tmp102->tz = thermal_zone_of_sensor_register(&client->dev, 0,
220 &client->dev,
221 tmp102_read_temp, NULL);
222 if (IS_ERR(tmp102->tz))
223 tmp102->tz = NULL;
224
207 dev_info(&client->dev, "initialized\n"); 225 dev_info(&client->dev, "initialized\n");
208 226
209 return 0; 227 return 0;
@@ -220,6 +238,7 @@ static int tmp102_remove(struct i2c_client *client)
220{ 238{
221 struct tmp102 *tmp102 = i2c_get_clientdata(client); 239 struct tmp102 *tmp102 = i2c_get_clientdata(client);
222 240
241 thermal_zone_of_sensor_unregister(&client->dev, tmp102->tz);
223 hwmon_device_unregister(tmp102->hwmon_dev); 242 hwmon_device_unregister(tmp102->hwmon_dev);
224 sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); 243 sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group);
225 244