aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-09-03 11:11:46 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2007-10-09 22:56:30 -0400
commitc7f1f7166a83f8f5607cc03c7a6c5f936cde6b0d (patch)
treedbf005f88d2dfa4fb72504c913574adcbb39e22d
parent6438312367523b26bd628b60cfd16f25a7a6f7ae (diff)
hwmon: (it87) Add support for fan4 and fan5
Add support for the IT8716F and IT8718F fan4 and fan5. The late revisions of the IT8712F have these too but support is harder to add and nobody asked for it yet, so I didn't include it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
-rw-r--r--Documentation/hwmon/it873
-rw-r--r--drivers/hwmon/it87.c54
2 files changed, 41 insertions, 16 deletions
diff --git a/Documentation/hwmon/it87 b/Documentation/hwmon/it87
index 81ecc7e41c50..5b704a40256b 100644
--- a/Documentation/hwmon/it87
+++ b/Documentation/hwmon/it87
@@ -90,7 +90,8 @@ upper VID bits share their pins with voltage inputs (in5 and in6) so you
90can't have both on a given board. 90can't have both on a given board.
91 91
92The IT8716F, IT8718F and later IT8712F revisions have support for 92The IT8716F, IT8718F and later IT8712F revisions have support for
932 additional fans. They are not yet supported by the driver. 932 additional fans. They are supported by the driver for the IT8716F and
94IT8718F but not for the IT8712F
94 95
95The IT8716F and IT8718F, and late IT8712F and IT8705F also have optional 96The IT8716F and IT8718F, and late IT8712F and IT8705F also have optional
9616-bit tachometer counters for fans 1 to 3. This is better (no more fan 9716-bit tachometer counters for fans 1 to 3. This is better (no more fan
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 41a90e5613bc..cd741b79c178 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -141,10 +141,10 @@ static int fix_pwm_polarity;
141 141
142/* Monitors: 9 voltage (0 to 7, battery), 3 temp (1 to 3), 3 fan (1 to 3) */ 142/* Monitors: 9 voltage (0 to 7, battery), 3 temp (1 to 3), 3 fan (1 to 3) */
143 143
144#define IT87_REG_FAN(nr) (0x0d + (nr)) 144static const u8 IT87_REG_FAN[] = { 0x0d, 0x0e, 0x0f, 0x80, 0x82 };
145#define IT87_REG_FAN_MIN(nr) (0x10 + (nr)) 145static const u8 IT87_REG_FAN_MIN[] = { 0x10, 0x11, 0x12, 0x84, 0x86 };
146#define IT87_REG_FANX(nr) (0x18 + (nr)) 146static const u8 IT87_REG_FANX[] = { 0x18, 0x19, 0x1a, 0x81, 0x83 };
147#define IT87_REG_FANX_MIN(nr) (0x1b + (nr)) 147static const u8 IT87_REG_FANX_MIN[] = { 0x1b, 0x1c, 0x1d, 0x85, 0x87 };
148#define IT87_REG_FAN_MAIN_CTRL 0x13 148#define IT87_REG_FAN_MAIN_CTRL 0x13
149#define IT87_REG_FAN_CTL 0x14 149#define IT87_REG_FAN_CTL 0x14
150#define IT87_REG_PWM(nr) (0x15 + (nr)) 150#define IT87_REG_PWM(nr) (0x15 + (nr))
@@ -235,8 +235,8 @@ struct it87_data {
235 u8 in_max[8]; /* Register value */ 235 u8 in_max[8]; /* Register value */
236 u8 in_min[8]; /* Register value */ 236 u8 in_min[8]; /* Register value */
237 u8 has_fan; /* Bitfield, fans enabled */ 237 u8 has_fan; /* Bitfield, fans enabled */
238 u16 fan[3]; /* Register values, possibly combined */ 238 u16 fan[5]; /* Register values, possibly combined */
239 u16 fan_min[3]; /* Register values, possibly combined */ 239 u16 fan_min[5]; /* Register values, possibly combined */
240 u8 temp[3]; /* Register value */ 240 u8 temp[3]; /* Register value */
241 u8 temp_high[3]; /* Register value */ 241 u8 temp_high[3]; /* Register value */
242 u8 temp_low[3]; /* Register value */ 242 u8 temp_low[3]; /* Register value */
@@ -555,7 +555,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
555 } 555 }
556 556
557 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 557 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
558 it87_write_value(data, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); 558 it87_write_value(data, IT87_REG_FAN_MIN[nr], data->fan_min[nr]);
559 mutex_unlock(&data->update_lock); 559 mutex_unlock(&data->update_lock);
560 return count; 560 return count;
561} 561}
@@ -596,7 +596,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
596 596
597 /* Restore fan min limit */ 597 /* Restore fan min limit */
598 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 598 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
599 it87_write_value(data, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); 599 it87_write_value(data, IT87_REG_FAN_MIN[nr], data->fan_min[nr]);
600 600
601 mutex_unlock(&data->update_lock); 601 mutex_unlock(&data->update_lock);
602 return count; 602 return count;
@@ -729,9 +729,9 @@ static ssize_t set_fan16_min(struct device *dev, struct device_attribute *attr,
729 729
730 mutex_lock(&data->update_lock); 730 mutex_lock(&data->update_lock);
731 data->fan_min[nr] = FAN16_TO_REG(val); 731 data->fan_min[nr] = FAN16_TO_REG(val);
732 it87_write_value(data, IT87_REG_FAN_MIN(nr), 732 it87_write_value(data, IT87_REG_FAN_MIN[nr],
733 data->fan_min[nr] & 0xff); 733 data->fan_min[nr] & 0xff);
734 it87_write_value(data, IT87_REG_FANX_MIN(nr), 734 it87_write_value(data, IT87_REG_FANX_MIN[nr],
735 data->fan_min[nr] >> 8); 735 data->fan_min[nr] >> 8);
736 mutex_unlock(&data->update_lock); 736 mutex_unlock(&data->update_lock);
737 return count; 737 return count;
@@ -751,6 +751,8 @@ static struct sensor_device_attribute sensor_dev_attr_fan##offset##_min16 \
751show_fan16_offset(1); 751show_fan16_offset(1);
752show_fan16_offset(2); 752show_fan16_offset(2);
753show_fan16_offset(3); 753show_fan16_offset(3);
754show_fan16_offset(4);
755show_fan16_offset(5);
754 756
755/* Alarms */ 757/* Alarms */
756static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 758static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
@@ -851,6 +853,10 @@ static struct attribute *it87_attributes_opt[] = {
851 &sensor_dev_attr_fan2_min16.dev_attr.attr, 853 &sensor_dev_attr_fan2_min16.dev_attr.attr,
852 &sensor_dev_attr_fan3_input16.dev_attr.attr, 854 &sensor_dev_attr_fan3_input16.dev_attr.attr,
853 &sensor_dev_attr_fan3_min16.dev_attr.attr, 855 &sensor_dev_attr_fan3_min16.dev_attr.attr,
856 &sensor_dev_attr_fan4_input16.dev_attr.attr,
857 &sensor_dev_attr_fan4_min16.dev_attr.attr,
858 &sensor_dev_attr_fan5_input16.dev_attr.attr,
859 &sensor_dev_attr_fan5_min16.dev_attr.attr,
854 860
855 &sensor_dev_attr_fan1_input.dev_attr.attr, 861 &sensor_dev_attr_fan1_input.dev_attr.attr,
856 &sensor_dev_attr_fan1_min.dev_attr.attr, 862 &sensor_dev_attr_fan1_min.dev_attr.attr,
@@ -1024,6 +1030,20 @@ static int __devinit it87_probe(struct platform_device *pdev)
1024 &sensor_dev_attr_fan3_min16.dev_attr))) 1030 &sensor_dev_attr_fan3_min16.dev_attr)))
1025 goto ERROR4; 1031 goto ERROR4;
1026 } 1032 }
1033 if (data->has_fan & (1 << 3)) {
1034 if ((err = device_create_file(dev,
1035 &sensor_dev_attr_fan4_input16.dev_attr))
1036 || (err = device_create_file(dev,
1037 &sensor_dev_attr_fan4_min16.dev_attr)))
1038 goto ERROR4;
1039 }
1040 if (data->has_fan & (1 << 4)) {
1041 if ((err = device_create_file(dev,
1042 &sensor_dev_attr_fan5_input16.dev_attr))
1043 || (err = device_create_file(dev,
1044 &sensor_dev_attr_fan5_min16.dev_attr)))
1045 goto ERROR4;
1046 }
1027 } else { 1047 } else {
1028 /* 8-bit tachometers with clock divider */ 1048 /* 8-bit tachometers with clock divider */
1029 if (data->has_fan & (1 << 0)) { 1049 if (data->has_fan & (1 << 0)) {
@@ -1260,6 +1280,10 @@ static void __devinit it87_init_device(struct platform_device *pdev)
1260 it87_write_value(data, IT87_REG_FAN_16BIT, 1280 it87_write_value(data, IT87_REG_FAN_16BIT,
1261 tmp | 0x07); 1281 tmp | 0x07);
1262 } 1282 }
1283 if (tmp & (1 << 4))
1284 data->has_fan |= (1 << 3); /* fan4 enabled */
1285 if (tmp & (1 << 5))
1286 data->has_fan |= (1 << 4); /* fan5 enabled */
1263 } 1287 }
1264 1288
1265 /* Set current fan mode registers and the default settings for the 1289 /* Set current fan mode registers and the default settings for the
@@ -1314,21 +1338,21 @@ static struct it87_data *it87_update_device(struct device *dev)
1314 data->in[8] = 1338 data->in[8] =
1315 it87_read_value(data, IT87_REG_VIN(8)); 1339 it87_read_value(data, IT87_REG_VIN(8));
1316 1340
1317 for (i = 0; i < 3; i++) { 1341 for (i = 0; i < 5; i++) {
1318 /* Skip disabled fans */ 1342 /* Skip disabled fans */
1319 if (!(data->has_fan & (1 << i))) 1343 if (!(data->has_fan & (1 << i)))
1320 continue; 1344 continue;
1321 1345
1322 data->fan_min[i] = 1346 data->fan_min[i] =
1323 it87_read_value(data, IT87_REG_FAN_MIN(i)); 1347 it87_read_value(data, IT87_REG_FAN_MIN[i]);
1324 data->fan[i] = it87_read_value(data, 1348 data->fan[i] = it87_read_value(data,
1325 IT87_REG_FAN(i)); 1349 IT87_REG_FAN[i]);
1326 /* Add high byte if in 16-bit mode */ 1350 /* Add high byte if in 16-bit mode */
1327 if (data->type == it8716 || data->type == it8718) { 1351 if (data->type == it8716 || data->type == it8718) {
1328 data->fan[i] |= it87_read_value(data, 1352 data->fan[i] |= it87_read_value(data,
1329 IT87_REG_FANX(i)) << 8; 1353 IT87_REG_FANX[i]) << 8;
1330 data->fan_min[i] |= it87_read_value(data, 1354 data->fan_min[i] |= it87_read_value(data,
1331 IT87_REG_FANX_MIN(i)) << 8; 1355 IT87_REG_FANX_MIN[i]) << 8;
1332 } 1356 }
1333 } 1357 }
1334 for (i = 0; i < 3; i++) { 1358 for (i = 0; i < 3; i++) {