Changeset 6018

Show
Ignore:
Timestamp:
01/31/12 13:55:39 (4 months ago)
Author:
khali
Message:

Add detection of the National Semiconductor (now Texas Instruments)
LM96080. It is functionally compatible with the LM80 but detection is
completely different.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r6017 r6018  
    1919                  Add detection of GMT G781 
    2020                  Properly handle Super-I/O chips without logical device 
     21                  Add detection of National Semiconductor LM96080 
    2122 
    22233.3.1 (2011-07-21) 
  • lm-sensors/trunk/prog/detect/sensors-detect

    r6016 r6018  
    541541                driver => "lm80", 
    542542                i2c_addrs => [0x28..0x2f], 
    543                 i2c_detect => sub { lm80_detect(@_); }, 
     543                i2c_detect => sub { lm80_detect(@_, 0); }, 
     544        }, { 
     545                name => "National Semiconductor LM96080", 
     546                driver => "lm80", 
     547                i2c_addrs => [0x28..0x2f], 
     548                i2c_detect => sub { lm80_detect(@_, 1); }, 
    544549        }, { 
    545550                name => "National Semiconductor LM85", 
     
    42604265} 
    42614266 
     4267# Chip to detect: 0 = LM80, 1 = LM96080 
    42624268# Registers used: 
    42634269#   0x00: Configuration register 
    42644270#   0x02: Interrupt state register 
    4265 #   0x2a-0x3d: Limits registers 
    4266 # This one is easily misdetected since it doesn't provide identification 
     4271#   0x07: Converstion rate register (LM96080 only) 
     4272#   0x2a-0x3d: Limits registers (LM80 only) 
     4273#   0x3e: Manufacturer's ID register (LM96080 only) 
     4274#   0x3f: Steppind/die revision ID register (LM96080 only) 
     4275# The LM80 is easily misdetected since it doesn't provide identification 
    42674276# registers. So we have to use some tricks: 
    42684277#   - 6-bit addressing, so limits readings modulo 0x40 should be unchanged 
     
    42774286sub lm80_detect 
    42784287{ 
    4279         my ($file, $addr) = @_; 
     4288        my ($file, $addr, $chip) = @_; 
    42804289        my ($i, $reg); 
    42814290 
     
    42834292        return if (i2c_smbus_read_byte_data($file, 0x02) & 0xc0) != 0; 
    42844293 
    4285         for ($i = 0x2a; $i <= 0x3d; $i++) { 
    4286                 $reg = i2c_smbus_read_byte_data($file, $i); 
    4287                 return if i2c_smbus_read_byte_data($file, $i+0x40) != $reg; 
    4288                 return if i2c_smbus_read_byte_data($file, $i+0x80) != $reg; 
    4289                 return if i2c_smbus_read_byte_data($file, $i+0xc0) != $reg; 
    4290         } 
    4291  
    4292         # Refine a bit by checking whether limits are in the correct order 
    4293         # (min<max for voltages, hyst<max for temperature). Since it is still 
    4294         # possible that the chip is an LM80 with limits not properly set, 
    4295         # a few "errors" are tolerated. 
    4296         my $confidence = 0; 
    4297         for ($i = 0x2a; $i <= 0x3a; $i++) { 
     4294        if ($chip == 0) { 
     4295                for ($i = 0x2a; $i <= 0x3d; $i++) { 
     4296                        $reg = i2c_smbus_read_byte_data($file, $i); 
     4297                        return if i2c_smbus_read_byte_data($file, $i+0x40) != $reg; 
     4298                        return if i2c_smbus_read_byte_data($file, $i+0x80) != $reg; 
     4299                        return if i2c_smbus_read_byte_data($file, $i+0xc0) != $reg; 
     4300                } 
     4301 
     4302                # Refine a bit by checking whether limits are in the correct order 
     4303                # (min<max for voltages, hyst<max for temperature). Since it is still 
     4304                # possible that the chip is an LM80 with limits not properly set, 
     4305                # a few "errors" are tolerated. 
     4306                my $confidence = 0; 
     4307                for ($i = 0x2a; $i <= 0x3a; $i++) { 
     4308                        $confidence++ 
     4309                                if i2c_smbus_read_byte_data($file, $i) < i2c_smbus_read_byte_data($file, $i+1); 
     4310                } 
     4311                # hot temp<OS temp 
    42984312                $confidence++ 
    4299                         if i2c_smbus_read_byte_data($file, $i) < i2c_smbus_read_byte_data($file, $i+1); 
    4300         } 
    4301         # hot temp<OS temp 
    4302         $confidence++ 
    4303                 if i2c_smbus_read_byte_data($file, 0x38) < i2c_smbus_read_byte_data($file, 0x3a); 
    4304  
    4305         # Negative temperature limits are unlikely. 
    4306         for ($i = 0x3a; $i <= 0x3d; $i++) { 
    4307                 $confidence++ if (i2c_smbus_read_byte_data($file, $i) & 0x80) == 0; 
    4308         } 
    4309  
    4310         # $confidence is between 0 and 14 
    4311         $confidence = ($confidence >> 1) - 4; 
    4312         # $confidence is now between -4 and 3 
    4313  
    4314         return unless $confidence > 0; 
    4315  
    4316         return $confidence; 
     4313                        if i2c_smbus_read_byte_data($file, 0x38) < i2c_smbus_read_byte_data($file, 0x3a); 
     4314 
     4315                # Negative temperature limits are unlikely. 
     4316                for ($i = 0x3a; $i <= 0x3d; $i++) { 
     4317                        $confidence++ if (i2c_smbus_read_byte_data($file, $i) & 0x80) == 0; 
     4318                } 
     4319 
     4320                # $confidence is between 0 and 14 
     4321                $confidence = ($confidence >> 1) - 4; 
     4322                # $confidence is now between -4 and 3 
     4323 
     4324                return unless $confidence > 0; 
     4325                return $confidence; 
     4326        } elsif ($chip == 1) { 
     4327                return if (i2c_smbus_read_byte_data($file, 0x07) & 0xfe) != 0; 
     4328                return if i2c_smbus_read_byte_data($file, 0x3e) != 0x01; 
     4329                return if i2c_smbus_read_byte_data($file, 0x3f) != 0x08; 
     4330 
     4331                return 6; 
     4332        } 
    43174333} 
    43184334