From 4cf83be1b1df02e17d0977f026a54374d0f8a11b Mon Sep 17 00:00:00 2001 From: Andre Prendel Date: Tue, 14 Jul 2009 20:14:53 +0000 Subject: [PATCH] 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 --- CHANGES | 1 + prog/detect/sensors-detect | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/CHANGES b/CHANGES index 7c8f0430..75f6223a 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ SVN-HEAD sensors-detect: Refer to tmp401 driver if TMP411 is detected Clean up the discovery of i2c adapters Report unsupported Access Bus adapters + Add detection for TI's TMP421, TMP422 and TMP423 chips 3.1.1 (2009-06-21) isadump: Use geteuid instead of getuid so that setuid bit works diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 54ba6c9e..bcb0c8b7 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -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