Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Juerg Haefliger and committed by
Jean Delvare
d4b94e1f 7a1b76f2

+60 -20
+7 -5
Documentation/hwmon/dme1737
··· 42 42 This driver implements support for the hardware monitoring capabilities of the 43 43 SMSC DME1737 and Asus A8000 (which are the same), SMSC SCH5027, SCH311x, 44 44 and SCH5127 Super-I/O chips. These chips feature monitoring of 3 temp sensors 45 - temp[1-3] (2 remote diodes and 1 internal), 7 voltages in[0-6] (6 external and 45 + temp[1-3] (2 remote diodes and 1 internal), 8 voltages in[0-7] (7 external and 46 46 1 internal) and up to 6 fan speeds fan[1-6]. Additionally, the chips implement 47 47 up to 5 PWM outputs pwm[1-3,5-6] for controlling fan speeds both manually and 48 48 automatically. ··· 105 105 in4: V1_IN 0V - 1.5V 106 106 in5: VTR (+3.3V standby) 0V - 4.38V 107 107 in6: Vbat (+3.0V) 0V - 4.38V 108 + in7: Vtrip (+1.5V) 0V - 1.99V 108 109 109 110 Each voltage input has associated min and max limits which trigger an alarm 110 111 when crossed. ··· 218 217 vrm RW Voltage regulator module version 219 218 number. 220 219 221 - in[0-6]_input RO Measured voltage in millivolts. 222 - in[0-6]_min RW Low limit for voltage input. 223 - in[0-6]_max RW High limit for voltage input. 224 - in[0-6]_alarm RO Voltage input alarm. Returns 1 if 220 + in[0-7]_input RO Measured voltage in millivolts. 221 + in[0-7]_min RW Low limit for voltage input. 222 + in[0-7]_max RW High limit for voltage input. 223 + in[0-7]_alarm RO Voltage input alarm. Returns 1 if 225 224 voltage input is or went outside the 226 225 associated min-max range, 0 otherwise. 227 226 ··· 325 324 pwm5 opt opt 326 325 fan6 opt opt 327 326 pwm6 opt opt 327 + in7 yes
+53 -15
drivers/hwmon/dme1737.c
··· 77 77 * in4 +12V 78 78 * in5 VTR (+3.3V stby) 79 79 * in6 Vbat 80 + * in7 Vtrip (sch5127 only) 80 81 * 81 82 * --------------------------------------------------------------------- */ 82 83 83 - /* Voltages (in) numbered 0-6 (ix) */ 84 - #define DME1737_REG_IN(ix) ((ix) < 5 ? 0x20 + (ix) \ 85 - : 0x94 + (ix)) 84 + /* Voltages (in) numbered 0-7 (ix) */ 85 + #define DME1737_REG_IN(ix) ((ix) < 5 ? 0x20 + (ix) : \ 86 + (ix) < 7 ? 0x94 + (ix) : \ 87 + 0x1f) 86 88 #define DME1737_REG_IN_MIN(ix) ((ix) < 5 ? 0x44 + (ix) * 2 \ 87 89 : 0x91 + (ix) * 2) 88 90 #define DME1737_REG_IN_MAX(ix) ((ix) < 5 ? 0x45 + (ix) * 2 \ ··· 103 101 * IN_TEMP_LSB(1) = [temp3, temp1] 104 102 * IN_TEMP_LSB(2) = [in4, temp2] 105 103 * IN_TEMP_LSB(3) = [in3, in0] 106 - * IN_TEMP_LSB(4) = [in2, in1] */ 104 + * IN_TEMP_LSB(4) = [in2, in1] 105 + * IN_TEMP_LSB(5) = [res, in7] */ 107 106 #define DME1737_REG_IN_TEMP_LSB(ix) (0x84 + (ix)) 108 - static const u8 DME1737_REG_IN_LSB[] = {3, 4, 4, 3, 2, 0, 0}; 109 - static const u8 DME1737_REG_IN_LSB_SHL[] = {4, 4, 0, 0, 0, 0, 4}; 107 + static const u8 DME1737_REG_IN_LSB[] = {3, 4, 4, 3, 2, 0, 0, 5}; 108 + static const u8 DME1737_REG_IN_LSB_SHL[] = {4, 4, 0, 0, 0, 0, 4, 4}; 110 109 static const u8 DME1737_REG_TEMP_LSB[] = {1, 2, 1}; 111 110 static const u8 DME1737_REG_TEMP_LSB_SHL[] = {4, 4, 0}; 112 111 ··· 148 145 #define DME1737_REG_ALARM1 0x41 149 146 #define DME1737_REG_ALARM2 0x42 150 147 #define DME1737_REG_ALARM3 0x83 151 - static const u8 DME1737_BIT_ALARM_IN[] = {0, 1, 2, 3, 8, 16, 17}; 148 + static const u8 DME1737_BIT_ALARM_IN[] = {0, 1, 2, 3, 8, 16, 17, 18}; 152 149 static const u8 DME1737_BIT_ALARM_TEMP[] = {4, 5, 6}; 153 150 static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; 154 151 ··· 193 190 #define HAS_PWM_MIN (1 << 4) /* bit 4 */ 194 191 #define HAS_FAN(ix) (1 << ((ix) + 5)) /* bits 5-10 */ 195 192 #define HAS_PWM(ix) (1 << ((ix) + 11)) /* bits 11-16 */ 193 + #define HAS_IN7 (1 << 17) /* bit 17 */ 196 194 197 195 /* --------------------------------------------------------------------- 198 196 * Data structures and manipulation thereof ··· 217 213 u32 has_features; 218 214 219 215 /* Register values */ 220 - u16 in[7]; 221 - u8 in_min[7]; 222 - u8 in_max[7]; 216 + u16 in[8]; 217 + u8 in_min[8]; 218 + u8 in_max[8]; 223 219 s16 temp[3]; 224 220 s8 temp_min[3]; 225 221 s8 temp_max[3]; ··· 251 247 static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300, 252 248 3300}; 253 249 static const int IN_NOMINAL_SCH5127[] = {2500, 2250, 3300, 1125, 1125, 3300, 254 - 3300}; 250 + 3300, 1500}; 255 251 #define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \ 256 252 (type) == sch5027 ? IN_NOMINAL_SCH5027 : \ 257 253 (type) == sch5127 ? IN_NOMINAL_SCH5127 : \ ··· 584 580 { 585 581 struct dme1737_data *data = dev_get_drvdata(dev); 586 582 int ix; 587 - u8 lsb[5]; 583 + u8 lsb[6]; 588 584 589 585 mutex_lock(&data->update_lock); 590 586 ··· 607 603 /* Voltage inputs are stored as 16 bit values even 608 604 * though they have only 12 bits resolution. This is 609 605 * to make it consistent with the temp inputs. */ 606 + if (ix == 7 && !(data->has_features & HAS_IN7)) { 607 + continue; 608 + } 610 609 data->in[ix] = dme1737_read(data, 611 610 DME1737_REG_IN(ix)) << 8; 612 611 data->in_min[ix] = dme1737_read(data, ··· 642 635 * which the registers are read (MSB first, then LSB) is 643 636 * important! */ 644 637 for (ix = 0; ix < ARRAY_SIZE(lsb); ix++) { 638 + if (ix == 5 && !(data->has_features & HAS_IN7)) { 639 + continue; 640 + } 645 641 lsb[ix] = dme1737_read(data, 646 642 DME1737_REG_IN_TEMP_LSB(ix)); 647 643 } 648 644 for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { 645 + if (ix == 7 && !(data->has_features & HAS_IN7)) { 646 + continue; 647 + } 649 648 data->in[ix] |= (lsb[DME1737_REG_IN_LSB[ix]] << 650 649 DME1737_REG_IN_LSB_SHL[ix]) & 0xf0; 651 650 } ··· 775 762 776 763 /* --------------------------------------------------------------------- 777 764 * Voltage sysfs attributes 778 - * ix = [0-5] 765 + * ix = [0-7] 779 766 * --------------------------------------------------------------------- */ 780 767 781 768 #define SYS_IN_INPUT 0 ··· 1452 1439 * Sysfs device attribute defines and structs 1453 1440 * --------------------------------------------------------------------- */ 1454 1441 1455 - /* Voltages 0-6 */ 1442 + /* Voltages 0-7 */ 1456 1443 1457 1444 #define SENSOR_DEVICE_ATTR_IN(ix) \ 1458 1445 static SENSOR_DEVICE_ATTR_2(in##ix##_input, S_IRUGO, \ ··· 1471 1458 SENSOR_DEVICE_ATTR_IN(4); 1472 1459 SENSOR_DEVICE_ATTR_IN(5); 1473 1460 SENSOR_DEVICE_ATTR_IN(6); 1461 + SENSOR_DEVICE_ATTR_IN(7); 1474 1462 1475 1463 /* Temperatures 1-3 */ 1476 1464 ··· 1707 1693 1708 1694 static const struct attribute_group dme1737_zone_hyst_group = { 1709 1695 .attrs = dme1737_zone_hyst_attr, 1696 + }; 1697 + 1698 + /* The following struct holds voltage in7 related attributes, which 1699 + * are not available in all chips. The following chips support them: 1700 + * SCH5127 */ 1701 + static struct attribute *dme1737_in7_attr[] = { 1702 + &sensor_dev_attr_in7_input.dev_attr.attr, 1703 + &sensor_dev_attr_in7_min.dev_attr.attr, 1704 + &sensor_dev_attr_in7_max.dev_attr.attr, 1705 + &sensor_dev_attr_in7_alarm.dev_attr.attr, 1706 + NULL 1707 + }; 1708 + 1709 + static const struct attribute_group dme1737_in7_group = { 1710 + .attrs = dme1737_in7_attr, 1710 1711 }; 1711 1712 1712 1713 /* The following structs hold the PWM attributes, some of which are optional. ··· 2015 1986 if (data->has_features & HAS_ZONE_HYST) { 2016 1987 sysfs_remove_group(&dev->kobj, &dme1737_zone_hyst_group); 2017 1988 } 1989 + if (data->has_features & HAS_IN7) { 1990 + sysfs_remove_group(&dev->kobj, &dme1737_in7_group); 1991 + } 2018 1992 sysfs_remove_group(&dev->kobj, &dme1737_group); 2019 1993 2020 1994 if (!data->client) { ··· 2061 2029 (err = sysfs_create_group(&dev->kobj, 2062 2030 &dme1737_zone_hyst_group))) { 2063 2031 goto exit_remove; 2032 + } 2033 + if (data->has_features & HAS_IN7) { 2034 + err = sysfs_create_group(&dev->kobj, &dme1737_in7_group); 2035 + if (err) { 2036 + goto exit_remove; 2037 + } 2064 2038 } 2065 2039 2066 2040 /* Create fan sysfs attributes */ ··· 2226 2188 data->has_features |= HAS_ZONE3; 2227 2189 break; 2228 2190 case sch5127: 2229 - data->has_features |= HAS_FAN(2) | HAS_PWM(2); 2191 + data->has_features |= HAS_FAN(2) | HAS_PWM(2) | HAS_IN7; 2230 2192 break; 2231 2193 default: 2232 2194 break;