| 246 | | } , |
| 247 | | { |
| 248 | | vendid => 0x1039, |
| 249 | | devid => 0x0645, |
| 250 | | func => 0, |
| 251 | | procid => "Silicon Integrated Systems SIS645", |
| 252 | | driver => "i2c-sis645", |
| 253 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| 254 | | } , |
| 255 | | { |
| 256 | | vendid => 0x1039, |
| 257 | | devid => 0x0646, |
| 258 | | func => 0, |
| 259 | | procid => "Silicon Integrated Systems SIS645DX", |
| 260 | | driver => "i2c-sis645", |
| 261 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| 262 | | } , |
| 263 | | { |
| 264 | | vendid => 0x1039, |
| 265 | | devid => 0x0648, |
| 266 | | func => 0, |
| 267 | | procid => "Silicon Integrated Systems SIS648", |
| 268 | | driver => "i2c-sis645", |
| 269 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| 270 | | } , |
| 271 | | { |
| 272 | | vendid => 0x1039, |
| 273 | | devid => 0x0650, |
| 274 | | func => 0, |
| 275 | | procid => "Silicon Integrated Systems SIS650", |
| 276 | | driver => "i2c-sis645", |
| 277 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| 278 | | } , |
| 279 | | { |
| 280 | | vendid => 0x1039, |
| 281 | | devid => 0x0651, |
| 282 | | func => 0, |
| 283 | | procid => "Silicon Integrated Systems SIS651", |
| 284 | | driver => "i2c-sis645", |
| 285 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| 286 | | } , |
| 287 | | { |
| 288 | | vendid => 0x1039, |
| 289 | | devid => 0x0735, |
| 290 | | func => 0, |
| 291 | | procid => "Silicon Integrated Systems SIS735", |
| 292 | | driver => "i2c-sis645", |
| 293 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| 294 | | } , |
| 295 | | { |
| 296 | | vendid => 0x1039, |
| 297 | | devid => 0x0745, |
| 298 | | func => 0, |
| 299 | | procid => "Silicon Integrated Systems SIS745", |
| 300 | | driver => "i2c-sis645", |
| 301 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| 302 | | } , |
| 303 | | { |
| 304 | | vendid => 0x1039, |
| 305 | | devid => 0x0746, |
| 306 | | func => 0, |
| 307 | | procid => "Silicon Integrated Systems SIS746", |
| 308 | | driver => "i2c-sis645", |
| 309 | | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| | 714 | ); |
| | 715 | |
| | 716 | # The following entries used to appear directly in @pci_adapters. |
| | 717 | # Because of the tendency of SiS chipsets to have their real PCI |
| | 718 | # IDs obscured, we have to qualify these with a custom detection |
| | 719 | # routine before we add them to the @pci_adapters list. |
| | 720 | # |
| | 721 | use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); |
| | 722 | @pci_adapters_sis5595 = ( |
| | 723 | { |
| | 724 | vendid => 0x1039, |
| | 725 | devid => 0x0008, |
| | 726 | func => 0, |
| | 727 | procid => "Silicon Integrated Systems SIS5595", |
| | 728 | driver => "i2c-sis5595", |
| | 729 | match => sub { $_[0] =~ /^SMBus SIS5595 adapter at [0-9,a-f]{4}/ }, |
| | 730 | } , |
| | 731 | ); |
| | 732 | |
| | 733 | @pci_adapters_sis645 = ( |
| | 734 | { |
| | 735 | vendid => 0x1039, |
| | 736 | devid => 0x0008, |
| | 737 | func => 0, |
| | 738 | procid => "Silicon Integrated Systems SIS5595", |
| | 739 | driver => "i2c-sis645", |
| | 740 | match => sub { $_[0] =~ /^SiS645 SMBus adapter at [0-9,a-f]{4}/ }, |
| | 741 | } , |
| | 742 | { |
| | 743 | vendid => 0x1039, |
| | 744 | devid => 0x0016, |
| | 745 | func => 1, |
| | 746 | procid => "Silicon Integrated Systems SMBus Controller", |
| | 747 | driver => "i2c-sis645", |
| | 748 | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| | 749 | } , |
| | 750 | { |
| | 751 | vendid => 0x1039, |
| | 752 | devid => 0x0018, |
| | 753 | func => 0, |
| | 754 | procid => "Silicon Integrated Systems 85C503/5513 (LPC Bridge)", |
| | 755 | driver => "i2c-sis645", |
| | 756 | match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| | 757 | } , |
| | 758 | ); |
| | 759 | |
| | 760 | @pci_adapters_sis96x = ( |
| | 761 | { |
| | 762 | vendid => 0x1039, |
| | 763 | devid => 0x0016, |
| | 764 | func => 1, |
| | 765 | procid => "Silicon Integrated Systems SMBus Controller", |
| | 766 | driver => "i2c-sis96x", |
| | 767 | match => sub { $_[0] =~ /^SiS96x SMBus adapter at 0x[0-9,a-f]{4}/ }, |
| | 768 | } , |
| | 1756 | # [0] -> VERSION |
| | 1757 | # [1] -> PATCHLEVEL |
| | 1758 | # [2] -> SUBLEVEL |
| | 1759 | # [3] -> EXTRAVERSION |
| | 1760 | # |
| | 1761 | use vars qw(@kernel_version); |
| | 1762 | |
| | 1763 | sub initialize_kernel_version |
| | 1764 | { |
| | 1765 | `uname -r` =~ /(\d+)\.(\d+)\.(\d+)(.*)/; |
| | 1766 | @kernel_version = ($1, $2, $3, $4); |
| | 1767 | } |
| | 1768 | |
| | 1769 | sub kernel_version_at_least |
| | 1770 | { |
| | 1771 | my ($vers, $plvl, $slvl) = @_; |
| | 1772 | return 1 if ($kernel_version[0] > $vers || |
| | 1773 | ($kernel_version[0] == $vers && |
| | 1774 | ($kernel_version[1] > $plvl || |
| | 1775 | ($kernel_version[1] == $plvl && |
| | 1776 | ($kernel_version[2] >= $slvl))))); |
| | 1777 | return 0; |
| | 1778 | } |
| | 1779 | |
| 1825 | | return @pci_list; |
| 1826 | | } |
| 1827 | | |
| 1828 | | # This function returns a list of hashes. Each hash has some PCI |
| 1829 | | # information. The important fields here are 'bus', 'slot', 'func' (they |
| 1830 | | # uniquely identify a PCI device in a computer) and 'desc' (a functional |
| 1831 | | # description of the PCI device). If this is an 'unknown device', the |
| 1832 | | # vendid and devid fields are set instead. |
| 1833 | | sub read_proc_pci |
| 1834 | | { |
| 1835 | | my @pci_list; |
| 1836 | | open INPUTFILE, "/proc/pci" or return; |
| 1837 | | while (<INPUTFILE>) { |
| 1838 | | my $record = {}; |
| 1839 | | if (($record->{bus},$record->{slot},$record->{func}) = |
| 1840 | | /^\s*Bus\s*(\S)+\s*,\s*device\s*(\S+)\s*,\s*function\s*(\S+)\s*:\s*$/) { |
| 1841 | | my $desc = <INPUTFILE>; |
| 1842 | | $_ = <INPUTFILE>; |
| 1843 | | if (($desc =~ /Unknown device/) and |
| 1844 | | (($record->{vendid},$record->{devid}) = |
| 1845 | | /^\s*Vendor id=(\S+)\.\s*Device id=(\S+)\.$/)) { |
| 1846 | | $record->{vendid} = hex $record->{vendid}; |
| 1847 | | $record->{devid} = hex $record->{devid}; |
| 1848 | | } else { |
| 1849 | | $record->{desc} = $desc; |
| 1850 | | } |
| 1851 | | push @pci_list,$record; |
| 1852 | | } |
| 1853 | | } |
| 1854 | | close INPUTFILE or return; |
| 1855 | | return @pci_list; |
| | 1825 | return %pci_list; |
| | 1854 | sub adapter_pci_detection_sis_96x |
| | 1855 | { |
| | 1856 | my $driver=""; |
| | 1857 | |
| | 1858 | # first, determine which driver if any... |
| | 1859 | if (kernel_version_at_least(2,6,0)) { |
| | 1860 | if (exists $pci_list{"1039:0016"}) { |
| | 1861 | $driver = "i2c-sis96x"; |
| | 1862 | } elsif (exists $pci_list{"1039:0008"}) { |
| | 1863 | $driver = "i2c-sis5595"; |
| | 1864 | } |
| | 1865 | } elsif (kernel_version_at_least(2,4,0)) { |
| | 1866 | if (exists $pci_list{"1039:0008"}) { |
| | 1867 | if ((exists $pci_list{"1039:0645"}) || |
| | 1868 | (exists $pci_list{"1039:0646"}) || |
| | 1869 | (exists $pci_list{"1039:0648"}) || |
| | 1870 | (exists $pci_list{"1039:0650"}) || |
| | 1871 | (exists $pci_list{"1039:0651"}) || |
| | 1872 | (exists $pci_list{"1039:0735"}) || |
| | 1873 | (exists $pci_list{"1039:0745"}) || |
| | 1874 | (exists $pci_list{"1039:0746"})) { |
| | 1875 | $driver = "i2c-sis645"; |
| | 1876 | } else { |
| | 1877 | $driver = "i2c-sis5595"; |
| | 1878 | } |
| | 1879 | } elsif ((exists $pci_list{"1039:0016"}) || |
| | 1880 | (exists $pci_list{"1039:0018"})) { |
| | 1881 | $driver = "i2c-sis645"; |
| | 1882 | } |
| | 1883 | } |
| | 1884 | |
| | 1885 | # then, add the appropriate entries to @pci_adapters |
| | 1886 | if ($driver eq "i2c-sis5595") { |
| | 1887 | push @pci_adapters, @pci_adapters_sis5595; |
| | 1888 | } elsif ($driver eq "i2c-sis645") { |
| | 1889 | push @pci_adapters, @pci_adapters_sis645; |
| | 1890 | } elsif ($driver eq "i2c-sis96x") { |
| | 1891 | push @pci_adapters, @pci_adapters_sis96x; |
| | 1892 | } |
| | 1893 | } |
| | 1894 | |