aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/f71882fg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/f71882fg.c')
-rw-r--r--drivers/hwmon/f71882fg.c250
1 files changed, 191 insertions, 59 deletions
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;
92module_param(force_id, ushort, 0); 95module_param(force_id, ushort, 0);
93MODULE_PARM_DESC(force_id, "Override the detected device ID"); 96MODULE_PARM_DESC(force_id, "Override the detected device ID");
94 97
95enum chips { f71862fg, f71882fg, f8000 }; 98enum chips { f71858fg, f71862fg, f71882fg, f8000 };
96 99
97static const char *f71882fg_names[] = { 100static 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
253static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 259static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
254 260
261/* Temp and in attr for the f71858fg */
262static 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 */
256static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = { 306static 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 */
477static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { 530static 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 */
647static 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[] = {
659static struct sensor_device_attribute_2 f8000_fan_attr[] = { 713static 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
912static 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
860static struct f71882fg_data *f71882fg_update_device(struct device *dev) 920static 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
1175static ssize_t show_temp_max(struct device *dev, struct device_attribute 1252static 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;