aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2008-08-06 16:41:05 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-08-06 16:41:05 -0400
commit84f768c1633cfc547d82b9dc671ffea2f3785542 (patch)
treeec72183fa24730b12c99f3a0ee2d039b8f1070d8 /drivers/hwmon
parent68f823de3f1916cc0694376330c08377706b877d (diff)
hwmon: (thmc50) Add support for critical temperature limits
Add critical temperature limits to the driver. These limits are read only. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/thmc50.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c
index 3b01001108c1..7d97431e132f 100644
--- a/drivers/hwmon/thmc50.c
+++ b/drivers/hwmon/thmc50.c
@@ -55,8 +55,11 @@ I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs "
55static const u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 }; 55static const u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 };
56static const u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C }; 56static const u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C };
57static const u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B }; 57static const u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B };
58static const u8 THMC50_REG_TEMP_CRITICAL[] = { 0x13, 0x14, 0x14 };
59static const u8 THMC50_REG_TEMP_DEFAULT[] = { 0x17, 0x18, 0x18 };
58 60
59#define THMC50_REG_CONF_nFANOFF 0x20 61#define THMC50_REG_CONF_nFANOFF 0x20
62#define THMC50_REG_CONF_PROGRAMMED 0x08
60 63
61/* Each client has this additional data */ 64/* Each client has this additional data */
62struct thmc50_data { 65struct thmc50_data {
@@ -72,6 +75,7 @@ struct thmc50_data {
72 s8 temp_input[3]; 75 s8 temp_input[3];
73 s8 temp_max[3]; 76 s8 temp_max[3];
74 s8 temp_min[3]; 77 s8 temp_min[3];
78 s8 temp_critical[3];
75 u8 analog_out; 79 u8 analog_out;
76 u8 alarms; 80 u8 alarms;
77}; 81};
@@ -199,6 +203,15 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
199 return count; 203 return count;
200} 204}
201 205
206static ssize_t show_temp_critical(struct device *dev,
207 struct device_attribute *attr,
208 char *buf)
209{
210 int nr = to_sensor_dev_attr(attr)->index;
211 struct thmc50_data *data = thmc50_update_device(dev);
212 return sprintf(buf, "%d\n", data->temp_critical[nr] * 1000);
213}
214
202static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, 215static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
203 char *buf) 216 char *buf)
204{ 217{
@@ -214,7 +227,9 @@ static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \
214static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ 227static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
215 show_temp_min, set_temp_min, offset - 1); \ 228 show_temp_min, set_temp_min, offset - 1); \
216static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ 229static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
217 show_temp_max, set_temp_max, offset - 1); 230 show_temp_max, set_temp_max, offset - 1); \
231static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO, \
232 show_temp_critical, NULL, offset - 1);
218 233
219temp_reg(1); 234temp_reg(1);
220temp_reg(2); 235temp_reg(2);
@@ -234,10 +249,12 @@ static struct attribute *thmc50_attributes[] = {
234 &sensor_dev_attr_temp1_max.dev_attr.attr, 249 &sensor_dev_attr_temp1_max.dev_attr.attr,
235 &sensor_dev_attr_temp1_min.dev_attr.attr, 250 &sensor_dev_attr_temp1_min.dev_attr.attr,
236 &sensor_dev_attr_temp1_input.dev_attr.attr, 251 &sensor_dev_attr_temp1_input.dev_attr.attr,
252 &sensor_dev_attr_temp1_crit.dev_attr.attr,
237 &sensor_dev_attr_temp1_alarm.dev_attr.attr, 253 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
238 &sensor_dev_attr_temp2_max.dev_attr.attr, 254 &sensor_dev_attr_temp2_max.dev_attr.attr,
239 &sensor_dev_attr_temp2_min.dev_attr.attr, 255 &sensor_dev_attr_temp2_min.dev_attr.attr,
240 &sensor_dev_attr_temp2_input.dev_attr.attr, 256 &sensor_dev_attr_temp2_input.dev_attr.attr,
257 &sensor_dev_attr_temp2_crit.dev_attr.attr,
241 &sensor_dev_attr_temp2_alarm.dev_attr.attr, 258 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
242 &sensor_dev_attr_temp2_fault.dev_attr.attr, 259 &sensor_dev_attr_temp2_fault.dev_attr.attr,
243 &sensor_dev_attr_pwm1.dev_attr.attr, 260 &sensor_dev_attr_pwm1.dev_attr.attr,
@@ -254,6 +271,7 @@ static struct attribute *temp3_attributes[] = {
254 &sensor_dev_attr_temp3_max.dev_attr.attr, 271 &sensor_dev_attr_temp3_max.dev_attr.attr,
255 &sensor_dev_attr_temp3_min.dev_attr.attr, 272 &sensor_dev_attr_temp3_min.dev_attr.attr,
256 &sensor_dev_attr_temp3_input.dev_attr.attr, 273 &sensor_dev_attr_temp3_input.dev_attr.attr,
274 &sensor_dev_attr_temp3_crit.dev_attr.attr,
257 &sensor_dev_attr_temp3_alarm.dev_attr.attr, 275 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
258 &sensor_dev_attr_temp3_fault.dev_attr.attr, 276 &sensor_dev_attr_temp3_fault.dev_attr.attr,
259 NULL 277 NULL
@@ -429,6 +447,10 @@ static struct thmc50_data *thmc50_update_device(struct device *dev)
429 447
430 int temps = data->has_temp3 ? 3 : 2; 448 int temps = data->has_temp3 ? 3 : 2;
431 int i; 449 int i;
450 int prog = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
451
452 prog &= THMC50_REG_CONF_PROGRAMMED;
453
432 for (i = 0; i < temps; i++) { 454 for (i = 0; i < temps; i++) {
433 data->temp_input[i] = i2c_smbus_read_byte_data(client, 455 data->temp_input[i] = i2c_smbus_read_byte_data(client,
434 THMC50_REG_TEMP[i]); 456 THMC50_REG_TEMP[i]);
@@ -436,6 +458,10 @@ static struct thmc50_data *thmc50_update_device(struct device *dev)
436 THMC50_REG_TEMP_MAX[i]); 458 THMC50_REG_TEMP_MAX[i]);
437 data->temp_min[i] = i2c_smbus_read_byte_data(client, 459 data->temp_min[i] = i2c_smbus_read_byte_data(client,
438 THMC50_REG_TEMP_MIN[i]); 460 THMC50_REG_TEMP_MIN[i]);
461 data->temp_critical[i] =
462 i2c_smbus_read_byte_data(client,
463 prog ? THMC50_REG_TEMP_CRITICAL[i]
464 : THMC50_REG_TEMP_DEFAULT[i]);
439 } 465 }
440 data->analog_out = 466 data->analog_out =
441 i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT); 467 i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT);