Pull sbs into release branch
[platform/kernel/linux-starfive.git] / drivers / hwmon / w83627ehf.c
index a336793..c51ae2e 100644 (file)
@@ -272,6 +272,7 @@ struct w83627ehf_data {
        u8 fan_min[5];
        u8 fan_div[5];
        u8 has_fan;             /* some fan inputs can be disabled */
+       u8 temp_type[3];
        s8 temp1;
        s8 temp1_max;
        s8 temp1_max_hyst;
@@ -846,6 +847,15 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
 store_temp_reg(OVER, temp_max);
 store_temp_reg(HYST, temp_max_hyst);
 
+static ssize_t
+show_temp_type(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct w83627ehf_data *data = w83627ehf_update_device(dev);
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       return sprintf(buf, "%d\n", (int)data->temp_type[nr]);
+}
+
 static struct sensor_device_attribute sda_temp[] = {
        SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0),
        SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0),
@@ -865,6 +875,9 @@ static struct sensor_device_attribute sda_temp[] = {
        SENSOR_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4),
        SENSOR_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5),
        SENSOR_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13),
+       SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0),
+       SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1),
+       SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2),
 };
 
 #define show_pwm_reg(reg) \
@@ -1188,7 +1201,7 @@ static void w83627ehf_device_remove_files(struct device *dev)
 static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data)
 {
        int i;
-       u8 tmp;
+       u8 tmp, diode;
 
        /* Start monitoring is needed */
        tmp = w83627ehf_read_value(data, W83627EHF_REG_CONFIG);
@@ -1205,6 +1218,20 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data)
                                              W83627EHF_REG_TEMP_CONFIG[i],
                                              tmp & 0xfe);
        }
+
+       /* Enable VBAT monitoring if needed */
+       tmp = w83627ehf_read_value(data, W83627EHF_REG_VBAT);
+       if (!(tmp & 0x01))
+               w83627ehf_write_value(data, W83627EHF_REG_VBAT, tmp | 0x01);
+
+       /* Get thermal sensor types */
+       diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
+       for (i = 0; i < 3; i++) {
+               if ((tmp & (0x02 << i)))
+                       data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 2;
+               else
+                       data->temp_type[i] = 4; /* thermistor */
+       }
 }
 
 static int __devinit w83627ehf_probe(struct platform_device *pdev)
@@ -1242,11 +1269,6 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
        /* Initialize the chip */
        w83627ehf_init_device(data);
 
-       /* A few vars need to be filled upon startup */
-       for (i = 0; i < 5; i++)
-               data->fan_min[i] = w83627ehf_read_value(data,
-                                  W83627EHF_REG_FAN_MIN[i]);
-
        data->vrm = vid_which_vrm();
        superio_enter(sio_data->sioreg);
        /* Set VID input sensibility if needed. In theory the BIOS should
@@ -1423,8 +1445,9 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
                sio_name = sio_name_W83627DHG;
                break;
        default:
-               pr_info(DRVNAME ": unsupported chip ID: 0x%04x\n",
-                       val);
+               if (val != 0xffff)
+                       pr_debug(DRVNAME ": unsupported chip ID: 0x%04x\n",
+                                val);
                superio_exit(sioaddr);
                return -ENODEV;
        }