aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm85.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/hwmon/lm85.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r--drivers/hwmon/lm85.c173
1 files changed, 73 insertions, 100 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 6c53d987de10..b3841a615595 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -5,7 +5,7 @@
5 Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> 5 Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com>
6 Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> 6 Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de>
7 Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> 7 Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com>
8 Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> 8 Copyright (C) 2007--2009 Jean Delvare <khali@linux-fr.org>
9 9
10 Chip details at <http://www.national.com/ds/LM/LM85.pdf> 10 Chip details at <http://www.national.com/ds/LM/LM85.pdf>
11 11
@@ -38,9 +38,11 @@
38/* Addresses to scan */ 38/* Addresses to scan */
39static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 39static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
40 40
41/* Insmod parameters */ 41enum chips {
42I2C_CLIENT_INSMOD_7(lm85b, lm85c, adm1027, adt7463, adt7468, emc6d100, 42 any_chip, lm85b, lm85c,
43 emc6d102); 43 adm1027, adt7463, adt7468,
44 emc6d100, emc6d102
45};
44 46
45/* The LM85 registers */ 47/* The LM85 registers */
46 48
@@ -323,8 +325,7 @@ struct lm85_data {
323 struct lm85_zone zone[3]; 325 struct lm85_zone zone[3];
324}; 326};
325 327
326static int lm85_detect(struct i2c_client *client, int kind, 328static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info);
327 struct i2c_board_info *info);
328static int lm85_probe(struct i2c_client *client, 329static int lm85_probe(struct i2c_client *client,
329 const struct i2c_device_id *id); 330 const struct i2c_device_id *id);
330static int lm85_remove(struct i2c_client *client); 331static int lm85_remove(struct i2c_client *client);
@@ -357,7 +358,7 @@ static struct i2c_driver lm85_driver = {
357 .remove = lm85_remove, 358 .remove = lm85_remove,
358 .id_table = lm85_id, 359 .id_table = lm85_id,
359 .detect = lm85_detect, 360 .detect = lm85_detect,
360 .address_data = &addr_data, 361 .address_list = normal_i2c,
361}; 362};
362 363
363 364
@@ -1156,113 +1157,85 @@ static int lm85_is_fake(struct i2c_client *client)
1156} 1157}
1157 1158
1158/* Return 0 if detection is successful, -ENODEV otherwise */ 1159/* Return 0 if detection is successful, -ENODEV otherwise */
1159static int lm85_detect(struct i2c_client *client, int kind, 1160static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info)
1160 struct i2c_board_info *info)
1161{ 1161{
1162 struct i2c_adapter *adapter = client->adapter; 1162 struct i2c_adapter *adapter = client->adapter;
1163 int address = client->addr; 1163 int address = client->addr;
1164 const char *type_name; 1164 const char *type_name;
1165 int company, verstep;
1165 1166
1166 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 1167 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
1167 /* We need to be able to do byte I/O */ 1168 /* We need to be able to do byte I/O */
1168 return -ENODEV; 1169 return -ENODEV;
1169 } 1170 }
1170 1171
1171 /* If auto-detecting, determine the chip type */ 1172 /* Determine the chip type */
1172 if (kind < 0) { 1173 company = lm85_read_value(client, LM85_REG_COMPANY);
1173 int company = lm85_read_value(client, LM85_REG_COMPANY); 1174 verstep = lm85_read_value(client, LM85_REG_VERSTEP);
1174 int verstep = lm85_read_value(client, LM85_REG_VERSTEP); 1175
1175 1176 dev_dbg(&adapter->dev, "Detecting device at 0x%02x with "
1176 dev_dbg(&adapter->dev, "Detecting device at 0x%02x with " 1177 "COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
1177 "COMPANY: 0x%02x and VERSTEP: 0x%02x\n", 1178 address, company, verstep);
1178 address, company, verstep); 1179
1179 1180 /* All supported chips have the version in common */
1180 /* All supported chips have the version in common */ 1181 if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC &&
1181 if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC && 1182 (verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) {
1182 (verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) { 1183 dev_dbg(&adapter->dev,
1183 dev_dbg(&adapter->dev, "Autodetection failed: " 1184 "Autodetection failed: unsupported version\n");
1184 "unsupported version\n"); 1185 return -ENODEV;
1185 return -ENODEV; 1186 }
1186 } 1187 type_name = "lm85";
1187 kind = any_chip; 1188
1188 1189 /* Now, refine the detection */
1189 /* Now, refine the detection */ 1190 if (company == LM85_COMPANY_NATIONAL) {
1190 if (company == LM85_COMPANY_NATIONAL) { 1191 switch (verstep) {
1191 switch (verstep) { 1192 case LM85_VERSTEP_LM85C:
1192 case LM85_VERSTEP_LM85C: 1193 type_name = "lm85c";
1193 kind = lm85c; 1194 break;
1194 break; 1195 case LM85_VERSTEP_LM85B:
1195 case LM85_VERSTEP_LM85B: 1196 type_name = "lm85b";
1196 kind = lm85b; 1197 break;
1197 break; 1198 case LM85_VERSTEP_LM96000_1:
1198 case LM85_VERSTEP_LM96000_1: 1199 case LM85_VERSTEP_LM96000_2:
1199 case LM85_VERSTEP_LM96000_2: 1200 /* Check for Winbond WPCD377I */
1200 /* Check for Winbond WPCD377I */ 1201 if (lm85_is_fake(client)) {
1201 if (lm85_is_fake(client)) { 1202 dev_dbg(&adapter->dev,
1202 dev_dbg(&adapter->dev, 1203 "Found Winbond WPCD377I, ignoring\n");
1203 "Found Winbond WPCD377I, " 1204 return -ENODEV;
1204 "ignoring\n");
1205 return -ENODEV;
1206 }
1207 break;
1208 }
1209 } else if (company == LM85_COMPANY_ANALOG_DEV) {
1210 switch (verstep) {
1211 case LM85_VERSTEP_ADM1027:
1212 kind = adm1027;
1213 break;
1214 case LM85_VERSTEP_ADT7463:
1215 case LM85_VERSTEP_ADT7463C:
1216 kind = adt7463;
1217 break;
1218 case LM85_VERSTEP_ADT7468_1:
1219 case LM85_VERSTEP_ADT7468_2:
1220 kind = adt7468;
1221 break;
1222 }
1223 } else if (company == LM85_COMPANY_SMSC) {
1224 switch (verstep) {
1225 case LM85_VERSTEP_EMC6D100_A0:
1226 case LM85_VERSTEP_EMC6D100_A1:
1227 /* Note: we can't tell a '100 from a '101 */
1228 kind = emc6d100;
1229 break;
1230 case LM85_VERSTEP_EMC6D102:
1231 kind = emc6d102;
1232 break;
1233 } 1205 }
1234 } else { 1206 break;
1235 dev_dbg(&adapter->dev, "Autodetection failed: " 1207 }
1236 "unknown vendor\n"); 1208 } else if (company == LM85_COMPANY_ANALOG_DEV) {
1237 return -ENODEV; 1209 switch (verstep) {
1210 case LM85_VERSTEP_ADM1027:
1211 type_name = "adm1027";
1212 break;
1213 case LM85_VERSTEP_ADT7463:
1214 case LM85_VERSTEP_ADT7463C:
1215 type_name = "adt7463";
1216 break;
1217 case LM85_VERSTEP_ADT7468_1:
1218 case LM85_VERSTEP_ADT7468_2:
1219 type_name = "adt7468";
1220 break;
1221 }
1222 } else if (company == LM85_COMPANY_SMSC) {
1223 switch (verstep) {
1224 case LM85_VERSTEP_EMC6D100_A0:
1225 case LM85_VERSTEP_EMC6D100_A1:
1226 /* Note: we can't tell a '100 from a '101 */
1227 type_name = "emc6d100";
1228 break;
1229 case LM85_VERSTEP_EMC6D102:
1230 type_name = "emc6d102";
1231 break;
1238 } 1232 }
1233 } else {
1234 dev_dbg(&adapter->dev,
1235 "Autodetection failed: unknown vendor\n");
1236 return -ENODEV;
1239 } 1237 }
1240 1238
1241 switch (kind) {
1242 case lm85b:
1243 type_name = "lm85b";
1244 break;
1245 case lm85c:
1246 type_name = "lm85c";
1247 break;
1248 case adm1027:
1249 type_name = "adm1027";
1250 break;
1251 case adt7463:
1252 type_name = "adt7463";
1253 break;
1254 case adt7468:
1255 type_name = "adt7468";
1256 break;
1257 case emc6d100:
1258 type_name = "emc6d100";
1259 break;
1260 case emc6d102:
1261 type_name = "emc6d102";
1262 break;
1263 default:
1264 type_name = "lm85";
1265 }
1266 strlcpy(info->type, type_name, I2C_NAME_SIZE); 1239 strlcpy(info->type, type_name, I2C_NAME_SIZE);
1267 1240
1268 return 0; 1241 return 0;