]> Pileus Git - ~andy/linux/blobdiff - drivers/hwmon/it87.c
Merge tag 'spi-for-linus' of git://git.secretlab.ca/git/linux
[~andy/linux] / drivers / hwmon / it87.c
index e0d1910c04d969c7dcd5e1a8faccf399e5d146c8..37fc980fde240d7a7dd023cf27fc12aa8577a3f8 100644 (file)
@@ -19,6 +19,8 @@
  *            IT8726F  Super I/O chip w/LPC interface
  *            IT8728F  Super I/O chip w/LPC interface
  *            IT8758E  Super I/O chip w/LPC interface
+ *            IT8771E  Super I/O chip w/LPC interface
+ *            IT8772E  Super I/O chip w/LPC interface
  *            IT8782F  Super I/O chip w/LPC interface
  *            IT8783E/F Super I/O chip w/LPC interface
  *            Sis950   A clone of the IT8705F
@@ -61,8 +63,8 @@
 
 #define DRVNAME "it87"
 
-enum chips { it87, it8712, it8716, it8718, it8720, it8721, it8728, it8782,
-            it8783 };
+enum chips { it87, it8712, it8716, it8718, it8720, it8721, it8728, it8771,
+            it8772, it8782, it8783 };
 
 static unsigned short force_id;
 module_param(force_id, ushort, 0);
@@ -140,6 +142,8 @@ static inline void superio_exit(void)
 #define IT8721F_DEVID 0x8721
 #define IT8726F_DEVID 0x8726
 #define IT8728F_DEVID 0x8728
+#define IT8771E_DEVID 0x8771
+#define IT8772E_DEVID 0x8772
 #define IT8782F_DEVID 0x8782
 #define IT8783E_DEVID 0x8783
 #define IT87_ACT_REG  0x30
@@ -228,6 +232,101 @@ static const u8 IT87_REG_TEMP_OFFSET[]    = { 0x56, 0x57, 0x59 };
 #define IT87_REG_AUTO_TEMP(nr, i) (0x60 + (nr) * 8 + (i))
 #define IT87_REG_AUTO_PWM(nr, i)  (0x65 + (nr) * 8 + (i))
 
