Changeset 1865

Show
Ignore:
Timestamp:
07/07/03 12:31:41 (11 years ago)
Author:
khali
Message:

Add LM90 detection.

Fix binmode call for Perl 5.005.
Open /dev/i2c* in binary mode.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/detect/sensors-detect

    r1847 r1865  
    771771            fscscy_detect pcf8591_detect arp_detect ipmi_kcs_detect 
    772772            ipmi_smic_detect via8231_isa_detect lm85_detect smartbatt_detect 
    773             adm1026_detect w83l785ts_detect lm83_detect); 
     773            adm1026_detect w83l785ts_detect lm83_detect lm90_detect); 
    774774 
    775775# This is a list of all recognized chips.  
     
    10471047       driver => "lm83", 
    10481048       i2c_addrs => [0x18..0x1a,0x29..0x2b,0x4c..0x4e], 
     1049       i2c_detect => sub { lm83_detect 0, @_ }, 
     1050     }, 
     1051     { 
     1052       name => "National Semiconductor LM90", 
     1053       driver => "to-be-written", 
     1054       i2c_addrs => [0x4c], 
    10491055       i2c_detect => sub { lm83_detect 0, @_ }, 
    10501056     }, 
     
    13551361  sysopen (IOPORTS, "/dev/port", O_RDWR) 
    13561362    or die "/dev/port: $!\n"; 
    1357   binmode (IOPORTS, ':raw'); 
     1363  binmode IOPORTS; 
    13581364} 
    13591365 
     
    19341940                   "/dev/i2c[-/]$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"), 
    19351941             next; 
     1942      binmode FILE; 
    19361943      i2c_set_slave_addr \*FILE,$new_misdetected_ref->[$i]->{i2c_addr} or 
    19371944           print("Can't set I2C address for ", 
     
    19621969                   "/dev/i2c[-/]$new_detected_ref->[$i]->{i2c_devnr}?!?\n"), 
    19631970             next; 
     1971      binmode FILE; 
    19641972      i2c_set_slave_addr \*FILE,$new_detected_ref->[$i]->{i2c_addr} or 
    19651973           print("Can't set I2C address for ", 
     
    20322040      open FILE,"/dev/i2c/$adapter_nr" or  
    20332041         (print "Can't open /dev/i2c[-/]$adapter_nr\n"), return; 
     2042  binmode FILE; 
    20342043 
    20352044  # Now scan each address in turn 
     
    23792388sub lm83_detect 
    23802389{ 
    2381   my $reg; 
    23822390  my ($chip, $file,$addr) = @_; 
    23832391  return if $chip == 0 and i2c_smbus_read_byte_data($file,0xfe) != 0x01; 
    23842392  return 8 
    23852393        if i2c_smbus_read_byte_data($file,0x04) == 0x00; 
     2394  return 6; 
     2395} 
     2396 
     2397# $_[0]: Chip to detect 
     2398#   (0 = LM90) 
     2399# $_[1]: A reference to the file descriptor to access this chip. 
     2400#        We may assume an i2c_set_slave_addr was already done. 
     2401# $_[2]: Address 
     2402# Returns: undef if not detected, 6, 7 or 8 if detected. 
     2403# Registers used: 
     2404#   0x03: Configuration 
     2405#   0xfe: Manufacturer ID 
     2406#   0xff: Chip ID / die revision 
     2407sub lm90_detect 
     2408{ 
     2409  my $reg; 
     2410  my ($chip, $file,$addr) = @_; 
     2411  return if $chip == 0 and i2c_smbus_read_byte_data($file,0xfe) != 0x01; 
     2412  return if (i2c_smbus_read_byte_data($file,0x03) & 0x2a) != 0; 
     2413  return 8 
     2414        if ($reg = i2c_smbus_read_byte_data($file,0xff)) == 0x21; 
     2415  return 7 
     2416    if $reg > 0x21 and $reg < 0x30; 
    23862417  return 6; 
    23872418}