]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
viafb: fix I2C emulation on GPIO ports
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Thu, 29 Dec 2011 23:37:07 +0000 (23:37 +0000)
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Sun, 12 Feb 2012 22:15:16 +0000 (22:15 +0000)
This patch fixes the I2C emulation on GPIO ports by enabling it
(software controlled) and disabling the output on a GPIO line before
reading it.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
drivers/video/via/via_i2c.c

index 78f1405dbab794a280853a2c1e686b4ad757040a..dd53058bbbb7cf0b2c19d27561936d894b05ac14 100644 (file)
@@ -51,7 +51,7 @@ static void via_i2c_setscl(void *data, int state)
                val |= 0x01;
                break;
        case VIA_PORT_GPIO:
-               val |= 0x80;
+               val |= 0x82;
                break;
        default:
                printk(KERN_ERR "viafb_i2c: specify wrong i2c type.\n");
@@ -67,6 +67,9 @@ static int via_i2c_getscl(void *data)
        int ret = 0;
 
        spin_lock_irqsave(&i2c_vdev->reg_lock, flags);
+       if (adap_data->type == VIA_PORT_GPIO)
+               via_write_reg_mask(adap_data->io_port, adap_data->ioport_index,
+                       0, 0x80);
        if (via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x08)
                ret = 1;
        spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags);
@@ -80,6 +83,9 @@ static int via_i2c_getsda(void *data)
        int ret = 0;
 
        spin_lock_irqsave(&i2c_vdev->reg_lock, flags);
+       if (adap_data->type == VIA_PORT_GPIO)
+               via_write_reg_mask(adap_data->io_port, adap_data->ioport_index,
+                       0, 0x40);
        if (via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x04)
                ret = 1;
        spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags);
@@ -103,7 +109,7 @@ static void via_i2c_setsda(void *data, int state)
                val |= 0x01;
                break;
        case VIA_PORT_GPIO:
-               val |= 0x40;
+               val |= 0x42;
                break;
        default:
                printk(KERN_ERR "viafb_i2c: specify wrong i2c type.\n");