+struct it87_devices {
+       const char *name;
+       u16 features;
+       u8 peci_mask;
+       u8 old_peci_mask;
+};
+
+#define FEAT_12MV_ADC          (1 << 0)
+#define FEAT_NEWER_AUTOPWM     (1 << 1)
+#define FEAT_OLD_AUTOPWM       (1 << 2)
+#define FEAT_16BIT_FANS                (1 << 3)
+#define FEAT_TEMP_OFFSET       (1 << 4)
+#define FEAT_TEMP_PECI         (1 << 5)
+#define FEAT_TEMP_OLD_PECI     (1 << 6)
+
+static const struct it87_devices it87_devices[] = {
+       [it87] = {
+               .name = "it87",
+               .features = FEAT_OLD_AUTOPWM,   /* may need to overwrite */
+       },
+       [it8712] = {
+               .name = "it8712",
+               .features = FEAT_OLD_AUTOPWM,   /* may need to overwrite */
+       },
+       [it8716] = {
+               .name = "it8716",
+               .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET,
+       },
+       [it8718] = {
+               .name = "it8718",
+               .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
+                 | FEAT_TEMP_OLD_PECI,
+               .old_peci_mask = 0x4,
+       },
+       [it8720] = {
+               .name = "it8720",
+               .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
+                 | FEAT_TEMP_OLD_PECI,
+               .old_peci_mask = 0x4,
+       },
+       [it8721] = {
+               .name = "it8721",
+               .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
+                 | FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI,
+               .peci_mask = 0x05,
+               .old_peci_mask = 0x02,  /* Actually reports PCH */
+       },
+       [it8728] = {
+               .name = "it8728",
+               .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
+                 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI,
+               .peci_mask = 0x07,
+       },
+       [it8771] = {
+               .name = "it8771",
+               .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
+                 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI,
+                                       /* PECI: guesswork */
+                                       /* 12mV ADC (OHM) */
+                                       /* 16 bit fans (OHM) */
+               .peci_mask = 0x07,
+       },
+       [it8772] = {
+               .name = "it8772",
+               .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
+                 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI,
+                                       /* PECI (coreboot) */
+                                       /* 12mV ADC (HWSensors4, OHM) */
+                                       /* 16 bit fans (HWSensors4, OHM) */
+               .peci_mask = 0x07,
+       },
+       [it8782] = {
+               .name = "it8782",
+               .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
+                 | FEAT_TEMP_OLD_PECI,
+               .old_peci_mask = 0x4,
+       },
+       [it8783] = {
+               .name = "it8783",
+               .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
+                 | FEAT_TEMP_OLD_PECI,
+               .old_peci_mask = 0x4,
+       },
+};
+
+#define has_16bit_fans(data)   ((data)->features & FEAT_16BIT_FANS)
+#define has_12mv_adc(data)     ((data)->features & FEAT_12MV_ADC)
+#define has_newer_autopwm(data)        ((data)->features & FEAT_NEWER_AUTOPWM)
+#define has_old_autopwm(data)  ((data)->features & FEAT_OLD_AUTOPWM)
+#define has_temp_offset(data)  ((data)->features & FEAT_TEMP_OFFSET)
+#define has_temp_peci(data, nr)        (((data)->features & FEAT_TEMP_PECI) && \
+                                ((data)->peci_mask & (1 << nr)))
+#define has_temp_old_peci(data, nr) \
+                               (((data)->features & FEAT_TEMP_OLD_PECI) && \
+                                ((data)->old_peci_mask & (1 << nr)))
 
 struct it87_sio_data {
        enum chips type;
@@ -251,7 +350,9 @@ struct it87_sio_data {
 struct it87_data {
        struct device *hwmon_dev;
        enum chips type;
-       u8 revision;
+       u16 features;
+       u8 peci_mask;
+       u8 old_peci_mask;
 
        unsigned short addr;
        const char *name;
@@ -265,7 +366,8 @@ struct it87_data {
        u16 fan[5][2];          /* Register values, [nr][0]=fan, [1]=min */
        u8 has_temp;            /* Bitfield, temp sensors enabled */
        s8 temp[3][4];          /* [nr][0]=temp, [1]=min, [2]=max, [3]=offset */
-       u8 sensor;              /* Register value */
+       u8 sensor;              /* Register value (IT87_REG_TEMP_ENABLE) */
+       u8 extra;               /* Register value (IT87_REG_TEMP_EXTRA) */
        u8 fan_div[3];          /* Register encoding, shifted right */
        u8 vid;                 /* Register encoding, combined */
        u8 vrm;
@@ -293,37 +395,6 @@ struct it87_data {
        s8 auto_temp[3][5];     /* [nr][0] is point1_temp_hyst */
 };
 
-static inline int has_12mv_adc(const struct it87_data *data)
-{
-       /*
-        * IT8721F and later have a 12 mV ADC, also with internal scaling
-        * on selected inputs.
-        */
-       return data->type == it8721
-           || data->type == it8728;
-}
-
-static inline int has_newer_autopwm(const struct it87_data *data)
-{
-       /*
-        * IT8721F and later have separate registers for the temperature
-        * mapping and the manual duty cycle.
-        */
-       return data->type == it8721
-           || data->type == it8728;
-}
-
-static inline int has_temp_offset(const struct it87_data *data)
-{
-       return data->type == it8716
-           || data->type == it8718
-           || data->type == it8720
-           || data->type == it8721
-           || data->type == it8728
-           || data->type == it8782
-           || data->type == it8783;
-}
-
 static int adc_lsb(const struct it87_data *data, int nr)
 {
        int lsb = has_12mv_adc(data) ? 12 : 16;
@@ -335,7 +406,7 @@ static int adc_lsb(const struct it87_data *data, int nr)
 static u8 in_to_reg(const struct it87_data *data, int nr, long val)
 {
        val = DIV_ROUND_CLOSEST(val, adc_lsb(data, nr));
-       return SENSORS_LIMIT(val, 0, 255);
+       return clamp_val(val, 0, 255);
 }
 
 static int in_from_reg(const struct it87_data *data, int nr, int val)
@@ -347,16 +418,15 @@ static inline u8 FAN_TO_REG(long rpm, int div)
 {
        if (rpm == 0)
                return 255;
-       rpm = SENSORS_LIMIT(rpm, 1, 1000000);
-       return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1,
-                            254);
+       rpm = clamp_val(rpm, 1, 1000000);
+       return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
 }
 
 static inline u16 FAN16_TO_REG(long rpm)
 {
        if (rpm == 0)
                return 0xffff;
-       return SENSORS_LIMIT((1350000 + rpm) / (rpm * 2), 1, 0xfffe);
+       return clamp_val((1350000 + rpm) / (rpm * 2), 1, 0xfffe);
 }
 
 #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : (val) == 255 ? 0 : \
@@ -365,8 +435,8 @@ static inline u16 FAN16_TO_REG(long rpm)
 #define FAN16_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \
                             1350000 / ((val) * 2))
 
-#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val) < 0 ? (((val) - 500) / 1000) : \
-                                       ((val) + 500) / 1000), -128, 127))
+#define TEMP_TO_REG(val) (clamp_val(((val) < 0 ? (((val) - 500) / 1000) : \
+                                   ((val) + 500) / 1000), -128, 127))
 #define TEMP_FROM_REG(val) ((val) * 1000)
 
 static u8 pwm_to_reg(const struct it87_data *data, long val)
