aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/hwmon/max665012
-rw-r--r--drivers/hwmon/max6650.c34
2 files changed, 36 insertions, 10 deletions
diff --git a/Documentation/hwmon/max6650 b/Documentation/hwmon/max6650
index b26fef5f950e..58d9644a2bde 100644
--- a/Documentation/hwmon/max6650
+++ b/Documentation/hwmon/max6650
@@ -2,10 +2,14 @@ Kernel driver max6650
2===================== 2=====================
3 3
4Supported chips: 4Supported chips:
5 * Maxim 6650 / 6651 5 * Maxim MAX6650
6 Prefix: 'max6650' 6 Prefix: 'max6650'
7 Addresses scanned: none 7 Addresses scanned: none
8 Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf 8 Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf
9 * Maxim MAX6651
10 Prefix: 'max6651'
11 Addresses scanned: none
12 Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf
9 13
10Authors: 14Authors:
11 Hans J. Koch <hjk@hansjkoch.de> 15 Hans J. Koch <hjk@hansjkoch.de>
@@ -15,10 +19,10 @@ Authors:
15Description 19Description
16----------- 20-----------
17 21
18This driver implements support for the Maxim 6650/6651 22This driver implements support for the Maxim MAX6650 and MAX6651.
19 23
20The 2 devices are very similar, but the Maxim 6550 has a reduced feature 24The 2 devices are very similar, but the MAX6550 has a reduced feature
21set, e.g. only one fan-input, instead of 4 for the 6651. 25set, e.g. only one fan-input, instead of 4 for the MAX6651.
22 26
23The driver is not able to distinguish between the 2 devices. 27The driver is not able to distinguish between the 2 devices.
24 28
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index cced18626174..ece3aafa54b3 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -116,7 +116,8 @@ static struct max6650_data *max6650_update_device(struct device *dev);
116 */ 116 */
117 117
118static const struct i2c_device_id max6650_id[] = { 118static const struct i2c_device_id max6650_id[] = {
119 { "max6650", 0 }, 119 { "max6650", 1 },
120 { "max6651", 4 },
120 { } 121 { }
121}; 122};
122MODULE_DEVICE_TABLE(i2c, max6650_id); 123MODULE_DEVICE_TABLE(i2c, max6650_id);
@@ -138,6 +139,7 @@ struct max6650_data
138{ 139{
139 struct device *hwmon_dev; 140 struct device *hwmon_dev;
140 struct mutex update_lock; 141 struct mutex update_lock;
142 int nr_fans;
141 char valid; /* zero until following fields are valid */ 143 char valid; /* zero until following fields are valid */
142 unsigned long last_updated; /* in jiffies */ 144 unsigned long last_updated; /* in jiffies */
143 145
@@ -489,9 +491,6 @@ static mode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a,
489 491
490static struct attribute *max6650_attrs[] = { 492static struct attribute *max6650_attrs[] = {
491 &sensor_dev_attr_fan1_input.dev_attr.attr, 493 &sensor_dev_attr_fan1_input.dev_attr.attr,
492 &sensor_dev_attr_fan2_input.dev_attr.attr,
493 &sensor_dev_attr_fan3_input.dev_attr.attr,
494 &sensor_dev_attr_fan4_input.dev_attr.attr,
495 &dev_attr_fan1_target.attr, 494 &dev_attr_fan1_target.attr,
496 &dev_attr_fan1_div.attr, 495 &dev_attr_fan1_div.attr,
497 &dev_attr_pwm1_enable.attr, 496 &dev_attr_pwm1_enable.attr,
@@ -509,6 +508,17 @@ static struct attribute_group max6650_attr_grp = {
509 .is_visible = max6650_attrs_visible, 508 .is_visible = max6650_attrs_visible,
510}; 509};
511 510
511static struct attribute *max6651_attrs[] = {
512 &sensor_dev_attr_fan2_input.dev_attr.attr,
513 &sensor_dev_attr_fan3_input.dev_attr.attr,
514 &sensor_dev_attr_fan4_input.dev_attr.attr,
515 NULL
516};
517
518static const struct attribute_group max6651_attr_grp = {
519 .attrs = max6651_attrs,
520};
521
512/* 522/*
513 * Real code 523 * Real code
514 */ 524 */
@@ -526,6 +536,7 @@ static int max6650_probe(struct i2c_client *client,
526 536
527 i2c_set_clientdata(client, data); 537 i2c_set_clientdata(client, data);
528 mutex_init(&data->update_lock); 538 mutex_init(&data->update_lock);
539 data->nr_fans = id->driver_data;
529 540
530 /* 541 /*
531 * Initialize the max6650 chip 542 * Initialize the max6650 chip
@@ -537,6 +548,12 @@ static int max6650_probe(struct i2c_client *client,
537 err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp); 548 err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp);
538 if (err) 549 if (err)
539 goto err_free; 550 goto err_free;
551 /* 3 additional fan inputs for the MAX6651 */
552 if (data->nr_fans == 4) {
553 err = sysfs_create_group(&client->dev.kobj, &max6651_attr_grp);
554 if (err)
555 goto err_remove;
556 }
540 557
541 data->hwmon_dev = hwmon_device_register(&client->dev); 558 data->hwmon_dev = hwmon_device_register(&client->dev);
542 if (!IS_ERR(data->hwmon_dev)) 559 if (!IS_ERR(data->hwmon_dev))
@@ -544,6 +561,9 @@ static int max6650_probe(struct i2c_client *client,
544 561
545 err = PTR_ERR(data->hwmon_dev); 562 err = PTR_ERR(data->hwmon_dev);
546 dev_err(&client->dev, "error registering hwmon device.\n"); 563 dev_err(&client->dev, "error registering hwmon device.\n");
564 if (data->nr_fans == 4)
565 sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp);
566err_remove:
547 sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); 567 sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp);
548err_free: 568err_free:
549 kfree(data); 569 kfree(data);
@@ -554,8 +574,10 @@ static int max6650_remove(struct i2c_client *client)
554{ 574{
555 struct max6650_data *data = i2c_get_clientdata(client); 575 struct max6650_data *data = i2c_get_clientdata(client);
556 576
557 sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp);
558 hwmon_device_unregister(data->hwmon_dev); 577 hwmon_device_unregister(data->hwmon_dev);
578 if (data->nr_fans == 4)
579 sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp);
580 sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp);
559 kfree(data); 581 kfree(data);
560 return 0; 582 return 0;
561} 583}
@@ -668,7 +690,7 @@ static struct max6650_data *max6650_update_device(struct device *dev)
668 MAX6650_REG_SPEED); 690 MAX6650_REG_SPEED);
669 data->config = i2c_smbus_read_byte_data(client, 691 data->config = i2c_smbus_read_byte_data(client,
670 MAX6650_REG_CONFIG); 692 MAX6650_REG_CONFIG);
671 for (i = 0; i < 4; i++) { 693 for (i = 0; i < data->nr_fans; i++) {
672 data->tach[i] = i2c_smbus_read_byte_data(client, 694 data->tach[i] = i2c_smbus_read_byte_data(client,
673 tach_reg[i]); 695 tach_reg[i]);
674 } 696 }