aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/w83793.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 7cadef8cd87d..253ffaf1568a 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -205,6 +205,7 @@ struct w83793_data {
205 205
206 u8 has_pwm; 206 u8 has_pwm;
207 u8 has_temp; 207 u8 has_temp;
208 u8 has_vid;
208 u8 pwm_enable; /* Register value, each Temp has 1 bit */ 209 u8 pwm_enable; /* Register value, each Temp has 1 bit */
209 u8 pwm_uptime; /* Register value */ 210 u8 pwm_uptime; /* Register value */
210 u8 pwm_downtime; /* Register value */ 211 u8 pwm_downtime; /* Register value */
@@ -1025,9 +1026,12 @@ static struct sensor_device_attribute_2 w83793_left_pwm[] = {
1025 SENSOR_ATTR_PWM(8), 1026 SENSOR_ATTR_PWM(8),
1026}; 1027};
1027 1028
1028static struct sensor_device_attribute_2 sda_single_files[] = { 1029static struct sensor_device_attribute_2 w83793_vid[] = {
1029 SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), 1030 SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0),
1030 SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), 1031 SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1),
1032};
1033
1034static struct sensor_device_attribute_2 sda_single_files[] = {
1031 SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm, 1035 SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm,
1032 NOT_USED, NOT_USED), 1036 NOT_USED, NOT_USED),
1033 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, 1037 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep,
@@ -1080,6 +1084,9 @@ static int w83793_detach_client(struct i2c_client *client)
1080 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) 1084 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++)
1081 device_remove_file(dev, &sda_single_files[i].dev_attr); 1085 device_remove_file(dev, &sda_single_files[i].dev_attr);
1082 1086
1087 for (i = 0; i < ARRAY_SIZE(w83793_vid); i++)
1088 device_remove_file(dev, &w83793_vid[i].dev_attr);
1089
1083 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) 1090 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++)
1084 device_remove_file(dev, &w83793_left_fan[i].dev_attr); 1091 device_remove_file(dev, &w83793_left_fan[i].dev_attr);
1085 1092
@@ -1358,6 +1365,13 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1358 if (tmp & 0x02) 1365 if (tmp & 0x02)
1359 data->has_temp |= 0x20; 1366 data->has_temp |= 0x20;
1360 1367
1368 /* Detect the VID usage and ignore unused input */
1369 tmp = w83793_read_value(client, W83793_REG_MFC);
1370 if (!(tmp & 0x29))
1371 data->has_vid |= 0x1; /* has VIDA */
1372 if (tmp & 0x80)
1373 data->has_vid |= 0x2; /* has VIDB */
1374
1361 /* Register sysfs hooks */ 1375 /* Register sysfs hooks */
1362 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { 1376 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) {
1363 err = device_create_file(dev, 1377 err = device_create_file(dev,
@@ -1366,6 +1380,14 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1366 goto exit_remove; 1380 goto exit_remove;
1367 } 1381 }
1368 1382
1383 for (i = 0; i < ARRAY_SIZE(w83793_vid); i++) {
1384 if (!(data->has_vid & (1 << i)))
1385 continue;
1386 err = device_create_file(dev, &w83793_vid[i].dev_attr);
1387 if (err)
1388 goto exit_remove;
1389 }
1390
1369 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { 1391 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) {
1370 err = device_create_file(dev, &sda_single_files[i].dev_attr); 1392 err = device_create_file(dev, &sda_single_files[i].dev_attr);
1371 if (err) 1393 if (err)
@@ -1429,6 +1451,9 @@ exit_remove:
1429 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) 1451 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++)
1430 device_remove_file(dev, &sda_single_files[i].dev_attr); 1452 device_remove_file(dev, &sda_single_files[i].dev_attr);
1431 1453
1454 for (i = 0; i < ARRAY_SIZE(w83793_vid); i++)
1455 device_remove_file(dev, &w83793_vid[i].dev_attr);
1456
1432 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) 1457 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++)
1433 device_remove_file(dev, &w83793_left_fan[i].dev_attr); 1458 device_remove_file(dev, &w83793_left_fan[i].dev_attr);
1434 1459
@@ -1593,8 +1618,10 @@ static struct w83793_data *w83793_update_device(struct device *dev)
1593 for (i = 0; i < ARRAY_SIZE(data->alarms); i++) 1618 for (i = 0; i < ARRAY_SIZE(data->alarms); i++)
1594 data->alarms[i] = 1619 data->alarms[i] =
1595 w83793_read_value(client, W83793_REG_ALARM(i)); 1620 w83793_read_value(client, W83793_REG_ALARM(i));
1596 data->vid[0] = w83793_read_value(client, W83793_REG_VID_INA); 1621 if (data->has_vid & 0x01)
1597 data->vid[1] = w83793_read_value(client, W83793_REG_VID_INB); 1622 data->vid[0] = w83793_read_value(client, W83793_REG_VID_INA);
1623 if (data->has_vid & 0x02)
1624 data->vid[1] = w83793_read_value(client, W83793_REG_VID_INB);
1598 w83793_update_nonvolatile(dev); 1625 w83793_update_nonvolatile(dev);
1599 data->last_updated = jiffies; 1626 data->last_updated = jiffies;
1600 data->valid = 1; 1627 data->valid = 1;