@@ -406,35 +476,6 @@ static const unsigned int pwm_freq[8] = {
        750000 / 128,
 };
 
-static inline int has_16bit_fans(const struct it87_data *data)
-{
-       /*
-        * IT8705F Datasheet 0.4.1, 3h == Version G.
-        * IT8712F Datasheet 0.9.1, section 8.3.5 indicates 8h == Version J.
-        * These are the first revisions with 16-bit tachometer support.
-        */
-       return (data->type == it87 && data->revision >= 0x03)
-           || (data->type == it8712 && data->revision >= 0x08)
-           || data->type == it8716
-           || data->type == it8718
-           || data->type == it8720
-           || data->type == it8721
-           || data->type == it8728
-           || data->type == it8782
-           || data->type == it8783;
-}
-
-static inline int has_old_autopwm(const struct it87_data *data)
-{
-       /*
-        * The old automatic fan speed control interface is implemented
-        * by IT8705F chips up to revision F and IT8712F chips up to
-        * revision G.
-        */
-       return (data->type == it87 && data->revision < 0x03)
-           || (data->type == it8712 && data->revision < 0x08);
-}
-
 static int it87_probe(struct platform_device *pdev);
 static int it87_remove(struct platform_device *pdev);
 
@@ -619,7 +660,11 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr,
        int nr = sensor_attr->index;
        struct it87_data *data = it87_update_device(dev);
        u8 reg = data->sensor;      /* In case value is updated while used */
+       u8 extra = data->extra;
 
+       if ((has_temp_peci(data, nr) && (reg >> 6 == nr + 1))
+           || (has_temp_old_peci(data, nr) && (extra & 0x80)))
+               return sprintf(buf, "6\n");  /* Intel PECI */
        if (reg & (1 << nr))
                return sprintf(buf, "3\n");  /* thermal diode */
        if (reg & (8 << nr))
@@ -635,7 +680,7 @@ static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr,
 
        struct it87_data *data = dev_get_drvdata(dev);
        long val;
-       u8 reg;
+       u8 reg, extra;
 
        if (kstrtol(buf, 10, &val) < 0)
                return -EINVAL;
@@ -643,22 +688,34 @@ static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr,
        reg = it87_read_value(data, IT87_REG_TEMP_ENABLE);
        reg &= ~(1 << nr);
        reg &= ~(8 << nr);
+       if (has_temp_peci(data, nr) && (reg >> 6 == nr + 1 || val == 6))
+               reg &= 0x3f;
+       extra = it87_read_value(data, IT87_REG_TEMP_EXTRA);
+       if (has_temp_old_peci(data, nr) && ((extra & 0x80) || val == 6))
+               extra &= 0x7f;
        if (val == 2) { /* backwards compatibility */
-               dev_warn(dev, "Sensor type 2 is deprecated, please use 4 "
-                        "instead\n");
+               dev_warn(dev,
+                        "Sensor type 2 is deprecated, please use 4 instead\n");
                val = 4;
        }
