aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ads1015.c3
-rw-r--r--drivers/hwmon/f75375s.c18
-rw-r--r--drivers/hwmon/max6639.c22
-rw-r--r--drivers/hwmon/pmbus/max34440.c2
-rw-r--r--drivers/hwmon/w83627ehf.c28
5 files changed, 42 insertions, 31 deletions
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index eedca3cf9968..dd87ae96c262 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -271,7 +271,7 @@ static int ads1015_probe(struct i2c_client *client,
271 continue; 271 continue;
272 err = device_create_file(&client->dev, &ads1015_in[k].dev_attr); 272 err = device_create_file(&client->dev, &ads1015_in[k].dev_attr);
273 if (err) 273 if (err)
274 goto exit_free; 274 goto exit_remove;
275 } 275 }
276 276
277 data->hwmon_dev = hwmon_device_register(&client->dev); 277 data->hwmon_dev = hwmon_device_register(&client->dev);
@@ -285,7 +285,6 @@ static int ads1015_probe(struct i2c_client *client,
285exit_remove: 285exit_remove:
286 for (k = 0; k < ADS1015_CHANNELS; ++k) 286 for (k = 0; k < ADS1015_CHANNELS; ++k)
287 device_remove_file(&client->dev, &ads1015_in[k].dev_attr); 287 device_remove_file(&client->dev, &ads1015_in[k].dev_attr);
288exit_free:
289 kfree(data); 288 kfree(data);
290exit: 289exit:
291 return err; 290 return err;
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index eedf574ab539..6bab2001ef3b 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -172,7 +172,7 @@ static inline void f75375_write8(struct i2c_client *client, u8 reg,
172static inline void f75375_write16(struct i2c_client *client, u8 reg, 172static inline void f75375_write16(struct i2c_client *client, u8 reg,
173 u16 value) 173 u16 value)
174{ 174{
175 int err = i2c_smbus_write_byte_data(client, reg, (value << 8)); 175 int err = i2c_smbus_write_byte_data(client, reg, (value >> 8));
176 if (err) 176 if (err)
177 return; 177 return;
178 i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF)); 178 i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF));
@@ -200,9 +200,6 @@ static struct f75375_data *f75375_update_device(struct device *dev)
200 f75375_read16(client, F75375_REG_FAN_MIN(nr)); 200 f75375_read16(client, F75375_REG_FAN_MIN(nr));
201 data->fan_target[nr] = 201 data->fan_target[nr] =
202 f75375_read16(client, F75375_REG_FAN_EXP(nr)); 202 f75375_read16(client, F75375_REG_FAN_EXP(nr));
203 data->pwm[nr] = f75375_read8(client,
204 F75375_REG_FAN_PWM_DUTY(nr));
205
206 } 203 }
207 for (nr = 0; nr < 4; nr++) { 204 for (nr = 0; nr < 4; nr++) {
208 data->in_max[nr] = 205 data->in_max[nr] =
@@ -218,6 +215,8 @@ static struct f75375_data *f75375_update_device(struct device *dev)
218 if (time_after(jiffies, data->last_updated + 2 * HZ) 215 if (time_after(jiffies, data->last_updated + 2 * HZ)
219 || !data->valid) { 216 || !data->valid) {
220 for (nr = 0; nr < 2; nr++) { 217 for (nr = 0; nr < 2; nr++) {
218 data->pwm[nr] = f75375_read8(client,
219 F75375_REG_FAN_PWM_DUTY(nr));
221 /* assign MSB, therefore shift it by 8 bits */ 220 /* assign MSB, therefore shift it by 8 bits */
222 data->temp11[nr] = 221 data->temp11[nr] =
223 f75375_read8(client, F75375_REG_TEMP(nr)) << 8; 222 f75375_read8(client, F75375_REG_TEMP(nr)) << 8;
@@ -341,8 +340,6 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
341 fanmode |= (1 << F75387_FAN_MANU_MODE(nr)); 340 fanmode |= (1 << F75387_FAN_MANU_MODE(nr));
342 fanmode |= (1 << F75387_FAN_DUTY_MODE(nr)); 341 fanmode |= (1 << F75387_FAN_DUTY_MODE(nr));
343 data->pwm[nr] = 255; 342 data->pwm[nr] = 255;
344 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
345 data->pwm[nr]);
346 break; 343 break;
347 case 1: /* PWM */ 344 case 1: /* PWM */
348 fanmode |= (1 << F75387_FAN_MANU_MODE(nr)); 345 fanmode |= (1 << F75387_FAN_MANU_MODE(nr));
@@ -362,14 +359,12 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
362 case 0: /* full speed */ 359 case 0: /* full speed */
363 fanmode |= (3 << FAN_CTRL_MODE(nr)); 360 fanmode |= (3 << FAN_CTRL_MODE(nr));
364 data->pwm[nr] = 255; 361 data->pwm[nr] = 255;
365 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
366 data->pwm[nr]);
367 break; 362 break;
368 case 1: /* PWM */ 363 case 1: /* PWM */
369 fanmode |= (3 << FAN_CTRL_MODE(nr)); 364 fanmode |= (3 << FAN_CTRL_MODE(nr));
370 break; 365 break;
371 case 2: /* AUTOMATIC*/ 366 case 2: /* AUTOMATIC*/
372 fanmode |= (2 << FAN_CTRL_MODE(nr)); 367 fanmode |= (1 << FAN_CTRL_MODE(nr));
373 break; 368 break;
374 case 3: /* fan speed */ 369 case 3: /* fan speed */
375 break; 370 break;
@@ -378,6 +373,9 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
378 373
379 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode); 374 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode);
380 data->pwm_enable[nr] = val; 375 data->pwm_enable[nr] = val;
376 if (val == 0)
377 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
378 data->pwm[nr]);
381 return 0; 379 return 0;
382} 380}
383 381
@@ -723,7 +721,7 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data,
723 if (data->kind == f75387) { 721 if (data->kind == f75387) {
724 bool manu, duty; 722 bool manu, duty;
725 723
726 if (!(conf & (1 << F75387_FAN_CTRL_LINEAR(nr)))) 724 if (!(mode & (1 << F75387_FAN_CTRL_LINEAR(nr))))
727 data->pwm_mode[nr] = 1; 725 data->pwm_mode[nr] = 1;
728 726
729 manu = ((mode >> F75387_FAN_MANU_MODE(nr)) & 1); 727 manu = ((mode >> F75387_FAN_MANU_MODE(nr)) & 1);
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c
index e10a092c603c..a6760bacd915 100644
--- a/drivers/hwmon/max6639.c
+++ b/drivers/hwmon/max6639.c
@@ -72,8 +72,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END };
72 72
73static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; 73static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 };
74 74
75#define FAN_FROM_REG(val, div, rpm_range) ((val) == 0 ? -1 : \ 75#define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \
76 (val) == 255 ? 0 : (rpm_ranges[rpm_range] * 30) / ((div + 1) * (val))) 76 0 : (rpm_ranges[rpm_range] * 30) / (val))
77#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255) 77#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255)
78 78
79/* 79/*
@@ -333,7 +333,7 @@ static ssize_t show_fan_input(struct device *dev,
333 return PTR_ERR(data); 333 return PTR_ERR(data);
334 334
335 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], 335 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index],
336 data->ppr, data->rpm_range)); 336 data->rpm_range));
337} 337}
338 338
339static ssize_t show_alarm(struct device *dev, 339static ssize_t show_alarm(struct device *dev,
@@ -429,9 +429,9 @@ static int max6639_init_client(struct i2c_client *client)
429 struct max6639_data *data = i2c_get_clientdata(client); 429 struct max6639_data *data = i2c_get_clientdata(client);
430 struct max6639_platform_data *max6639_info = 430 struct max6639_platform_data *max6639_info =
431 client->dev.platform_data; 431 client->dev.platform_data;
432 int i = 0; 432 int i;
433 int rpm_range = 1; /* default: 4000 RPM */ 433 int rpm_range = 1; /* default: 4000 RPM */
434 int err = 0; 434 int err;
435 435
436 /* Reset chip to default values, see below for GCONFIG setup */ 436 /* Reset chip to default values, see below for GCONFIG setup */
437 err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, 437 err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG,
@@ -446,11 +446,6 @@ static int max6639_init_client(struct i2c_client *client)
446 else 446 else
447 data->ppr = 2; 447 data->ppr = 2;
448 data->ppr -= 1; 448 data->ppr -= 1;
449 err = i2c_smbus_write_byte_data(client,
450 MAX6639_REG_FAN_PPR(i),
451 data->ppr << 5);
452 if (err)
453 goto exit;
454 449
455 if (max6639_info) 450 if (max6639_info)
456 rpm_range = rpm_range_to_reg(max6639_info->rpm_range); 451 rpm_range = rpm_range_to_reg(max6639_info->rpm_range);
@@ -458,6 +453,13 @@ static int max6639_init_client(struct i2c_client *client)
458 453
459 for (i = 0; i < 2; i++) { 454 for (i = 0; i < 2; i++) {
460 455
456 /* Set Fan pulse per revolution */
457 err = i2c_smbus_write_byte_data(client,
458 MAX6639_REG_FAN_PPR(i),
459 data->ppr << 6);
460 if (err)
461 goto exit;
462
461 /* Fans config PWM, RPM */ 463 /* Fans config PWM, RPM */
462 err = i2c_smbus_write_byte_data(client, 464 err = i2c_smbus_write_byte_data(client,
463 MAX6639_REG_FAN_CONFIG1(i), 465 MAX6639_REG_FAN_CONFIG1(i),
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index beaf5a8d9c45..9b97a5b3cf3d 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -82,7 +82,7 @@ static int max34440_write_word_data(struct i2c_client *client, int page,
82 case PMBUS_VIRT_RESET_TEMP_HISTORY: 82 case PMBUS_VIRT_RESET_TEMP_HISTORY:
83 ret = pmbus_write_word_data(client, page, 83 ret = pmbus_write_word_data(client, page,
84 MAX34440_MFR_TEMPERATURE_PEAK, 84 MAX34440_MFR_TEMPERATURE_PEAK,
85 0xffff); 85 0x8000);
86 break; 86 break;
87 default: 87 default:
88 ret = -ENODATA; 88 ret = -ENODATA;
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 2dfae7d7cc5b..5276d1933dbc 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1920,9 +1920,26 @@ w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data,
1920 fan4min = 0; 1920 fan4min = 0;
1921 fan5pin = 0; 1921 fan5pin = 0;
1922 } else if (sio_data->kind == nct6776) { 1922 } else if (sio_data->kind == nct6776) {
1923 fan3pin = !(superio_inb(sio_data->sioreg, 0x24) & 0x40); 1923 bool gpok = superio_inb(sio_data->sioreg, 0x27) & 0x80;
1924 fan4pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x01); 1924
1925 fan5pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x02); 1925 superio_select(sio_data->sioreg, W83627EHF_LD_HWM);
1926 regval = superio_inb(sio_data->sioreg, SIO_REG_ENABLE);
1927
1928 if (regval & 0x80)
1929 fan3pin = gpok;
1930 else
1931 fan3pin = !(superio_inb(sio_data->sioreg, 0x24) & 0x40);
1932
1933 if (regval & 0x40)
1934 fan4pin = gpok;
1935 else
1936 fan4pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x01);
1937
1938 if (regval & 0x20)
1939 fan5pin = gpok;
1940 else
1941 fan5pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x02);
1942
1926 fan4min = fan4pin; 1943 fan4min = fan4pin;
1927 } else if (sio_data->kind == w83667hg || sio_data->kind == w83667hg_b) { 1944 } else if (sio_data->kind == w83667hg || sio_data->kind == w83667hg_b) {
1928 fan3pin = 1; 1945 fan3pin = 1;
@@ -2337,11 +2354,6 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
2337 for (i = 0; i < data->pwm_num; i++) 2354 for (i = 0; i < data->pwm_num; i++)
2338 data->pwm_enable_orig[i] = data->pwm_enable[i]; 2355 data->pwm_enable_orig[i] = data->pwm_enable[i];
2339 2356
2340 /* Read pwm data to save original values */
2341 w83627ehf_update_pwm_common(dev, data);
2342 for (i = 0; i < data->pwm_num; i++)
2343 data->pwm_enable_orig[i] = data->pwm_enable[i];
2344
2345 /* Register sysfs hooks */ 2357 /* Register sysfs hooks */
2346 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays); i++) { 2358 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays); i++) {
2347 err = device_create_file(dev, &sda_sf3_arrays[i].dev_attr); 2359 err = device_create_file(dev, &sda_sf3_arrays[i].dev_attr);