aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1021.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/adm1021.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r--drivers/hwmon/adm1021.c87
1 files changed, 30 insertions, 57 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index afc594318125..1ad0a885c5a5 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -34,9 +34,8 @@
34static const unsigned short normal_i2c[] = { 34static const unsigned short normal_i2c[] = {
35 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; 35 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
36 36
37/* Insmod parameters */ 37enum chips {
38I2C_CLIENT_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, 38 adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066 };
39 mc1066);
40 39
41/* adm1021 constants specified below */ 40/* adm1021 constants specified below */
42 41
@@ -97,7 +96,7 @@ struct adm1021_data {
97 96
98static int adm1021_probe(struct i2c_client *client, 97static int adm1021_probe(struct i2c_client *client,
99 const struct i2c_device_id *id); 98 const struct i2c_device_id *id);
100static int adm1021_detect(struct i2c_client *client, int kind, 99static int adm1021_detect(struct i2c_client *client,
101 struct i2c_board_info *info); 100 struct i2c_board_info *info);
102static void adm1021_init_client(struct i2c_client *client); 101static void adm1021_init_client(struct i2c_client *client);
103static int adm1021_remove(struct i2c_client *client); 102static int adm1021_remove(struct i2c_client *client);
@@ -130,7 +129,7 @@ static struct i2c_driver adm1021_driver = {
130 .remove = adm1021_remove, 129 .remove = adm1021_remove,
131 .id_table = adm1021_id, 130 .id_table = adm1021_id,
132 .detect = adm1021_detect, 131 .detect = adm1021_detect,
133 .address_data = &addr_data, 132 .address_list = normal_i2c,
134}; 133};
135 134
136static ssize_t show_temp(struct device *dev, 135static ssize_t show_temp(struct device *dev,
@@ -284,13 +283,12 @@ static const struct attribute_group adm1021_group = {
284}; 283};
285 284
286/* Return 0 if detection is successful, -ENODEV otherwise */ 285/* Return 0 if detection is successful, -ENODEV otherwise */
287static int adm1021_detect(struct i2c_client *client, int kind, 286static int adm1021_detect(struct i2c_client *client,
288 struct i2c_board_info *info) 287 struct i2c_board_info *info)
289{ 288{
290 struct i2c_adapter *adapter = client->adapter; 289 struct i2c_adapter *adapter = client->adapter;
291 int i; 290 const char *type_name;
292 const char *type_name = ""; 291 int conv_rate, status, config, man_id, dev_id;
293 int conv_rate, status, config;
294 292
295 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 293 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
296 pr_debug("adm1021: detect failed, " 294 pr_debug("adm1021: detect failed, "
@@ -303,62 +301,37 @@ static int adm1021_detect(struct i2c_client *client, int kind,
303 ADM1021_REG_CONV_RATE_R); 301 ADM1021_REG_CONV_RATE_R);
304 config = i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R); 302 config = i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R);
305 303
306 /* Now, we do the remaining detection. */ 304 /* Check unused bits */
307 if (kind < 0) { 305 if ((status & 0x03) || (config & 0x3F) || (conv_rate & 0xF8)) {
308 if ((status & 0x03) != 0x00 || (config & 0x3F) != 0x00 306 pr_debug("adm1021: detect failed, chip not detected!\n");
309 || (conv_rate & 0xF8) != 0x00) { 307 return -ENODEV;
310 pr_debug("adm1021: detect failed, "
311 "chip not detected!\n");
312 return -ENODEV;
313 }
314 } 308 }
315 309
316 /* Determine the chip type. */ 310 /* Determine the chip type. */
317 if (kind <= 0) { 311 man_id = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID);
318 i = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID); 312 dev_id = i2c_smbus_read_byte_data(client, ADM1021_REG_DEV_ID);
319 if (i == 0x41)
320 if ((i2c_smbus_read_byte_data(client,
321 ADM1021_REG_DEV_ID) & 0xF0) == 0x30)
322 kind = adm1023;
323 else
324 kind = adm1021;
325 else if (i == 0x49)
326 kind = thmc10;
327 else if (i == 0x23)
328 kind = gl523sm;
329 else if ((i == 0x4d) &&
330 (i2c_smbus_read_byte_data(client,
331 ADM1021_REG_DEV_ID) == 0x01))
332 kind = max1617a;
333 else if (i == 0x54)
334 kind = mc1066;
335 /* LM84 Mfr ID in a different place, and it has more unused bits */
336 else if (conv_rate == 0x00
337 && (kind == 0 /* skip extra detection */
338 || ((config & 0x7F) == 0x00
339 && (status & 0xAB) == 0x00)))
340 kind = lm84;
341 else
342 kind = max1617;
343 }
344 313
345 if (kind == max1617) { 314 if (man_id == 0x4d && dev_id == 0x01)
346 type_name = "max1617";
347 } else if (kind == max1617a) {
348 type_name = "max1617a"; 315 type_name = "max1617a";
349 } else if (kind == adm1021) { 316 else if (man_id == 0x41) {
350 type_name = "adm1021"; 317 if ((dev_id & 0xF0) == 0x30)
351 } else if (kind == adm1023) { 318 type_name = "adm1023";
352 type_name = "adm1023"; 319 else
353 } else if (kind == thmc10) { 320 type_name = "adm1021";
321 } else if (man_id == 0x49)
354 type_name = "thmc10"; 322 type_name = "thmc10";
355 } else if (kind == lm84) { 323 else if (man_id == 0x23)
356 type_name = "lm84";
357 } else if (kind == gl523sm) {
358 type_name = "gl523sm"; 324 type_name = "gl523sm";
359 } else if (kind == mc1066) { 325 else if (man_id == 0x54)
360 type_name = "mc1066"; 326 type_name = "mc1066";
361 } 327 /* LM84 Mfr ID in a different place, and it has more unused bits */
328 else if (conv_rate == 0x00
329 && (config & 0x7F) == 0x00
330 && (status & 0xAB) == 0x00)
331 type_name = "lm84";
332 else
333 type_name = "max1617";
334
362 pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n", 335 pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n",
363 type_name, i2c_adapter_id(adapter), client->addr); 336 type_name, i2c_adapter_id(adapter), client->addr);
364 strlcpy(info->type, type_name, I2C_NAME_SIZE); 337 strlcpy(info->type, type_name, I2C_NAME_SIZE);