-       /* 3 = thermal diode; 4 = thermistor; 0 = disabled */
+       /* 3 = thermal diode; 4 = thermistor; 6 = Intel PECI; 0 = disabled */
        if (val == 3)
                reg |= 1 << nr;
        else if (val == 4)
                reg |= 8 << nr;
+       else if (has_temp_peci(data, nr) && val == 6)
+               reg |= (nr + 1) << 6;
+       else if (has_temp_old_peci(data, nr) && val == 6)
+               extra |= 0x80;
        else if (val != 0)
                return -EINVAL;
 
        mutex_lock(&data->update_lock);
        data->sensor = reg;
+       data->extra = extra;
        it87_write_value(data, IT87_REG_TEMP_ENABLE, data->sensor);
+       if (has_temp_old_peci(data, nr))
+               it87_write_value(data, IT87_REG_TEMP_EXTRA, data->extra);
        data->valid = 0;        /* Force cache refresh */
        mutex_unlock(&data->update_lock);
        return count;
@@ -847,8 +904,8 @@ static int check_trip_points(struct device *dev, int nr)
        }
 
        if (err) {
-               dev_err(dev, "Inconsistent trip points, not switching to "
-                       "automatic mode\n");
+               dev_err(dev,
+                       "Inconsistent trip points, not switching to automatic mode\n");
                dev_err(dev, "Adjust the trip points and try again\n");
        }
        return err;
@@ -1122,47 +1179,80 @@ static SENSOR_DEVICE_ATTR_2(fan5_input, S_IRUGO, show_fan, NULL, 4, 0);
 static SENSOR_DEVICE_ATTR_2(fan5_min, S_IRUGO | S_IWUSR, show_fan, set_fan,
                            4, 1);
 
