i2c-omap: Switch to static adapter numbering
[powerpc.git] / drivers / i2c / busses / i2c-viapro.c
index c9366b5..7a2bc06 100644 (file)
@@ -4,7 +4,7 @@
     Copyright (c) 1998 - 2002  Frodo Looijaard <frodol@dds.nl>,
     Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>,
     Mark D. Studebaker <mdsxyz123@yahoo.com>
-    Copyright (C) 2005  Jean Delvare <khali@linux-fr.org>
+    Copyright (C) 2005 - 2007  Jean Delvare <khali@linux-fr.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -34,6 +34,9 @@
    VT8233A            0x3147             yes?
    VT8235             0x3177             yes
    VT8237R            0x3227             yes
+   VT8237A            0x3337             yes
+   VT8251             0x3287             yes
+   CX700              0x8324             yes
 
    Note: we assume there can only be one device, with one SMBus interface.
 */
@@ -142,19 +145,18 @@ static int vt596_transaction(u8 size)
        /* Make sure the SMBus host is ready to start transmitting */
        if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
                dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). "
-                       "Resetting... ", temp);
+                       "Resetting...\n", temp);
 
                outb_p(temp, SMBHSTSTS);
                if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
-                       printk("Failed! (0x%02x)\n", temp);
+                       dev_err(&vt596_adapter.dev, "SMBus reset failed! "
+                               "(0x%02x)\n", temp);
                        return -1;
-               } else {
-                       printk("Successful!\n");
                }
        }
 
        /* Start the transaction by setting bit 6 */
-       outb_p(0x40 | (size & 0x3C), SMBHSTCNT);
+       outb_p(0x40 | size, SMBHSTCNT);
 
        /* We will always wait for a fraction of a second */
        do {
@@ -171,7 +173,7 @@ static int vt596_transaction(u8 size)
        if (temp & 0x10) {
                result = -1;
                dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n",
-                       inb_p(SMBHSTCNT) & 0x3C);
+                       size);
        }
 
        if (temp & 0x08) {
@@ -180,11 +182,13 @@ static int vt596_transaction(u8 size)
        }
 
        if (temp & 0x04) {
+               int read = inb_p(SMBHSTADD) & 0x01;
                result = -1;
-               /* Quick commands are used to probe for chips, so
-                  errors are expected, and we don't want to frighten the
-                  user. */
-               if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK)
+               /* The quick and receive byte commands are used to probe
+                  for chips, so errors are expected, and we don't want
+                  to frighten the user. */
+               if (!((size == VT596_QUICK && !read) ||
+                     (size == VT596_BYTE && read)))
                        dev_err(&vt596_adapter.dev, "Transaction error!\n");
        }
 
@@ -296,13 +300,14 @@ static u32 vt596_func(struct i2c_adapter *adapter)
        return func;
 }
 
-static struct i2c_algorithm smbus_algorithm = {
+static const struct i2c_algorithm smbus_algorithm = {
        .smbus_xfer     = vt596_access,
        .functionality  = vt596_func,
 };
 
 static struct i2c_adapter vt596_adapter = {
        .owner          = THIS_MODULE,
+       .id             = I2C_HW_SMBUS_VIA2,
        .class          = I2C_CLASS_HWMON,
        .algo           = &smbus_algorithm,
 };
@@ -380,7 +385,10 @@ found:
        dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
 
        switch (pdev->device) {
+       case PCI_DEVICE_ID_VIA_CX700:
+       case PCI_DEVICE_ID_VIA_8251:
        case PCI_DEVICE_ID_VIA_8237:
+       case PCI_DEVICE_ID_VIA_8237A:
        case PCI_DEVICE_ID_VIA_8235:
        case PCI_DEVICE_ID_VIA_8233A:
        case PCI_DEVICE_ID_VIA_8233_0:
@@ -396,7 +404,7 @@ found:
        }
 
        vt596_adapter.dev.parent = &pdev->dev;
-       snprintf(vt596_adapter.name, I2C_NAME_SIZE,
+       snprintf(vt596_adapter.name, sizeof(vt596_adapter.name),
                 "SMBus Via Pro adapter at %04x", vt596_smba);
 
        vt596_pdev = pci_dev_get(pdev);
@@ -431,15 +439,20 @@ static struct pci_device_id vt596_ids[] = {
          .driver_data = SMBBA3 },
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237),
          .driver_data = SMBBA3 },
+       { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237A),
+         .driver_data = SMBBA3 },
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4),
          .driver_data = SMBBA1 },
+       { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8251),
+         .driver_data = SMBBA3 },
+       { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700),
+         .driver_data = SMBBA3 },
        { 0, }
 };
 
 MODULE_DEVICE_TABLE(pci, vt596_ids);
 
 static struct pci_driver vt596_driver = {
-       .owner          = THIS_MODULE,
        .name           = "vt596_smbus",
        .id_table       = vt596_ids,
        .probe          = vt596_probe,
@@ -462,9 +475,9 @@ static void __exit i2c_vt596_exit(void)
        }
 }
 
-MODULE_AUTHOR(
-    "Frodo Looijaard <frodol@dds.nl> and "
-    "Philip Edelbrock <phil@netroedge.com>");
+MODULE_AUTHOR("Kyosti Malkki <kmalkki@cc.hut.fi>, "
+             "Mark D. Studebaker <mdsxyz123@yahoo.com> and "
+             "Jean Delvare <khali@linux-fr.org>");
 MODULE_DESCRIPTION("vt82c596 SMBus driver");
 MODULE_LICENSE("GPL");