From b6becb237ee05307338b78037ce92a25ceb39634 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 3 Oct 2009 10:38:14 +0000 Subject: [PATCH] Add detection for National Semiconductor LM73. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5779 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/CHANGES b/CHANGES index 6ebb2b0d..bf016873 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ SVN-HEAD Drop AMD K10 detection (unreliable sensors) Add detection for AMD Family 11h thermal sensors Add detection for Intel Atom thermal sensors + Add detection for National Semiconductor LM73 sysconfig-lm_sensors-convert: Fix exit code 3.1.1 (2009-06-21) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 93366885..9ff5f0a1 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -947,6 +947,11 @@ use vars qw(@i2c_adapter_names); driver => "lm63", # Not yet i2c_addrs => [0x4c], i2c_detect => sub { lm63_detect(@_, 2); }, + }, { + name => "National Semiconductor LM73", + driver => "lm73", + i2c_addrs => [0x48..0x4a, 0x4c..0x4e], + i2c_detect => sub { lm73_detect(@_); }, }, { name => "National Semiconductor LM92", driver => "lm92", @@ -3585,6 +3590,37 @@ sub lm75_detect return 3; } +# Registers used: +# 0x00: Temperature +# 0x01: Configuration +# 0x02: High Limit +# 0x03: Low Limit +# 0x04: Status +# 0x07: Manufacturer ID and Product ID +sub lm73_detect +{ + my ($file, $addr) = @_; + + my $conf = i2c_smbus_read_byte_data($file, 0x01); + my $status = i2c_smbus_read_byte_data($file, 0x04); + + # Bits that always return 0 + return if ($conf & 0x0c) or ($status & 0x10); + + return if i2c_smbus_read_word_data($file, 0x07) != 0x9001; + + # Make sure the chip supports SMBus read word transactions + my $cur = i2c_smbus_read_word_data($file, 0x00); + return if $cur < 0; + my $high = i2c_smbus_read_word_data($file, 0x02); + return if $high < 0; + my $low = i2c_smbus_read_word_data($file, 0x03); + return if $low < 0; + return if ($cur & 0x0300) or (($high | $low) & 0x1f00); + + return 3; +} + # Registers used: # 0x00: Temperature # 0x01: Configuration