aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/adm1026.c20
-rw-r--r--drivers/hwmon/applesmc.c48
-rw-r--r--drivers/hwmon/lm63.c59
-rw-r--r--drivers/hwmon/lm85.c1
-rw-r--r--drivers/hwmon/via686a.c14
5 files changed, 86 insertions, 56 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index 65335b268fa9..9975bbfb1b31 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -916,27 +916,27 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
916 int nr = sensor_attr->index; 916 int nr = sensor_attr->index;
917 struct i2c_client *client = to_i2c_client(dev); 917 struct i2c_client *client = to_i2c_client(dev);
918 struct adm1026_data *data = i2c_get_clientdata(client); 918 struct adm1026_data *data = i2c_get_clientdata(client);
919 int val, orig_div, new_div, shift; 919 int val, orig_div, new_div;
920 920
921 val = simple_strtol(buf, NULL, 10); 921 val = simple_strtol(buf, NULL, 10);
922 new_div = DIV_TO_REG(val); 922 new_div = DIV_TO_REG(val);
923 if (new_div == 0) { 923
924 return -EINVAL;
925 }
926 mutex_lock(&data->update_lock); 924 mutex_lock(&data->update_lock);
927 orig_div = data->fan_div[nr]; 925 orig_div = data->fan_div[nr];
928 data->fan_div[nr] = DIV_FROM_REG(new_div); 926 data->fan_div[nr] = DIV_FROM_REG(new_div);
929 927
930 if (nr < 4) { /* 0 <= nr < 4 */ 928 if (nr < 4) { /* 0 <= nr < 4 */
931 shift = 2 * nr;
932 adm1026_write_value(client, ADM1026_REG_FAN_DIV_0_3, 929 adm1026_write_value(client, ADM1026_REG_FAN_DIV_0_3,
933 ((DIV_TO_REG(orig_div) & (~(0x03 << shift))) | 930 (DIV_TO_REG(data->fan_div[0]) << 0) |
934 (new_div << shift))); 931 (DIV_TO_REG(data->fan_div[1]) << 2) |
932 (DIV_TO_REG(data->fan_div[2]) << 4) |
933 (DIV_TO_REG(data->fan_div[3]) << 6));
935 } else { /* 3 < nr < 8 */ 934 } else { /* 3 < nr < 8 */
936 shift = 2 * (nr - 4);
937 adm1026_write_value(client, ADM1026_REG_FAN_DIV_4_7, 935 adm1026_write_value(client, ADM1026_REG_FAN_DIV_4_7,
938 ((DIV_TO_REG(orig_div) & (~(0x03 << (2 * shift)))) | 936 (DIV_TO_REG(data->fan_div[4]) << 0) |
939 (new_div << shift))); 937 (DIV_TO_REG(data->fan_div[5]) << 2) |
938 (DIV_TO_REG(data->fan_div[6]) << 4) |
939 (DIV_TO_REG(data->fan_div[7]) << 6));
940 } 940 }
941 941
942 if (data->fan_div[nr] != orig_div) { 942 if (data->fan_div[nr] != orig_div) {
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index b6598aa557a0..87a5fd51dd5e 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -162,6 +162,10 @@ static const char *temperature_sensors_sets[][41] = {
162/* Set 22: MacBook Pro 7,1 */ 162/* Set 22: MacBook Pro 7,1 */
163 { "TB0T", "TB1T", "TB2T", "TC0D", "TC0P", "TN0D", "TN0P", "TN0S", 163 { "TB0T", "TB1T", "TB2T", "TC0D", "TC0P", "TN0D", "TN0P", "TN0S",
164 "TN1D", "TN1F", "TN1G", "TN1S", "Th1H", "Ts0P", "Ts0S", NULL }, 164 "TN1D", "TN1F", "TN1G", "TN1S", "Th1H", "Ts0P", "Ts0S", NULL },
165/* Set 23: MacBook Air 3,1 */
166 { "TB0T", "TB1T", "TB2T", "TC0D", "TC0E", "TC0P", "TC1E", "TCZ3",
167 "TCZ4", "TCZ5", "TG0E", "TG1E", "TG2E", "TGZ3", "TGZ4", "TGZ5",
168 "TH0F", "TH0O", "TM0P" },
165}; 169};
166 170
167/* List of keys used to read/write fan speeds */ 171/* List of keys used to read/write fan speeds */
@@ -444,38 +448,22 @@ static int applesmc_read_motion_sensor(int index, s16* value)
444} 448}
445 449
446/* 450/*
447 * applesmc_device_init - initialize the accelerometer. Returns zero on success 451 * applesmc_device_init - initialize the accelerometer. Can sleep.
448 * and negative error code on failure. Can sleep.
449 */ 452 */
450static int applesmc_device_init(void) 453static void applesmc_device_init(void)
451{ 454{
452 int total, ret = -ENXIO; 455 int total;
453 u8 buffer[2]; 456 u8 buffer[2];
454 457
455 if (!applesmc_accelerometer) 458 if (!applesmc_accelerometer)
456 return 0; 459 return;
457 460
458 mutex_lock(&applesmc_lock); 461 mutex_lock(&applesmc_lock);
459 462
460 for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) { 463 for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
461 if (debug)
462 printk(KERN_DEBUG "applesmc try %d\n", total);
463 if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) && 464 if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
464 (buffer[0] != 0x00 || buffer[1] != 0x00)) { 465 (buffer[0] != 0x00 || buffer[1] != 0x00))
465 if (total == INIT_TIMEOUT_MSECS) {
466 printk(KERN_DEBUG "applesmc: device has"
467 " already been initialized"
468 " (0x%02x, 0x%02x).\n",
469 buffer[0], buffer[1]);
470 } else {
471 printk(KERN_DEBUG "applesmc: device"
472 " successfully initialized"
473 " (0x%02x, 0x%02x).\n",
474 buffer[0], buffer[1]);
475 }
476 ret = 0;
477 goto out; 466 goto out;
478 }
479 buffer[0] = 0xe0; 467 buffer[0] = 0xe0;
480 buffer[1] = 0x00; 468 buffer[1] = 0x00;
481 applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2); 469 applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
@@ -486,7 +474,6 @@ static int applesmc_device_init(void)
486 474
487out: 475out:
488 mutex_unlock(&applesmc_lock); 476 mutex_unlock(&applesmc_lock);
489 return ret;
490} 477}
491 478
492/* 479/*
@@ -512,13 +499,8 @@ static int applesmc_get_fan_count(void)
512/* Device model stuff */ 499/* Device model stuff */
513static int applesmc_probe(struct platform_device *dev) 500static int applesmc_probe(struct platform_device *dev)
514{ 501{
515 int ret; 502 applesmc_device_init();
516
517 ret = applesmc_device_init();
518 if (ret)
519 return ret;
520 503
521 printk(KERN_INFO "applesmc: device successfully initialized.\n");
522 return 0; 504 return 0;
523} 505}
524 506
@@ -535,9 +517,7 @@ static int applesmc_pm_resume(struct device *dev)
535/* Reinitialize device on resume from hibernation */ 517/* Reinitialize device on resume from hibernation */
536static int applesmc_pm_restore(struct device *dev) 518static int applesmc_pm_restore(struct device *dev)
537{ 519{
538 int ret = applesmc_device_init(); 520 applesmc_device_init();
539 if (ret)
540 return ret;
541 return applesmc_pm_resume(dev); 521 return applesmc_pm_resume(dev);
542} 522}
543 523
@@ -1524,11 +1504,17 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1524 { .accelerometer = 1, .light = 1, .temperature_set = 21 }, 1504 { .accelerometer = 1, .light = 1, .temperature_set = 21 },
1525/* MacBook Pro 7,1: accelerometer, backlight and temperature set 22 */ 1505/* MacBook Pro 7,1: accelerometer, backlight and temperature set 22 */
1526 { .accelerometer = 1, .light = 1, .temperature_set = 22 }, 1506 { .accelerometer = 1, .light = 1, .temperature_set = 22 },
1507/* MacBook Air 3,1: accelerometer, backlight and temperature set 23 */
1508 { .accelerometer = 0, .light = 0, .temperature_set = 23 },
1527}; 1509};
1528 1510
1529/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1511/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
1530 * So we need to put "Apple MacBook Pro" before "Apple MacBook". */ 1512 * So we need to put "Apple MacBook Pro" before "Apple MacBook". */
1531static __initdata struct dmi_system_id applesmc_whitelist[] = { 1513static __initdata struct dmi_system_id applesmc_whitelist[] = {
1514 { applesmc_dmi_match, "Apple MacBook Air 3", {
1515 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1516 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir3") },
1517 &applesmc_dmi_data[23]},
1532 { applesmc_dmi_match, "Apple MacBook Air 2", { 1518 { applesmc_dmi_match, "Apple MacBook Air 2", {
1533 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1519 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1534 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir2") }, 1520 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir2") },
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 776aeb3019d2..508cb291f71b 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -98,6 +98,9 @@ static const unsigned short normal_i2c[] = { 0x18, 0x4c, 0x4e, I2C_CLIENT_END };
98 * value, it uses signed 8-bit values with LSB = 1 degree Celsius. 98 * value, it uses signed 8-bit values with LSB = 1 degree Celsius.
99 * For remote temperature, low and high limits, it uses signed 11-bit values 99 * For remote temperature, low and high limits, it uses signed 11-bit values
100 * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers. 100 * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers.
101 * For LM64 the actual remote diode temperature is 16 degree Celsius higher
102 * than the register reading. Remote temperature setpoints have to be
103 * adapted accordingly.
101 */ 104 */
102 105
103#define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ 106#define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \
@@ -165,6 +168,8 @@ struct lm63_data {
165 struct mutex update_lock; 168 struct mutex update_lock;
166 char valid; /* zero until following fields are valid */ 169 char valid; /* zero until following fields are valid */
167 unsigned long last_updated; /* in jiffies */ 170 unsigned long last_updated; /* in jiffies */
171 int kind;
172 int temp2_offset;
168 173
169 /* registers values */ 174 /* registers values */
170 u8 config, config_fan; 175 u8 config, config_fan;
@@ -247,16 +252,34 @@ static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dum
247 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); 252 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2);
248} 253}
249 254
250static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, 255/*
251 char *buf) 256 * There are 8bit registers for both local(temp1) and remote(temp2) sensor.
257 * For remote sensor registers temp2_offset has to be considered,
258 * for local sensor it must not.
259 * So we need separate 8bit accessors for local and remote sensor.
260 */
261static ssize_t show_local_temp8(struct device *dev,
262 struct device_attribute *devattr,
263 char *buf)
252{ 264{
253 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 265 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
254 struct lm63_data *data = lm63_update_device(dev); 266 struct lm63_data *data = lm63_update_device(dev);
255 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])); 267 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index]));
256} 268}
257 269
258static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, 270static ssize_t show_remote_temp8(struct device *dev,
259 const char *buf, size_t count) 271 struct device_attribute *devattr,
272 char *buf)
273{
274 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
275 struct lm63_data *data = lm63_update_device(dev);
276 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])
277 + data->temp2_offset);
278}
279
280static ssize_t set_local_temp8(struct device *dev,
281 struct device_attribute *dummy,
282 const char *buf, size_t count)
260{ 283{
261 struct i2c_client *client = to_i2c_client(dev); 284 struct i2c_client *client = to_i2c_client(dev);
262 struct lm63_data *data = i2c_get_clientdata(client); 285 struct lm63_data *data = i2c_get_clientdata(client);
@@ -274,7 +297,8 @@ static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
274{ 297{
275 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 298 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
276 struct lm63_data *data = lm63_update_device(dev); 299 struct lm63_data *data = lm63_update_device(dev);
277 return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])); 300 return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])
301 + data->temp2_offset);
278} 302}
279 303
280static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, 304static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
@@ -294,7 +318,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
294 int nr = attr->index; 318 int nr = attr->index;
295 319
296 mutex_lock(&data->update_lock); 320 mutex_lock(&data->update_lock);
297 data->temp11[nr] = TEMP11_TO_REG(val); 321 data->temp11[nr] = TEMP11_TO_REG(val - data->temp2_offset);
298 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 322 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
299 data->temp11[nr] >> 8); 323 data->temp11[nr] >> 8);
300 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 324 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
@@ -310,6 +334,7 @@ static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute
310{ 334{
311 struct lm63_data *data = lm63_update_device(dev); 335 struct lm63_data *data = lm63_update_device(dev);
312 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2]) 336 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2])
337 + data->temp2_offset
313 - TEMP8_FROM_REG(data->temp2_crit_hyst)); 338 - TEMP8_FROM_REG(data->temp2_crit_hyst));
314} 339}
315 340
@@ -324,7 +349,7 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *
324 long hyst; 349 long hyst;
325 350
326 mutex_lock(&data->update_lock); 351 mutex_lock(&data->update_lock);
327 hyst = TEMP8_FROM_REG(data->temp8[2]) - val; 352 hyst = TEMP8_FROM_REG(data->temp8[2]) + data->temp2_offset - val;
328 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, 353 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
329 HYST_TO_REG(hyst)); 354 HYST_TO_REG(hyst));
330 mutex_unlock(&data->update_lock); 355 mutex_unlock(&data->update_lock);
@@ -355,16 +380,21 @@ static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan,
355static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); 380static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1);
356static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); 381static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL);
357 382
358static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); 383static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_local_temp8, NULL, 0);
359static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, 384static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_local_temp8,
360 set_temp8, 1); 385 set_local_temp8, 1);
361 386
362static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); 387static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0);
363static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, 388static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11,
364 set_temp11, 1); 389 set_temp11, 1);
365static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, 390static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11,
366 set_temp11, 2); 391 set_temp11, 2);
367static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2); 392/*
393 * On LM63, temp2_crit can be set only once, which should be job
394 * of the bootloader.
395 */
396static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_remote_temp8,
397 NULL, 2);
368static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, 398static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst,
369 set_temp2_crit_hyst); 399 set_temp2_crit_hyst);
370 400
@@ -479,7 +509,12 @@ static int lm63_probe(struct i2c_client *new_client,
479 data->valid = 0; 509 data->valid = 0;
480 mutex_init(&data->update_lock); 510 mutex_init(&data->update_lock);
481 511
482 /* Initialize the LM63 chip */ 512 /* Set the device type */
513 data->kind = id->driver_data;
514 if (data->kind == lm64)
515 data->temp2_offset = 16000;
516
517 /* Initialize chip */
483 lm63_init_client(new_client); 518 lm63_init_client(new_client);
484 519
485 /* Register sysfs hooks */ 520 /* Register sysfs hooks */
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index b3841a615595..2e8f0c9458d4 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1259,6 +1259,7 @@ static int lm85_probe(struct i2c_client *client,
1259 switch (data->type) { 1259 switch (data->type) {
1260 case adm1027: 1260 case adm1027:
1261 case adt7463: 1261 case adt7463:
1262 case adt7468:
1262 case emc6d100: 1263 case emc6d100:
1263 case emc6d102: 1264 case emc6d102:
1264 data->freq_map = adm1027_freq_map; 1265 data->freq_map = adm1027_freq_map;
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index f397ce7ad598..b2074e3ba2f1 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -687,6 +687,13 @@ static int __devexit via686a_remove(struct platform_device *pdev)
687 return 0; 687 return 0;
688} 688}
689 689
690static void via686a_update_fan_div(struct via686a_data *data)
691{
692 int reg = via686a_read_value(data, VIA686A_REG_FANDIV);
693 data->fan_div[0] = (reg >> 4) & 0x03;
694 data->fan_div[1] = reg >> 6;
695}
696
690static void __devinit via686a_init_device(struct via686a_data *data) 697static void __devinit via686a_init_device(struct via686a_data *data)
691{ 698{
692 u8 reg; 699 u8 reg;
@@ -700,6 +707,9 @@ static void __devinit via686a_init_device(struct via686a_data *data)
700 via686a_write_value(data, VIA686A_REG_TEMP_MODE, 707 via686a_write_value(data, VIA686A_REG_TEMP_MODE,
701 (reg & ~VIA686A_TEMP_MODE_MASK) 708 (reg & ~VIA686A_TEMP_MODE_MASK)
702 | VIA686A_TEMP_MODE_CONTINUOUS); 709 | VIA686A_TEMP_MODE_CONTINUOUS);
710
711 /* Pre-read fan clock divisor values */
712 via686a_update_fan_div(data);
703} 713}
704 714
705static struct via686a_data *via686a_update_device(struct device *dev) 715static struct via686a_data *via686a_update_device(struct device *dev)
@@ -751,9 +761,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
751 (via686a_read_value(data, VIA686A_REG_TEMP_LOW23) & 761 (via686a_read_value(data, VIA686A_REG_TEMP_LOW23) &
752 0xc0) >> 6; 762 0xc0) >> 6;
753 763
754 i = via686a_read_value(data, VIA686A_REG_FANDIV); 764 via686a_update_fan_div(data);
755 data->fan_div[0] = (i >> 4) & 0x03;
756 data->fan_div[1] = i >> 6;
757 data->alarms = 765 data->alarms =
758 via686a_read_value(data, 766 via686a_read_value(data,
759 VIA686A_REG_ALARM1) | 767 VIA686A_REG_ALARM1) |