diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-14 15:50:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-14 15:50:19 -0400 |
commit | 4fa435018d740cb83d74c92306aa1f796da91ddd (patch) | |
tree | b2b5783837be3d17b65b924b051aeb01e6b1fce9 /drivers/hwmon/it87.c | |
parent | 7441dd12e607651128e676866630a848b664d6e7 (diff) | |
parent | a022fef5a2b19086b329d1cc64a5d78aa83e2908 (diff) |
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
* 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6: (53 commits)
hwmon: (vt8231) fix sparse warning
hwmon: (sis5595) fix sparse warning
hwmon: (w83627hf) don't assume bank 0
hwmon: (w83627hf) Fix setting fan min right after driver load
hwmon: (w83627hf) De-macro sysfs callback functions
hwmon: Add new combined driver for FSC chips
hwmon: (ibmpex) Release IPMI user if hwmon registration fails
hwmon: (dme1737) Add sch311x support
hwmon: (dme1737) group functions logically
hwmon: (dme1737) cleanups
hwmon: IBM power meter driver
hwmon: (coretemp) Add support for Celeron 4xx
hwmon: (lm87) Disable VID when it should be
hwmon: (w83781d) Add individual alarm and beep files
hwmon: VRM is not read from registers
MAINTAINERS: update hwmon subsystem git trees
hwmon: Fix the code examples in documentation
hwmon: update sysfs interface document - error handling
hwmon: (thmc50) Fix a debug message
hwmon: (thmc50) Don't create temp3 if not enabled
...
Diffstat (limited to 'drivers/hwmon/it87.c')
-rw-r--r-- | drivers/hwmon/it87.c | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index d75dba9b810b..6a182e14cf58 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)) | 144 | static const u8 IT87_REG_FAN[] = { 0x0d, 0x0e, 0x0f, 0x80, 0x82 }; |
145 | #define IT87_REG_FAN_MIN(nr) (0x10 + (nr)) | 145 | static const u8 IT87_REG_FAN_MIN[] = { 0x10, 0x11, 0x12, 0x84, 0x86 }; |
146 | #define IT87_REG_FANX(nr) (0x18 + (nr)) | 146 | static const u8 IT87_REG_FANX[] = { 0x18, 0x19, 0x1a, 0x81, 0x83 }; |
147 | #define IT87_REG_FANX_MIN(nr) (0x1b + (nr)) | 147 | static 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)) |
@@ -222,7 +222,7 @@ struct it87_sio_data { | |||
222 | /* For each registered chip, we need to keep some data in memory. | 222 | /* For each registered chip, we need to keep some data in memory. |
223 | The structure is dynamically allocated. */ | 223 | The structure is dynamically allocated. */ |
224 | struct it87_data { | 224 | struct it87_data { |
225 | struct class_device *class_dev; | 225 | struct device *hwmon_dev; |
226 | enum chips type; | 226 | enum chips type; |
227 | 227 | ||
228 | unsigned short addr; | 228 | unsigned short addr; |
@@ -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 \ | |||
751 | show_fan16_offset(1); | 751 | show_fan16_offset(1); |
752 | show_fan16_offset(2); | 752 | show_fan16_offset(2); |
753 | show_fan16_offset(3); | 753 | show_fan16_offset(3); |
754 | show_fan16_offset(4); | ||
755 | show_fan16_offset(5); | ||
754 | 756 | ||
755 | /* Alarms */ | 757 | /* Alarms */ |
756 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 758 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -763,7 +765,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | |||
763 | static ssize_t | 765 | static ssize_t |
764 | show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 766 | show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
765 | { | 767 | { |
766 | struct it87_data *data = it87_update_device(dev); | 768 | struct it87_data *data = dev_get_drvdata(dev); |
767 | return sprintf(buf, "%u\n", data->vrm); | 769 | return sprintf(buf, "%u\n", data->vrm); |
768 | } | 770 | } |
769 | static ssize_t | 771 | static ssize_t |
@@ -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)) { |
@@ -1089,9 +1109,9 @@ static int __devinit it87_probe(struct platform_device *pdev) | |||
1089 | goto ERROR4; | 1109 | goto ERROR4; |
1090 | } | 1110 | } |
1091 | 1111 | ||
1092 | data->class_dev = hwmon_device_register(dev); | 1112 | data->hwmon_dev = hwmon_device_register(dev); |
1093 | if (IS_ERR(data->class_dev)) { | 1113 | if (IS_ERR(data->hwmon_dev)) { |
1094 | err = PTR_ERR(data->class_dev); | 1114 | err = PTR_ERR(data->hwmon_dev); |
1095 | goto ERROR4; | 1115 | goto ERROR4; |
1096 | } | 1116 | } |
1097 | 1117 | ||
@@ -1113,7 +1133,7 @@ static int __devexit it87_remove(struct platform_device *pdev) | |||
1113 | { | 1133 | { |
1114 | struct it87_data *data = platform_get_drvdata(pdev); | 1134 | struct it87_data *data = platform_get_drvdata(pdev); |
1115 | 1135 | ||
1116 | hwmon_device_unregister(data->class_dev); | 1136 | hwmon_device_unregister(data->hwmon_dev); |
1117 | sysfs_remove_group(&pdev->dev.kobj, &it87_group); | 1137 | sysfs_remove_group(&pdev->dev.kobj, &it87_group); |
1118 | sysfs_remove_group(&pdev->dev.kobj, &it87_group_opt); | 1138 | sysfs_remove_group(&pdev->dev.kobj, &it87_group_opt); |
1119 | 1139 | ||
@@ -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++) { |