aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/dme1737.c
diff options
context:
space:
mode:
authorJuerg Haefliger <juergh@gmail.com>2008-08-06 16:41:03 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-08-06 16:41:03 -0400
commit549edb83327f2a5027a22d65b10603b01dc40175 (patch)
treef30b17f061ad28f132c9e11eb4a4d079d1cf6a5e /drivers/hwmon/dme1737.c
parent55d68d75ab00e60953f8784af5927b60967a297f (diff)
hwmon: (dme1737) Add support for the SMSC SCH5027
Add support for the SCH5027. The differences to the DME1737 are: - No support for programmable temp offsets - In auto mode, PWM outputs stay on min value if temp goes below low threshold and can't be programmed to fully turn off - Different voltage scaling - No VID input Signed-off-by: Juerg Haefliger <juergh@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/dme1737.c')
-rw-r--r--drivers/hwmon/dme1737.c193
1 files changed, 130 insertions, 63 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index b36290048b98..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 "
57static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; 57static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END};
58 58
59/* Insmod parameters */ 59/* Insmod parameters */
60I2C_CLIENT_INSMOD_1(dme1737); 60I2C_CLIENT_INSMOD_2(dme1737, sch5027);
61
62/* ISA chip types */
63enum 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};
221static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300, 226static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300,
222 3300}; 227 3300};
223#define IN_NOMINAL(ix, type) (((type) == dme1737) ? \ 228static 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. */
230static inline int IN_FROM_REG(int reg, int ix, int res, int type) 237static 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
236static inline int IN_TO_REG(int val, int ix, int type) 242static 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;
@@ -1570,43 +1582,56 @@ 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
1611static 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. */
1618static 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
1608static const struct attribute_group dme1737_group = { 1633static 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.
@@ -1618,7 +1643,6 @@ static struct attribute *dme1737_pwm1_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
@@ -1629,7 +1653,6 @@ static struct attribute *dme1737_pwm2_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
@@ -1640,7 +1663,6 @@ static struct attribute *dme1737_pwm3_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
@@ -1667,6 +1689,15 @@ static const struct attribute_group dme1737_pwm_group[] = {
1667 { .attrs = dme1737_pwm6_attr }, 1689 { .attrs = dme1737_pwm6_attr },
1668}; 1690};
1669 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. */
1695static 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,
1699};
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. */
@@ -1722,31 +1753,23 @@ static const struct attribute_group dme1737_fan_group[] = {
1722 { .attrs = dme1737_fan6_attr }, 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. */
1727static struct attribute *dme1737_misc_chmod_attr[] = { 1758static 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
1748static const struct attribute_group dme1737_misc_chmod_group = { 1771static const struct attribute_group dme1737_zone_chmod_group = {
1749 .attrs = dme1737_misc_chmod_attr, 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-
@@ -1757,7 +1780,6 @@ static struct attribute *dme1737_pwm1_chmod_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};
@@ -1766,7 +1788,6 @@ static struct attribute *dme1737_pwm2_chmod_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};
@@ -1775,7 +1796,6 @@ static struct attribute *dme1737_pwm3_chmod_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};
@@ -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 sysfs attributes */ 1970 /* Change permissions of zone sysfs attributes */
1931 dme1737_chmod_group(dev, &dme1737_misc_chmod_group, 1971 dme1737_chmod_group(dev, &dme1737_zone_chmod_group,
1932 S_IRUGO | S_IWUSR); 1972 S_IRUGO | S_IWUSR);
1933 1973
1974 /* Change permissions of misc sysfs attributes */
1975 if (data->type != sch5027) {
1976 dme1737_chmod_group(dev, &dme1737_misc_group,
1977 S_IRUGO | S_IWUSR);
1978 }
1979
1934 /* Change permissions of PWM sysfs attributes */ 1980 /* Change permissions of PWM sysfs attributes */
1935 for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_chmod_group); ix++) { 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_chmod_group[ix], 1984 &dme1737_pwm_chmod_group[ix],
1939 S_IRUGO | S_IWUSR); 1985 S_IRUGO | S_IWUSR);
1986 if (data->type != sch5027 && ix < 3) {
1987 dme1737_chmod_file(dev,
1988 dme1737_pwm_misc_attr[ix],
1989 S_IRUGO | S_IWUSR);
1990 }
1940 } 1991 }
1941 } 1992 }
1942 1993
@@ -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))) {
@@ -2371,7 +2438,7 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2371 goto exit_kfree; 2438 goto exit_kfree;
2372 } 2439 }
2373 } 2440 }
2374 data->type = -1; 2441 data->type = sch311x;
2375 2442
2376 /* Fill in the remaining client fields and initialize the mutex */ 2443 /* Fill in the remaining client fields and initialize the mutex */
2377 strlcpy(client->name, "sch311x", I2C_NAME_SIZE); 2444 strlcpy(client->name, "sch311x", I2C_NAME_SIZE);