332
332
man_id = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID);
333
333
dev_id = i2c_smbus_read_byte_data(client, ADM1021_REG_DEV_ID);
335
if (man_id < 0 || dev_id < 0)
335
338
if (man_id == 0x4d && dev_id == 0x01)
336
339
type_name = "max1617a";
337
340
else if (man_id == 0x41) {
338
341
if ((dev_id & 0xF0) == 0x30)
339
342
type_name = "adm1023";
343
else if ((dev_id & 0xF0) == 0x00)
344
type_name = "adm1021";
341
type_name = "adm1021";
342
347
} else if (man_id == 0x49)
343
348
type_name = "thmc10";
344
349
else if (man_id == 0x23)
345
350
type_name = "gl523sm";
346
351
else if (man_id == 0x54)
347
352
type_name = "mc1066";
348
/* LM84 Mfr ID in a different place, and it has more unused bits */
349
else if (conv_rate == 0x00
350
&& (config & 0x7F) == 0x00
351
&& (status & 0xAB) == 0x00)
354
type_name = "max1617";
354
int lte, rte, lhi, rhi, llo, rlo;
356
/* extra checks for LM84 and MAX1617 to avoid misdetections */
358
llo = i2c_smbus_read_byte_data(client, ADM1021_REG_THYST_R(0));
359
rlo = i2c_smbus_read_byte_data(client, ADM1021_REG_THYST_R(1));
361
/* fail if any of the additional register reads failed */
362
if (llo < 0 || rlo < 0)
365
lte = i2c_smbus_read_byte_data(client, ADM1021_REG_TEMP(0));
366
rte = i2c_smbus_read_byte_data(client, ADM1021_REG_TEMP(1));
367
lhi = i2c_smbus_read_byte_data(client, ADM1021_REG_TOS_R(0));
368
rhi = i2c_smbus_read_byte_data(client, ADM1021_REG_TOS_R(1));
371
* Fail for negative temperatures and negative high limits.
372
* This check also catches read errors on the tested registers.
374
if ((s8)lte < 0 || (s8)rte < 0 || (s8)lhi < 0 || (s8)rhi < 0)
377
/* fail if all registers hold the same value */
378
if (lte == rte && lte == lhi && lte == rhi && lte == llo
383
* LM84 Mfr ID is in a different place,
384
* and it has more unused bits.
386
if (conv_rate == 0x00
387
&& (config & 0x7F) == 0x00
388
&& (status & 0xAB) == 0x00) {
391
/* fail if low limits are larger than high limits */
392
if ((s8)llo > lhi || (s8)rlo > rhi)
394
type_name = "max1617";
356
398
pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n",
357
399
type_name, i2c_adapter_id(adapter), client->addr);