-#define show_pwm_offset(offset)                                                \
-static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR,     \
-               show_pwm_enable, set_pwm_enable, offset - 1);           \
-static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR,              \
-               show_pwm, set_pwm, offset - 1);                         \
-static DEVICE_ATTR(pwm##offset##_freq,                                 \
-               (offset == 1 ? S_IRUGO | S_IWUSR : S_IRUGO),            \
-               show_pwm_freq, (offset == 1 ? set_pwm_freq : NULL));    \
-static SENSOR_DEVICE_ATTR(pwm##offset##_auto_channels_temp,            \
-               S_IRUGO | S_IWUSR, show_pwm_temp_map, set_pwm_temp_map, \
-               offset - 1);                                            \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point1_pwm,             \
-               S_IRUGO | S_IWUSR, show_auto_pwm, set_auto_pwm,         \
-               offset - 1, 0);                                         \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point2_pwm,             \
-               S_IRUGO | S_IWUSR, show_auto_pwm, set_auto_pwm,         \
-               offset - 1, 1);                                         \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point3_pwm,             \
-               S_IRUGO | S_IWUSR, show_auto_pwm, set_auto_pwm,         \
-               offset - 1, 2);                                         \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point4_pwm,             \
-               S_IRUGO, show_auto_pwm, NULL, offset - 1, 3);           \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point1_temp,            \
-               S_IRUGO | S_IWUSR, show_auto_temp, set_auto_temp,       \
-               offset - 1, 1);                                         \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point1_temp_hyst,       \
-               S_IRUGO | S_IWUSR, show_auto_temp, set_auto_temp,       \
-               offset - 1, 0);                                         \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point2_temp,            \
-               S_IRUGO | S_IWUSR, show_auto_temp, set_auto_temp,       \
-               offset - 1, 2);                                         \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point3_temp,            \
-               S_IRUGO | S_IWUSR, show_auto_temp, set_auto_temp,       \
-               offset - 1, 3);                                         \
-static SENSOR_DEVICE_ATTR_2(pwm##offset##_auto_point4_temp,            \
-               S_IRUGO | S_IWUSR, show_auto_temp, set_auto_temp,       \
-               offset - 1, 4);
-
-show_pwm_offset(1);
-show_pwm_offset(2);
-show_pwm_offset(3);
+static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
+                         show_pwm_enable, set_pwm_enable, 0);
+static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 0);
+static DEVICE_ATTR(pwm1_freq, S_IRUGO | S_IWUSR, show_pwm_freq, set_pwm_freq);
+static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp, S_IRUGO | S_IWUSR,
+                         show_pwm_temp_map, set_pwm_temp_map, 0);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 0, 0);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 0, 1);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 0, 2);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point4_pwm, S_IRUGO,
+                           show_auto_pwm, NULL, 0, 3);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 0, 1);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp_hyst, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 0, 0);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 0, 2);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 0, 3);
+static SENSOR_DEVICE_ATTR_2(pwm1_auto_point4_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 0, 4);
+
+static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR,
+                         show_pwm_enable, set_pwm_enable, 1);
+static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 1);
+static DEVICE_ATTR(pwm2_freq, S_IRUGO, show_pwm_freq, NULL);
+static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp, S_IRUGO | S_IWUSR,
+                         show_pwm_temp_map, set_pwm_temp_map, 1);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 1, 0);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 1, 1);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 1, 2);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point4_pwm, S_IRUGO,
+                           show_auto_pwm, NULL, 1, 3);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 1, 1);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp_hyst, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 1, 0);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 1, 2);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 1, 3);
+static SENSOR_DEVICE_ATTR_2(pwm2_auto_point4_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 1, 4);
+
+static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR,
+                         show_pwm_enable, set_pwm_enable, 2);
+static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 2);
+static DEVICE_ATTR(pwm3_freq, S_IRUGO, show_pwm_freq, NULL);
+static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR,
+                         show_pwm_temp_map, set_pwm_temp_map, 2);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 2, 0);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 2, 1);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_pwm, S_IRUGO | S_IWUSR,
+                           show_auto_pwm, set_auto_pwm, 2, 2);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point4_pwm, S_IRUGO,
+                           show_auto_pwm, NULL, 2, 3);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 2, 1);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp_hyst, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 2, 0);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 2, 2);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 2, 3);
+static SENSOR_DEVICE_ATTR_2(pwm3_auto_point4_temp, S_IRUGO | S_IWUSR,
+                           show_auto_temp, set_auto_temp, 2, 4);
 
 /* Alarms */
 static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
