aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/asb100.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/asb100.c')
-rw-r--r--drivers/hwmon/asb100.c66
1 files changed, 22 insertions, 44 deletions
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 8acf82977e7b..7dada559b3a1 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -51,9 +51,6 @@
51/* I2C addresses to scan */ 51/* I2C addresses to scan */
52static const unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; 52static const unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END };
53 53
54/* Insmod parameters */
55I2C_CLIENT_INSMOD_1(asb100);
56
57static unsigned short force_subclients[4]; 54static unsigned short force_subclients[4];
58module_param_array(force_subclients, short, NULL, 0); 55module_param_array(force_subclients, short, NULL, 0);
59MODULE_PARM_DESC(force_subclients, "List of subclient addresses: " 56MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
@@ -209,14 +206,14 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 val);
209 206
210static int asb100_probe(struct i2c_client *client, 207static int asb100_probe(struct i2c_client *client,
211 const struct i2c_device_id *id); 208 const struct i2c_device_id *id);
212static int asb100_detect(struct i2c_client *client, int kind, 209static int asb100_detect(struct i2c_client *client,
213 struct i2c_board_info *info); 210 struct i2c_board_info *info);
214static int asb100_remove(struct i2c_client *client); 211static int asb100_remove(struct i2c_client *client);
215static struct asb100_data *asb100_update_device(struct device *dev); 212static struct asb100_data *asb100_update_device(struct device *dev);
216static void asb100_init_client(struct i2c_client *client); 213static void asb100_init_client(struct i2c_client *client);
217 214
218static const struct i2c_device_id asb100_id[] = { 215static const struct i2c_device_id asb100_id[] = {
219 { "asb100", asb100 }, 216 { "asb100", 0 },
220 { } 217 { }
221}; 218};
222MODULE_DEVICE_TABLE(i2c, asb100_id); 219MODULE_DEVICE_TABLE(i2c, asb100_id);
@@ -230,7 +227,7 @@ static struct i2c_driver asb100_driver = {
230 .remove = asb100_remove, 227 .remove = asb100_remove,
231 .id_table = asb100_id, 228 .id_table = asb100_id,
232 .detect = asb100_detect, 229 .detect = asb100_detect,
233 .address_data = &addr_data, 230 .address_list = normal_i2c,
234}; 231};
235 232
236/* 7 Voltages */ 233/* 7 Voltages */
@@ -697,10 +694,11 @@ ERROR_SC_2:
697} 694}
698 695
699/* Return 0 if detection is successful, -ENODEV otherwise */ 696/* Return 0 if detection is successful, -ENODEV otherwise */
700static int asb100_detect(struct i2c_client *client, int kind, 697static int asb100_detect(struct i2c_client *client,
701 struct i2c_board_info *info) 698 struct i2c_board_info *info)
702{ 699{
703 struct i2c_adapter *adapter = client->adapter; 700 struct i2c_adapter *adapter = client->adapter;
701 int val1, val2;
704 702
705 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 703 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
706 pr_debug("asb100.o: detect failed, " 704 pr_debug("asb100.o: detect failed, "
@@ -708,50 +706,30 @@ static int asb100_detect(struct i2c_client *client, int kind,
708 return -ENODEV; 706 return -ENODEV;
709 } 707 }
710 708
711 /* The chip may be stuck in some other bank than bank 0. This may 709 val1 = i2c_smbus_read_byte_data(client, ASB100_REG_BANK);
712 make reading other information impossible. Specify a force=... or 710 val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN);
713 force_*=... parameter, and the chip will be reset to the right
714 bank. */
715 if (kind < 0) {
716
717 int val1 = i2c_smbus_read_byte_data(client, ASB100_REG_BANK);
718 int val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN);
719
720 /* If we're in bank 0 */
721 if ((!(val1 & 0x07)) &&
722 /* Check for ASB100 ID (low byte) */
723 (((!(val1 & 0x80)) && (val2 != 0x94)) ||
724 /* Check for ASB100 ID (high byte ) */
725 ((val1 & 0x80) && (val2 != 0x06)))) {
726 pr_debug("asb100.o: detect failed, "
727 "bad chip id 0x%02x!\n", val2);
728 return -ENODEV;
729 }
730 711
731 } /* kind < 0 */ 712 /* If we're in bank 0 */
713 if ((!(val1 & 0x07)) &&
714 /* Check for ASB100 ID (low byte) */
715 (((!(val1 & 0x80)) && (val2 != 0x94)) ||
716 /* Check for ASB100 ID (high byte ) */
717 ((val1 & 0x80) && (val2 != 0x06)))) {
718 pr_debug("asb100: detect failed, bad chip id 0x%02x!\n", val2);
719 return -ENODEV;
720 }
732 721
733 /* We have either had a force parameter, or we have already detected 722 /* Put it now into bank 0 and Vendor ID High Byte */
734 Winbond. Put it now into bank 0 and Vendor ID High Byte */
735 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 723 i2c_smbus_write_byte_data(client, ASB100_REG_BANK,
736 (i2c_smbus_read_byte_data(client, ASB100_REG_BANK) & 0x78) 724 (i2c_smbus_read_byte_data(client, ASB100_REG_BANK) & 0x78)
737 | 0x80); 725 | 0x80);
738 726
739 /* Determine the chip type. */ 727 /* Determine the chip type. */
740 if (kind <= 0) { 728 val1 = i2c_smbus_read_byte_data(client, ASB100_REG_WCHIPID);
741 int val1 = i2c_smbus_read_byte_data(client, ASB100_REG_WCHIPID); 729 val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN);
742 int val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); 730
743 731 if (val1 != 0x31 || val2 != 0x06)
744 if ((val1 == 0x31) && (val2 == 0x06)) 732 return -ENODEV;
745 kind = asb100;
746 else {
747 if (kind == 0)
748 dev_warn(&adapter->dev, "ignoring "
749 "'force' parameter for unknown chip "
750 "at adapter %d, address 0x%02x.\n",
751 i2c_adapter_id(adapter), client->addr);
752 return -ENODEV;
753 }
754 }
755 733
756 strlcpy(info->type, "asb100", I2C_NAME_SIZE); 734 strlcpy(info->type, "asb100", I2C_NAME_SIZE);
757 735