Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / i2c / busses / i2c-piix4.c
index 8edc957..d9c7c00 100644 (file)
 /*
    Supports:
        Intel PIIX4, 440MX
-       Serverworks OSB4, CSB5, CSB6
+       Serverworks OSB4, CSB5, CSB6, HT-1000
        SMSC Victory66
 
    Note: we assume there can only be one device, with one SMBus interface.
 */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/config.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
+#include <linux/delay.h>
 #include <linux/stddef.h>
 #include <linux/sched.h>
 #include <linux/ioport.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
 #include <linux/apm_bios.h>
+#include <linux/dmi.h>
 #include <asm/io.h>
 
 
@@ -90,13 +90,13 @@ struct sd {
 
 /* If force is set to anything different from 0, we forcibly enable the
    PIIX4. DANGEROUS! */
-static int force = 0;
+static int force;
 module_param (force, int, 0);
 MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!");
 
 /* If force_addr is set to anything different from 0, we forcibly enable
    the PIIX4 at the given address. VERY DANGEROUS! */
-static int force_addr = 0;
+static int force_addr;
 module_param (force_addr, int, 0);
 MODULE_PARM_DESC(force_addr,
                 "Forcibly enable the PIIX4 at the given address. "
@@ -104,28 +104,24 @@ MODULE_PARM_DESC(force_addr,
 
 /* If fix_hstcfg is set to anything different from 0, we reset one of the
    registers to be a valid value. */
-static int fix_hstcfg = 0;
+static int fix_hstcfg;
 module_param (fix_hstcfg, int, 0);
 MODULE_PARM_DESC(fix_hstcfg,
                "Fix config register. Needed on some boards (Force CPCI735).");
 
 static int piix4_transaction(void);
 
-static unsigned short piix4_smba = 0;
+static unsigned short piix4_smba;
+static struct pci_driver piix4_driver;
 static struct i2c_adapter piix4_adapter;
 
-/*
- * Get DMI information.
- */
-static int __devinit ibm_dmi_probe(void)
-{
-#ifdef CONFIG_X86
-       extern int is_unsafe_smbus;
-       return is_unsafe_smbus;
-#else
-       return 0;
-#endif
-}
+static struct dmi_system_id __devinitdata piix4_dmi_table[] = {
+       {
+               .ident = "IBM",
+               .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), },
+       },
+       { },
+};
 
 static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
                                const struct pci_device_id *id)
@@ -138,7 +134,9 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
 
        dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev));
 
-       if(ibm_dmi_probe()) {
+       /* Don't access SMBus on IBM systems which get corrupted eeproms */
+       if (dmi_check_system(piix4_dmi_table) &&
+                       PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) {
                dev_err(&PIIX4_dev->dev, "IBM Laptop detected; this module "
                        "may corrupt your serial eeprom! Refusing to load "
                        "module!\n");
@@ -160,7 +158,7 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
                }
        }
 
-       if (!request_region(piix4_smba, SMBIOSIZE, "piix4-smbus")) {
+       if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
                dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n",
                        piix4_smba);
                return -ENODEV;
@@ -246,7 +244,7 @@ static int piix4_transaction(void)
        /* Make sure the SMBus host is ready to start transmitting */
        if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
                dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). "
-                       "Resetting... \n", temp);
+                       "Resetting...\n", temp);
                outb_p(temp, SMBHSTSTS);
                if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
                        dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
@@ -261,7 +259,7 @@ static int piix4_transaction(void)
 
        /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
        do {
-               i2c_delay(1);
+               msleep(1);
                temp = inb_p(SMBHSTSTS);
        } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
 
@@ -402,65 +400,36 @@ static u32 piix4_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = piix4_access,
        .functionality  = piix4_func,
 };
 
 static struct i2c_adapter piix4_adapter = {
        .owner          = THIS_MODULE,
-       .class          = I2C_ADAP_CLASS_SMBUS,
+       .class          = I2C_CLASS_HWMON,
        .algo           = &smbus_algorithm,
-       .name           = "unset",
 };
 
 static struct pci_device_id piix4_ids[] = {
-       {
-               .vendor =       PCI_VENDOR_ID_INTEL,
-               .device =       PCI_DEVICE_ID_INTEL_82371AB_3,
-               .subvendor =    PCI_ANY_ID,
-               .subdevice =    PCI_ANY_ID,
-               .driver_data =  3
-       },
-       {
-               .vendor =       PCI_VENDOR_ID_SERVERWORKS,
-               .device =       PCI_DEVICE_ID_SERVERWORKS_OSB4,
-               .subvendor =    PCI_ANY_ID,
-               .subdevice =    PCI_ANY_ID,
-               .driver_data =  0,
-       },
-       {
-               .vendor =       PCI_VENDOR_ID_SERVERWORKS,
-               .device =       PCI_DEVICE_ID_SERVERWORKS_CSB5,
-               .subvendor =    PCI_ANY_ID,
-               .subdevice =    PCI_ANY_ID,
-               .driver_data =  0,
-       },
-       {
-               .vendor =       PCI_VENDOR_ID_SERVERWORKS,
-               .device =       PCI_DEVICE_ID_SERVERWORKS_CSB6,
-               .subvendor =    PCI_ANY_ID,
-               .subdevice =    PCI_ANY_ID,
-               .driver_data =  0,
-       },
-       {
-               .vendor =       PCI_VENDOR_ID_INTEL,
-               .device =       PCI_DEVICE_ID_INTEL_82443MX_3,
-               .subvendor =    PCI_ANY_ID,
-               .subdevice =    PCI_ANY_ID,
-               .driver_data =  3,
-       },
-       {
-               .vendor =       PCI_VENDOR_ID_EFAR,
-               .device =       PCI_DEVICE_ID_EFAR_SLC90E66_3,
-               .subvendor =    PCI_ANY_ID,
-               .subdevice =    PCI_ANY_ID,
-               .driver_data =  0,
-       },
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3),
+         .driver_data = 3 },
+       { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4),
+         .driver_data = 0 },
+       { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5),
+         .driver_data = 0 },
+       { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6),
+         .driver_data = 0 },
+       { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB),
+         .driver_data = 0 },
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3),
+         .driver_data = 3 },
+       { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3),
+         .driver_data = 0 },
        { 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, piix4_ids);
+
 static int __devinit piix4_probe(struct pci_dev *dev,
                                const struct pci_device_id *id)
 {
@@ -495,7 +464,7 @@ static void __devexit piix4_remove(struct pci_dev *dev)
 }
 
 static struct pci_driver piix4_driver = {
-       .name           = "piix4-smbus",
+       .name           = "piix4_smbus",
        .id_table       = piix4_ids,
        .probe          = piix4_probe,
        .remove         = __devexit_p(piix4_remove),
@@ -503,7 +472,7 @@ static struct pci_driver piix4_driver = {
 
 static int __init i2c_piix4_init(void)
 {
-       return pci_module_init(&piix4_driver);
+       return pci_register_driver(&piix4_driver);
 }
 
 static void __exit i2c_piix4_exit(void)