aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJuerg Haefliger <juergh@gmail.com>2011-01-12 15:55:13 -0500
committerJean Delvare <khali@endymion.delvare>2011-01-12 15:55:13 -0500
commitd4b94e1fa6c69fd74abca5b7db1ab350d65ce89b (patch)
tree89a7d4a1a5439896f64862cfd89d91c0a2a74d57 /drivers/hwmon
parent7a1b76f2a46016809c7bcacf81e89948cc306703 (diff)
hwmon: (dme1737) Add support for in7 for SCH5127
Add support for the 1.5V voltage monitoring input (in7) of the SMSC SCH5127 chip. Signed-off-by: Juerg Haefliger <juergh@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/dme1737.c68
1 files changed, 53 insertions, 15 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index e9a610bfd0cc..ec683eabd7ac 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -77,12 +77,14 @@ enum chips { dme1737, sch5027, sch311x, sch5127 };
77 * in4 +12V 77 * in4 +12V
78 * in5 VTR (+3.3V stby) 78 * in5 VTR (+3.3V stby)
79 * in6 Vbat 79 * in6 Vbat
80 * in7 Vtrip (sch5127 only)
80 * 81 *
81 * --------------------------------------------------------------------- */ 82 * --------------------------------------------------------------------- */
82 83
83/* Voltages (in) numbered 0-6 (ix) */ 84/* Voltages (in) numbered 0-7 (ix) */
84#define DME1737_REG_IN(ix) ((ix) < 5 ? 0x20 + (ix) \ 85#define DME1737_REG_IN(ix) ((ix) < 5 ? 0x20 + (ix) : \
85 : 0x94 + (ix)) 86 (ix) < 7 ? 0x94 + (ix) : \
87 0x1f)
86#define DME1737_REG_IN_MIN(ix) ((ix) < 5 ? 0x44 + (ix) * 2 \ 88#define DME1737_REG_IN_MIN(ix) ((ix) < 5 ? 0x44 + (ix) * 2 \
87 : 0x91 + (ix) * 2) 89 : 0x91 + (ix) * 2)
88#define DME1737_REG_IN_MAX(ix) ((ix) < 5 ? 0x45 + (ix) * 2 \ 90#define DME1737_REG_IN_MAX(ix) ((ix) < 5 ? 0x45 + (ix) * 2 \
@@ -101,10 +103,11 @@ enum chips { dme1737, sch5027, sch311x, sch5127 };
101 * IN_TEMP_LSB(1) = [temp3, temp1] 103 * IN_TEMP_LSB(1) = [temp3, temp1]
102 * IN_TEMP_LSB(2) = [in4, temp2] 104 * IN_TEMP_LSB(2) = [in4, temp2]
103 * IN_TEMP_LSB(3) = [in3, in0] 105 * IN_TEMP_LSB(3) = [in3, in0]
104 * IN_TEMP_LSB(4) = [in2, in1] */ 106 * IN_TEMP_LSB(4) = [in2, in1]
107 * IN_TEMP_LSB(5) = [res, in7] */
105#define DME1737_REG_IN_TEMP_LSB(ix) (0x84 + (ix)) 108#define DME1737_REG_IN_TEMP_LSB(ix) (0x84 + (ix))
106static const u8 DME1737_REG_IN_LSB[] = {3, 4, 4, 3, 2, 0, 0}; 109static const u8 DME1737_REG_IN_LSB[] = {3, 4, 4, 3, 2, 0, 0, 5};
107static const u8 DME1737_REG_IN_LSB_SHL[] = {4, 4, 0, 0, 0, 0, 4}; 110static const u8 DME1737_REG_IN_LSB_SHL[] = {4, 4, 0, 0, 0, 0, 4, 4};
108static const u8 DME1737_REG_TEMP_LSB[] = {1, 2, 1}; 111static const u8 DME1737_REG_TEMP_LSB[] = {1, 2, 1};
109static const u8 DME1737_REG_TEMP_LSB_SHL[] = {4, 4, 0}; 112static const u8 DME1737_REG_TEMP_LSB_SHL[] = {4, 4, 0};
110 113
@@ -145,7 +148,7 @@ static const u8 DME1737_REG_TEMP_LSB_SHL[] = {4, 4, 0};
145#define DME1737_REG_ALARM1 0x41 148#define DME1737_REG_ALARM1 0x41
146#define DME1737_REG_ALARM2 0x42 149#define DME1737_REG_ALARM2 0x42
147#define DME1737_REG_ALARM3 0x83 150#define DME1737_REG_ALARM3 0x83
148static const u8 DME1737_BIT_ALARM_IN[] = {0, 1, 2, 3, 8, 16, 17}; 151static const u8 DME1737_BIT_ALARM_IN[] = {0, 1, 2, 3, 8, 16, 17, 18};
149static const u8 DME1737_BIT_ALARM_TEMP[] = {4, 5, 6}; 152static const u8 DME1737_BIT_ALARM_TEMP[] = {4, 5, 6};
150static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; 153static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23};
151 154
@@ -190,6 +193,7 @@ static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23};
190#define HAS_PWM_MIN (1 << 4) /* bit 4 */ 193#define HAS_PWM_MIN (1 << 4) /* bit 4 */
191#define HAS_FAN(ix) (1 << ((ix) + 5)) /* bits 5-10 */ 194#define HAS_FAN(ix) (1 << ((ix) + 5)) /* bits 5-10 */
192#define HAS_PWM(ix) (1 << ((ix) + 11)) /* bits 11-16 */ 195#define HAS_PWM(ix) (1 << ((ix) + 11)) /* bits 11-16 */
196#define HAS_IN7 (1 << 17) /* bit 17 */
193 197
194/* --------------------------------------------------------------------- 198/* ---------------------------------------------------------------------
195 * Data structures and manipulation thereof 199 * Data structures and manipulation thereof
@@ -213,9 +217,9 @@ struct dme1737_data {
213 u32 has_features; 217 u32 has_features;
214 218
215 /* Register values */ 219 /* Register values */
216 u16 in[7]; 220 u16 in[8];
217 u8 in_min[7]; 221 u8 in_min[8];
218 u8 in_max[7]; 222 u8 in_max[8];
219 s16 temp[3]; 223 s16 temp[3];
220 s8 temp_min[3]; 224 s8 temp_min[3];
221 s8 temp_max[3]; 225 s8 temp_max[3];
@@ -247,7 +251,7 @@ static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300,
247static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300, 251static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300,
248 3300}; 252 3300};
249static const int IN_NOMINAL_SCH5127[] = {2500, 2250, 3300, 1125, 1125, 3300, 253static const int IN_NOMINAL_SCH5127[] = {2500, 2250, 3300, 1125, 1125, 3300,
250 3300}; 254 3300, 1500};
251#define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \ 255#define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \
252 (type) == sch5027 ? IN_NOMINAL_SCH5027 : \ 256 (type) == sch5027 ? IN_NOMINAL_SCH5027 : \
253 (type) == sch5127 ? IN_NOMINAL_SCH5127 : \ 257 (type) == sch5127 ? IN_NOMINAL_SCH5127 : \
@@ -580,7 +584,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev)
580{ 584{
581 struct dme1737_data *data = dev_get_drvdata(dev); 585 struct dme1737_data *data = dev_get_drvdata(dev);
582 int ix; 586 int ix;
583 u8 lsb[5]; 587 u8 lsb[6];
584 588
585 mutex_lock(&data->update_lock); 589 mutex_lock(&data->update_lock);
586 590
@@ -603,6 +607,9 @@ static struct dme1737_data *dme1737_update_device(struct device *dev)
603 /* Voltage inputs are stored as 16 bit values even 607 /* Voltage inputs are stored as 16 bit values even
604 * though they have only 12 bits resolution. This is 608 * though they have only 12 bits resolution. This is
605 * to make it consistent with the temp inputs. */ 609 * to make it consistent with the temp inputs. */
610 if (ix == 7 && !(data->has_features & HAS_IN7)) {
611 continue;
612 }
606 data->in[ix] = dme1737_read(data, 613 data->in[ix] = dme1737_read(data,
607 DME1737_REG_IN(ix)) << 8; 614 DME1737_REG_IN(ix)) << 8;
608 data->in_min[ix] = dme1737_read(data, 615 data->in_min[ix] = dme1737_read(data,
@@ -635,10 +642,16 @@ static struct dme1737_data *dme1737_update_device(struct device *dev)
635 * which the registers are read (MSB first, then LSB) is 642 * which the registers are read (MSB first, then LSB) is
636 * important! */ 643 * important! */
637 for (ix = 0; ix < ARRAY_SIZE(lsb); ix++) { 644 for (ix = 0; ix < ARRAY_SIZE(lsb); ix++) {
645 if (ix == 5 && !(data->has_features & HAS_IN7)) {
646 continue;
647 }
638 lsb[ix] = dme1737_read(data, 648 lsb[ix] = dme1737_read(data,
639 DME1737_REG_IN_TEMP_LSB(ix)); 649 DME1737_REG_IN_TEMP_LSB(ix));
640 } 650 }
641 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { 651 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) {
652 if (ix == 7 && !(data->has_features & HAS_IN7)) {
653 continue;
654 }
642 data->in[ix] |= (lsb[DME1737_REG_IN_LSB[ix]] << 655 data->in[ix] |= (lsb[DME1737_REG_IN_LSB[ix]] <<
643 DME1737_REG_IN_LSB_SHL[ix]) & 0xf0; 656 DME1737_REG_IN_LSB_SHL[ix]) & 0xf0;
644 } 657 }
@@ -762,7 +775,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev)
762 775
763/* --------------------------------------------------------------------- 776/* ---------------------------------------------------------------------
764 * Voltage sysfs attributes 777 * Voltage sysfs attributes
765 * ix = [0-5] 778 * ix = [0-7]
766 * --------------------------------------------------------------------- */ 779 * --------------------------------------------------------------------- */
767 780
768#define SYS_IN_INPUT 0 781#define SYS_IN_INPUT 0
@@ -1439,7 +1452,7 @@ static ssize_t show_name(struct device *dev, struct device_attribute *attr,
1439 * Sysfs device attribute defines and structs 1452 * Sysfs device attribute defines and structs
1440 * --------------------------------------------------------------------- */ 1453 * --------------------------------------------------------------------- */
1441 1454
1442/* Voltages 0-6 */ 1455/* Voltages 0-7 */
1443 1456
1444#define SENSOR_DEVICE_ATTR_IN(ix) \ 1457#define SENSOR_DEVICE_ATTR_IN(ix) \
1445static SENSOR_DEVICE_ATTR_2(in##ix##_input, S_IRUGO, \ 1458static SENSOR_DEVICE_ATTR_2(in##ix##_input, S_IRUGO, \
@@ -1458,6 +1471,7 @@ SENSOR_DEVICE_ATTR_IN(3);
1458SENSOR_DEVICE_ATTR_IN(4); 1471SENSOR_DEVICE_ATTR_IN(4);
1459SENSOR_DEVICE_ATTR_IN(5); 1472SENSOR_DEVICE_ATTR_IN(5);
1460SENSOR_DEVICE_ATTR_IN(6); 1473SENSOR_DEVICE_ATTR_IN(6);
1474SENSOR_DEVICE_ATTR_IN(7);
1461 1475
1462/* Temperatures 1-3 */ 1476/* Temperatures 1-3 */
1463 1477
@@ -1695,6 +1709,21 @@ static const struct attribute_group dme1737_zone_hyst_group = {
1695 .attrs = dme1737_zone_hyst_attr, 1709 .attrs = dme1737_zone_hyst_attr,
1696}; 1710};
1697 1711
1712/* The following struct holds voltage in7 related attributes, which
1713 * are not available in all chips. The following chips support them:
1714 * SCH5127 */
1715static struct attribute *dme1737_in7_attr[] = {
1716 &sensor_dev_attr_in7_input.dev_attr.attr,
1717 &sensor_dev_attr_in7_min.dev_attr.attr,
1718 &sensor_dev_attr_in7_max.dev_attr.attr,
1719 &sensor_dev_attr_in7_alarm.dev_attr.attr,
1720 NULL
1721};
1722
1723static const struct attribute_group dme1737_in7_group = {
1724 .attrs = dme1737_in7_attr,
1725};
1726
1698/* The following structs hold the PWM attributes, some of which are optional. 1727/* The following structs hold the PWM attributes, some of which are optional.
1699 * Their creation depends on the chip configuration which is determined during 1728 * Their creation depends on the chip configuration which is determined during
1700 * module load. */ 1729 * module load. */
@@ -1986,6 +2015,9 @@ static void dme1737_remove_files(struct device *dev)
1986 if (data->has_features & HAS_ZONE_HYST) { 2015 if (data->has_features & HAS_ZONE_HYST) {
1987 sysfs_remove_group(&dev->kobj, &dme1737_zone_hyst_group); 2016 sysfs_remove_group(&dev->kobj, &dme1737_zone_hyst_group);
1988 } 2017 }
2018 if (data->has_features & HAS_IN7) {
2019 sysfs_remove_group(&dev->kobj, &dme1737_in7_group);
2020 }
1989 sysfs_remove_group(&dev->kobj, &dme1737_group); 2021 sysfs_remove_group(&dev->kobj, &dme1737_group);
1990 2022
1991 if (!data->client) { 2023 if (!data->client) {
@@ -2030,6 +2062,12 @@ static int dme1737_create_files(struct device *dev)
2030 &dme1737_zone_hyst_group))) { 2062 &dme1737_zone_hyst_group))) {
2031 goto exit_remove; 2063 goto exit_remove;
2032 } 2064 }
2065 if (data->has_features & HAS_IN7) {
2066 err = sysfs_create_group(&dev->kobj, &dme1737_in7_group);
2067 if (err) {
2068 goto exit_remove;
2069 }
2070 }
2033 2071
2034 /* Create fan sysfs attributes */ 2072 /* Create fan sysfs attributes */
2035 for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { 2073 for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) {
@@ -2188,7 +2226,7 @@ static int dme1737_init_device(struct device *dev)
2188 data->has_features |= HAS_ZONE3; 2226 data->has_features |= HAS_ZONE3;
2189 break; 2227 break;
2190 case sch5127: 2228 case sch5127:
2191 data->has_features |= HAS_FAN(2) | HAS_PWM(2); 2229 data->has_features |= HAS_FAN(2) | HAS_PWM(2) | HAS_IN7;
2192 break; 2230 break;
2193 default: 2231 default:
2194 break; 2232 break;