Changeset 5400
- Timestamp:
- 11/22/08 17:05:13 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r5399 r5400 758 758 driver => "lm87", 759 759 i2c_addrs => [0x2c..0x2e], 760 i2c_detect => sub { lm87_detect( @_); },760 i2c_detect => sub { lm87_detect(0, @_); }, 761 761 }, 762 762 { … … 764 764 driver => "lm87", 765 765 i2c_addrs => [0x2c..0x2e], 766 i2c_detect => sub { adm1024_detect(0, @_); },766 i2c_detect => sub { lm87_detect(1, @_); }, 767 767 }, 768 768 { … … 4429 4429 } 4430 4430 4431 # $_[0]: A reference to the file descriptor to access this chip. 4432 # $_[1]: Address 4431 # $_[0]: Chip to detect (0 = LM87, 1 = ADM1024) 4432 # $_[1]: A reference to the file descriptor to access this chip. 4433 # $_[2]: Address 4433 4434 # Returns: undef if not detected, (7) if detected. 4434 # Registers used: 0x3E, 0x3F 4435 # Assume lower 2 bits of reg 0x3F are for revisions. 4435 # Registers used: 4436 # 0x3e: Company ID 4437 # 0x3f: Revision 4438 # 0x40: Configuration 4436 4439 sub lm87_detect 4437 4440 { 4438 my ($file, $addr) = @_; 4439 return if i2c_smbus_read_byte_data($file, 0x3e) != 0x02; 4440 return if (i2c_smbus_read_byte_data($file, 0x3f) & 0xfc) != 0x04; 4441 my ($chip, $file, $addr) = @_; 4442 my $cid = i2c_smbus_read_byte_data($file, 0x3e); 4443 my $rev = i2c_smbus_read_byte_data($file, 0x3f); 4444 4445 if ($chip == 0) { 4446 return if $cid != 0x02; # National Semiconductor 4447 return if ($rev & 0xfc) != 0x04; 4448 } 4449 if ($chip == 1) { 4450 return if $cid != 0x41; # Analog Devices 4451 return if ($rev & 0xf0) != 0x10; 4452 } 4453 4454 my $cfg = i2c_smbus_read_byte_data($file, 0x40); 4455 return if ($cfg & 0x80) != 0x00; 4456 4441 4457 return (7); 4442 4458 } … … 4796 4812 return unless ($reg == 0x41); 4797 4813 return unless (i2c_smbus_read_byte_data($file, 0x17) & 0xf0) == 0x40; 4798 return (8);4799 }4800 4801 # $_[0]: Chip to detect (0 = ADM1024)4802 # $_[1]: A reference to the file descriptor to access this chip.4803 # $_[2]: Address4804 # Returns: undef if not detected, (8) if detected.4805 # Registers used:4806 # 0x3e: Company ID4807 # 0x3f: Revision4808 # 0x40: Configuration4809 sub adm1024_detect4810 {4811 my $reg;4812 my ($chip, $file, $addr) = @_;4813 $reg = i2c_smbus_read_byte_data($file, 0x3e);4814 return unless ($reg == 0x41);4815 return unless (i2c_smbus_read_byte_data($file, 0x40) & 0x80) == 0x00;4816 return unless (i2c_smbus_read_byte_data($file, 0x3f) & 0xf0) == 0x10;4817 4814 return (8); 4818 4815 }
