diff options
Diffstat (limited to 'drivers/hwmon/dme1737.c')
-rw-r--r-- | drivers/hwmon/dme1737.c | 292 |
1 files changed, 181 insertions, 111 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index 5e2cf0aef480..cdb8311e4ef7 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c | |||
@@ -1,11 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * dme1737.c - Driver for the SMSC DME1737, Asus A8000, and SMSC SCH311x | 2 | * dme1737.c - Driver for the SMSC DME1737, Asus A8000, SMSC SCH311x and |
3 | * Super-I/O chips integrated hardware monitoring features. | 3 | * SCH5027 Super-I/O chips integrated hardware monitoring features. |
4 | * Copyright (c) 2007 Juerg Haefliger <juergh@gmail.com> | 4 | * Copyright (c) 2007, 2008 Juerg Haefliger <juergh@gmail.com> |
5 | * | 5 | * |
6 | * This driver is an I2C/ISA hybrid, meaning that it uses the I2C bus to access | 6 | * This driver is an I2C/ISA hybrid, meaning that it uses the I2C bus to access |
7 | * the chip registers if a DME1737 (or A8000) is found and the ISA bus if a | 7 | * the chip registers if a DME1737, A8000, or SCH5027 is found and the ISA bus |
8 | * SCH311x chip is found. Both types of chips have very similar hardware | 8 | * if a SCH311x chip is found. Both types of chips have very similar hardware |
9 | * monitoring capabilities but differ in the way they can be accessed. | 9 | * monitoring capabilities but differ in the way they can be accessed. |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
@@ -57,7 +57,10 @@ MODULE_PARM_DESC(probe_all_addr, "Include probing of non-standard LPC " | |||
57 | static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; | 57 | static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; |
58 | 58 | ||
59 | /* Insmod parameters */ | 59 | /* Insmod parameters */ |
60 | I2C_CLIENT_INSMOD_1(dme1737); | 60 | I2C_CLIENT_INSMOD_2(dme1737, sch5027); |
61 | |||
62 | /* ISA chip types */ | ||
63 | enum isa_chips { sch311x = sch5027 + 1 }; | ||
61 | 64 | ||
62 | /* --------------------------------------------------------------------- | 65 | /* --------------------------------------------------------------------- |
63 | * Registers | 66 | * Registers |
@@ -163,6 +166,7 @@ static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; | |||
163 | #define DME1737_VERSTEP 0x88 | 166 | #define DME1737_VERSTEP 0x88 |
164 | #define DME1737_VERSTEP_MASK 0xf8 | 167 | #define DME1737_VERSTEP_MASK 0xf8 |
165 | #define SCH311X_DEVICE 0x8c | 168 | #define SCH311X_DEVICE 0x8c |
169 | #define SCH5027_VERSTEP 0x69 | ||
166 | 170 | ||
167 | /* Length of ISA address segment */ | 171 | /* Length of ISA address segment */ |
168 | #define DME1737_EXTENT 2 | 172 | #define DME1737_EXTENT 2 |
@@ -182,6 +186,7 @@ struct dme1737_data { | |||
182 | unsigned long last_update; /* in jiffies */ | 186 | unsigned long last_update; /* in jiffies */ |
183 | unsigned long last_vbat; /* in jiffies */ | 187 | unsigned long last_vbat; /* in jiffies */ |
184 | enum chips type; | 188 | enum chips type; |
189 | const int *in_nominal; /* pointer to IN_NOMINAL array */ | ||
185 | 190 | ||
186 | u8 vid; | 191 | u8 vid; |
187 | u8 pwm_rr_en; | 192 | u8 pwm_rr_en; |
@@ -220,23 +225,23 @@ static const int IN_NOMINAL_DME1737[] = {5000, 2250, 3300, 5000, 12000, 3300, | |||
220 | 3300}; | 225 | 3300}; |
221 | static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300, | 226 | static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300, |
222 | 3300}; | 227 | 3300}; |
223 | #define IN_NOMINAL(ix, type) (((type) == dme1737) ? \ | 228 | static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300, |
224 | IN_NOMINAL_DME1737[(ix)] : \ | 229 | 3300}; |
225 | IN_NOMINAL_SCH311x[(ix)]) | 230 | #define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \ |
231 | (type) == sch5027 ? IN_NOMINAL_SCH5027 : \ | ||
232 | IN_NOMINAL_DME1737) | ||
226 | 233 | ||
227 | /* Voltage input | 234 | /* Voltage input |
228 | * Voltage inputs have 16 bits resolution, limit values have 8 bits | 235 | * Voltage inputs have 16 bits resolution, limit values have 8 bits |
229 | * resolution. */ | 236 | * resolution. */ |
230 | static inline int IN_FROM_REG(int reg, int ix, int res, int type) | 237 | static inline int IN_FROM_REG(int reg, int nominal, int res) |
231 | { | 238 | { |
232 | return (reg * IN_NOMINAL(ix, type) + (3 << (res - 3))) / | 239 | return (reg * nominal + (3 << (res - 3))) / (3 << (res - 2)); |
233 | (3 << (res - 2)); | ||
234 | } | 240 | } |
235 | 241 | ||
236 | static inline int IN_TO_REG(int val, int ix, int type) | 242 | static inline int IN_TO_REG(int val, int nominal) |
237 | { | 243 | { |
238 | return SENSORS_LIMIT((val * 192 + IN_NOMINAL(ix, type) / 2) / | 244 | return SENSORS_LIMIT((val * 192 + nominal / 2) / nominal, 0, 255); |
239 | IN_NOMINAL(ix, type), 0, 255); | ||
240 | } | 245 | } |
241 | 246 | ||
242 | /* Temperature input | 247 | /* Temperature input |
@@ -565,7 +570,10 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
565 | 570 | ||
566 | /* Sample register contents every 1 sec */ | 571 | /* Sample register contents every 1 sec */ |
567 | if (time_after(jiffies, data->last_update + HZ) || !data->valid) { | 572 | if (time_after(jiffies, data->last_update + HZ) || !data->valid) { |
568 | data->vid = dme1737_read(client, DME1737_REG_VID) & 0x3f; | 573 | if (data->type != sch5027) { |
574 | data->vid = dme1737_read(client, DME1737_REG_VID) & | ||
575 | 0x3f; | ||
576 | } | ||
569 | 577 | ||
570 | /* In (voltage) registers */ | 578 | /* In (voltage) registers */ |
571 | for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { | 579 | for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { |
@@ -593,8 +601,10 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
593 | DME1737_REG_TEMP_MIN(ix)); | 601 | DME1737_REG_TEMP_MIN(ix)); |
594 | data->temp_max[ix] = dme1737_read(client, | 602 | data->temp_max[ix] = dme1737_read(client, |
595 | DME1737_REG_TEMP_MAX(ix)); | 603 | DME1737_REG_TEMP_MAX(ix)); |
596 | data->temp_offset[ix] = dme1737_read(client, | 604 | if (data->type != sch5027) { |
597 | DME1737_REG_TEMP_OFFSET(ix)); | 605 | data->temp_offset[ix] = dme1737_read(client, |
606 | DME1737_REG_TEMP_OFFSET(ix)); | ||
607 | } | ||
598 | } | 608 | } |
599 | 609 | ||
600 | /* In and temp LSB registers | 610 | /* In and temp LSB registers |
@@ -669,9 +679,11 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
669 | data->zone_abs[ix] = dme1737_read(client, | 679 | data->zone_abs[ix] = dme1737_read(client, |
670 | DME1737_REG_ZONE_ABS(ix)); | 680 | DME1737_REG_ZONE_ABS(ix)); |
671 | } | 681 | } |
672 | for (ix = 0; ix < ARRAY_SIZE(data->zone_hyst); ix++) { | 682 | if (data->type != sch5027) { |
673 | data->zone_hyst[ix] = dme1737_read(client, | 683 | for (ix = 0; ix < ARRAY_SIZE(data->zone_hyst); ix++) { |
684 | data->zone_hyst[ix] = dme1737_read(client, | ||
674 | DME1737_REG_ZONE_HYST(ix)); | 685 | DME1737_REG_ZONE_HYST(ix)); |
686 | } | ||
675 | } | 687 | } |
676 | 688 | ||
677 | /* Alarm registers */ | 689 | /* Alarm registers */ |
@@ -735,13 +747,13 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, | |||
735 | 747 | ||
736 | switch (fn) { | 748 | switch (fn) { |
737 | case SYS_IN_INPUT: | 749 | case SYS_IN_INPUT: |
738 | res = IN_FROM_REG(data->in[ix], ix, 16, data->type); | 750 | res = IN_FROM_REG(data->in[ix], data->in_nominal[ix], 16); |
739 | break; | 751 | break; |
740 | case SYS_IN_MIN: | 752 | case SYS_IN_MIN: |
741 | res = IN_FROM_REG(data->in_min[ix], ix, 8, data->type); | 753 | res = IN_FROM_REG(data->in_min[ix], data->in_nominal[ix], 8); |
742 | break; | 754 | break; |
743 | case SYS_IN_MAX: | 755 | case SYS_IN_MAX: |
744 | res = IN_FROM_REG(data->in_max[ix], ix, 8, data->type); | 756 | res = IN_FROM_REG(data->in_max[ix], data->in_nominal[ix], 8); |
745 | break; | 757 | break; |
746 | case SYS_IN_ALARM: | 758 | case SYS_IN_ALARM: |
747 | res = (data->alarms >> DME1737_BIT_ALARM_IN[ix]) & 0x01; | 759 | res = (data->alarms >> DME1737_BIT_ALARM_IN[ix]) & 0x01; |
@@ -768,12 +780,12 @@ static ssize_t set_in(struct device *dev, struct device_attribute *attr, | |||
768 | mutex_lock(&data->update_lock); | 780 | mutex_lock(&data->update_lock); |
769 | switch (fn) { | 781 | switch (fn) { |
770 | case SYS_IN_MIN: | 782 | case SYS_IN_MIN: |
771 | data->in_min[ix] = IN_TO_REG(val, ix, data->type); | 783 | data->in_min[ix] = IN_TO_REG(val, data->in_nominal[ix]); |
772 | dme1737_write(client, DME1737_REG_IN_MIN(ix), | 784 | dme1737_write(client, DME1737_REG_IN_MIN(ix), |
773 | data->in_min[ix]); | 785 | data->in_min[ix]); |
774 | break; | 786 | break; |
775 | case SYS_IN_MAX: | 787 | case SYS_IN_MAX: |
776 | data->in_max[ix] = IN_TO_REG(val, ix, data->type); | 788 | data->in_max[ix] = IN_TO_REG(val, data->in_nominal[ix]); |
777 | dme1737_write(client, DME1737_REG_IN_MAX(ix), | 789 | dme1737_write(client, DME1737_REG_IN_MAX(ix), |
778 | data->in_max[ix]); | 790 | data->in_max[ix]); |
779 | break; | 791 | break; |
@@ -1166,7 +1178,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, | |||
1166 | return sprintf(buf, "%d\n", res); | 1178 | return sprintf(buf, "%d\n", res); |
1167 | } | 1179 | } |
1168 | 1180 | ||
1169 | static struct attribute *dme1737_attr_pwm[]; | 1181 | static struct attribute *dme1737_pwm_chmod_attr[]; |
1170 | static void dme1737_chmod_file(struct device*, struct attribute*, mode_t); | 1182 | static void dme1737_chmod_file(struct device*, struct attribute*, mode_t); |
1171 | 1183 | ||
1172 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | 1184 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
@@ -1230,7 +1242,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
1230 | switch (val) { | 1242 | switch (val) { |
1231 | case 0: | 1243 | case 0: |
1232 | /* Change permissions of pwm[ix] to read-only */ | 1244 | /* Change permissions of pwm[ix] to read-only */ |
1233 | dme1737_chmod_file(dev, dme1737_attr_pwm[ix], | 1245 | dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], |
1234 | S_IRUGO); | 1246 | S_IRUGO); |
1235 | /* Turn fan fully on */ | 1247 | /* Turn fan fully on */ |
1236 | data->pwm_config[ix] = PWM_EN_TO_REG(0, | 1248 | data->pwm_config[ix] = PWM_EN_TO_REG(0, |
@@ -1245,12 +1257,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
1245 | dme1737_write(client, DME1737_REG_PWM_CONFIG(ix), | 1257 | dme1737_write(client, DME1737_REG_PWM_CONFIG(ix), |
1246 | data->pwm_config[ix]); | 1258 | data->pwm_config[ix]); |
1247 | /* Change permissions of pwm[ix] to read-writeable */ | 1259 | /* Change permissions of pwm[ix] to read-writeable */ |
1248 | dme1737_chmod_file(dev, dme1737_attr_pwm[ix], | 1260 | dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], |
1249 | S_IRUGO | S_IWUSR); | 1261 | S_IRUGO | S_IWUSR); |
1250 | break; | 1262 | break; |
1251 | case 2: | 1263 | case 2: |
1252 | /* Change permissions of pwm[ix] to read-only */ | 1264 | /* Change permissions of pwm[ix] to read-only */ |
1253 | dme1737_chmod_file(dev, dme1737_attr_pwm[ix], | 1265 | dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], |
1254 | S_IRUGO); | 1266 | S_IRUGO); |
1255 | /* Turn on auto mode using the saved zone channel | 1267 | /* Turn on auto mode using the saved zone channel |
1256 | * assignment */ | 1268 | * assignment */ |
@@ -1570,88 +1582,98 @@ static struct attribute *dme1737_attr[] ={ | |||
1570 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 1582 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
1571 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | 1583 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, |
1572 | &sensor_dev_attr_temp1_fault.dev_attr.attr, | 1584 | &sensor_dev_attr_temp1_fault.dev_attr.attr, |
1573 | &sensor_dev_attr_temp1_offset.dev_attr.attr, | ||
1574 | &sensor_dev_attr_temp2_input.dev_attr.attr, | 1585 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
1575 | &sensor_dev_attr_temp2_min.dev_attr.attr, | 1586 | &sensor_dev_attr_temp2_min.dev_attr.attr, |
1576 | &sensor_dev_attr_temp2_max.dev_attr.attr, | 1587 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
1577 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | 1588 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, |
1578 | &sensor_dev_attr_temp2_fault.dev_attr.attr, | 1589 | &sensor_dev_attr_temp2_fault.dev_attr.attr, |
1579 | &sensor_dev_attr_temp2_offset.dev_attr.attr, | ||
1580 | &sensor_dev_attr_temp3_input.dev_attr.attr, | 1590 | &sensor_dev_attr_temp3_input.dev_attr.attr, |
1581 | &sensor_dev_attr_temp3_min.dev_attr.attr, | 1591 | &sensor_dev_attr_temp3_min.dev_attr.attr, |
1582 | &sensor_dev_attr_temp3_max.dev_attr.attr, | 1592 | &sensor_dev_attr_temp3_max.dev_attr.attr, |
1583 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | 1593 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, |
1584 | &sensor_dev_attr_temp3_fault.dev_attr.attr, | 1594 | &sensor_dev_attr_temp3_fault.dev_attr.attr, |
1585 | &sensor_dev_attr_temp3_offset.dev_attr.attr, | ||
1586 | /* Zones */ | 1595 | /* Zones */ |
1587 | &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr, | ||
1588 | &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr, | 1596 | &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr, |
1589 | &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr, | 1597 | &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr, |
1590 | &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr, | 1598 | &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr, |
1591 | &sensor_dev_attr_zone1_auto_channels_temp.dev_attr.attr, | 1599 | &sensor_dev_attr_zone1_auto_channels_temp.dev_attr.attr, |
1592 | &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr, | ||
1593 | &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr, | 1600 | &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr, |
1594 | &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, | 1601 | &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, |
1595 | &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, | 1602 | &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, |
1596 | &sensor_dev_attr_zone2_auto_channels_temp.dev_attr.attr, | 1603 | &sensor_dev_attr_zone2_auto_channels_temp.dev_attr.attr, |
1597 | &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr, | ||
1598 | &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, | 1604 | &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, |
1599 | &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, | 1605 | &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, |
1600 | &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, | 1606 | &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, |
1601 | &sensor_dev_attr_zone3_auto_channels_temp.dev_attr.attr, | 1607 | &sensor_dev_attr_zone3_auto_channels_temp.dev_attr.attr, |
1608 | NULL | ||
1609 | }; | ||
1610 | |||
1611 | static const struct attribute_group dme1737_group = { | ||
1612 | .attrs = dme1737_attr, | ||
1613 | }; | ||
1614 | |||
1615 | /* The following struct holds misc attributes, which are not available in all | ||
1616 | * chips. Their creation depends on the chip type which is determined during | ||
1617 | * module load. */ | ||
1618 | static struct attribute *dme1737_misc_attr[] = { | ||
1619 | /* Temperatures */ | ||
1620 | &sensor_dev_attr_temp1_offset.dev_attr.attr, | ||
1621 | &sensor_dev_attr_temp2_offset.dev_attr.attr, | ||
1622 | &sensor_dev_attr_temp3_offset.dev_attr.attr, | ||
1623 | /* Zones */ | ||
1624 | &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr, | ||
1625 | &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr, | ||
1626 | &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr, | ||
1602 | /* Misc */ | 1627 | /* Misc */ |
1603 | &dev_attr_vrm.attr, | 1628 | &dev_attr_vrm.attr, |
1604 | &dev_attr_cpu0_vid.attr, | 1629 | &dev_attr_cpu0_vid.attr, |
1605 | NULL | 1630 | NULL |
1606 | }; | 1631 | }; |
1607 | 1632 | ||
1608 | static const struct attribute_group dme1737_group = { | 1633 | static const struct attribute_group dme1737_misc_group = { |
1609 | .attrs = dme1737_attr, | 1634 | .attrs = dme1737_misc_attr, |
1610 | }; | 1635 | }; |
1611 | 1636 | ||
1612 | /* The following structs hold the PWM attributes, some of which are optional. | 1637 | /* The following structs hold the PWM attributes, some of which are optional. |
1613 | * Their creation depends on the chip configuration which is determined during | 1638 | * Their creation depends on the chip configuration which is determined during |
1614 | * module load. */ | 1639 | * module load. */ |
1615 | static struct attribute *dme1737_attr_pwm1[] = { | 1640 | static struct attribute *dme1737_pwm1_attr[] = { |
1616 | &sensor_dev_attr_pwm1.dev_attr.attr, | 1641 | &sensor_dev_attr_pwm1.dev_attr.attr, |
1617 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, | 1642 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, |
1618 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | 1643 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
1619 | &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr, | 1644 | &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr, |
1620 | &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr, | 1645 | &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr, |
1621 | &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr, | ||
1622 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | 1646 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, |
1623 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, | 1647 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, |
1624 | NULL | 1648 | NULL |
1625 | }; | 1649 | }; |
1626 | static struct attribute *dme1737_attr_pwm2[] = { | 1650 | static struct attribute *dme1737_pwm2_attr[] = { |
1627 | &sensor_dev_attr_pwm2.dev_attr.attr, | 1651 | &sensor_dev_attr_pwm2.dev_attr.attr, |
1628 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, | 1652 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, |
1629 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | 1653 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, |
1630 | &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr, | 1654 | &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr, |
1631 | &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr, | 1655 | &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr, |
1632 | &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr, | ||
1633 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | 1656 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, |
1634 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, | 1657 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, |
1635 | NULL | 1658 | NULL |
1636 | }; | 1659 | }; |
1637 | static struct attribute *dme1737_attr_pwm3[] = { | 1660 | static struct attribute *dme1737_pwm3_attr[] = { |
1638 | &sensor_dev_attr_pwm3.dev_attr.attr, | 1661 | &sensor_dev_attr_pwm3.dev_attr.attr, |
1639 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, | 1662 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, |
1640 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | 1663 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, |
1641 | &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr, | 1664 | &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr, |
1642 | &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr, | 1665 | &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr, |
1643 | &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr, | ||
1644 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | 1666 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, |
1645 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | 1667 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, |
1646 | NULL | 1668 | NULL |
1647 | }; | 1669 | }; |
1648 | static struct attribute *dme1737_attr_pwm5[] = { | 1670 | static struct attribute *dme1737_pwm5_attr[] = { |
1649 | &sensor_dev_attr_pwm5.dev_attr.attr, | 1671 | &sensor_dev_attr_pwm5.dev_attr.attr, |
1650 | &sensor_dev_attr_pwm5_freq.dev_attr.attr, | 1672 | &sensor_dev_attr_pwm5_freq.dev_attr.attr, |
1651 | &sensor_dev_attr_pwm5_enable.dev_attr.attr, | 1673 | &sensor_dev_attr_pwm5_enable.dev_attr.attr, |
1652 | NULL | 1674 | NULL |
1653 | }; | 1675 | }; |
1654 | static struct attribute *dme1737_attr_pwm6[] = { | 1676 | static struct attribute *dme1737_pwm6_attr[] = { |
1655 | &sensor_dev_attr_pwm6.dev_attr.attr, | 1677 | &sensor_dev_attr_pwm6.dev_attr.attr, |
1656 | &sensor_dev_attr_pwm6_freq.dev_attr.attr, | 1678 | &sensor_dev_attr_pwm6_freq.dev_attr.attr, |
1657 | &sensor_dev_attr_pwm6_enable.dev_attr.attr, | 1679 | &sensor_dev_attr_pwm6_enable.dev_attr.attr, |
@@ -1659,53 +1681,62 @@ static struct attribute *dme1737_attr_pwm6[] = { | |||
1659 | }; | 1681 | }; |
1660 | 1682 | ||
1661 | static const struct attribute_group dme1737_pwm_group[] = { | 1683 | static const struct attribute_group dme1737_pwm_group[] = { |
1662 | { .attrs = dme1737_attr_pwm1 }, | 1684 | { .attrs = dme1737_pwm1_attr }, |
1663 | { .attrs = dme1737_attr_pwm2 }, | 1685 | { .attrs = dme1737_pwm2_attr }, |
1664 | { .attrs = dme1737_attr_pwm3 }, | 1686 | { .attrs = dme1737_pwm3_attr }, |
1665 | { .attrs = NULL }, | 1687 | { .attrs = NULL }, |
1666 | { .attrs = dme1737_attr_pwm5 }, | 1688 | { .attrs = dme1737_pwm5_attr }, |
1667 | { .attrs = dme1737_attr_pwm6 }, | 1689 | { .attrs = dme1737_pwm6_attr }, |
1690 | }; | ||
1691 | |||
1692 | /* The following struct holds misc PWM attributes, which are not available in | ||
1693 | * all chips. Their creation depends on the chip type which is determined | ||
1694 | * during module load. */ | ||
1695 | static struct attribute *dme1737_pwm_misc_attr[] = { | ||
1696 | &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr, | ||
1697 | &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr, | ||
1698 | &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr, | ||
1668 | }; | 1699 | }; |
1669 | 1700 | ||
1670 | /* The following structs hold the fan attributes, some of which are optional. | 1701 | /* The following structs hold the fan attributes, some of which are optional. |
1671 | * Their creation depends on the chip configuration which is determined during | 1702 | * Their creation depends on the chip configuration which is determined during |
1672 | * module load. */ | 1703 | * module load. */ |
1673 | static struct attribute *dme1737_attr_fan1[] = { | 1704 | static struct attribute *dme1737_fan1_attr[] = { |
1674 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 1705 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
1675 | &sensor_dev_attr_fan1_min.dev_attr.attr, | 1706 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
1676 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | 1707 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, |
1677 | &sensor_dev_attr_fan1_type.dev_attr.attr, | 1708 | &sensor_dev_attr_fan1_type.dev_attr.attr, |
1678 | NULL | 1709 | NULL |
1679 | }; | 1710 | }; |
1680 | static struct attribute *dme1737_attr_fan2[] = { | 1711 | static struct attribute *dme1737_fan2_attr[] = { |
1681 | &sensor_dev_attr_fan2_input.dev_attr.attr, | 1712 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
1682 | &sensor_dev_attr_fan2_min.dev_attr.attr, | 1713 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
1683 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | 1714 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, |
1684 | &sensor_dev_attr_fan2_type.dev_attr.attr, | 1715 | &sensor_dev_attr_fan2_type.dev_attr.attr, |
1685 | NULL | 1716 | NULL |
1686 | }; | 1717 | }; |
1687 | static struct attribute *dme1737_attr_fan3[] = { | 1718 | static struct attribute *dme1737_fan3_attr[] = { |
1688 | &sensor_dev_attr_fan3_input.dev_attr.attr, | 1719 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
1689 | &sensor_dev_attr_fan3_min.dev_attr.attr, | 1720 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
1690 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | 1721 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, |
1691 | &sensor_dev_attr_fan3_type.dev_attr.attr, | 1722 | &sensor_dev_attr_fan3_type.dev_attr.attr, |
1692 | NULL | 1723 | NULL |
1693 | }; | 1724 | }; |
1694 | static struct attribute *dme1737_attr_fan4[] = { | 1725 | static struct attribute *dme1737_fan4_attr[] = { |
1695 | &sensor_dev_attr_fan4_input.dev_attr.attr, | 1726 | &sensor_dev_attr_fan4_input.dev_attr.attr, |
1696 | &sensor_dev_attr_fan4_min.dev_attr.attr, | 1727 | &sensor_dev_attr_fan4_min.dev_attr.attr, |
1697 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | 1728 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, |
1698 | &sensor_dev_attr_fan4_type.dev_attr.attr, | 1729 | &sensor_dev_attr_fan4_type.dev_attr.attr, |
1699 | NULL | 1730 | NULL |
1700 | }; | 1731 | }; |
1701 | static struct attribute *dme1737_attr_fan5[] = { | 1732 | static struct attribute *dme1737_fan5_attr[] = { |
1702 | &sensor_dev_attr_fan5_input.dev_attr.attr, | 1733 | &sensor_dev_attr_fan5_input.dev_attr.attr, |
1703 | &sensor_dev_attr_fan5_min.dev_attr.attr, | 1734 | &sensor_dev_attr_fan5_min.dev_attr.attr, |
1704 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, | 1735 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, |
1705 | &sensor_dev_attr_fan5_max.dev_attr.attr, | 1736 | &sensor_dev_attr_fan5_max.dev_attr.attr, |
1706 | NULL | 1737 | NULL |
1707 | }; | 1738 | }; |
1708 | static struct attribute *dme1737_attr_fan6[] = { | 1739 | static struct attribute *dme1737_fan6_attr[] = { |
1709 | &sensor_dev_attr_fan6_input.dev_attr.attr, | 1740 | &sensor_dev_attr_fan6_input.dev_attr.attr, |
1710 | &sensor_dev_attr_fan6_min.dev_attr.attr, | 1741 | &sensor_dev_attr_fan6_min.dev_attr.attr, |
1711 | &sensor_dev_attr_fan6_alarm.dev_attr.attr, | 1742 | &sensor_dev_attr_fan6_alarm.dev_attr.attr, |
@@ -1714,94 +1745,83 @@ static struct attribute *dme1737_attr_fan6[] = { | |||
1714 | }; | 1745 | }; |
1715 | 1746 | ||
1716 | static const struct attribute_group dme1737_fan_group[] = { | 1747 | static const struct attribute_group dme1737_fan_group[] = { |
1717 | { .attrs = dme1737_attr_fan1 }, | 1748 | { .attrs = dme1737_fan1_attr }, |
1718 | { .attrs = dme1737_attr_fan2 }, | 1749 | { .attrs = dme1737_fan2_attr }, |
1719 | { .attrs = dme1737_attr_fan3 }, | 1750 | { .attrs = dme1737_fan3_attr }, |
1720 | { .attrs = dme1737_attr_fan4 }, | 1751 | { .attrs = dme1737_fan4_attr }, |
1721 | { .attrs = dme1737_attr_fan5 }, | 1752 | { .attrs = dme1737_fan5_attr }, |
1722 | { .attrs = dme1737_attr_fan6 }, | 1753 | { .attrs = dme1737_fan6_attr }, |
1723 | }; | 1754 | }; |
1724 | 1755 | ||
1725 | /* The permissions of all of the following attributes are changed to read- | 1756 | /* The permissions of the following zone attributes are changed to read- |
1726 | * writeable if the chip is *not* locked. Otherwise they stay read-only. */ | 1757 | * writeable if the chip is *not* locked. Otherwise they stay read-only. */ |
1727 | static struct attribute *dme1737_attr_lock[] = { | 1758 | static struct attribute *dme1737_zone_chmod_attr[] = { |
1728 | /* Temperatures */ | ||
1729 | &sensor_dev_attr_temp1_offset.dev_attr.attr, | ||
1730 | &sensor_dev_attr_temp2_offset.dev_attr.attr, | ||
1731 | &sensor_dev_attr_temp3_offset.dev_attr.attr, | ||
1732 | /* Zones */ | ||
1733 | &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr, | ||
1734 | &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr, | 1759 | &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr, |
1735 | &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr, | 1760 | &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr, |
1736 | &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr, | 1761 | &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr, |
1737 | &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr, | ||
1738 | &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr, | 1762 | &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr, |
1739 | &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, | 1763 | &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, |
1740 | &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, | 1764 | &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, |
1741 | &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr, | ||
1742 | &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, | 1765 | &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, |
1743 | &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, | 1766 | &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, |
1744 | &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, | 1767 | &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, |
1745 | NULL | 1768 | NULL |
1746 | }; | 1769 | }; |
1747 | 1770 | ||
1748 | static const struct attribute_group dme1737_lock_group = { | 1771 | static const struct attribute_group dme1737_zone_chmod_group = { |
1749 | .attrs = dme1737_attr_lock, | 1772 | .attrs = dme1737_zone_chmod_attr, |
1750 | }; | 1773 | }; |
1751 | 1774 | ||
1752 | /* The permissions of the following PWM attributes are changed to read- | 1775 | /* The permissions of the following PWM attributes are changed to read- |
1753 | * writeable if the chip is *not* locked and the respective PWM is available. | 1776 | * writeable if the chip is *not* locked and the respective PWM is available. |
1754 | * Otherwise they stay read-only. */ | 1777 | * Otherwise they stay read-only. */ |
1755 | static struct attribute *dme1737_attr_pwm1_lock[] = { | 1778 | static struct attribute *dme1737_pwm1_chmod_attr[] = { |
1756 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, | 1779 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, |
1757 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | 1780 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
1758 | &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr, | 1781 | &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr, |
1759 | &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr, | 1782 | &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr, |
1760 | &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr, | ||
1761 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | 1783 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, |
1762 | NULL | 1784 | NULL |
1763 | }; | 1785 | }; |
1764 | static struct attribute *dme1737_attr_pwm2_lock[] = { | 1786 | static struct attribute *dme1737_pwm2_chmod_attr[] = { |
1765 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, | 1787 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, |
1766 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | 1788 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, |
1767 | &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr, | 1789 | &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr, |
1768 | &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr, | 1790 | &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr, |
1769 | &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr, | ||
1770 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | 1791 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, |
1771 | NULL | 1792 | NULL |
1772 | }; | 1793 | }; |
1773 | static struct attribute *dme1737_attr_pwm3_lock[] = { | 1794 | static struct attribute *dme1737_pwm3_chmod_attr[] = { |
1774 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, | 1795 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, |
1775 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | 1796 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, |
1776 | &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr, | 1797 | &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr, |
1777 | &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr, | 1798 | &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr, |
1778 | &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr, | ||
1779 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | 1799 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, |
1780 | NULL | 1800 | NULL |
1781 | }; | 1801 | }; |
1782 | static struct attribute *dme1737_attr_pwm5_lock[] = { | 1802 | static struct attribute *dme1737_pwm5_chmod_attr[] = { |
1783 | &sensor_dev_attr_pwm5.dev_attr.attr, | 1803 | &sensor_dev_attr_pwm5.dev_attr.attr, |
1784 | &sensor_dev_attr_pwm5_freq.dev_attr.attr, | 1804 | &sensor_dev_attr_pwm5_freq.dev_attr.attr, |
1785 | NULL | 1805 | NULL |
1786 | }; | 1806 | }; |
1787 | static struct attribute *dme1737_attr_pwm6_lock[] = { | 1807 | static struct attribute *dme1737_pwm6_chmod_attr[] = { |
1788 | &sensor_dev_attr_pwm6.dev_attr.attr, | 1808 | &sensor_dev_attr_pwm6.dev_attr.attr, |
1789 | &sensor_dev_attr_pwm6_freq.dev_attr.attr, | 1809 | &sensor_dev_attr_pwm6_freq.dev_attr.attr, |
1790 | NULL | 1810 | NULL |
1791 | }; | 1811 | }; |
1792 | 1812 | ||
1793 | static const struct attribute_group dme1737_pwm_lock_group[] = { | 1813 | static const struct attribute_group dme1737_pwm_chmod_group[] = { |
1794 | { .attrs = dme1737_attr_pwm1_lock }, | 1814 | { .attrs = dme1737_pwm1_chmod_attr }, |
1795 | { .attrs = dme1737_attr_pwm2_lock }, | 1815 | { .attrs = dme1737_pwm2_chmod_attr }, |
1796 | { .attrs = dme1737_attr_pwm3_lock }, | 1816 | { .attrs = dme1737_pwm3_chmod_attr }, |
1797 | { .attrs = NULL }, | 1817 | { .attrs = NULL }, |
1798 | { .attrs = dme1737_attr_pwm5_lock }, | 1818 | { .attrs = dme1737_pwm5_chmod_attr }, |
1799 | { .attrs = dme1737_attr_pwm6_lock }, | 1819 | { .attrs = dme1737_pwm6_chmod_attr }, |
1800 | }; | 1820 | }; |
1801 | 1821 | ||
1802 | /* Pwm[1-3] are read-writeable if the associated pwm is in manual mode and the | 1822 | /* Pwm[1-3] are read-writeable if the associated pwm is in manual mode and the |
1803 | * chip is not locked. Otherwise they are read-only. */ | 1823 | * chip is not locked. Otherwise they are read-only. */ |
1804 | static struct attribute *dme1737_attr_pwm[] = { | 1824 | static struct attribute *dme1737_pwm_chmod_attr[] = { |
1805 | &sensor_dev_attr_pwm1.dev_attr.attr, | 1825 | &sensor_dev_attr_pwm1.dev_attr.attr, |
1806 | &sensor_dev_attr_pwm2.dev_attr.attr, | 1826 | &sensor_dev_attr_pwm2.dev_attr.attr, |
1807 | &sensor_dev_attr_pwm3.dev_attr.attr, | 1827 | &sensor_dev_attr_pwm3.dev_attr.attr, |
@@ -1875,9 +1895,17 @@ static void dme1737_remove_files(struct device *dev) | |||
1875 | if (data->has_pwm & (1 << ix)) { | 1895 | if (data->has_pwm & (1 << ix)) { |
1876 | sysfs_remove_group(&dev->kobj, | 1896 | sysfs_remove_group(&dev->kobj, |
1877 | &dme1737_pwm_group[ix]); | 1897 | &dme1737_pwm_group[ix]); |
1898 | if (data->type != sch5027 && ix < 3) { | ||
1899 | sysfs_remove_file(&dev->kobj, | ||
1900 | dme1737_pwm_misc_attr[ix]); | ||
1901 | } | ||
1878 | } | 1902 | } |
1879 | } | 1903 | } |
1880 | 1904 | ||
1905 | if (data->type != sch5027) { | ||
1906 | sysfs_remove_group(&dev->kobj, &dme1737_misc_group); | ||
1907 | } | ||
1908 | |||
1881 | sysfs_remove_group(&dev->kobj, &dme1737_group); | 1909 | sysfs_remove_group(&dev->kobj, &dme1737_group); |
1882 | 1910 | ||
1883 | if (!data->client.driver) { | 1911 | if (!data->client.driver) { |
@@ -1901,6 +1929,13 @@ static int dme1737_create_files(struct device *dev) | |||
1901 | goto exit_remove; | 1929 | goto exit_remove; |
1902 | } | 1930 | } |
1903 | 1931 | ||
1932 | /* Create misc sysfs attributes */ | ||
1933 | if ((data->type != sch5027) && | ||
1934 | (err = sysfs_create_group(&dev->kobj, | ||
1935 | &dme1737_misc_group))) { | ||
1936 | goto exit_remove; | ||
1937 | } | ||
1938 | |||
1904 | /* Create fan sysfs attributes */ | 1939 | /* Create fan sysfs attributes */ |
1905 | for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { | 1940 | for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { |
1906 | if (data->has_fan & (1 << ix)) { | 1941 | if (data->has_fan & (1 << ix)) { |
@@ -1918,6 +1953,11 @@ static int dme1737_create_files(struct device *dev) | |||
1918 | &dme1737_pwm_group[ix]))) { | 1953 | &dme1737_pwm_group[ix]))) { |
1919 | goto exit_remove; | 1954 | goto exit_remove; |
1920 | } | 1955 | } |
1956 | if (data->type != sch5027 && ix < 3 && | ||
1957 | (err = sysfs_create_file(&dev->kobj, | ||
1958 | dme1737_pwm_misc_attr[ix]))) { | ||
1959 | goto exit_remove; | ||
1960 | } | ||
1921 | } | 1961 | } |
1922 | } | 1962 | } |
1923 | 1963 | ||
@@ -1927,16 +1967,27 @@ static int dme1737_create_files(struct device *dev) | |||
1927 | dev_info(dev, "Device is locked. Some attributes " | 1967 | dev_info(dev, "Device is locked. Some attributes " |
1928 | "will be read-only.\n"); | 1968 | "will be read-only.\n"); |
1929 | } else { | 1969 | } else { |
1930 | /* Change permissions of standard attributes */ | 1970 | /* Change permissions of zone sysfs attributes */ |
1931 | dme1737_chmod_group(dev, &dme1737_lock_group, | 1971 | dme1737_chmod_group(dev, &dme1737_zone_chmod_group, |
1932 | S_IRUGO | S_IWUSR); | 1972 | S_IRUGO | S_IWUSR); |
1933 | 1973 | ||
1934 | /* Change permissions of PWM attributes */ | 1974 | /* Change permissions of misc sysfs attributes */ |
1935 | for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_lock_group); ix++) { | 1975 | if (data->type != sch5027) { |
1976 | dme1737_chmod_group(dev, &dme1737_misc_group, | ||
1977 | S_IRUGO | S_IWUSR); | ||
1978 | } | ||
1979 | |||
1980 | /* Change permissions of PWM sysfs attributes */ | ||
1981 | for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_chmod_group); ix++) { | ||
1936 | if (data->has_pwm & (1 << ix)) { | 1982 | if (data->has_pwm & (1 << ix)) { |
1937 | dme1737_chmod_group(dev, | 1983 | dme1737_chmod_group(dev, |
1938 | &dme1737_pwm_lock_group[ix], | 1984 | &dme1737_pwm_chmod_group[ix], |
1985 | S_IRUGO | S_IWUSR); | ||
1986 | if (data->type != sch5027 && ix < 3) { | ||
1987 | dme1737_chmod_file(dev, | ||
1988 | dme1737_pwm_misc_attr[ix], | ||
1939 | S_IRUGO | S_IWUSR); | 1989 | S_IRUGO | S_IWUSR); |
1990 | } | ||
1940 | } | 1991 | } |
1941 | } | 1992 | } |
1942 | 1993 | ||
@@ -1945,7 +1996,7 @@ static int dme1737_create_files(struct device *dev) | |||
1945 | if ((data->has_pwm & (1 << ix)) && | 1996 | if ((data->has_pwm & (1 << ix)) && |
1946 | (PWM_EN_FROM_REG(data->pwm_config[ix]) == 1)) { | 1997 | (PWM_EN_FROM_REG(data->pwm_config[ix]) == 1)) { |
1947 | dme1737_chmod_file(dev, | 1998 | dme1737_chmod_file(dev, |
1948 | dme1737_attr_pwm[ix], | 1999 | dme1737_pwm_chmod_attr[ix], |
1949 | S_IRUGO | S_IWUSR); | 2000 | S_IRUGO | S_IWUSR); |
1950 | } | 2001 | } |
1951 | } | 2002 | } |
@@ -1966,6 +2017,9 @@ static int dme1737_init_device(struct device *dev) | |||
1966 | int ix; | 2017 | int ix; |
1967 | u8 reg; | 2018 | u8 reg; |
1968 | 2019 | ||
2020 | /* Point to the right nominal voltages array */ | ||
2021 | data->in_nominal = IN_NOMINAL(data->type); | ||
2022 | |||
1969 | data->config = dme1737_read(client, DME1737_REG_CONFIG); | 2023 | data->config = dme1737_read(client, DME1737_REG_CONFIG); |
1970 | /* Inform if part is not monitoring/started */ | 2024 | /* Inform if part is not monitoring/started */ |
1971 | if (!(data->config & 0x01)) { | 2025 | if (!(data->config & 0x01)) { |
@@ -2076,7 +2130,9 @@ static int dme1737_init_device(struct device *dev) | |||
2076 | data->pwm_acz[2] = 4; /* pwm3 -> zone3 */ | 2130 | data->pwm_acz[2] = 4; /* pwm3 -> zone3 */ |
2077 | 2131 | ||
2078 | /* Set VRM */ | 2132 | /* Set VRM */ |
2079 | data->vrm = vid_which_vrm(); | 2133 | if (data->type != sch5027) { |
2134 | data->vrm = vid_which_vrm(); | ||
2135 | } | ||
2080 | 2136 | ||
2081 | return 0; | 2137 | return 0; |
2082 | } | 2138 | } |
@@ -2095,9 +2151,10 @@ static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data) | |||
2095 | dme1737_sio_enter(sio_cip); | 2151 | dme1737_sio_enter(sio_cip); |
2096 | 2152 | ||
2097 | /* Check device ID | 2153 | /* Check device ID |
2098 | * The DME1737 can return either 0x78 or 0x77 as its device ID. */ | 2154 | * The DME1737 can return either 0x78 or 0x77 as its device ID. |
2155 | * The SCH5027 returns 0x89 as its device ID. */ | ||
2099 | reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20); | 2156 | reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20); |
2100 | if (!(reg == 0x77 || reg == 0x78)) { | 2157 | if (!(reg == 0x77 || reg == 0x78 || reg == 0x89)) { |
2101 | err = -ENODEV; | 2158 | err = -ENODEV; |
2102 | goto exit; | 2159 | goto exit; |
2103 | } | 2160 | } |
@@ -2166,15 +2223,24 @@ static int dme1737_i2c_detect(struct i2c_adapter *adapter, int address, | |||
2166 | company = dme1737_read(client, DME1737_REG_COMPANY); | 2223 | company = dme1737_read(client, DME1737_REG_COMPANY); |
2167 | verstep = dme1737_read(client, DME1737_REG_VERSTEP); | 2224 | verstep = dme1737_read(client, DME1737_REG_VERSTEP); |
2168 | 2225 | ||
2169 | if (!((company == DME1737_COMPANY_SMSC) && | 2226 | if (company == DME1737_COMPANY_SMSC && |
2170 | ((verstep & DME1737_VERSTEP_MASK) == DME1737_VERSTEP))) { | 2227 | (verstep & DME1737_VERSTEP_MASK) == DME1737_VERSTEP) { |
2228 | kind = dme1737; | ||
2229 | } else if (company == DME1737_COMPANY_SMSC && | ||
2230 | verstep == SCH5027_VERSTEP) { | ||
2231 | kind = sch5027; | ||
2232 | } else { | ||
2171 | err = -ENODEV; | 2233 | err = -ENODEV; |
2172 | goto exit_kfree; | 2234 | goto exit_kfree; |
2173 | } | 2235 | } |
2174 | } | 2236 | } |
2175 | 2237 | ||
2176 | kind = dme1737; | 2238 | if (kind == sch5027) { |
2177 | name = "dme1737"; | 2239 | name = "sch5027"; |
2240 | } else { | ||
2241 | kind = dme1737; | ||
2242 | name = "dme1737"; | ||
2243 | } | ||
2178 | data->type = kind; | 2244 | data->type = kind; |
2179 | 2245 | ||
2180 | /* Fill in the remaining client fields and put it into the global | 2246 | /* Fill in the remaining client fields and put it into the global |
@@ -2187,8 +2253,9 @@ static int dme1737_i2c_detect(struct i2c_adapter *adapter, int address, | |||
2187 | goto exit_kfree; | 2253 | goto exit_kfree; |
2188 | } | 2254 | } |
2189 | 2255 | ||
2190 | dev_info(dev, "Found a DME1737 chip at 0x%02x (rev 0x%02x).\n", | 2256 | dev_info(dev, "Found a %s chip at 0x%02x (rev 0x%02x).\n", |
2191 | client->addr, verstep); | 2257 | kind == sch5027 ? "SCH5027" : "DME1737", client->addr, |
2258 | verstep); | ||
2192 | 2259 | ||
2193 | /* Initialize the DME1737 chip */ | 2260 | /* Initialize the DME1737 chip */ |
2194 | if ((err = dme1737_init_device(dev))) { | 2261 | if ((err = dme1737_init_device(dev))) { |
@@ -2360,15 +2427,18 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev) | |||
2360 | client->addr = res->start; | 2427 | client->addr = res->start; |
2361 | platform_set_drvdata(pdev, data); | 2428 | platform_set_drvdata(pdev, data); |
2362 | 2429 | ||
2363 | company = dme1737_read(client, DME1737_REG_COMPANY); | 2430 | /* Skip chip detection if module is loaded with force_id parameter */ |
2364 | device = dme1737_read(client, DME1737_REG_DEVICE); | 2431 | if (!force_id) { |
2432 | company = dme1737_read(client, DME1737_REG_COMPANY); | ||
2433 | device = dme1737_read(client, DME1737_REG_DEVICE); | ||
2365 | 2434 | ||
2366 | if (!((company == DME1737_COMPANY_SMSC) && | 2435 | if (!((company == DME1737_COMPANY_SMSC) && |
2367 | (device == SCH311X_DEVICE))) { | 2436 | (device == SCH311X_DEVICE))) { |
2368 | err = -ENODEV; | 2437 | err = -ENODEV; |
2369 | goto exit_kfree; | 2438 | goto exit_kfree; |
2439 | } | ||
2370 | } | 2440 | } |
2371 | data->type = -1; | 2441 | data->type = sch311x; |
2372 | 2442 | ||
2373 | /* Fill in the remaining client fields and initialize the mutex */ | 2443 | /* Fill in the remaining client fields and initialize the mutex */ |
2374 | strlcpy(client->name, "sch311x", I2C_NAME_SIZE); | 2444 | strlcpy(client->name, "sch311x", I2C_NAME_SIZE); |