mfd: Disable TWL4030/5030 I2C1/I2C4 internal pull-ups
authorMoiz Sonasath <m-sonasath@ti.com>
Wed, 17 Feb 2010 00:57:21 +0000 (18:57 -0600)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 7 Mar 2010 21:17:23 +0000 (22:17 +0100)
This patch disables TWL4030/5030 I2C1 adn I2C4(SR) internal pull-up, to
use only the external HW resistor >=470 Ohm for the assured
functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that
without a proper pull-up resistor, there is data corruption during
multi-byte transfer. RTC(time_set) test case was used for testing.

From the analysis done, it was concluded that ideally we need a
pull-up of 1.6k Ohm(recomended) or atleast 470 Ohm or greater for
assured performance in HS mode.

Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Allen Pais <allen.pais@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/twl-core.c
include/linux/i2c/twl.h

index 942a1e837819d21d9ac9846c74edc0a18f60b0b5..7ccc39f3aa48e61ccf7fb98d1618a9170ebe6c6f 100644 (file)
@@ -958,6 +958,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
        int                             status;
        unsigned                        i;
        struct twl4030_platform_data    *pdata = client->dev.platform_data;
+       u8 temp;
 
        if (!pdata) {
                dev_dbg(&client->dev, "no platform data?\n");
@@ -1025,6 +1026,18 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
                        goto fail;
        }
 
+       /* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
+        * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
+        * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
+        */
+
+       if (twl_class_is_4030()) {
+               twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1);
+               temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
+               I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
+               twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
+       }
+
        status = add_children(pdata, id->driver_data);
 fail:
        if (status < 0)
index 9733e9e53f2b77d2eab88ba0947068b26f1cb710..e28d4c0e45bd2fd27b38833616f90d5543f4576c 100644 (file)
@@ -239,6 +239,21 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
 /*----------------------------------------------------------------------*/
 
+/*Interface Bit Register (INTBR) offsets
+ *(Use TWL_4030_MODULE_INTBR)
+ */
+
+#define REG_GPPUPDCTR1                 0x0F
+
+/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
+
+#define I2C_SCL_CTRL_PU                        BIT(0)
+#define I2C_SDA_CTRL_PU                        BIT(2)
+#define SR_I2C_SCL_CTRL_PU             BIT(4)
+#define SR_I2C_SDA_CTRL_PU             BIT(6)
+
+/*----------------------------------------------------------------------*/
+
 /*
  * Keypad register offsets (use TWL4030_MODULE_KEYPAD)
  * ... SIH/interrupt only