@@ -1640,6 +1730,12 @@ static int __init it87_find(unsigned short *address,
        case IT8728F_DEVID:
                sio_data->type = it8728;
                break;
+       case IT8771E_DEVID:
+               sio_data->type = it8771;
+               break;
+       case IT8772E_DEVID:
+               sio_data->type = it8772;
+               break;
        case IT8782F_DEVID:
                sio_data->type = it8782;
                break;
@@ -1757,10 +1853,11 @@ static int __init it87_find(unsigned short *address,
 
                reg = superio_inb(IT87_SIO_GPIO3_REG);
                if (sio_data->type == it8721 || sio_data->type == it8728 ||
+                   sio_data->type == it8771 || sio_data->type == it8772 ||
                    sio_data->type == it8782) {
                        /*
                         * IT8721F/IT8758E, and IT8782F don't have VID pins
-                        * at all, not sure about the IT8728F.
+                        * at all, not sure about the IT8728F and compatibles.
                         */
                        sio_data->skip_vid = 1;
                } else {
@@ -1814,7 +1911,9 @@ static int __init it87_find(unsigned short *address,
                if (reg & (1 << 0))
                        sio_data->internal |= (1 << 0);
                if ((reg & (1 << 1)) || sio_data->type == it8721 ||
-                   sio_data->type == it8728)
+                   sio_data->type == it8728 ||
+                   sio_data->type == it8771 ||
+                   sio_data->type == it8772)
                        sio_data->internal |= (1 << 1);
 
                /*
@@ -1919,17 +2018,6 @@ static int it87_probe(struct platform_device *pdev)
        int err = 0, i;
        int enable_pwm_interface;
        int fan_beep_need_rw;
-       static const char * const names[] = {
-               "it87",
-               "it8712",
-               "it8716",
-               "it8718",
-               "it8720",
-               "it8721",
-               "it8728",
-               "it8782",
-               "it8783",
-       };
 
        res = platform_get_resource(pdev, IORESOURCE_IO, 0);
        if (!devm_request_region(&pdev->dev, res->start, IT87_EC_EXTENT,
@@ -1946,8 +2034,31 @@ static int it87_probe(struct platform_device *pdev)
 
        data->addr = res->start;
        data->type = sio_data->type;
-       data->revision = sio_data->revision;
-       data->name = names[sio_data->type];
+       data->features = it87_devices[sio_data->type].features;
+       data->peci_mask = it87_devices[sio_data->type].peci_mask;
+       data->old_peci_mask = it87_devices[sio_data->type].old_peci_mask;
+       data->name = it87_devices[sio_data->type].name;
+       /*
+        * IT8705F Datasheet 0.4.1, 3h == Version G.
+        * IT8712F Datasheet 0.9.1, section 8.3.5 indicates 8h == Version J.
+        * These are the first revisions with 16-bit tachometer support.
+        */
+       switch (data->type) {
+       case it87:
+               if (sio_data->revision >= 0x03) {
+                       data->features &= ~FEAT_OLD_AUTOPWM;
+                       data->features |= FEAT_16BIT_FANS;
+               }
+               break;
+       case it8712:
+               if (sio_data->revision >= 0x08) {
+                       data->features &= ~FEAT_OLD_AUTOPWM;
+                       data->features |= FEAT_16BIT_FANS;
+               }
+               break;
+       default:
+               break;
+       }
 
        /* Now, we do the remaining detection. */
        if ((it87_read_value(data, IT87_REG_CONFIG) & 0x80)
@@ -2176,8 +2287,8 @@ static int it87_check_pwm(struct device *dev)
                         * PWM interface).
                         */
                        if (!((pwm[0] | pwm[1] | pwm[2]) & 0x80)) {
-                               dev_info(dev, "Reconfiguring PWM to "
-                                        "active high polarity\n");
+                               dev_info(dev,
+                                        "Reconfiguring PWM to active high polarity\n");
                                it87_write_value(data, IT87_REG_FAN_CTL,
                                                 tmp | 0x87);
                                for (i = 0; i < 3; i++)
@@ -2187,16 +2298,16 @@ static int it87_check_pwm(struct device *dev)
                                return 1;
                        }
 
-                       dev_info(dev, "PWM configuration is "
-                                "too broken to be fixed\n");
+                       dev_info(dev,
+                                "PWM configuration is too broken to be fixed\n");
                }
 
-               dev_info(dev, "Detected broken BIOS "
-                        "defaults, disabling PWM interface\n");
+               dev_info(dev,
+                        "Detected broken BIOS defaults, disabling PWM interface\n");
                return 0;
        } else if (fix_pwm_polarity) {
-               dev_info(dev, "PWM configuration looks "
-                        "sane, won't touch\n");
+               dev_info(dev,
+                        "PWM configuration looks sane, won't touch\n");
        }
 
        return 1;
@@ -2407,6 +2518,7 @@ static struct it87_data *it87_update_device(struct device *dev)
                        it87_update_pwm_ctrl(data, i);
 
                data->sensor = it87_read_value(data, IT87_REG_TEMP_ENABLE);
+               data->extra = it87_read_value(data, IT87_REG_TEMP_EXTRA);
                /*
                 * The IT8705F does not have VID capability.
                 * The IT8718F and later don't use IT87_REG_VID for the
@@ -2508,8 +2620,7 @@ static void __exit sm_it87_exit(void)
 }
 
 
-MODULE_AUTHOR("Chris Gauthron, "
-             "Jean Delvare <khali@linux-fr.org>");
+MODULE_AUTHOR("Chris Gauthron, Jean Delvare <khali@linux-fr.org>");
 MODULE_DESCRIPTION("IT8705F/IT871xF/IT872xF hardware monitoring driver");
 module_param(update_vbat, bool, 0);
 MODULE_PARM_DESC(update_vbat, "Update vbat if set else return powerup value");