From 290bdb74ad34b7dac965e6773406682b05883f06 Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sun, 29 Jul 2001 22:48:15 +0000 Subject: [PATCH] Add a "blacklist" to the 5595 drivers so that they refuse to load when encountering a long list of unsupported chips. All these chips have the same 1039/0008 ID as the 5595 but are incompatible. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1150 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 2 ++ kernel/busses/i2c-sis5595.c | 58 +++++++++++++++++++++++++++++++++++++ kernel/chips/sis5595.c | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) diff --git a/CHANGES b/CHANGES index b304ef92..077357ad 100644 --- a/CHANGES +++ b/CHANGES @@ -25,9 +25,11 @@ ask CVS about it: Library: ds1621 and it87 updates Module i2c-ali15x3: Allow force_addr=0xaddr; enable if not enabled. Module i2c-i801: Fix 82801BA detection broken by kernel 2.4.6 + Module i2c-sis5595: Recognize unsupported chips and refuse to load Module adm1025: Fixed temp2 min/max writes Module ds1621: Add 12-bit precision mode Module it87: Enable all alarms, add in8 support, add sensor type selection + Module sis5595: Recognize unsupported chips and refuse to load Module w83781d: Fix fan speed for as99127f (broken by 2.6.0) Program sensors: it87 updates Program sensors-detect: Fix ADM1024 and ADM1025 detection. diff --git a/kernel/busses/i2c-sis5595.c b/kernel/busses/i2c-sis5595.c index 8627ec65..63ed91ee 100644 --- a/kernel/busses/i2c-sis5595.c +++ b/kernel/busses/i2c-sis5595.c @@ -21,6 +21,27 @@ /* Note: we assume there can only be one SIS5595 with one SMBus interface */ +/* + Note: all have mfr. ID 0x1039. + SUPPORTED PCI ID + 5595 0008 + + Note: these chips contain a 0008 device which is incompatible with the + 5595. We recognize these by the presence of the listed + "blacklist" PCI ID and refuse to load. + + NOT SUPPORTED PCI ID BLACKLIST PCI ID + 540 0008 0540 + 550 0008 0550 + 5513 0008 5511 + 5581 0008 5597 + 5582 0008 5597 + 5597 0008 5597 + 5598 0008 5597/5598 + 630 0008 0630 + 730 0008 0730 +*/ + /* TO DO: * Add Block Transfers (ugly, but supported by the adapter) * Add adapter resets @@ -39,6 +60,34 @@ #include +#ifndef PCI_DEVICE_ID_SI_540 +#define PCI_DEVICE_ID_SI_540 0x0540 +#endif +#ifndef PCI_DEVICE_ID_SI_550 +#define PCI_DEVICE_ID_SI_550 0x0550 +#endif +#ifndef PCI_DEVICE_ID_SI_630 +#define PCI_DEVICE_ID_SI_630 0x0630 +#endif +#ifndef PCI_DEVICE_ID_SI_730 +#define PCI_DEVICE_ID_SI_730 0x0730 +#endif +#ifndef PCI_DEVICE_ID_SI_5598 +#define PCI_DEVICE_ID_SI_5598 0x5598 +#endif + +static int blacklist[] = { + PCI_DEVICE_ID_SI_540, + PCI_DEVICE_ID_SI_550, + PCI_DEVICE_ID_SI_630, + PCI_DEVICE_ID_SI_730, + PCI_DEVICE_ID_SI_5511, /* 5513 chip has the 0008 device but + that ID shows up in other chips so we + use the 5511 ID for recognition */ + PCI_DEVICE_ID_SI_5597, + PCI_DEVICE_ID_SI_5598, + 0 }; + /* Length of ISA address segment */ #define SIS5595_EXTENT 8 /* SIS5595 SMBus registers */ @@ -152,6 +201,7 @@ int sis5595_setup(void) u16 a; u8 val; struct pci_dev *SIS5595_dev; + int *i; /* First check whether we can access PCI at all */ if (pci_present() == 0) { @@ -168,6 +218,14 @@ int sis5595_setup(void) return -ENODEV; } + /* Look for imposters */ + for(i = blacklist; *i != 0; i++) { + if (pci_find_device(PCI_VENDOR_ID_SI, *i, NULL)) { + printk("i2c-sis5595.o: Error: Looked for SIS5595 but found unsupported device %.4X\n", *i); + return -ENODEV; + } + } + /* Determine the address of the SMBus areas */ pci_read_config_word(SIS5595_dev, ACPI_BASE, &sis5595_base); if(sis5595_base == 0 && force_addr == 0) { diff --git a/kernel/chips/sis5595.c b/kernel/chips/sis5595.c index c6d412af..ab5c45d3 100644 --- a/kernel/chips/sis5595.c +++ b/kernel/chips/sis5595.c @@ -26,6 +26,21 @@ Version PCI ID PCI Revision 1 1039/0008 01 2 1039/0008 C0 + + Note: these chips contain a 0008 device which is incompatible with the + 5595. We recognize these by the presence of the listed + "blacklist" PCI ID and refuse to load. + + NOT SUPPORTED PCI ID BLACKLIST PCI ID + 540 0008 0540 + 550 0008 0550 + 5513 0008 5511 + 5581 0008 5597 + 5582 0008 5597 + 5597 0008 5597 + 5598 0008 5597/5598 + 630 0008 0630 + 730 0008 0730 */ #include @@ -71,6 +86,33 @@ static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(sis5595); +#ifndef PCI_DEVICE_ID_SI_540 +#define PCI_DEVICE_ID_SI_540 0x0540 +#endif +#ifndef PCI_DEVICE_ID_SI_550 +#define PCI_DEVICE_ID_SI_550 0x0550 +#endif +#ifndef PCI_DEVICE_ID_SI_630 +#define PCI_DEVICE_ID_SI_630 0x0630 +#endif +#ifndef PCI_DEVICE_ID_SI_730 +#define PCI_DEVICE_ID_SI_730 0x0730 +#endif +#ifndef PCI_DEVICE_ID_SI_5598 +#define PCI_DEVICE_ID_SI_5598 0x5598 +#endif + +static int blacklist[] = { + PCI_DEVICE_ID_SI_540, + PCI_DEVICE_ID_SI_550, + PCI_DEVICE_ID_SI_630, + PCI_DEVICE_ID_SI_730, + PCI_DEVICE_ID_SI_5511, /* 5513 chip has the 0008 device but + that ID shows up in other chips so we + use the 5511 ID for recognition */ + PCI_DEVICE_ID_SI_5597, + PCI_DEVICE_ID_SI_5598, + 0 }; /* SiS southbridge has a LM78-like chip integrated on the same IC. This driver is a customized copy of lm78.c @@ -311,6 +353,7 @@ int sis5595_attach_adapter(struct i2c_adapter *adapter) int sis5595_find_sis(int *address) { u16 val; + int *i; if (!pci_present()) return -ENODEV; @@ -320,6 +363,13 @@ int sis5595_find_sis(int *address) NULL))) return -ENODEV; + /* Look for imposters */ + for(i = blacklist; *i != 0; i++) { + if (pci_find_device(PCI_VENDOR_ID_SI, *i, NULL)) { + printk("sis5595.o: Error: Looked for SIS5595 but found unsupported device %.4X\n", *i); + return -ENODEV; + } + } if (PCIBIOS_SUCCESSFUL != pci_read_config_word(s_bridge, SIS5595_BASE_REG, &val))