From b5e2ad69b5f5cc13f5a96b09335896d6d5dbed78 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 27 Mar 2012 18:54:35 +0530 Subject: i2c: tegra: Support for I2C_M_REV_DIR_ADDR protocol mangling Add support for protocol mangling "I2C_M_REV_DIR_ADDR" Change-Id: Icdef16885f1cf6ed1ce9c4003a94c2c2e917ced2 Signed-off-by: Laxman Dewangan Reviewed-on: http://git-master/r/92572 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Stephen Warren --- drivers/i2c/busses/i2c-tegra.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index bde4a6dd8e33..a4c1e0d82939 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -633,6 +633,10 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_bus *i2c_bus, tegra_i2c_flush_fifos(i2c_dev); + /* Toggle the direction flag if rev dir is selected */ + if (msg->flags & I2C_M_REV_DIR_ADDR) + msg->flags ^= I2C_M_RD; + i2c_dev->msg_buf = msg->buf; i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err = I2C_ERR_NONE; @@ -690,6 +694,10 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_bus *i2c_bus, if (i2c_dev->is_dvc) dvc_i2c_mask_irq(i2c_dev, DVC_CTRL_REG3_I2C_DONE_INTR_EN); + /* Restore the message flag */ + if (msg->flags & I2C_M_REV_DIR_ADDR) + msg->flags ^= I2C_M_RD; + if (WARN_ON(ret == 0)) { dev_err(i2c_dev->dev, "i2c transfer timed out, addr 0x%04x, data 0x%02x\n", @@ -783,7 +791,8 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], static u32 tegra_i2c_func(struct i2c_adapter *adap) { - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | + I2C_FUNC_PROTOCOL_MANGLING; } static const struct i2c_algorithm tegra_i2c_algo = { -- cgit v1.2.3