Changeset 4325

Show
Ignore:
Timestamp:
02/15/07 11:45:49 (6 years ago)
Author:
khali
Message:

sensors-detect: Add Dallas DS75 detection.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r4324 r4325  
    2323                          Speed up the LM75 and LM77 detection 
    2424                          Clean up the EEPROM detection 
     25                          Add Dallas DS75 detection 
    2526 
    2627 
  • lm-sensors/trunk/prog/detect/sensors-detect

    r4314 r4325  
    820820       driver => "lm75", 
    821821       i2c_addrs => [0x48..0x4f], 
    822        i2c_detect => sub { lm75_detect(@_); }, 
    823      } , 
     822       i2c_detect => sub { lm75_detect(0, @_); }, 
     823     }, 
     824     { 
     825       name => "Dallas Semiconductor DS75", 
     826       driver => "lm75", 
     827       i2c_addrs => [0x48..0x4f], 
     828       i2c_detect => sub { lm75_detect(1, @_); }, 
     829     }, 
    824830     { 
    825831       name => "National Semiconductor LM77", 
     
    33043310} 
    33053311 
    3306 # $_[0]: A reference to the file descriptor to access this chip. 
    3307 # $_[1]: Address 
     3312# $_[0]: Chip to detect (0 = LM75, 1 = DS75) 
     3313# $_[1]: A reference to the file descriptor to access this chip. 
     3314# $_[2]: Address (unused) 
    33083315# Returns: undef if not detected, 3 or 6 if detected; 
    33093316#   6 means that the temperatures make sense; 
     
    33213328# documented. 
    33223329# Note that register 0x00 may change, so we can't use the modulo trick on it. 
     3330# The DS75 is a bit different, it doesn't cycle over 8-byte boundaries, and 
     3331# all register addresses from 0x04 to 0x0f behave like 0x04-0x07 do for 
     3332# the LM75. 
    33233333sub lm75_detect 
    33243334{ 
    33253335  my $i; 
    3326   my ($file,$addr) = @_; 
     3336  my ($chip, $file, $addr) = @_; 
    33273337  my $cur = i2c_smbus_read_word_data($file,0x00); 
    33283338  my $conf = i2c_smbus_read_byte_data($file,0x01); 
    33293339 
    33303340  my $hyst = i2c_smbus_read_word_data($file,0x02); 
    3331   return if i2c_smbus_read_word_data($file,0x04) != $hyst; 
    3332   return if i2c_smbus_read_word_data($file,0x05) != $hyst; 
    3333   return if i2c_smbus_read_word_data($file,0x06) != $hyst; 
    3334   return if i2c_smbus_read_word_data($file,0x07) != $hyst; 
     3341  my $maxreg = $chip == 1 ? 0x0f : 0x07; 
     3342  for $i (0x04 .. $maxreg) { 
     3343    return if i2c_smbus_read_word_data($file, $i) != $hyst; 
     3344  } 
    33353345 
    33363346  my $os = i2c_smbus_read_word_data($file,0x03); 
    3337   return if i2c_smbus_read_word_data($file,0x04) != $os; 
    3338   return if i2c_smbus_read_word_data($file,0x05) != $os; 
    3339   return if i2c_smbus_read_word_data($file,0x06) != $os; 
    3340   return if i2c_smbus_read_word_data($file,0x07) != $os; 
    3341  
    3342   for ($i = 8; $i <= 248; $i += 40) { 
    3343     return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf; 
    3344     return if i2c_smbus_read_word_data($file, $i + 0x02) != $hyst; 
    3345     return if i2c_smbus_read_word_data($file, $i + 0x03) != $os; 
     3347  for $i (0x04 .. $maxreg) { 
     3348    return if i2c_smbus_read_word_data($file, $i) != $os; 
     3349  } 
     3350 
     3351  if ($chip == 0) { 
     3352    for ($i = 8; $i <= 248; $i += 40) { 
     3353      return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf 
     3354             or i2c_smbus_read_word_data($file, $i + 0x02) != $hyst 
     3355             or i2c_smbus_read_word_data($file, $i + 0x03) != $os; 
     3356    } 
    33463357  } 
    33473358 
     
    33543365  $os = swap_bytes($os); 
    33553366  # Unused bits 
    3356   return if ($conf & 0xe0); 
     3367  return if $chip == 0 and ($conf & 0xe0); 
     3368  return if $chip == 1 and ($conf & 0x80); 
    33573369 
    33583370  $cur = $cur >> 8;