2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-31 22:35:23 +00:00

sensors-detect: Add TMP42x chip detection

This patch adds detection for TI's TMP421, TMP422 and TMP423 chips to
sensors-detect. Only the manufactory ID and the device ID is used for
detection. I hope this is reliable enough.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5754 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Andre Prendel
2009-07-14 20:14:53 +00:00
parent f69dbc887a
commit 4cf83be1b1
2 changed files with 36 additions and 0 deletions

View File

@@ -907,6 +907,21 @@ use vars qw(@i2c_adapter_names);
driver => "tmp401",
i2c_addrs => [0x4c..0x4e],
i2c_detect => sub { lm90_detect(@_, 10); },
}, {
name => "Texas Instruments TMP421",
driver => "tmp421",
i2c_addrs => [0x2a, 0x4c..0x4f], # 0x1c-0x1f not probed.
i2c_detect => sub { tmp42x_detect(@_, 0); },
}, {
name => "Texas Instruments TMP422",
driver => "tmp421",
i2c_addrs => [0x4c..0x4f],
i2c_detect => sub { tmp42x_detect(@_, 1); },
}, {
name => "Texas Instruments TMP423",
driver => "tmp421",
i2c_addrs => [0x4c, 0x4d],
i2c_detect => sub { tmp42x_detect(@_, 2); },
}, {
name => "National Semiconductor LM95231",
driver => "to-be-written",
@@ -3906,6 +3921,26 @@ sub lm90_detect
return;
}
# Chip to detect: 0 = TMP421, 1 = TMP422, 2 = TMP423
# Registers used:
# 0xfe: Manufactorer ID
# 0xff: Device ID
sub tmp42x_detect()
{
my ($file, $addr, $chip) = @_;
my $mid = i2c_smbus_read_byte_data($file, 0xfe);
my $cid = i2c_smbus_read_byte_data($file, 0xff);
return if ($mid != 0x55);
return 6 if ($chip == 0 && $cid == 0x21); # TMP421
return 6 if ($chip == 1 && $cid == 0x22); # TMP422
return 6 if ($chip == 2 && $cid == 0x23); # TMP423
return;
}
# Registers used:
# 0x03: Configuration (no low nibble, returns the previous low nibble)
# 0x04: Conversion rate