Changeset 5408

Show
Ignore:
Timestamp:
11/24/08 14:24:00 (4 years ago)
Author:
khali
Message:

Add a separate look-up table to figure out an I2C adapter's driver
based on the adapters description in sysfs. This is more efficient to
have one entry per driver than one per device as we did so far.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect

    r5407 r5408  
    5454# either pci.c or oldproc.c). If no driver is written yet, set the 
    5555# driver (Driver Name) field to "to-be-written". 
    56 # The match (Match Description) field should contain a regular expression 
    57 # matching the adapter name as it would appear in /sys/class/i2c-adapter. 
    5856@pci_adapters = ( 
    5957     { 
     
    6260       procid => "Intel 82371AB PIIX4 ACPI", 
    6361       driver => "i2c-piix4", 
    64        match => qr/^SMBus PIIX4 adapter at /, 
    6562     }, 
    6663     { 
     
    7572       procid => "Intel 82443MX Mobile", 
    7673       driver => "i2c-piix4", 
    77        match => qr/^SMBus PIIX4 adapter at /, 
    7874     }, 
    7975     { 
     
    8278       procid => "Intel 82801AA ICH", 
    8379       driver => "i2c-i801", 
    84        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    8580     }, 
    8681     { 
     
    8984       procid => "Intel 82801AB ICH0", 
    9085       driver => "i2c-i801", 
    91        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    9286     }, 
    9387     { 
     
    9690       procid => "Intel 82801BA ICH2", 
    9791       driver => "i2c-i801", 
    98        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    9992     }, 
    10093     { 
     
    10396       procid => "Intel 82801CA/CAM ICH3", 
    10497       driver => "i2c-i801", 
    105        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    10698     }, 
    10799     { 
     
    110102       procid => "Intel 82801DB ICH4", 
    111103       driver => "i2c-i801", 
    112        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    113104     }, 
    114105     { 
     
    117108       procid => "Intel 82801EB ICH5", 
    118109       driver => "i2c-i801", 
    119        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    120110     }, 
    121111     { 
     
    124114       procid => "Intel 6300ESB", 
    125115       driver => "i2c-i801", 
    126        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    127116     }, 
    128117     { 
     
    131120       procid => "Intel Enterprise Southbridge - ESB2", 
    132121       driver => "i2c-i801", 
    133        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    134122     }, 
    135123     { 
     
    138126       procid => "Intel 82801FB ICH6", 
    139127       driver => "i2c-i801", 
    140        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    141128     }, 
    142129     { 
     
    145132       procid => "Intel 82801G ICH7", 
    146133       driver => "i2c-i801", 
    147        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    148134     }, 
    149135     { 
     
    152138       procid => "Intel 82801H ICH8", 
    153139       driver => "i2c-i801", 
    154        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    155140     }, 
    156141     { 
     
    159144       procid => "Intel ICH9", 
    160145       driver => "i2c-i801", 
    161        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    162146     }, 
    163147     { 
     
    166150       procid => "Intel Tolapai", 
    167151       driver => "i2c-i801", 
    168        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    169152     }, 
    170153     { 
     
    173156       procid => "Intel ICH10", 
    174157       driver => "i2c-i801", 
    175        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    176158     }, 
    177159     { 
     
    180162       procid => "Intel ICH10", 
    181163       driver => "i2c-i801", 
    182        match => qr/^SMBus I801 adapter at [0-9a-f]{4}/, 
    183164     }, 
    184165     { 
     
    187168       procid => "Intel SCH", 
    188169       driver => "i2c-isch", 
    189        match => qr/^SMBus SCH adapter at [0-9a-f]{4}/, 
    190170     }, 
    191171     { 
     
    194174       procid => "VIA Technologies VT82C586B Apollo ACPI", 
    195175       driver => "i2c-via", 
    196        match => qr/^VIA i2c/, 
    197176     }, 
    198177     { 
     
    201180       procid => "VIA Technologies VT82C596 Apollo ACPI", 
    202181       driver => "i2c-viapro", 
    203        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    204182     }, 
    205183     { 
     
    208186       procid => "VIA Technologies VT82C596B ACPI", 
    209187       driver => "i2c-viapro", 
    210        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    211188     }, 
    212189     { 
     
    215192       procid => "VIA Technologies VT82C686 Apollo ACPI", 
    216193       driver => "i2c-viapro", 
    217        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    218194     }, 
    219195     { 
     
    222198       procid => "VIA Technologies VT8233 VLink South Bridge", 
    223199       driver => "i2c-viapro", 
    224        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    225200     }, 
    226201     { 
     
    229204       procid => "VIA Technologies VT8233A South Bridge", 
    230205       driver => "i2c-viapro", 
    231        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    232206     }, 
    233207     { 
     
    236210       procid => "VIA Technologies VT8233A/8235 South Bridge", 
    237211       driver => "i2c-viapro", 
    238        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    239212     }, 
    240213     { 
     
    243216       procid => "VIA Technologies VT8237 South Bridge", 
    244217       driver => "i2c-viapro", 
    245        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    246218     }, 
    247219     { 
     
    250222       procid => "VIA Technologies VT8237A South Bridge", 
    251223       driver => "i2c-viapro", 
    252        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    253224     }, 
    254225     { 
     
    257228       procid => "VIA Technologies VT8231 South Bridge", 
    258229       driver => "i2c-viapro", 
    259        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    260230     }, 
    261231     { 
     
    264234       procid => "VIA Technologies VT8251 South Bridge", 
    265235       driver => "i2c-viapro", 
    266        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    267236     }, 
    268237     { 
     
    271240       procid => "VIA Technologies CX700 South Bridge", 
    272241       driver => "i2c-viapro", 
    273        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    274242     }, 
    275243     { 
     
    278246       procid => "VIA Technologies VX800/VX820 South Bridge", 
    279247       driver => "i2c-viapro", 
    280        match => qr/^SMBus V(IA|ia) Pro adapter at/, 
    281248     }, 
    282249     { 
     
    303270       procid => "Silicon Integrated Systems SIS630", 
    304271       driver => "i2c-sis630", 
    305        match => qr/^SMBus SIS630 adapter at [0-9a-f]{4}/, 
    306272     }, 
    307273     { 
     
    310276       procid => "Silicon Integrated Systems SIS730", 
    311277       driver => "i2c-sis630", 
    312        match => qr/^SMBus SIS630 adapter at [0-9a-f]{4}/, 
    313278     }, 
    314279# 
     
    320285       procid => "Acer Labs 1533/1543", 
    321286       driver => "i2c-ali15x3", 
    322        match => qr/^SMBus ALI15X3 adapter at/, 
    323287     }, 
    324288     { 
     
    327291       procid => "Acer Labs 1535", 
    328292       driver => "i2c-ali1535", 
    329        match => qr/^SMBus ALI1535 adapter at/, 
    330293     }, 
    331294     { 
     
    334297       procid => "Acer Labs 1563", 
    335298       driver => "i2c-ali1563", 
    336        match => qr/^SMBus ALi 1563 Adapter @/, 
    337299     }, 
    338300     { 
     
    341303       procid => "AMD-756 Athlon ACPI", 
    342304       driver => "i2c-amd756", 
    343        match => qr/^SMBus AMD756 adapter at [0-9a-f]{4}/, 
    344305     }, 
    345306     { 
     
    348309       procid => "AMD-766 Athlon ACPI", 
    349310       driver => "i2c-amd756", 
    350        match => qr/^SMBus AMD766 adapter at [0-9a-f]{4}/, 
    351311     }, 
    352312     { 
     
    355315       procid => "AMD-768 System Management", 
    356316       driver => "i2c-amd756", 
    357        match => qr/^SMBus AMD768 adapter at [0-9a-f]{4}/, 
    358317     }, 
    359318     { 
     
    362321       procid => "AMD-8111 ACPI", 
    363322       driver => "i2c-amd756", 
    364        match => qr/^SMBus AMD8111 adapter at [0-9a-f]{4}/, 
    365323     }, 
    366324     { 
     
    369327       procid => "AMD-8111 SMBus 2.0", 
    370328       driver => "i2c-amd8111", 
    371        match => qr/^SMBus2 AMD8111 adapter at [0-9a-f]{4}/, 
    372329     }, 
    373330     { 
     
    376333       procid => "nVidia nForce SMBus", 
    377334       driver => "i2c-amd756", 
    378        match => qr/^SMBus nVidia nForce adapter at [0-9a-f]{4}/, 
    379335     }, 
    380336     { 
     
    383339       procid => "nVidia Corporation nForce2 SMBus (MCP)", 
    384340       driver => "i2c-nforce2", 
    385        match => qr/^SMBus nForce2 adapter at /, 
    386341     }, 
    387342     { 
     
    390345       procid => "nVidia Corporation nForce2 Ultra 400 SMBus (MCP)", 
    391346       driver => "i2c-nforce2", 
    392        match => qr/^SMBus nForce2 adapter at /, 
    393347     }, 
    394348     { 
     
    397351       procid => "nVidia Corporation nForce3 Pro150 SMBus (MCP)", 
    398352       driver => "i2c-nforce2", 
    399        match => qr/^SMBus nForce2 adapter at /, 
    400353     }, 
    401354     { 
     
    404357       procid => "nVidia Corporation nForce3 250Gb SMBus (MCP)", 
    405358       driver => "i2c-nforce2", 
    406        match => qr/^SMBus nForce2 adapter at /, 
    407359     }, 
    408360     { 
     
    411363       procid => "nVidia Corporation nForce4 SMBus (MCP)", 
    412364       driver => "i2c-nforce2", 
    413        match => qr/^SMBus nForce2 adapter at /, 
    414365     }, 
    415366     { 
     
    418369       procid => "nVidia Corporation nForce4 SMBus (MCP-04)", 
    419370       driver => "i2c-nforce2", 
    420        match => qr/^SMBus nForce2 adapter at /, 
    421371     }, 
    422372     { 
     
    425375       procid => "nVidia Corporation nForce4 SMBus (MCP51)", 
    426376       driver => "i2c-nforce2", 
    427        match => qr/^SMBus nForce2 adapter at /, 
    428377     }, 
    429378     { 
     
    432381       procid => "nVidia Corporation nForce4 SMBus (MCP55)", 
    433382       driver => "i2c-nforce2", 
    434        match => qr/^SMBus nForce2 adapter at /, 
    435383     }, 
    436384     { 
     
    439387       procid => "nVidia Corporation nForce4 SMBus (MCP61)", 
    440388       driver => "i2c-nforce2", 
    441        match => qr/^SMBus nForce2 adapter at /, 
    442389     }, 
    443390     { 
     
    446393       procid => "nVidia Corporation nForce4 SMBus (MCP65)", 
    447394       driver => "i2c-nforce2", 
    448        match => qr/^SMBus nForce2 adapter at /, 
    449395     }, 
    450396     { 
     
    453399       procid => "ServerWorks OSB4 South Bridge", 
    454400       driver => "i2c-piix4", 
    455        match => qr/^SMBus PIIX4 adapter at /, 
    456401     }, 
    457402     { 
     
    460405       procid => "SMSC Victory66 South Bridge", 
    461406       driver => "i2c-piix4", 
    462        match => qr/^SMBus PIIX4 adapter at /, 
    463407     }, 
    464408     { 
     
    467411       procid => "ServerWorks CSB5 South Bridge", 
    468412       driver => "i2c-piix4", 
    469        match => qr/^SMBus PIIX4 adapter at /, 
    470413     }, 
    471414     { 
     
    474417       procid => "ServerWorks CSB6 South Bridge", 
    475418       driver => "i2c-piix4", 
    476        match => qr/^SMBus PIIX4 adapter at /, 
    477419     }, 
    478420     { 
     
    481423       procid => "ServerWorks HT-1000 South Bridge", 
    482424       driver => "i2c-piix4", 
    483        match => qr/^SMBus PIIX4 adapter at /, 
    484425     }, 
    485426     { 
     
    488429       procid => "ATI Technologies Inc ATI SMBus", 
    489430       driver => "i2c-piix4", 
    490        match => qr/^SMBus PIIX4 adapter at /, 
    491431     }, 
    492432     { 
     
    495435       procid => "ATI Technologies Inc ATI SMBus", 
    496436       driver => "i2c-piix4", 
    497        match => qr/^SMBus PIIX4 adapter at /, 
    498437     }, 
    499438     { 
     
    502441       procid => "ATI Technologies Inc IXP SB400 SMBus Controller", 
    503442       driver => "i2c-piix4", 
    504        match => qr/^SMBus PIIX4 adapter at /, 
    505443     }, 
    506444     { 
     
    509447       procid => "ATI Technologies Inc SB600 SMBus", 
    510448       driver => "i2c-piix4", 
    511        match => qr/^SMBus PIIX4 adapter at /, 
    512449     }, 
    513450     { 
     
    516453       procid => "SCx200 Bridge", 
    517454       driver => "scx200_acb", 
    518        match => qr/^(NatSemi SCx200 ACCESS\.bus|SCx200 ACB\d+) /, 
    519455     }, 
    520456     { 
     
    523459       procid => "SC1100 Bridge", 
    524460       driver => "scx200_acb", 
    525        match => qr/^(NatSemi SCx200 ACCESS\.bus|SCx200 ACB\d+) /, 
    526461     }, 
    527462     { 
     
    530465       procid => "CS5535 ISA bridge", 
    531466       driver => "scx200_acb", 
    532        match => qr/^CS5535 ACB\d+ /, 
    533467     }, 
    534468     { 
     
    537471       procid => "CS5536 [Geode companion] ISA", 
    538472       driver => "scx200_acb", 
    539        match => qr/^CS553[56] ACB\d+ /, 
    540473     }, 
    541474); 
     
    553486       procid => "Silicon Integrated Systems SIS5595", 
    554487       driver => "i2c-sis5595", 
    555        match => qr/^SMBus SIS5595 adapter at [0-9a-f]{4}/, 
    556488     }, 
    557489); 
     
    563495       procid => "Silicon Integrated Systems SMBus Controller", 
    564496       driver => "i2c-sis96x", 
    565        match => qr/^SiS96x SMBus adapter at 0x[0-9a-f]{4}/, 
    566      }, 
     497     }, 
     498); 
     499 
     500# Look-up table to find out an I2C bus' driver based on the bus name. 
     501# The match field should contain a regular expression matching the I2C 
     502# bus name as it would appear in /sys/class/i2c-adapter. 
     503# Note that new drivers probably don't need to be added to this table 
     504# if they bind to their device, as we will be able to get the driver name 
     505# from sysfs directly. 
     506use vars qw(@i2c_adapter_names); 
     507@i2c_adapter_names = ( 
     508        { driver => "i2c-piix4",        match => qr/^SMBus PIIX4 adapter at / }, 
     509        { driver => "i2c-i801",         match => qr/^SMBus I801 adapter at / }, 
     510        { driver => "i2c-via",          match => qr/^VIA i2c/ }, 
     511        { driver => "i2c-viapro",       match => qr/^SMBus V(IA|ia) Pro adapter at / }, 
     512        { driver => "i2c-sis5595",      match => qr/^SMBus SIS5595 adapter at / }, 
     513        { driver => "i2c-sis630",       match => qr/^SMBus SIS630 adapter at / }, 
     514        { driver => "i2c-sis96x",       match => qr/^SiS96x SMBus adapter at / }, 
     515        { driver => "i2c-ali15x3",      match => qr/^SMBus ALI15X3 adapter at / }, 
     516        { driver => "i2c-ali1535",      match => qr/^SMBus ALI1535 adapter at/ }, 
     517        { driver => "i2c-ali1563",      match => qr/^SMBus ALi 1563 Adapter @ / }, 
     518        { driver => "i2c-amd756",       match => qr/^SMBus (AMD756|AMD766|AMD768|AMD8111|nVidia nForce) adapter at / }, 
     519        { driver => "i2c-amd8111",      match => qr/^SMBus2 AMD8111 adapter at / }, 
     520        { driver => "i2c-nforce2",      match => qr/^SMBus nForce2 adapter at / }, 
     521        { driver => "scx200_acb",       match => qr/^(NatSemi SCx200 ACCESS\.bus|SCx200 ACB\d+|CS553[56] ACB\d+) / }, 
    567522); 
    568523 
     
    23712326    # fails, fall back to searching our list of known I2C adapters. 
    23722327    $entry->{'driver'} = sysfs_device_driver("${class_dir}/i2c-$1/device") 
    2373                       || find_adapter_driver($entry->{'name'}); 
     2328                      || find_i2c_adapter_driver($entry->{'name'}) 
     2329                      || 'UNKNOWN'; 
     2330    print $entry->{'driver'}, "\n"; 
    23742331    $i2c_adapters[$1] = $entry; 
    23752332  } 
     
    25762533 
    25772534# $_[0]: Adapter description as found in /sys/class/i2c-adapter 
    2578 sub find_adapter_driver 
    2579 { 
    2580   my $adapter; 
    2581   for $adapter (@pci_adapters) { 
    2582     return $adapter->{driver} 
    2583       if (exists $adapter->{match} && $_[0] =~ $adapter->{match}); 
    2584   } 
    2585   return "UNKNOWN"; 
     2535sub find_i2c_adapter_driver 
     2536{ 
     2537        my $name = shift; 
     2538        my $entry; 
     2539 
     2540        foreach $entry (@i2c_adapter_names) { 
     2541                return $entry->{driver} 
     2542                        if $name =~ $entry->{match}; 
     2543        } 
    25862544} 
    25872545