aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/adm1021.c76
1 files changed, 25 insertions, 51 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index afc594318125..33acf29531af 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -288,9 +288,8 @@ static int adm1021_detect(struct i2c_client *client, int kind,
288 struct i2c_board_info *info) 288 struct i2c_board_info *info)
289{ 289{
290 struct i2c_adapter *adapter = client->adapter; 290 struct i2c_adapter *adapter = client->adapter;
291 int i; 291 const char *type_name;
292 const char *type_name = ""; 292 int conv_rate, status, config, man_id, dev_id;
293 int conv_rate, status, config;
294 293
295 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 294 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
296 pr_debug("adm1021: detect failed, " 295 pr_debug("adm1021: detect failed, "
@@ -303,62 +302,37 @@ static int adm1021_detect(struct i2c_client *client, int kind,
303 ADM1021_REG_CONV_RATE_R); 302 ADM1021_REG_CONV_RATE_R);
304 config = i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R); 303 config = i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R);
305 304
306 /* Now, we do the remaining detection. */ 305 /* Check unused bits */
307 if (kind < 0) { 306 if ((status & 0x03) || (config & 0x3F) || (conv_rate & 0xF8)) {
308 if ((status & 0x03) != 0x00 || (config & 0x3F) != 0x00 307 pr_debug("adm1021: detect failed, chip not detected!\n");
309 || (conv_rate & 0xF8) != 0x00) { 308 return -ENODEV;
310 pr_debug("adm1021: detect failed, "
311 "chip not detected!\n");
312 return -ENODEV;
313 }
314 } 309 }
315 310
316 /* Determine the chip type. */ 311 /* Determine the chip type. */
317 if (kind <= 0) { 312 man_id = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID);
318 i = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID); 313 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 314
345 if (kind == max1617) { 315 if (man_id == 0x4d && dev_id == 0x01)
346 type_name = "max1617";
347 } else if (kind == max1617a) {
348 type_name = "max1617a"; 316 type_name = "max1617a";
349 } else if (kind == adm1021) { 317 else if (man_id == 0x41) {
350 type_name = "adm1021"; 318 if ((dev_id & 0xF0) == 0x30)
351 } else if (kind == adm1023) { 319 type_name = "adm1023";
352 type_name = "adm1023"; 320 else
353 } else if (kind == thmc10) { 321 type_name = "adm1021";
322 } else if (man_id == 0x49)
354 type_name = "thmc10"; 323 type_name = "thmc10";
355 } else if (kind == lm84) { 324 else if (man_id == 0x23)
356 type_name = "lm84";
357 } else if (kind == gl523sm) {
358 type_name = "gl523sm"; 325 type_name = "gl523sm";
359 } else if (kind == mc1066) { 326 else if (man_id == 0x54)
360 type_name = "mc1066"; 327 type_name = "mc1066";
361 } 328 /* LM84 Mfr ID in a different place, and it has more unused bits */
329 else if (conv_rate == 0x00
330 && (config & 0x7F) == 0x00
331 && (status & 0xAB) == 0x00)
332 type_name = "lm84";
333 else
334 type_name = "max1617";
335
362 pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n", 336 pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n",
363 type_name, i2c_adapter_id(adapter), client->addr); 337 type_name, i2c_adapter_id(adapter), client->addr);
364 strlcpy(info->type, type_name, I2C_NAME_SIZE); 338 strlcpy(info->type, type_name, I2C_NAME_SIZE);