diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/Kconfig | 16 | ||||
-rw-r--r-- | drivers/hwmon/Makefile | 1 | ||||
-rw-r--r-- | drivers/hwmon/f71882fg.c | 250 | ||||
-rw-r--r-- | drivers/hwmon/hwmon.c | 29 | ||||
-rw-r--r-- | drivers/hwmon/ibmaem.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/max6650.c | 86 | ||||
-rw-r--r-- | drivers/hwmon/sht15.c | 10 | ||||
-rw-r--r-- | drivers/hwmon/tmp401.c | 690 | ||||
-rw-r--r-- | drivers/hwmon/w83627ehf.c | 10 |
9 files changed, 1024 insertions, 69 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index d73f5f473e38..f8090e137fef 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -306,11 +306,11 @@ config SENSORS_F71805F | |||
306 | will be called f71805f. | 306 | will be called f71805f. |
307 | 307 | ||
308 | config SENSORS_F71882FG | 308 | config SENSORS_F71882FG |
309 | tristate "Fintek F71862FG, F71882FG and F8000" | 309 | tristate "Fintek F71858FG, F71862FG, F71882FG and F8000" |
310 | depends on EXPERIMENTAL | 310 | depends on EXPERIMENTAL |
311 | help | 311 | help |
312 | If you say yes here you get support for hardware monitoring | 312 | If you say yes here you get support for hardware monitoring |
313 | features of the Fintek F71882FG/F71883FG, F71862FG/71863FG | 313 | features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG |
314 | and F8000 Super-I/O chips. | 314 | and F8000 Super-I/O chips. |
315 | 315 | ||
316 | This driver can also be built as a module. If so, the module | 316 | This driver can also be built as a module. If so, the module |
@@ -418,7 +418,7 @@ config SENSORS_IBMAEM | |||
418 | power sensors and capping hardware in various IBM System X | 418 | power sensors and capping hardware in various IBM System X |
419 | servers that support Active Energy Manager. This includes | 419 | servers that support Active Energy Manager. This includes |
420 | the x3350, x3550, x3650, x3655, x3755, x3850 M2, x3950 M2, | 420 | the x3350, x3550, x3650, x3655, x3755, x3850 M2, x3950 M2, |
421 | and certain HS2x/LS2x/QS2x blades. | 421 | and certain HC10/HS2x/LS2x/QS2x blades. |
422 | 422 | ||
423 | This driver can also be built as a module. If so, the module | 423 | This driver can also be built as a module. If so, the module |
424 | will be called ibmaem. | 424 | will be called ibmaem. |
@@ -787,6 +787,16 @@ config SENSORS_THMC50 | |||
787 | This driver can also be built as a module. If so, the module | 787 | This driver can also be built as a module. If so, the module |
788 | will be called thmc50. | 788 | will be called thmc50. |
789 | 789 | ||
790 | config SENSORS_TMP401 | ||
791 | tristate "Texas Instruments TMP401 and compatibles" | ||
792 | depends on I2C && EXPERIMENTAL | ||
793 | help | ||
794 | If you say yes here you get support for Texas Instruments TMP401 and | ||
795 | TMP411 temperature sensor chips. | ||
796 | |||
797 | This driver can also be built as a module. If so, the module | ||
798 | will be called tmp401. | ||
799 | |||
790 | config SENSORS_VIA686A | 800 | config SENSORS_VIA686A |
791 | tristate "VIA686A" | 801 | tristate "VIA686A" |
792 | depends on PCI | 802 | depends on PCI |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 0ae26984ba45..b793dce6bed5 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -82,6 +82,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o | |||
82 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o | 82 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o |
83 | obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o | 83 | obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o |
84 | obj-$(CONFIG_SENSORS_THMC50) += thmc50.o | 84 | obj-$(CONFIG_SENSORS_THMC50) += thmc50.o |
85 | obj-$(CONFIG_SENSORS_TMP401) += tmp401.o | ||
85 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o | 86 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o |
86 | obj-$(CONFIG_SENSORS_VT1211) += vt1211.o | 87 | obj-$(CONFIG_SENSORS_VT1211) += vt1211.o |
87 | obj-$(CONFIG_SENSORS_VT8231) += vt8231.o | 88 | obj-$(CONFIG_SENSORS_VT8231) += vt8231.o |
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 5f81ddf71508..4146105f1a57 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Hans Edgington <hans@edgington.nl> * | 2 | * Copyright (C) 2006 by Hans Edgington <hans@edgington.nl> * |
3 | * Copyright (C) 2007,2008 by Hans de Goede <hdegoede@redhat.com> * | 3 | * Copyright (C) 2007-2009 Hans de Goede <hdegoede@redhat.com> * |
4 | * * | 4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * | 6 | * it under the terms of the GNU General Public License as published by * |
@@ -32,6 +32,7 @@ | |||
32 | 32 | ||
33 | #define DRVNAME "f71882fg" | 33 | #define DRVNAME "f71882fg" |
34 | 34 | ||
35 | #define SIO_F71858FG_LD_HWM 0x02 /* Hardware monitor logical device */ | ||
35 | #define SIO_F71882FG_LD_HWM 0x04 /* Hardware monitor logical device */ | 36 | #define SIO_F71882FG_LD_HWM 0x04 /* Hardware monitor logical device */ |
36 | #define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */ | 37 | #define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */ |
37 | #define SIO_LOCK_KEY 0xAA /* Key to diasble Super-I/O */ | 38 | #define SIO_LOCK_KEY 0xAA /* Key to diasble Super-I/O */ |
@@ -44,6 +45,7 @@ | |||
44 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ | 45 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ |
45 | 46 | ||
46 | #define SIO_FINTEK_ID 0x1934 /* Manufacturers ID */ | 47 | #define SIO_FINTEK_ID 0x1934 /* Manufacturers ID */ |
48 | #define SIO_F71858_ID 0x0507 /* Chipset ID */ | ||
47 | #define SIO_F71862_ID 0x0601 /* Chipset ID */ | 49 | #define SIO_F71862_ID 0x0601 /* Chipset ID */ |
48 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ | 50 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ |
49 | #define SIO_F8000_ID 0x0581 /* Chipset ID */ | 51 | #define SIO_F8000_ID 0x0581 /* Chipset ID */ |
@@ -70,6 +72,7 @@ | |||
70 | #define F71882FG_REG_TEMP_HIGH(nr) (0x81 + 2 * (nr)) | 72 | #define F71882FG_REG_TEMP_HIGH(nr) (0x81 + 2 * (nr)) |
71 | #define F71882FG_REG_TEMP_STATUS 0x62 | 73 | #define F71882FG_REG_TEMP_STATUS 0x62 |
72 | #define F71882FG_REG_TEMP_BEEP 0x63 | 74 | #define F71882FG_REG_TEMP_BEEP 0x63 |
75 | #define F71882FG_REG_TEMP_CONFIG 0x69 | ||
73 | #define F71882FG_REG_TEMP_HYST(nr) (0x6C + (nr)) | 76 | #define F71882FG_REG_TEMP_HYST(nr) (0x6C + (nr)) |
74 | #define F71882FG_REG_TEMP_TYPE 0x6B | 77 | #define F71882FG_REG_TEMP_TYPE 0x6B |
75 | #define F71882FG_REG_TEMP_DIODE_OPEN 0x6F | 78 | #define F71882FG_REG_TEMP_DIODE_OPEN 0x6F |
@@ -92,9 +95,10 @@ static unsigned short force_id; | |||
92 | module_param(force_id, ushort, 0); | 95 | module_param(force_id, ushort, 0); |
93 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 96 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
94 | 97 | ||
95 | enum chips { f71862fg, f71882fg, f8000 }; | 98 | enum chips { f71858fg, f71862fg, f71882fg, f8000 }; |
96 | 99 | ||
97 | static const char *f71882fg_names[] = { | 100 | static const char *f71882fg_names[] = { |
101 | "f71858fg", | ||
98 | "f71862fg", | 102 | "f71862fg", |
99 | "f71882fg", | 103 | "f71882fg", |
100 | "f8000", | 104 | "f8000", |
@@ -119,6 +123,7 @@ struct f71882fg_data { | |||
119 | struct device *hwmon_dev; | 123 | struct device *hwmon_dev; |
120 | 124 | ||
121 | struct mutex update_lock; | 125 | struct mutex update_lock; |
126 | int temp_start; /* temp numbering start (0 or 1) */ | ||
122 | char valid; /* !=0 if following fields are valid */ | 127 | char valid; /* !=0 if following fields are valid */ |
123 | unsigned long last_updated; /* In jiffies */ | 128 | unsigned long last_updated; /* In jiffies */ |
124 | unsigned long last_limits; /* In jiffies */ | 129 | unsigned long last_limits; /* In jiffies */ |
@@ -136,7 +141,7 @@ struct f71882fg_data { | |||
136 | /* Note: all models have only 3 temperature channels, but on some | 141 | /* Note: all models have only 3 temperature channels, but on some |
137 | they are addressed as 0-2 and on others as 1-3, so for coding | 142 | they are addressed as 0-2 and on others as 1-3, so for coding |
138 | convenience we reserve space for 4 channels */ | 143 | convenience we reserve space for 4 channels */ |
139 | u8 temp[4]; | 144 | u16 temp[4]; |
140 | u8 temp_ovt[4]; | 145 | u8 temp_ovt[4]; |
141 | u8 temp_high[4]; | 146 | u8 temp_high[4]; |
142 | u8 temp_hyst[2]; /* 2 hysts stored per reg */ | 147 | u8 temp_hyst[2]; /* 2 hysts stored per reg */ |
@@ -144,6 +149,7 @@ struct f71882fg_data { | |||
144 | u8 temp_status; | 149 | u8 temp_status; |
145 | u8 temp_beep; | 150 | u8 temp_beep; |
146 | u8 temp_diode_open; | 151 | u8 temp_diode_open; |
152 | u8 temp_config; | ||
147 | u8 pwm[4]; | 153 | u8 pwm[4]; |
148 | u8 pwm_enable; | 154 | u8 pwm_enable; |
149 | u8 pwm_auto_point_hyst[2]; | 155 | u8 pwm_auto_point_hyst[2]; |
@@ -247,11 +253,55 @@ static struct platform_driver f71882fg_driver = { | |||
247 | .name = DRVNAME, | 253 | .name = DRVNAME, |
248 | }, | 254 | }, |
249 | .probe = f71882fg_probe, | 255 | .probe = f71882fg_probe, |
250 | .remove = __devexit_p(f71882fg_remove), | 256 | .remove = f71882fg_remove, |
251 | }; | 257 | }; |
252 | 258 | ||
253 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 259 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
254 | 260 | ||
261 | /* Temp and in attr for the f71858fg */ | ||
262 | static struct sensor_device_attribute_2 f71858fg_in_temp_attr[] = { | ||
263 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), | ||
264 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), | ||
265 | SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2), | ||
266 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 0), | ||
267 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, | ||
268 | store_temp_max, 0, 0), | ||
269 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, | ||
270 | store_temp_max_hyst, 0, 0), | ||
271 | SENSOR_ATTR_2(temp1_max_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 0), | ||
272 | SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, | ||
273 | store_temp_crit, 0, 0), | ||
274 | SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | ||
275 | 0, 0), | ||
276 | SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 4), | ||
277 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 0), | ||
278 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1), | ||
279 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_max, | ||
280 | store_temp_max, 0, 1), | ||
281 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, | ||
282 | store_temp_max_hyst, 0, 1), | ||
283 | SENSOR_ATTR_2(temp2_max_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1), | ||
284 | SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, | ||
285 | store_temp_crit, 0, 1), | ||
286 | SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | ||
287 | 0, 1), | ||
288 | SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), | ||
289 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 1), | ||
290 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), | ||
291 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2), | ||
292 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, | ||
293 | store_temp_max, 0, 2), | ||
294 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, | ||
295 | store_temp_max_hyst, 0, 2), | ||
296 | SENSOR_ATTR_2(temp3_max_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2), | ||
297 | SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, | ||
298 | store_temp_crit, 0, 2), | ||
299 | SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | ||
300 | 0, 2), | ||
301 | SENSOR_ATTR_2(temp3_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), | ||
302 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), | ||
303 | }; | ||
304 | |||
255 | /* Temp and in attr common to both the f71862fg and f71882fg */ | 305 | /* Temp and in attr common to both the f71862fg and f71882fg */ |
256 | static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = { | 306 | static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = { |
257 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), | 307 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), |
@@ -344,6 +394,7 @@ static struct sensor_device_attribute_2 f8000_in_temp_attr[] = { | |||
344 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max, | 394 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max, |
345 | store_temp_max, 0, 0), | 395 | store_temp_max, 0, 0), |
346 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 4), | 396 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 4), |
397 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 0), | ||
347 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1), | 398 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1), |
348 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_crit, | 399 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_crit, |
349 | store_temp_crit, 0, 1), | 400 | store_temp_crit, 0, 1), |
@@ -351,12 +402,14 @@ static struct sensor_device_attribute_2 f8000_in_temp_attr[] = { | |||
351 | store_temp_max, 0, 1), | 402 | store_temp_max, 0, 1), |
352 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), | 403 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), |
353 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 1), | 404 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 1), |
405 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), | ||
354 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2), | 406 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2), |
355 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_crit, | 407 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_crit, |
356 | store_temp_crit, 0, 2), | 408 | store_temp_crit, 0, 2), |
357 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max, | 409 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max, |
358 | store_temp_max, 0, 2), | 410 | store_temp_max, 0, 2), |
359 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), | 411 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), |
412 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), | ||
360 | }; | 413 | }; |
361 | 414 | ||
362 | /* Fan / PWM attr common to all models */ | 415 | /* Fan / PWM attr common to all models */ |
@@ -395,6 +448,9 @@ static struct sensor_device_attribute_2 fxxxx_fan_attr[] = { | |||
395 | show_pwm_auto_point_channel, | 448 | show_pwm_auto_point_channel, |
396 | store_pwm_auto_point_channel, 0, 1), | 449 | store_pwm_auto_point_channel, 0, 1), |
397 | 450 | ||
451 | SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2), | ||
452 | SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
453 | store_pwm_enable, 0, 2), | ||
398 | SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR, | 454 | SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR, |
399 | show_pwm_interpolate, store_pwm_interpolate, 0, 2), | 455 | show_pwm_interpolate, store_pwm_interpolate, 0, 2), |
400 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, | 456 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, |
@@ -450,9 +506,6 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = { | |||
450 | SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, | 506 | SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, |
451 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), | 507 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
452 | 508 | ||
453 | SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2), | ||
454 | SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
455 | store_pwm_enable, 0, 2), | ||
456 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, | 509 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
457 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 510 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
458 | 1, 2), | 511 | 1, 2), |
@@ -473,22 +526,8 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = { | |||
473 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), | 526 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
474 | }; | 527 | }; |
475 | 528 | ||
476 | /* Fan / PWM attr for the f71882fg */ | 529 | /* Fan / PWM attr common to both the f71882fg and f71858fg */ |
477 | static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { | 530 | static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = { |
478 | SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
479 | store_fan_beep, 0, 0), | ||
480 | SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
481 | store_fan_beep, 0, 1), | ||
482 | SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
483 | store_fan_beep, 0, 2), | ||
484 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), | ||
485 | SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR, | ||
486 | show_fan_full_speed, | ||
487 | store_fan_full_speed, 0, 3), | ||
488 | SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
489 | store_fan_beep, 0, 3), | ||
490 | SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3), | ||
491 | |||
492 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, | 531 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
493 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 532 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
494 | 0, 0), | 533 | 0, 0), |
@@ -565,9 +604,6 @@ static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { | |||
565 | SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO, | 604 | SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO, |
566 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), | 605 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
567 | 606 | ||
568 | SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2), | ||
569 | SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
570 | store_pwm_enable, 0, 2), | ||
571 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, | 607 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
572 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 608 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
573 | 0, 2), | 609 | 0, 2), |
@@ -605,6 +641,24 @@ static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { | |||
605 | show_pwm_auto_point_temp_hyst, NULL, 2, 2), | 641 | show_pwm_auto_point_temp_hyst, NULL, 2, 2), |
606 | SENSOR_ATTR_2(pwm3_auto_point4_temp_hyst, S_IRUGO, | 642 | SENSOR_ATTR_2(pwm3_auto_point4_temp_hyst, S_IRUGO, |
607 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), | 643 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
644 | }; | ||
645 | |||
646 | /* Fan / PWM attr found on the f71882fg but not on the f71858fg */ | ||
647 | static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { | ||
648 | SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
649 | store_fan_beep, 0, 0), | ||
650 | SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
651 | store_fan_beep, 0, 1), | ||
652 | SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
653 | store_fan_beep, 0, 2), | ||
654 | |||
655 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), | ||
656 | SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR, | ||
657 | show_fan_full_speed, | ||
658 | store_fan_full_speed, 0, 3), | ||
659 | SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
660 | store_fan_beep, 0, 3), | ||
661 | SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3), | ||
608 | 662 | ||
609 | SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3), | 663 | SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3), |
610 | SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | 664 | SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
@@ -659,8 +713,6 @@ static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { | |||
659 | static struct sensor_device_attribute_2 f8000_fan_attr[] = { | 713 | static struct sensor_device_attribute_2 f8000_fan_attr[] = { |
660 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), | 714 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), |
661 | 715 | ||
662 | SENSOR_ATTR_2(pwm3, S_IRUGO, show_pwm, NULL, 0, 2), | ||
663 | |||
664 | SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR, | 716 | SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
665 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 717 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
666 | 0, 2), | 718 | 0, 2), |
@@ -857,13 +909,20 @@ static void f71882fg_write16(struct f71882fg_data *data, u8 reg, u16 val) | |||
857 | outb(val & 255, data->addr + DATA_REG_OFFSET); | 909 | outb(val & 255, data->addr + DATA_REG_OFFSET); |
858 | } | 910 | } |
859 | 911 | ||
912 | static u16 f71882fg_read_temp(struct f71882fg_data *data, int nr) | ||
913 | { | ||
914 | if (data->type == f71858fg) | ||
915 | return f71882fg_read16(data, F71882FG_REG_TEMP(nr)); | ||
916 | else | ||
917 | return f71882fg_read8(data, F71882FG_REG_TEMP(nr)); | ||
918 | } | ||
919 | |||
860 | static struct f71882fg_data *f71882fg_update_device(struct device *dev) | 920 | static struct f71882fg_data *f71882fg_update_device(struct device *dev) |
861 | { | 921 | { |
862 | struct f71882fg_data *data = dev_get_drvdata(dev); | 922 | struct f71882fg_data *data = dev_get_drvdata(dev); |
863 | int nr, reg = 0, reg2; | 923 | int nr, reg = 0, reg2; |
864 | int nr_fans = (data->type == f71882fg) ? 4 : 3; | 924 | int nr_fans = (data->type == f71882fg) ? 4 : 3; |
865 | int nr_ins = (data->type == f8000) ? 3 : 9; | 925 | int nr_ins = (data->type == f71858fg || data->type == f8000) ? 3 : 9; |
866 | int temp_start = (data->type == f8000) ? 0 : 1; | ||
867 | 926 | ||
868 | mutex_lock(&data->update_lock); | 927 | mutex_lock(&data->update_lock); |
869 | 928 | ||
@@ -878,7 +937,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
878 | } | 937 | } |
879 | 938 | ||
880 | /* Get High & boundary temps*/ | 939 | /* Get High & boundary temps*/ |
881 | for (nr = temp_start; nr < 3 + temp_start; nr++) { | 940 | for (nr = data->temp_start; nr < 3 + data->temp_start; nr++) { |
882 | data->temp_ovt[nr] = f71882fg_read8(data, | 941 | data->temp_ovt[nr] = f71882fg_read8(data, |
883 | F71882FG_REG_TEMP_OVT(nr)); | 942 | F71882FG_REG_TEMP_OVT(nr)); |
884 | data->temp_high[nr] = f71882fg_read8(data, | 943 | data->temp_high[nr] = f71882fg_read8(data, |
@@ -886,14 +945,17 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
886 | } | 945 | } |
887 | 946 | ||
888 | if (data->type != f8000) { | 947 | if (data->type != f8000) { |
889 | data->fan_beep = f71882fg_read8(data, | ||
890 | F71882FG_REG_FAN_BEEP); | ||
891 | data->temp_beep = f71882fg_read8(data, | ||
892 | F71882FG_REG_TEMP_BEEP); | ||
893 | data->temp_hyst[0] = f71882fg_read8(data, | 948 | data->temp_hyst[0] = f71882fg_read8(data, |
894 | F71882FG_REG_TEMP_HYST(0)); | 949 | F71882FG_REG_TEMP_HYST(0)); |
895 | data->temp_hyst[1] = f71882fg_read8(data, | 950 | data->temp_hyst[1] = f71882fg_read8(data, |
896 | F71882FG_REG_TEMP_HYST(1)); | 951 | F71882FG_REG_TEMP_HYST(1)); |
952 | } | ||
953 | |||
954 | if (data->type == f71862fg || data->type == f71882fg) { | ||
955 | data->fan_beep = f71882fg_read8(data, | ||
956 | F71882FG_REG_FAN_BEEP); | ||
957 | data->temp_beep = f71882fg_read8(data, | ||
958 | F71882FG_REG_TEMP_BEEP); | ||
897 | /* Have to hardcode type, because temp1 is special */ | 959 | /* Have to hardcode type, because temp1 is special */ |
898 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); | 960 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); |
899 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; | 961 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; |
@@ -904,10 +966,10 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
904 | data->temp_type[1] = 6 /* PECI */; | 966 | data->temp_type[1] = 6 /* PECI */; |
905 | else if ((reg2 & 0x03) == 0x02) | 967 | else if ((reg2 & 0x03) == 0x02) |
906 | data->temp_type[1] = 5 /* AMDSI */; | 968 | data->temp_type[1] = 5 /* AMDSI */; |
907 | else if (data->type != f8000) | 969 | else if (data->type == f71862fg || data->type == f71882fg) |
908 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; | 970 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; |
909 | else | 971 | else |
910 | data->temp_type[1] = 2; /* F8000 only supports BJT */ | 972 | data->temp_type[1] = 2; /* Only supports BJT */ |
911 | 973 | ||
912 | data->pwm_enable = f71882fg_read8(data, | 974 | data->pwm_enable = f71882fg_read8(data, |
913 | F71882FG_REG_PWM_ENABLE); | 975 | F71882FG_REG_PWM_ENABLE); |
@@ -963,9 +1025,8 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
963 | F71882FG_REG_TEMP_STATUS); | 1025 | F71882FG_REG_TEMP_STATUS); |
964 | data->temp_diode_open = f71882fg_read8(data, | 1026 | data->temp_diode_open = f71882fg_read8(data, |
965 | F71882FG_REG_TEMP_DIODE_OPEN); | 1027 | F71882FG_REG_TEMP_DIODE_OPEN); |
966 | for (nr = temp_start; nr < 3 + temp_start; nr++) | 1028 | for (nr = data->temp_start; nr < 3 + data->temp_start; nr++) |
967 | data->temp[nr] = f71882fg_read8(data, | 1029 | data->temp[nr] = f71882fg_read_temp(data, nr); |
968 | F71882FG_REG_TEMP(nr)); | ||
969 | 1030 | ||
970 | data->fan_status = f71882fg_read8(data, | 1031 | data->fan_status = f71882fg_read8(data, |
971 | F71882FG_REG_FAN_STATUS); | 1032 | F71882FG_REG_FAN_STATUS); |
@@ -1168,8 +1229,24 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | |||
1168 | { | 1229 | { |
1169 | struct f71882fg_data *data = f71882fg_update_device(dev); | 1230 | struct f71882fg_data *data = f71882fg_update_device(dev); |
1170 | int nr = to_sensor_dev_attr_2(devattr)->index; | 1231 | int nr = to_sensor_dev_attr_2(devattr)->index; |
1232 | int sign, temp; | ||
1233 | |||
1234 | if (data->type == f71858fg) { | ||
1235 | /* TEMP_TABLE_SEL 1 or 3 ? */ | ||
1236 | if (data->temp_config & 1) { | ||
1237 | sign = data->temp[nr] & 0x0001; | ||
1238 | temp = (data->temp[nr] >> 5) & 0x7ff; | ||
1239 | } else { | ||
1240 | sign = data->temp[nr] & 0x8000; | ||
1241 | temp = (data->temp[nr] >> 5) & 0x3ff; | ||
1242 | } | ||
1243 | temp *= 125; | ||
1244 | if (sign) | ||
1245 | temp -= 128000; | ||
1246 | } else | ||
1247 | temp = data->temp[nr] * 1000; | ||
1171 | 1248 | ||
1172 | return sprintf(buf, "%d\n", data->temp[nr] * 1000); | 1249 | return sprintf(buf, "%d\n", temp); |
1173 | } | 1250 | } |
1174 | 1251 | ||
1175 | static ssize_t show_temp_max(struct device *dev, struct device_attribute | 1252 | static ssize_t show_temp_max(struct device *dev, struct device_attribute |
@@ -1440,6 +1517,10 @@ static ssize_t store_pwm_enable(struct device *dev, struct device_attribute | |||
1440 | int nr = to_sensor_dev_attr_2(devattr)->index; | 1517 | int nr = to_sensor_dev_attr_2(devattr)->index; |
1441 | long val = simple_strtol(buf, NULL, 10); | 1518 | long val = simple_strtol(buf, NULL, 10); |
1442 | 1519 | ||
1520 | /* Special case for F8000 pwm channel 3 which only does auto mode */ | ||
1521 | if (data->type == f8000 && nr == 2 && val != 2) | ||
1522 | return -EINVAL; | ||
1523 | |||
1443 | mutex_lock(&data->update_lock); | 1524 | mutex_lock(&data->update_lock); |
1444 | data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); | 1525 | data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); |
1445 | /* Special case for F8000 auto PWM mode / Thermostat mode */ | 1526 | /* Special case for F8000 auto PWM mode / Thermostat mode */ |
@@ -1458,6 +1539,12 @@ static ssize_t store_pwm_enable(struct device *dev, struct device_attribute | |||
1458 | } else { | 1539 | } else { |
1459 | switch (val) { | 1540 | switch (val) { |
1460 | case 1: | 1541 | case 1: |
1542 | /* The f71858fg does not support manual RPM mode */ | ||
1543 | if (data->type == f71858fg && | ||
1544 | ((data->pwm_enable >> (2 * nr)) & 1)) { | ||
1545 | count = -EINVAL; | ||
1546 | goto leave; | ||
1547 | } | ||
1461 | data->pwm_enable |= 2 << (2 * nr); | 1548 | data->pwm_enable |= 2 << (2 * nr); |
1462 | break; /* Manual */ | 1549 | break; /* Manual */ |
1463 | case 2: | 1550 | case 2: |
@@ -1616,9 +1703,9 @@ static ssize_t show_pwm_auto_point_channel(struct device *dev, | |||
1616 | int result; | 1703 | int result; |
1617 | struct f71882fg_data *data = f71882fg_update_device(dev); | 1704 | struct f71882fg_data *data = f71882fg_update_device(dev); |
1618 | int nr = to_sensor_dev_attr_2(devattr)->index; | 1705 | int nr = to_sensor_dev_attr_2(devattr)->index; |
1619 | int temp_start = (data->type == f8000) ? 0 : 1; | ||
1620 | 1706 | ||
1621 | result = 1 << ((data->pwm_auto_point_mapping[nr] & 3) - temp_start); | 1707 | result = 1 << ((data->pwm_auto_point_mapping[nr] & 3) - |
1708 | data->temp_start); | ||
1622 | 1709 | ||
1623 | return sprintf(buf, "%d\n", result); | 1710 | return sprintf(buf, "%d\n", result); |
1624 | } | 1711 | } |
@@ -1629,7 +1716,6 @@ static ssize_t store_pwm_auto_point_channel(struct device *dev, | |||
1629 | { | 1716 | { |
1630 | struct f71882fg_data *data = dev_get_drvdata(dev); | 1717 | struct f71882fg_data *data = dev_get_drvdata(dev); |
1631 | int nr = to_sensor_dev_attr_2(devattr)->index; | 1718 | int nr = to_sensor_dev_attr_2(devattr)->index; |
1632 | int temp_start = (data->type == f8000) ? 0 : 1; | ||
1633 | long val = simple_strtol(buf, NULL, 10); | 1719 | long val = simple_strtol(buf, NULL, 10); |
1634 | 1720 | ||
1635 | switch (val) { | 1721 | switch (val) { |
@@ -1645,7 +1731,7 @@ static ssize_t store_pwm_auto_point_channel(struct device *dev, | |||
1645 | default: | 1731 | default: |
1646 | return -EINVAL; | 1732 | return -EINVAL; |
1647 | } | 1733 | } |
1648 | val += temp_start; | 1734 | val += data->temp_start; |
1649 | mutex_lock(&data->update_lock); | 1735 | mutex_lock(&data->update_lock); |
1650 | data->pwm_auto_point_mapping[nr] = | 1736 | data->pwm_auto_point_mapping[nr] = |
1651 | f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(nr)); | 1737 | f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(nr)); |
@@ -1721,6 +1807,8 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1721 | 1807 | ||
1722 | data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; | 1808 | data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; |
1723 | data->type = sio_data->type; | 1809 | data->type = sio_data->type; |
1810 | data->temp_start = | ||
1811 | (data->type == f71858fg || data->type == f8000) ? 0 : 1; | ||
1724 | mutex_init(&data->update_lock); | 1812 | mutex_init(&data->update_lock); |
1725 | platform_set_drvdata(pdev, data); | 1813 | platform_set_drvdata(pdev, data); |
1726 | 1814 | ||
@@ -1736,19 +1824,6 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1736 | goto exit_free; | 1824 | goto exit_free; |
1737 | } | 1825 | } |
1738 | 1826 | ||
1739 | data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); | ||
1740 | /* If it is a 71862 and the fan / pwm part is enabled sanity check | ||
1741 | the pwm settings */ | ||
1742 | if (data->type == f71862fg && (start_reg & 0x02)) { | ||
1743 | if ((data->pwm_enable & 0x15) != 0x15) { | ||
1744 | dev_err(&pdev->dev, | ||
1745 | "Invalid (reserved) pwm settings: 0x%02x\n", | ||
1746 | (unsigned int)data->pwm_enable); | ||
1747 | err = -ENODEV; | ||
1748 | goto exit_free; | ||
1749 | } | ||
1750 | } | ||
1751 | |||
1752 | /* Register sysfs interface files */ | 1827 | /* Register sysfs interface files */ |
1753 | err = device_create_file(&pdev->dev, &dev_attr_name); | 1828 | err = device_create_file(&pdev->dev, &dev_attr_name); |
1754 | if (err) | 1829 | if (err) |
@@ -1756,6 +1831,20 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1756 | 1831 | ||
1757 | if (start_reg & 0x01) { | 1832 | if (start_reg & 0x01) { |
1758 | switch (data->type) { | 1833 | switch (data->type) { |
1834 | case f71858fg: | ||
1835 | data->temp_config = | ||
1836 | f71882fg_read8(data, F71882FG_REG_TEMP_CONFIG); | ||
1837 | if (data->temp_config & 0x10) | ||
1838 | /* The f71858fg temperature alarms behave as | ||
1839 | the f8000 alarms in this mode */ | ||
1840 | err = f71882fg_create_sysfs_files(pdev, | ||
1841 | f8000_in_temp_attr, | ||
1842 | ARRAY_SIZE(f8000_in_temp_attr)); | ||
1843 | else | ||
1844 | err = f71882fg_create_sysfs_files(pdev, | ||
1845 | f71858fg_in_temp_attr, | ||
1846 | ARRAY_SIZE(f71858fg_in_temp_attr)); | ||
1847 | break; | ||
1759 | case f71882fg: | 1848 | case f71882fg: |
1760 | err = f71882fg_create_sysfs_files(pdev, | 1849 | err = f71882fg_create_sysfs_files(pdev, |
1761 | f71882fg_in_temp_attr, | 1850 | f71882fg_in_temp_attr, |
@@ -1779,6 +1868,35 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1779 | } | 1868 | } |
1780 | 1869 | ||
1781 | if (start_reg & 0x02) { | 1870 | if (start_reg & 0x02) { |
1871 | data->pwm_enable = | ||
1872 | f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); | ||
1873 | |||
1874 | /* Sanity check the pwm settings */ | ||
1875 | switch (data->type) { | ||
1876 | case f71858fg: | ||
1877 | err = 0; | ||
1878 | for (i = 0; i < nr_fans; i++) | ||
1879 | if (((data->pwm_enable >> (i * 2)) & 3) == 3) | ||
1880 | err = 1; | ||
1881 | break; | ||
1882 | case f71862fg: | ||
1883 | err = (data->pwm_enable & 0x15) != 0x15; | ||
1884 | break; | ||
1885 | case f71882fg: | ||
1886 | err = 0; | ||
1887 | break; | ||
1888 | case f8000: | ||
1889 | err = data->pwm_enable & 0x20; | ||
1890 | break; | ||
1891 | } | ||
1892 | if (err) { | ||
1893 | dev_err(&pdev->dev, | ||
1894 | "Invalid (reserved) pwm settings: 0x%02x\n", | ||
1895 | (unsigned int)data->pwm_enable); | ||
1896 | err = -ENODEV; | ||
1897 | goto exit_unregister_sysfs; | ||
1898 | } | ||
1899 | |||
1782 | err = f71882fg_create_sysfs_files(pdev, fxxxx_fan_attr, | 1900 | err = f71882fg_create_sysfs_files(pdev, fxxxx_fan_attr, |
1783 | ARRAY_SIZE(fxxxx_fan_attr)); | 1901 | ARRAY_SIZE(fxxxx_fan_attr)); |
1784 | if (err) | 1902 | if (err) |
@@ -1794,6 +1912,13 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1794 | err = f71882fg_create_sysfs_files(pdev, | 1912 | err = f71882fg_create_sysfs_files(pdev, |
1795 | f71882fg_fan_attr, | 1913 | f71882fg_fan_attr, |
1796 | ARRAY_SIZE(f71882fg_fan_attr)); | 1914 | ARRAY_SIZE(f71882fg_fan_attr)); |
1915 | if (err) | ||
1916 | goto exit_unregister_sysfs; | ||
1917 | /* fall through! */ | ||
1918 | case f71858fg: | ||
1919 | err = f71882fg_create_sysfs_files(pdev, | ||
1920 | f71882fg_f71858fg_fan_attr, | ||
1921 | ARRAY_SIZE(f71882fg_f71858fg_fan_attr)); | ||
1797 | break; | 1922 | break; |
1798 | case f8000: | 1923 | case f8000: |
1799 | err = f71882fg_create_sysfs_files(pdev, | 1924 | err = f71882fg_create_sysfs_files(pdev, |
@@ -1878,6 +2003,9 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, | |||
1878 | 2003 | ||
1879 | devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); | 2004 | devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); |
1880 | switch (devid) { | 2005 | switch (devid) { |
2006 | case SIO_F71858_ID: | ||
2007 | sio_data->type = f71858fg; | ||
2008 | break; | ||
1881 | case SIO_F71862_ID: | 2009 | case SIO_F71862_ID: |
1882 | sio_data->type = f71862fg; | 2010 | sio_data->type = f71862fg; |
1883 | break; | 2011 | break; |
@@ -1892,7 +2020,11 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, | |||
1892 | goto exit; | 2020 | goto exit; |
1893 | } | 2021 | } |
1894 | 2022 | ||
1895 | superio_select(sioaddr, SIO_F71882FG_LD_HWM); | 2023 | if (sio_data->type == f71858fg) |
2024 | superio_select(sioaddr, SIO_F71858FG_LD_HWM); | ||
2025 | else | ||
2026 | superio_select(sioaddr, SIO_F71882FG_LD_HWM); | ||
2027 | |||
1896 | if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { | 2028 | if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { |
1897 | printk(KERN_WARNING DRVNAME ": Device not activated\n"); | 2029 | printk(KERN_WARNING DRVNAME ": Device not activated\n"); |
1898 | goto exit; | 2030 | goto exit; |
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index e15c3e7b07e9..29ea6753f3bb 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/hwmon.h> | 18 | #include <linux/hwmon.h> |
19 | #include <linux/gfp.h> | 19 | #include <linux/gfp.h> |
20 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
21 | #include <linux/pci.h> | ||
21 | 22 | ||
22 | #define HWMON_ID_PREFIX "hwmon" | 23 | #define HWMON_ID_PREFIX "hwmon" |
23 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" | 24 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" |
@@ -86,8 +87,36 @@ void hwmon_device_unregister(struct device *dev) | |||
86 | "hwmon_device_unregister() failed: bad class ID!\n"); | 87 | "hwmon_device_unregister() failed: bad class ID!\n"); |
87 | } | 88 | } |
88 | 89 | ||
90 | static void __init hwmon_pci_quirks(void) | ||
91 | { | ||
92 | #if defined CONFIG_X86 && defined CONFIG_PCI | ||
93 | struct pci_dev *sb; | ||
94 | u16 base; | ||
95 | u8 enable; | ||
96 | |||
97 | /* Open access to 0x295-0x296 on MSI MS-7031 */ | ||
98 | sb = pci_get_device(PCI_VENDOR_ID_ATI, 0x436c, NULL); | ||
99 | if (sb && | ||
100 | (sb->subsystem_vendor == 0x1462 && /* MSI */ | ||
101 | sb->subsystem_device == 0x0031)) { /* MS-7031 */ | ||
102 | |||
103 | pci_read_config_byte(sb, 0x48, &enable); | ||
104 | pci_read_config_word(sb, 0x64, &base); | ||
105 | |||
106 | if (base == 0 && !(enable & BIT(2))) { | ||
107 | dev_info(&sb->dev, | ||
108 | "Opening wide generic port at 0x295\n"); | ||
109 | pci_write_config_word(sb, 0x64, 0x295); | ||
110 | pci_write_config_byte(sb, 0x48, enable | BIT(2)); | ||
111 | } | ||
112 | } | ||
113 | #endif | ||
114 | } | ||
115 | |||
89 | static int __init hwmon_init(void) | 116 | static int __init hwmon_init(void) |
90 | { | 117 | { |
118 | hwmon_pci_quirks(); | ||
119 | |||
91 | hwmon_class = class_create(THIS_MODULE, "hwmon"); | 120 | hwmon_class = class_create(THIS_MODULE, "hwmon"); |
92 | if (IS_ERR(hwmon_class)) { | 121 | if (IS_ERR(hwmon_class)) { |
93 | printk(KERN_ERR "hwmon.c: couldn't create sysfs class\n"); | 122 | printk(KERN_ERR "hwmon.c: couldn't create sysfs class\n"); |
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c index fe74609a7feb..405d3fb5d76f 100644 --- a/drivers/hwmon/ibmaem.c +++ b/drivers/hwmon/ibmaem.c | |||
@@ -1127,3 +1127,4 @@ MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3650-*"); | |||
1127 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3655-*"); | 1127 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3655-*"); |
1128 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3755-*"); | 1128 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3755-*"); |
1129 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBM3850M2/x3950M2-*"); | 1129 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBM3850M2/x3950M2-*"); |
1130 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBMBladeHC10-*"); | ||
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index f27af6a9da41..86142a858238 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * also work with the MAX6651. It does not distinguish max6650 and max6651 | 12 | * also work with the MAX6651. It does not distinguish max6650 and max6651 |
13 | * chips. | 13 | * chips. |
14 | * | 14 | * |
15 | * Tha datasheet was last seen at: | 15 | * The datasheet was last seen at: |
16 | * | 16 | * |
17 | * http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf | 17 | * http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf |
18 | * | 18 | * |
@@ -98,6 +98,16 @@ I2C_CLIENT_INSMOD_1(max6650); | |||
98 | #define MAX6650_CFG_MODE_OPEN_LOOP 0x30 | 98 | #define MAX6650_CFG_MODE_OPEN_LOOP 0x30 |
99 | #define MAX6650_COUNT_MASK 0x03 | 99 | #define MAX6650_COUNT_MASK 0x03 |
100 | 100 | ||
101 | /* | ||
102 | * Alarm status register bits | ||
103 | */ | ||
104 | |||
105 | #define MAX6650_ALRM_MAX 0x01 | ||
106 | #define MAX6650_ALRM_MIN 0x02 | ||
107 | #define MAX6650_ALRM_TACH 0x04 | ||
108 | #define MAX6650_ALRM_GPIO1 0x08 | ||
109 | #define MAX6650_ALRM_GPIO2 0x10 | ||
110 | |||
101 | /* Minimum and maximum values of the FAN-RPM */ | 111 | /* Minimum and maximum values of the FAN-RPM */ |
102 | #define FAN_RPM_MIN 240 | 112 | #define FAN_RPM_MIN 240 |
103 | #define FAN_RPM_MAX 30000 | 113 | #define FAN_RPM_MAX 30000 |
@@ -151,6 +161,7 @@ struct max6650_data | |||
151 | u8 tach[4]; | 161 | u8 tach[4]; |
152 | u8 count; | 162 | u8 count; |
153 | u8 dac; | 163 | u8 dac; |
164 | u8 alarm; | ||
154 | }; | 165 | }; |
155 | 166 | ||
156 | static ssize_t get_fan(struct device *dev, struct device_attribute *devattr, | 167 | static ssize_t get_fan(struct device *dev, struct device_attribute *devattr, |
@@ -418,6 +429,33 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr, | |||
418 | return count; | 429 | return count; |
419 | } | 430 | } |
420 | 431 | ||
432 | /* | ||
433 | * Get alarm stati: | ||
434 | * Possible values: | ||
435 | * 0 = no alarm | ||
436 | * 1 = alarm | ||
437 | */ | ||
438 | |||
439 | static ssize_t get_alarm(struct device *dev, struct device_attribute *devattr, | ||
440 | char *buf) | ||
441 | { | ||
442 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
443 | struct max6650_data *data = max6650_update_device(dev); | ||
444 | struct i2c_client *client = to_i2c_client(dev); | ||
445 | int alarm = 0; | ||
446 | |||
447 | if (data->alarm & attr->index) { | ||
448 | mutex_lock(&data->update_lock); | ||
449 | alarm = 1; | ||
450 | data->alarm &= ~attr->index; | ||
451 | data->alarm |= i2c_smbus_read_byte_data(client, | ||
452 | MAX6650_REG_ALARM); | ||
453 | mutex_unlock(&data->update_lock); | ||
454 | } | ||
455 | |||
456 | return sprintf(buf, "%d\n", alarm); | ||
457 | } | ||
458 | |||
421 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, get_fan, NULL, 0); | 459 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, get_fan, NULL, 0); |
422 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, get_fan, NULL, 1); | 460 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, get_fan, NULL, 1); |
423 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, get_fan, NULL, 2); | 461 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, get_fan, NULL, 2); |
@@ -426,7 +464,41 @@ static DEVICE_ATTR(fan1_target, S_IWUSR | S_IRUGO, get_target, set_target); | |||
426 | static DEVICE_ATTR(fan1_div, S_IWUSR | S_IRUGO, get_div, set_div); | 464 | static DEVICE_ATTR(fan1_div, S_IWUSR | S_IRUGO, get_div, set_div); |
427 | static DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, get_enable, set_enable); | 465 | static DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, get_enable, set_enable); |
428 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, get_pwm, set_pwm); | 466 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, get_pwm, set_pwm); |
467 | static SENSOR_DEVICE_ATTR(fan1_max_alarm, S_IRUGO, get_alarm, NULL, | ||
468 | MAX6650_ALRM_MAX); | ||
469 | static SENSOR_DEVICE_ATTR(fan1_min_alarm, S_IRUGO, get_alarm, NULL, | ||
470 | MAX6650_ALRM_MIN); | ||
471 | static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, get_alarm, NULL, | ||
472 | MAX6650_ALRM_TACH); | ||
473 | static SENSOR_DEVICE_ATTR(gpio1_alarm, S_IRUGO, get_alarm, NULL, | ||
474 | MAX6650_ALRM_GPIO1); | ||
475 | static SENSOR_DEVICE_ATTR(gpio2_alarm, S_IRUGO, get_alarm, NULL, | ||
476 | MAX6650_ALRM_GPIO2); | ||
477 | |||
478 | static mode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a, | ||
479 | int n) | ||
480 | { | ||
481 | struct device *dev = container_of(kobj, struct device, kobj); | ||
482 | struct i2c_client *client = to_i2c_client(dev); | ||
483 | u8 alarm_en = i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM_EN); | ||
484 | struct device_attribute *devattr; | ||
429 | 485 | ||
486 | /* | ||
487 | * Hide the alarms that have not been enabled by the firmware | ||
488 | */ | ||
489 | |||
490 | devattr = container_of(a, struct device_attribute, attr); | ||
491 | if (devattr == &sensor_dev_attr_fan1_max_alarm.dev_attr | ||
492 | || devattr == &sensor_dev_attr_fan1_min_alarm.dev_attr | ||
493 | || devattr == &sensor_dev_attr_fan1_fault.dev_attr | ||
494 | || devattr == &sensor_dev_attr_gpio1_alarm.dev_attr | ||
495 | || devattr == &sensor_dev_attr_gpio2_alarm.dev_attr) { | ||
496 | if (!(alarm_en & to_sensor_dev_attr(devattr)->index)) | ||
497 | return 0; | ||
498 | } | ||
499 | |||
500 | return a->mode; | ||
501 | } | ||
430 | 502 | ||
431 | static struct attribute *max6650_attrs[] = { | 503 | static struct attribute *max6650_attrs[] = { |
432 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 504 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
@@ -437,11 +509,17 @@ static struct attribute *max6650_attrs[] = { | |||
437 | &dev_attr_fan1_div.attr, | 509 | &dev_attr_fan1_div.attr, |
438 | &dev_attr_pwm1_enable.attr, | 510 | &dev_attr_pwm1_enable.attr, |
439 | &dev_attr_pwm1.attr, | 511 | &dev_attr_pwm1.attr, |
512 | &sensor_dev_attr_fan1_max_alarm.dev_attr.attr, | ||
513 | &sensor_dev_attr_fan1_min_alarm.dev_attr.attr, | ||
514 | &sensor_dev_attr_fan1_fault.dev_attr.attr, | ||
515 | &sensor_dev_attr_gpio1_alarm.dev_attr.attr, | ||
516 | &sensor_dev_attr_gpio2_alarm.dev_attr.attr, | ||
440 | NULL | 517 | NULL |
441 | }; | 518 | }; |
442 | 519 | ||
443 | static struct attribute_group max6650_attr_grp = { | 520 | static struct attribute_group max6650_attr_grp = { |
444 | .attrs = max6650_attrs, | 521 | .attrs = max6650_attrs, |
522 | .is_visible = max6650_attrs_visible, | ||
445 | }; | 523 | }; |
446 | 524 | ||
447 | /* | 525 | /* |
@@ -659,6 +737,12 @@ static struct max6650_data *max6650_update_device(struct device *dev) | |||
659 | MAX6650_REG_COUNT); | 737 | MAX6650_REG_COUNT); |
660 | data->dac = i2c_smbus_read_byte_data(client, MAX6650_REG_DAC); | 738 | data->dac = i2c_smbus_read_byte_data(client, MAX6650_REG_DAC); |
661 | 739 | ||
740 | /* Alarms are cleared on read in case the condition that | ||
741 | * caused the alarm is removed. Keep the value latched here | ||
742 | * for providing the register through different alarm files. */ | ||
743 | data->alarm |= i2c_smbus_read_byte_data(client, | ||
744 | MAX6650_REG_ALARM); | ||
745 | |||
662 | data->last_updated = jiffies; | 746 | data->last_updated = jiffies; |
663 | data->valid = 1; | 747 | data->valid = 1; |
664 | } | 748 | } |
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index 6cbdc2fea734..56cd6004da36 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c | |||
@@ -627,35 +627,35 @@ static struct platform_driver sht_drivers[] = { | |||
627 | .owner = THIS_MODULE, | 627 | .owner = THIS_MODULE, |
628 | }, | 628 | }, |
629 | .probe = sht15_probe, | 629 | .probe = sht15_probe, |
630 | .remove = sht15_remove, | 630 | .remove = __devexit_p(sht15_remove), |
631 | }, { | 631 | }, { |
632 | .driver = { | 632 | .driver = { |
633 | .name = "sht11", | 633 | .name = "sht11", |
634 | .owner = THIS_MODULE, | 634 | .owner = THIS_MODULE, |
635 | }, | 635 | }, |
636 | .probe = sht15_probe, | 636 | .probe = sht15_probe, |
637 | .remove = sht15_remove, | 637 | .remove = __devexit_p(sht15_remove), |
638 | }, { | 638 | }, { |
639 | .driver = { | 639 | .driver = { |
640 | .name = "sht15", | 640 | .name = "sht15", |
641 | .owner = THIS_MODULE, | 641 | .owner = THIS_MODULE, |
642 | }, | 642 | }, |
643 | .probe = sht15_probe, | 643 | .probe = sht15_probe, |
644 | .remove = sht15_remove, | 644 | .remove = __devexit_p(sht15_remove), |
645 | }, { | 645 | }, { |
646 | .driver = { | 646 | .driver = { |
647 | .name = "sht71", | 647 | .name = "sht71", |
648 | .owner = THIS_MODULE, | 648 | .owner = THIS_MODULE, |
649 | }, | 649 | }, |
650 | .probe = sht15_probe, | 650 | .probe = sht15_probe, |
651 | .remove = sht15_remove, | 651 | .remove = __devexit_p(sht15_remove), |
652 | }, { | 652 | }, { |
653 | .driver = { | 653 | .driver = { |
654 | .name = "sht75", | 654 | .name = "sht75", |
655 | .owner = THIS_MODULE, | 655 | .owner = THIS_MODULE, |
656 | }, | 656 | }, |
657 | .probe = sht15_probe, | 657 | .probe = sht15_probe, |
658 | .remove = sht15_remove, | 658 | .remove = __devexit_p(sht15_remove), |
659 | }, | 659 | }, |
660 | }; | 660 | }; |
661 | 661 | ||
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c new file mode 100644 index 000000000000..7b34f2cd08bb --- /dev/null +++ b/drivers/hwmon/tmp401.c | |||
@@ -0,0 +1,690 @@ | |||
1 | /* tmp401.c | ||
2 | * | ||
3 | * Copyright (C) 2007,2008 Hans de Goede <hdegoede@redhat.com> | ||
4 | * Preliminary tmp411 support by: | ||
5 | * Gabriel Konat, Sander Leget, Wouter Willems | ||
6 | * Copyright (C) 2009 Andre Prendel <andre.prendel@gmx.de> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | /* | ||
24 | * Driver for the Texas Instruments TMP401 SMBUS temperature sensor IC. | ||
25 | * | ||
26 | * Note this IC is in some aspect similar to the LM90, but it has quite a | ||
27 | * few differences too, for example the local temp has a higher resolution | ||
28 | * and thus has 16 bits registers for its value and limit instead of 8 bits. | ||
29 | */ | ||
30 | |||
31 | #include <linux/module.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/jiffies.h> | ||
35 | #include <linux/i2c.h> | ||
36 | #include <linux/hwmon.h> | ||
37 | #include <linux/hwmon-sysfs.h> | ||
38 | #include <linux/err.h> | ||
39 | #include <linux/mutex.h> | ||
40 | #include <linux/sysfs.h> | ||
41 | |||
42 | /* Addresses to scan */ | ||
43 | static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; | ||
44 | |||
45 | /* Insmod parameters */ | ||
46 | I2C_CLIENT_INSMOD_2(tmp401, tmp411); | ||
47 | |||
48 | /* | ||
49 | * The TMP401 registers, note some registers have different addresses for | ||
50 | * reading and writing | ||
51 | */ | ||
52 | #define TMP401_STATUS 0x02 | ||
53 | #define TMP401_CONFIG_READ 0x03 | ||
54 | #define TMP401_CONFIG_WRITE 0x09 | ||
55 | #define TMP401_CONVERSION_RATE_READ 0x04 | ||
56 | #define TMP401_CONVERSION_RATE_WRITE 0x0A | ||
57 | #define TMP401_TEMP_CRIT_HYST 0x21 | ||
58 | #define TMP401_CONSECUTIVE_ALERT 0x22 | ||
59 | #define TMP401_MANUFACTURER_ID_REG 0xFE | ||
60 | #define TMP401_DEVICE_ID_REG 0xFF | ||
61 | #define TMP411_N_FACTOR_REG 0x18 | ||
62 | |||
63 | static const u8 TMP401_TEMP_MSB[2] = { 0x00, 0x01 }; | ||
64 | static const u8 TMP401_TEMP_LSB[2] = { 0x15, 0x10 }; | ||
65 | static const u8 TMP401_TEMP_LOW_LIMIT_MSB_READ[2] = { 0x06, 0x08 }; | ||
66 | static const u8 TMP401_TEMP_LOW_LIMIT_MSB_WRITE[2] = { 0x0C, 0x0E }; | ||
67 | static const u8 TMP401_TEMP_LOW_LIMIT_LSB[2] = { 0x17, 0x14 }; | ||
68 | static const u8 TMP401_TEMP_HIGH_LIMIT_MSB_READ[2] = { 0x05, 0x07 }; | ||
69 | static const u8 TMP401_TEMP_HIGH_LIMIT_MSB_WRITE[2] = { 0x0B, 0x0D }; | ||
70 | static const u8 TMP401_TEMP_HIGH_LIMIT_LSB[2] = { 0x16, 0x13 }; | ||
71 | /* These are called the THERM limit / hysteresis / mask in the datasheet */ | ||
72 | static const u8 TMP401_TEMP_CRIT_LIMIT[2] = { 0x20, 0x19 }; | ||
73 | |||
74 | static const u8 TMP411_TEMP_LOWEST_MSB[2] = { 0x30, 0x34 }; | ||
75 | static const u8 TMP411_TEMP_LOWEST_LSB[2] = { 0x31, 0x35 }; | ||
76 | static const u8 TMP411_TEMP_HIGHEST_MSB[2] = { 0x32, 0x36 }; | ||
77 | static const u8 TMP411_TEMP_HIGHEST_LSB[2] = { 0x33, 0x37 }; | ||
78 | |||
79 | /* Flags */ | ||
80 | #define TMP401_CONFIG_RANGE 0x04 | ||
81 | #define TMP401_CONFIG_SHUTDOWN 0x40 | ||
82 | #define TMP401_STATUS_LOCAL_CRIT 0x01 | ||
83 | #define TMP401_STATUS_REMOTE_CRIT 0x02 | ||
84 | #define TMP401_STATUS_REMOTE_OPEN 0x04 | ||
85 | #define TMP401_STATUS_REMOTE_LOW 0x08 | ||
86 | #define TMP401_STATUS_REMOTE_HIGH 0x10 | ||
87 | #define TMP401_STATUS_LOCAL_LOW 0x20 | ||
88 | #define TMP401_STATUS_LOCAL_HIGH 0x40 | ||
89 | |||
90 | /* Manufacturer / Device ID's */ | ||
91 | #define TMP401_MANUFACTURER_ID 0x55 | ||
92 | #define TMP401_DEVICE_ID 0x11 | ||
93 | #define TMP411_DEVICE_ID 0x12 | ||
94 | |||
95 | /* | ||
96 | * Functions declarations | ||
97 | */ | ||
98 | |||
99 | static int tmp401_probe(struct i2c_client *client, | ||
100 | const struct i2c_device_id *id); | ||
101 | static int tmp401_detect(struct i2c_client *client, int kind, | ||
102 | struct i2c_board_info *info); | ||
103 | static int tmp401_remove(struct i2c_client *client); | ||
104 | static struct tmp401_data *tmp401_update_device(struct device *dev); | ||
105 | |||
106 | /* | ||
107 | * Driver data (common to all clients) | ||
108 | */ | ||
109 | |||
110 | static const struct i2c_device_id tmp401_id[] = { | ||
111 | { "tmp401", tmp401 }, | ||
112 | { "tmp411", tmp411 }, | ||
113 | { } | ||
114 | }; | ||
115 | MODULE_DEVICE_TABLE(i2c, tmp401_id); | ||
116 | |||
117 | static struct i2c_driver tmp401_driver = { | ||
118 | .class = I2C_CLASS_HWMON, | ||
119 | .driver = { | ||
120 | .name = "tmp401", | ||
121 | }, | ||
122 | .probe = tmp401_probe, | ||
123 | .remove = tmp401_remove, | ||
124 | .id_table = tmp401_id, | ||
125 | .detect = tmp401_detect, | ||
126 | .address_data = &addr_data, | ||
127 | }; | ||
128 | |||
129 | /* | ||
130 | * Client data (each client gets its own) | ||
131 | */ | ||
132 | |||
133 | struct tmp401_data { | ||
134 | struct device *hwmon_dev; | ||
135 | struct mutex update_lock; | ||
136 | char valid; /* zero until following fields are valid */ | ||
137 | unsigned long last_updated; /* in jiffies */ | ||
138 | int kind; | ||
139 | |||
140 | /* register values */ | ||
141 | u8 status; | ||
142 | u8 config; | ||
143 | u16 temp[2]; | ||
144 | u16 temp_low[2]; | ||
145 | u16 temp_high[2]; | ||
146 | u8 temp_crit[2]; | ||
147 | u8 temp_crit_hyst; | ||
148 | u16 temp_lowest[2]; | ||
149 | u16 temp_highest[2]; | ||
150 | }; | ||
151 | |||
152 | /* | ||
153 | * Sysfs attr show / store functions | ||
154 | */ | ||
155 | |||
156 | static int tmp401_register_to_temp(u16 reg, u8 config) | ||
157 | { | ||
158 | int temp = reg; | ||
159 | |||
160 | if (config & TMP401_CONFIG_RANGE) | ||
161 | temp -= 64 * 256; | ||
162 | |||
163 | return (temp * 625 + 80) / 160; | ||
164 | } | ||
165 | |||
166 | static u16 tmp401_temp_to_register(long temp, u8 config) | ||
167 | { | ||
168 | if (config & TMP401_CONFIG_RANGE) { | ||
169 | temp = SENSORS_LIMIT(temp, -64000, 191000); | ||
170 | temp += 64000; | ||
171 | } else | ||
172 | temp = SENSORS_LIMIT(temp, 0, 127000); | ||
173 | |||
174 | return (temp * 160 + 312) / 625; | ||
175 | } | ||
176 | |||
177 | static int tmp401_crit_register_to_temp(u8 reg, u8 config) | ||
178 | { | ||
179 | int temp = reg; | ||
180 | |||
181 | if (config & TMP401_CONFIG_RANGE) | ||
182 | temp -= 64; | ||
183 | |||
184 | return temp * 1000; | ||
185 | } | ||
186 | |||
187 | static u8 tmp401_crit_temp_to_register(long temp, u8 config) | ||
188 | { | ||
189 | if (config & TMP401_CONFIG_RANGE) { | ||
190 | temp = SENSORS_LIMIT(temp, -64000, 191000); | ||
191 | temp += 64000; | ||
192 | } else | ||
193 | temp = SENSORS_LIMIT(temp, 0, 127000); | ||
194 | |||
195 | return (temp + 500) / 1000; | ||
196 | } | ||
197 | |||
198 | static ssize_t show_temp_value(struct device *dev, | ||
199 | struct device_attribute *devattr, char *buf) | ||
200 | { | ||
201 | int index = to_sensor_dev_attr(devattr)->index; | ||
202 | struct tmp401_data *data = tmp401_update_device(dev); | ||
203 | |||
204 | return sprintf(buf, "%d\n", | ||
205 | tmp401_register_to_temp(data->temp[index], data->config)); | ||
206 | } | ||
207 | |||
208 | static ssize_t show_temp_min(struct device *dev, | ||
209 | struct device_attribute *devattr, char *buf) | ||
210 | { | ||
211 | int index = to_sensor_dev_attr(devattr)->index; | ||
212 | struct tmp401_data *data = tmp401_update_device(dev); | ||
213 | |||
214 | return sprintf(buf, "%d\n", | ||
215 | tmp401_register_to_temp(data->temp_low[index], data->config)); | ||
216 | } | ||
217 | |||
218 | static ssize_t show_temp_max(struct device *dev, | ||
219 | struct device_attribute *devattr, char *buf) | ||
220 | { | ||
221 | int index = to_sensor_dev_attr(devattr)->index; | ||
222 | struct tmp401_data *data = tmp401_update_device(dev); | ||
223 | |||
224 | return sprintf(buf, "%d\n", | ||
225 | tmp401_register_to_temp(data->temp_high[index], data->config)); | ||
226 | } | ||
227 | |||
228 | static ssize_t show_temp_crit(struct device *dev, | ||
229 | struct device_attribute *devattr, char *buf) | ||
230 | { | ||
231 | int index = to_sensor_dev_attr(devattr)->index; | ||
232 | struct tmp401_data *data = tmp401_update_device(dev); | ||
233 | |||
234 | return sprintf(buf, "%d\n", | ||
235 | tmp401_crit_register_to_temp(data->temp_crit[index], | ||
236 | data->config)); | ||
237 | } | ||
238 | |||
239 | static ssize_t show_temp_crit_hyst(struct device *dev, | ||
240 | struct device_attribute *devattr, char *buf) | ||
241 | { | ||
242 | int temp, index = to_sensor_dev_attr(devattr)->index; | ||
243 | struct tmp401_data *data = tmp401_update_device(dev); | ||
244 | |||
245 | mutex_lock(&data->update_lock); | ||
246 | temp = tmp401_crit_register_to_temp(data->temp_crit[index], | ||
247 | data->config); | ||
248 | temp -= data->temp_crit_hyst * 1000; | ||
249 | mutex_unlock(&data->update_lock); | ||
250 | |||
251 | return sprintf(buf, "%d\n", temp); | ||
252 | } | ||
253 | |||
254 | static ssize_t show_temp_lowest(struct device *dev, | ||
255 | struct device_attribute *devattr, char *buf) | ||
256 | { | ||
257 | int index = to_sensor_dev_attr(devattr)->index; | ||
258 | struct tmp401_data *data = tmp401_update_device(dev); | ||
259 | |||
260 | return sprintf(buf, "%d\n", | ||
261 | tmp401_register_to_temp(data->temp_lowest[index], | ||
262 | data->config)); | ||
263 | } | ||
264 | |||
265 | static ssize_t show_temp_highest(struct device *dev, | ||
266 | struct device_attribute *devattr, char *buf) | ||
267 | { | ||
268 | int index = to_sensor_dev_attr(devattr)->index; | ||
269 | struct tmp401_data *data = tmp401_update_device(dev); | ||
270 | |||
271 | return sprintf(buf, "%d\n", | ||
272 | tmp401_register_to_temp(data->temp_highest[index], | ||
273 | data->config)); | ||
274 | } | ||
275 | |||
276 | static ssize_t show_status(struct device *dev, | ||
277 | struct device_attribute *devattr, char *buf) | ||
278 | { | ||
279 | int mask = to_sensor_dev_attr(devattr)->index; | ||
280 | struct tmp401_data *data = tmp401_update_device(dev); | ||
281 | |||
282 | if (data->status & mask) | ||
283 | return sprintf(buf, "1\n"); | ||
284 | else | ||
285 | return sprintf(buf, "0\n"); | ||
286 | } | ||
287 | |||
288 | static ssize_t store_temp_min(struct device *dev, struct device_attribute | ||
289 | *devattr, const char *buf, size_t count) | ||
290 | { | ||
291 | int index = to_sensor_dev_attr(devattr)->index; | ||
292 | struct tmp401_data *data = tmp401_update_device(dev); | ||
293 | long val; | ||
294 | u16 reg; | ||
295 | |||
296 | if (strict_strtol(buf, 10, &val)) | ||
297 | return -EINVAL; | ||
298 | |||
299 | reg = tmp401_temp_to_register(val, data->config); | ||
300 | |||
301 | mutex_lock(&data->update_lock); | ||
302 | |||
303 | i2c_smbus_write_byte_data(to_i2c_client(dev), | ||
304 | TMP401_TEMP_LOW_LIMIT_MSB_WRITE[index], reg >> 8); | ||
305 | i2c_smbus_write_byte_data(to_i2c_client(dev), | ||
306 | TMP401_TEMP_LOW_LIMIT_LSB[index], reg & 0xFF); | ||
307 | |||
308 | data->temp_low[index] = reg; | ||
309 | |||
310 | mutex_unlock(&data->update_lock); | ||
311 | |||
312 | return count; | ||
313 | } | ||
314 | |||
315 | static ssize_t store_temp_max(struct device *dev, struct device_attribute | ||
316 | *devattr, const char *buf, size_t count) | ||
317 | { | ||
318 | int index = to_sensor_dev_attr(devattr)->index; | ||
319 | struct tmp401_data *data = tmp401_update_device(dev); | ||
320 | long val; | ||
321 | u16 reg; | ||
322 | |||
323 | if (strict_strtol(buf, 10, &val)) | ||
324 | return -EINVAL; | ||
325 | |||
326 | reg = tmp401_temp_to_register(val, data->config); | ||
327 | |||
328 | mutex_lock(&data->update_lock); | ||
329 | |||
330 | i2c_smbus_write_byte_data(to_i2c_client(dev), | ||
331 | TMP401_TEMP_HIGH_LIMIT_MSB_WRITE[index], reg >> 8); | ||
332 | i2c_smbus_write_byte_data(to_i2c_client(dev), | ||
333 | TMP401_TEMP_HIGH_LIMIT_LSB[index], reg & 0xFF); | ||
334 | |||
335 | data->temp_high[index] = reg; | ||
336 | |||
337 | mutex_unlock(&data->update_lock); | ||
338 | |||
339 | return count; | ||
340 | } | ||
341 | |||
342 | static ssize_t store_temp_crit(struct device *dev, struct device_attribute | ||
343 | *devattr, const char *buf, size_t count) | ||
344 | { | ||
345 | int index = to_sensor_dev_attr(devattr)->index; | ||
346 | struct tmp401_data *data = tmp401_update_device(dev); | ||
347 | long val; | ||
348 | u8 reg; | ||
349 | |||
350 | if (strict_strtol(buf, 10, &val)) | ||
351 | return -EINVAL; | ||
352 | |||
353 | reg = tmp401_crit_temp_to_register(val, data->config); | ||
354 | |||
355 | mutex_lock(&data->update_lock); | ||
356 | |||
357 | i2c_smbus_write_byte_data(to_i2c_client(dev), | ||
358 | TMP401_TEMP_CRIT_LIMIT[index], reg); | ||
359 | |||
360 | data->temp_crit[index] = reg; | ||
361 | |||
362 | mutex_unlock(&data->update_lock); | ||
363 | |||
364 | return count; | ||
365 | } | ||
366 | |||
367 | static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attribute | ||
368 | *devattr, const char *buf, size_t count) | ||
369 | { | ||
370 | int temp, index = to_sensor_dev_attr(devattr)->index; | ||
371 | struct tmp401_data *data = tmp401_update_device(dev); | ||
372 | long val; | ||
373 | u8 reg; | ||
374 | |||
375 | if (strict_strtol(buf, 10, &val)) | ||
376 | return -EINVAL; | ||
377 | |||
378 | if (data->config & TMP401_CONFIG_RANGE) | ||
379 | val = SENSORS_LIMIT(val, -64000, 191000); | ||
380 | else | ||
381 | val = SENSORS_LIMIT(val, 0, 127000); | ||
382 | |||
383 | mutex_lock(&data->update_lock); | ||
384 | temp = tmp401_crit_register_to_temp(data->temp_crit[index], | ||
385 | data->config); | ||
386 | val = SENSORS_LIMIT(val, temp - 255000, temp); | ||
387 | reg = ((temp - val) + 500) / 1000; | ||
388 | |||
389 | i2c_smbus_write_byte_data(to_i2c_client(dev), | ||
390 | TMP401_TEMP_CRIT_HYST, reg); | ||
391 | |||
392 | data->temp_crit_hyst = reg; | ||
393 | |||
394 | mutex_unlock(&data->update_lock); | ||
395 | |||
396 | return count; | ||
397 | } | ||
398 | |||
399 | /* | ||
400 | * Resets the historical measurements of minimum and maximum temperatures. | ||
401 | * This is done by writing any value to any of the minimum/maximum registers | ||
402 | * (0x30-0x37). | ||
403 | */ | ||
404 | static ssize_t reset_temp_history(struct device *dev, | ||
405 | struct device_attribute *devattr, const char *buf, size_t count) | ||
406 | { | ||
407 | long val; | ||
408 | |||
409 | if (strict_strtol(buf, 10, &val)) | ||
410 | return -EINVAL; | ||
411 | |||
412 | if (val != 1) { | ||
413 | dev_err(dev, "temp_reset_history value %ld not" | ||
414 | " supported. Use 1 to reset the history!\n", val); | ||
415 | return -EINVAL; | ||
416 | } | ||
417 | i2c_smbus_write_byte_data(to_i2c_client(dev), | ||
418 | TMP411_TEMP_LOWEST_MSB[0], val); | ||
419 | |||
420 | return count; | ||
421 | } | ||
422 | |||
423 | static struct sensor_device_attribute tmp401_attr[] = { | ||
424 | SENSOR_ATTR(temp1_input, 0444, show_temp_value, NULL, 0), | ||
425 | SENSOR_ATTR(temp1_min, 0644, show_temp_min, store_temp_min, 0), | ||
426 | SENSOR_ATTR(temp1_max, 0644, show_temp_max, store_temp_max, 0), | ||
427 | SENSOR_ATTR(temp1_crit, 0644, show_temp_crit, store_temp_crit, 0), | ||
428 | SENSOR_ATTR(temp1_crit_hyst, 0644, show_temp_crit_hyst, | ||
429 | store_temp_crit_hyst, 0), | ||
430 | SENSOR_ATTR(temp1_min_alarm, 0444, show_status, NULL, | ||
431 | TMP401_STATUS_LOCAL_LOW), | ||
432 | SENSOR_ATTR(temp1_max_alarm, 0444, show_status, NULL, | ||
433 | TMP401_STATUS_LOCAL_HIGH), | ||
434 | SENSOR_ATTR(temp1_crit_alarm, 0444, show_status, NULL, | ||
435 | TMP401_STATUS_LOCAL_CRIT), | ||
436 | SENSOR_ATTR(temp2_input, 0444, show_temp_value, NULL, 1), | ||
437 | SENSOR_ATTR(temp2_min, 0644, show_temp_min, store_temp_min, 1), | ||
438 | SENSOR_ATTR(temp2_max, 0644, show_temp_max, store_temp_max, 1), | ||
439 | SENSOR_ATTR(temp2_crit, 0644, show_temp_crit, store_temp_crit, 1), | ||
440 | SENSOR_ATTR(temp2_crit_hyst, 0444, show_temp_crit_hyst, NULL, 1), | ||
441 | SENSOR_ATTR(temp2_fault, 0444, show_status, NULL, | ||
442 | TMP401_STATUS_REMOTE_OPEN), | ||
443 | SENSOR_ATTR(temp2_min_alarm, 0444, show_status, NULL, | ||
444 | TMP401_STATUS_REMOTE_LOW), | ||
445 | SENSOR_ATTR(temp2_max_alarm, 0444, show_status, NULL, | ||
446 | TMP401_STATUS_REMOTE_HIGH), | ||
447 | SENSOR_ATTR(temp2_crit_alarm, 0444, show_status, NULL, | ||
448 | TMP401_STATUS_REMOTE_CRIT), | ||
449 | }; | ||
450 | |||
451 | /* | ||
452 | * Additional features of the TMP411 chip. | ||
453 | * The TMP411 stores the minimum and maximum | ||
454 | * temperature measured since power-on, chip-reset, or | ||
455 | * minimum and maximum register reset for both the local | ||
456 | * and remote channels. | ||
457 | */ | ||
458 | static struct sensor_device_attribute tmp411_attr[] = { | ||
459 | SENSOR_ATTR(temp1_highest, 0444, show_temp_highest, NULL, 0), | ||
460 | SENSOR_ATTR(temp1_lowest, 0444, show_temp_lowest, NULL, 0), | ||
461 | SENSOR_ATTR(temp2_highest, 0444, show_temp_highest, NULL, 1), | ||
462 | SENSOR_ATTR(temp2_lowest, 0444, show_temp_lowest, NULL, 1), | ||
463 | SENSOR_ATTR(temp_reset_history, 0200, NULL, reset_temp_history, 0), | ||
464 | }; | ||
465 | |||
466 | /* | ||
467 | * Begin non sysfs callback code (aka Real code) | ||
468 | */ | ||
469 | |||
470 | static void tmp401_init_client(struct i2c_client *client) | ||
471 | { | ||
472 | int config, config_orig; | ||
473 | |||
474 | /* Set the conversion rate to 2 Hz */ | ||
475 | i2c_smbus_write_byte_data(client, TMP401_CONVERSION_RATE_WRITE, 5); | ||
476 | |||
477 | /* Start conversions (disable shutdown if necessary) */ | ||
478 | config = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); | ||
479 | if (config < 0) { | ||
480 | dev_warn(&client->dev, "Initialization failed!\n"); | ||
481 | return; | ||
482 | } | ||
483 | |||
484 | config_orig = config; | ||
485 | config &= ~TMP401_CONFIG_SHUTDOWN; | ||
486 | |||
487 | if (config != config_orig) | ||
488 | i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config); | ||
489 | } | ||
490 | |||
491 | static int tmp401_detect(struct i2c_client *client, int kind, | ||
492 | struct i2c_board_info *info) | ||
493 | { | ||
494 | struct i2c_adapter *adapter = client->adapter; | ||
495 | |||
496 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
497 | return -ENODEV; | ||
498 | |||
499 | /* Detect and identify the chip */ | ||
500 | if (kind <= 0) { | ||
501 | u8 reg; | ||
502 | |||
503 | reg = i2c_smbus_read_byte_data(client, | ||
504 | TMP401_MANUFACTURER_ID_REG); | ||
505 | if (reg != TMP401_MANUFACTURER_ID) | ||
506 | return -ENODEV; | ||
507 | |||
508 | reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG); | ||
509 | |||
510 | switch (reg) { | ||
511 | case TMP401_DEVICE_ID: | ||
512 | kind = tmp401; | ||
513 | break; | ||
514 | case TMP411_DEVICE_ID: | ||
515 | kind = tmp411; | ||
516 | break; | ||
517 | default: | ||
518 | return -ENODEV; | ||
519 | } | ||
520 | |||
521 | reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); | ||
522 | if (reg & 0x1b) | ||
523 | return -ENODEV; | ||
524 | |||
525 | reg = i2c_smbus_read_byte_data(client, | ||
526 | TMP401_CONVERSION_RATE_READ); | ||
527 | /* Datasheet says: 0x1-0x6 */ | ||
528 | if (reg > 15) | ||
529 | return -ENODEV; | ||
530 | } | ||
531 | strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE); | ||
532 | |||
533 | return 0; | ||
534 | } | ||
535 | |||
536 | static int tmp401_probe(struct i2c_client *client, | ||
537 | const struct i2c_device_id *id) | ||
538 | { | ||
539 | int i, err = 0; | ||
540 | struct tmp401_data *data; | ||
541 | const char *names[] = { "TMP401", "TMP411" }; | ||
542 | |||
543 | data = kzalloc(sizeof(struct tmp401_data), GFP_KERNEL); | ||
544 | if (!data) | ||
545 | return -ENOMEM; | ||
546 | |||
547 | i2c_set_clientdata(client, data); | ||
548 | mutex_init(&data->update_lock); | ||
549 | data->kind = id->driver_data; | ||
550 | |||
551 | /* Initialize the TMP401 chip */ | ||
552 | tmp401_init_client(client); | ||
553 | |||
554 | /* Register sysfs hooks */ | ||
555 | for (i = 0; i < ARRAY_SIZE(tmp401_attr); i++) { | ||
556 | err = device_create_file(&client->dev, | ||
557 | &tmp401_attr[i].dev_attr); | ||
558 | if (err) | ||
559 | goto exit_remove; | ||
560 | } | ||
561 | |||
562 | /* Register aditional tmp411 sysfs hooks */ | ||
563 | if (data->kind == tmp411) { | ||
564 | for (i = 0; i < ARRAY_SIZE(tmp411_attr); i++) { | ||
565 | err = device_create_file(&client->dev, | ||
566 | &tmp411_attr[i].dev_attr); | ||
567 | if (err) | ||
568 | goto exit_remove; | ||
569 | } | ||
570 | } | ||
571 | |||
572 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
573 | if (IS_ERR(data->hwmon_dev)) { | ||
574 | err = PTR_ERR(data->hwmon_dev); | ||
575 | data->hwmon_dev = NULL; | ||
576 | goto exit_remove; | ||
577 | } | ||
578 | |||
579 | dev_info(&client->dev, "Detected TI %s chip\n", | ||
580 | names[data->kind - 1]); | ||
581 | |||
582 | return 0; | ||
583 | |||
584 | exit_remove: | ||
585 | tmp401_remove(client); /* will also free data for us */ | ||
586 | return err; | ||
587 | } | ||
588 | |||
589 | static int tmp401_remove(struct i2c_client *client) | ||
590 | { | ||
591 | struct tmp401_data *data = i2c_get_clientdata(client); | ||
592 | int i; | ||
593 | |||
594 | if (data->hwmon_dev) | ||
595 | hwmon_device_unregister(data->hwmon_dev); | ||
596 | |||
597 | for (i = 0; i < ARRAY_SIZE(tmp401_attr); i++) | ||
598 | device_remove_file(&client->dev, &tmp401_attr[i].dev_attr); | ||
599 | |||
600 | if (data->kind == tmp411) { | ||
601 | for (i = 0; i < ARRAY_SIZE(tmp411_attr); i++) | ||
602 | device_remove_file(&client->dev, | ||
603 | &tmp411_attr[i].dev_attr); | ||
604 | } | ||
605 | |||
606 | kfree(data); | ||
607 | return 0; | ||
608 | } | ||
609 | |||
610 | static struct tmp401_data *tmp401_update_device_reg16( | ||
611 | struct i2c_client *client, struct tmp401_data *data) | ||
612 | { | ||
613 | int i; | ||
614 | |||
615 | for (i = 0; i < 2; i++) { | ||
616 | /* | ||
617 | * High byte must be read first immediately followed | ||
618 | * by the low byte | ||
619 | */ | ||
620 | data->temp[i] = i2c_smbus_read_byte_data(client, | ||
621 | TMP401_TEMP_MSB[i]) << 8; | ||
622 | data->temp[i] |= i2c_smbus_read_byte_data(client, | ||
623 | TMP401_TEMP_LSB[i]); | ||
624 | data->temp_low[i] = i2c_smbus_read_byte_data(client, | ||
625 | TMP401_TEMP_LOW_LIMIT_MSB_READ[i]) << 8; | ||
626 | data->temp_low[i] |= i2c_smbus_read_byte_data(client, | ||
627 | TMP401_TEMP_LOW_LIMIT_LSB[i]); | ||
628 | data->temp_high[i] = i2c_smbus_read_byte_data(client, | ||
629 | TMP401_TEMP_HIGH_LIMIT_MSB_READ[i]) << 8; | ||
630 | data->temp_high[i] |= i2c_smbus_read_byte_data(client, | ||
631 | TMP401_TEMP_HIGH_LIMIT_LSB[i]); | ||
632 | data->temp_crit[i] = i2c_smbus_read_byte_data(client, | ||
633 | TMP401_TEMP_CRIT_LIMIT[i]); | ||
634 | |||
635 | if (data->kind == tmp411) { | ||
636 | data->temp_lowest[i] = i2c_smbus_read_byte_data(client, | ||
637 | TMP411_TEMP_LOWEST_MSB[i]) << 8; | ||
638 | data->temp_lowest[i] |= i2c_smbus_read_byte_data( | ||
639 | client, TMP411_TEMP_LOWEST_LSB[i]); | ||
640 | |||
641 | data->temp_highest[i] = i2c_smbus_read_byte_data( | ||
642 | client, TMP411_TEMP_HIGHEST_MSB[i]) << 8; | ||
643 | data->temp_highest[i] |= i2c_smbus_read_byte_data( | ||
644 | client, TMP411_TEMP_HIGHEST_LSB[i]); | ||
645 | } | ||
646 | } | ||
647 | return data; | ||
648 | } | ||
649 | |||
650 | static struct tmp401_data *tmp401_update_device(struct device *dev) | ||
651 | { | ||
652 | struct i2c_client *client = to_i2c_client(dev); | ||
653 | struct tmp401_data *data = i2c_get_clientdata(client); | ||
654 | |||
655 | mutex_lock(&data->update_lock); | ||
656 | |||
657 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | ||
658 | data->status = i2c_smbus_read_byte_data(client, TMP401_STATUS); | ||
659 | data->config = i2c_smbus_read_byte_data(client, | ||
660 | TMP401_CONFIG_READ); | ||
661 | tmp401_update_device_reg16(client, data); | ||
662 | |||
663 | data->temp_crit_hyst = i2c_smbus_read_byte_data(client, | ||
664 | TMP401_TEMP_CRIT_HYST); | ||
665 | |||
666 | data->last_updated = jiffies; | ||
667 | data->valid = 1; | ||
668 | } | ||
669 | |||
670 | mutex_unlock(&data->update_lock); | ||
671 | |||
672 | return data; | ||
673 | } | ||
674 | |||
675 | static int __init tmp401_init(void) | ||
676 | { | ||
677 | return i2c_add_driver(&tmp401_driver); | ||
678 | } | ||
679 | |||
680 | static void __exit tmp401_exit(void) | ||
681 | { | ||
682 | i2c_del_driver(&tmp401_driver); | ||
683 | } | ||
684 | |||
685 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); | ||
686 | MODULE_DESCRIPTION("Texas Instruments TMP401 temperature sensor driver"); | ||
687 | MODULE_LICENSE("GPL"); | ||
688 | |||
689 | module_init(tmp401_init); | ||
690 | module_exit(tmp401_exit); | ||
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index e64b42058b21..0e9746913d2b 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -36,6 +36,7 @@ | |||
36 | w83627ehf 10 5 4 3 0x8850 0x88 0x5ca3 | 36 | w83627ehf 10 5 4 3 0x8850 0x88 0x5ca3 |
37 | 0x8860 0xa1 | 37 | 0x8860 0xa1 |
38 | w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3 | 38 | w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3 |
39 | w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3 | ||
39 | w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3 | 40 | w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3 |
40 | */ | 41 | */ |
41 | 42 | ||
@@ -53,12 +54,13 @@ | |||
53 | #include <asm/io.h> | 54 | #include <asm/io.h> |
54 | #include "lm75.h" | 55 | #include "lm75.h" |
55 | 56 | ||
56 | enum kinds { w83627ehf, w83627dhg, w83667hg }; | 57 | enum kinds { w83627ehf, w83627dhg, w83627dhg_p, w83667hg }; |
57 | 58 | ||
58 | /* used to set data->name = w83627ehf_device_names[data->sio_kind] */ | 59 | /* used to set data->name = w83627ehf_device_names[data->sio_kind] */ |
59 | static const char * w83627ehf_device_names[] = { | 60 | static const char * w83627ehf_device_names[] = { |
60 | "w83627ehf", | 61 | "w83627ehf", |
61 | "w83627dhg", | 62 | "w83627dhg", |
63 | "w83627dhg", | ||
62 | "w83667hg", | 64 | "w83667hg", |
63 | }; | 65 | }; |
64 | 66 | ||
@@ -86,6 +88,7 @@ MODULE_PARM_DESC(force_id, "Override the detected device ID"); | |||
86 | #define SIO_W83627EHF_ID 0x8850 | 88 | #define SIO_W83627EHF_ID 0x8850 |
87 | #define SIO_W83627EHG_ID 0x8860 | 89 | #define SIO_W83627EHG_ID 0x8860 |
88 | #define SIO_W83627DHG_ID 0xa020 | 90 | #define SIO_W83627DHG_ID 0xa020 |
91 | #define SIO_W83627DHG_P_ID 0xb070 | ||
89 | #define SIO_W83667HG_ID 0xa510 | 92 | #define SIO_W83667HG_ID 0xa510 |
90 | #define SIO_ID_MASK 0xFFF0 | 93 | #define SIO_ID_MASK 0xFFF0 |
91 | 94 | ||
@@ -1517,6 +1520,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr, | |||
1517 | static const char __initdata sio_name_W83627EHF[] = "W83627EHF"; | 1520 | static const char __initdata sio_name_W83627EHF[] = "W83627EHF"; |
1518 | static const char __initdata sio_name_W83627EHG[] = "W83627EHG"; | 1521 | static const char __initdata sio_name_W83627EHG[] = "W83627EHG"; |
1519 | static const char __initdata sio_name_W83627DHG[] = "W83627DHG"; | 1522 | static const char __initdata sio_name_W83627DHG[] = "W83627DHG"; |
1523 | static const char __initdata sio_name_W83627DHG_P[] = "W83627DHG-P"; | ||
1520 | static const char __initdata sio_name_W83667HG[] = "W83667HG"; | 1524 | static const char __initdata sio_name_W83667HG[] = "W83667HG"; |
1521 | 1525 | ||
1522 | u16 val; | 1526 | u16 val; |
@@ -1542,6 +1546,10 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr, | |||
1542 | sio_data->kind = w83627dhg; | 1546 | sio_data->kind = w83627dhg; |
1543 | sio_name = sio_name_W83627DHG; | 1547 | sio_name = sio_name_W83627DHG; |
1544 | break; | 1548 | break; |
1549 | case SIO_W83627DHG_P_ID: | ||
1550 | sio_data->kind = w83627dhg_p; | ||
1551 | sio_name = sio_name_W83627DHG_P; | ||
1552 | break; | ||
1545 | case SIO_W83667HG_ID: | 1553 | case SIO_W83667HG_ID: |
1546 | sio_data->kind = w83667hg; | 1554 | sio_data->kind = w83667hg; |
1547 | sio_name = sio_name_W83667HG; | 1555 | sio_name = sio_name_W83667HG; |