i2c-stub: Allow user to disable some commands
[safe/jmp/linux-2.6] / drivers / i2c / busses / i2c-viapro.c
index 1345da9..e4b1543 100644 (file)
@@ -37,6 +37,7 @@
    VT8251             0x3287             yes
    CX700              0x8324             yes
    VX800/VX820        0x8353             yes
+   VX855/VX875        0x8409             yes
 
    Note: we assume there can only be one device, with one SMBus interface.
 */
@@ -83,6 +84,7 @@ static unsigned short SMBHSTCFG = 0xD2;
 #define VT596_BYTE             0x04
 #define VT596_BYTE_DATA                0x08
 #define VT596_WORD_DATA                0x0C
+#define VT596_PROC_CALL                0x10
 #define VT596_BLOCK_DATA       0x14
 #define VT596_I2C_BLOCK_DATA   0x34
 
@@ -233,6 +235,12 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
                }
                size = VT596_WORD_DATA;
                break;
+       case I2C_SMBUS_PROC_CALL:
+               outb_p(command, SMBHSTCMD);
+               outb_p(data->word & 0xff, SMBHSTDAT0);
+               outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1);
+               size = VT596_PROC_CALL;
+               break;
        case I2C_SMBUS_I2C_BLOCK_DATA:
                if (!(vt596_features & FEATURE_I2CBLOCK))
                        goto exit_unsupported;
@@ -263,6 +271,9 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
        if (status)
                return status;
 
+       if (size == VT596_PROC_CALL)
+               read_write = I2C_SMBUS_READ;
+
        if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK))
                return 0;
 
@@ -272,6 +283,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
                data->byte = inb_p(SMBHSTDAT0);
                break;
        case VT596_WORD_DATA:
+       case VT596_PROC_CALL:
                data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8);
                break;
        case VT596_I2C_BLOCK_DATA:
@@ -296,7 +308,7 @@ static u32 vt596_func(struct i2c_adapter *adapter)
 {
        u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
            I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
-           I2C_FUNC_SMBUS_BLOCK_DATA;
+           I2C_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_DATA;
 
        if (vt596_features & FEATURE_I2CBLOCK)
                func |= I2C_FUNC_SMBUS_I2C_BLOCK;
@@ -310,7 +322,6 @@ static const struct i2c_algorithm smbus_algorithm = {
 
 static struct i2c_adapter vt596_adapter = {
        .owner          = THIS_MODULE,
-       .id             = I2C_HW_SMBUS_VIA2,
        .class          = I2C_CLASS_HWMON | I2C_CLASS_SPD,
        .algo           = &smbus_algorithm,
 };
@@ -321,10 +332,6 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
        unsigned char temp;
        int error = -ENODEV;
 
-       /* driver_data might come from user-space, so check it */
-       if (id->driver_data & 1 || id->driver_data > 0xff)
-               return -EINVAL;
-
        /* Determine the address of the SMBus areas */
        if (force_addr) {
                vt596_smba = force_addr & 0xfff0;
@@ -358,7 +365,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
 found:
        error = acpi_check_region(vt596_smba, 8, vt596_driver.name);
        if (error)
-               return error;
+               return -ENODEV;
 
        if (!request_region(vt596_smba, 8, vt596_driver.name)) {
                dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
@@ -398,6 +405,7 @@ found:
        switch (pdev->device) {
        case PCI_DEVICE_ID_VIA_CX700:
        case PCI_DEVICE_ID_VIA_VX800:
+       case PCI_DEVICE_ID_VIA_VX855:
        case PCI_DEVICE_ID_VIA_8251:
        case PCI_DEVICE_ID_VIA_8237:
        case PCI_DEVICE_ID_VIA_8237A:
@@ -463,6 +471,8 @@ static struct pci_device_id vt596_ids[] = {
          .driver_data = SMBBA3 },
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800),
          .driver_data = SMBBA3 },
+       { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855),
+         .driver_data = SMBBA3 },
        { 0, }
 };
 
@@ -472,7 +482,6 @@ static struct pci_driver vt596_driver = {
        .name           = "vt596_smbus",
        .id_table       = vt596_ids,
        .probe          = vt596_probe,
-       .dynids.use_driver_data = 1,
 };
 
 static int __init i2c_vt596_init(void)