diff options
author | David Yu <davyu@nvidia.com> | 2014-03-07 23:10:50 +0900 |
---|---|---|
committer | Harry Hong <hhong@nvidia.com> | 2014-03-12 17:42:22 -0700 |
commit | 1da62bf1062d08c46593a43444f598a187db5ac3 (patch) | |
tree | 76e9ad0cbbf8d52666a309a7650c3ff36b130be4 | |
parent | ce98dc80f689cbc3a75ebf316fc07a9e67580bf9 (diff) |
input: misc: mpu: fix i2c arbitration lost
Arbitration lost occurs when regulators are turned on while another
i2c device on the same bus is transferring data.
This impacts all the slave devices on the same bus.
tegra-i2c tegra11-i2c.0: --- register dump for debugging ----
tegra-i2c tegra11-i2c.0: I2C_CNFG - 0x2c00
tegra-i2c tegra11-i2c.0: I2C_PACKET_TRANSFER_STATUS - 0xff0021
tegra-i2c tegra11-i2c.0: I2C_FIFO_CONTROL - 0xe0
tegra-i2c tegra11-i2c.0: I2C_FIFO_STATUS - 0x800080
tegra-i2c tegra11-i2c.0: I2C_INT_MASK - 0xec
tegra-i2c tegra11-i2c.0: I2C_INT_STATUS - 0x2
tegra-i2c tegra11-i2c.0: msg->len - 3
tegra-i2c tegra11-i2c.0: is_msg_write - 1
tegra-i2c tegra11-i2c.0: buf_remaining - 0
tegra-i2c tegra11-i2c.0: i2c transfer timed out, addr 0x001c, data 0x6a
tegra-i2c tegra11-i2c.0: arbitration lost during communicate to add 0x69
tegra-i2c tegra11-i2c.0: Recovered Arbitration lost
tegra-i2c tegra11-i2c.0: arbitration lost during communicate to add 0x1c
tegra-i2c tegra11-i2c.0: Recovered Arbitration lost
tegra-i2c tegra11-i2c.0: arbitration lost during communicate to add 0x1c
tegra-i2c tegra11-i2c.0: Recovered Arbitration lost
Bug 1461473
Change-Id: I417e1e81fa0a1628784f5e6062fa6f8e1979a038
Signed-off-by: David Yu <davyu@nvidia.com>
Reviewed-on: http://git-master/r/379058
Reviewed-by: Harry Hong <hhong@nvidia.com>
Tested-by: Harry Hong <hhong@nvidia.com>
-rw-r--r-- | drivers/input/misc/mpu/inv_gyro.c | 6 | ||||
-rw-r--r-- | include/linux/mpu.h | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/drivers/input/misc/mpu/inv_gyro.c b/drivers/input/misc/mpu/inv_gyro.c index 9b67b9f88748..402c54b23e78 100644 --- a/drivers/input/misc/mpu/inv_gyro.c +++ b/drivers/input/misc/mpu/inv_gyro.c @@ -814,8 +814,14 @@ static int nvi_vreg_en_all(struct inv_gyro_state_s *inf) unsigned i; int err = 0; +#if LOCK_I2C_ON_REG_ON + i2c_lock_adapter(inf->sl_handle); +#endif for (i = 0; i < ARRAY_SIZE(nvi_vregs); i++) err |= nvi_vreg_en(inf, i); +#if LOCK_I2C_ON_REG_ON + i2c_unlock_adapter(inf->sl_handle); +#endif if (err == 1) mdelay(9); return err; diff --git a/include/linux/mpu.h b/include/linux/mpu.h index 876d805b8855..939847e83325 100644 --- a/include/linux/mpu.h +++ b/include/linux/mpu.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2012 Invensense, Inc. -* Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -56,6 +56,14 @@ **********************************************************************/ #define DEBUG_SYSFS_INTERFACE 1 +/*********************************************************************/ +/* LOCK_I2C_ON_REG_ON + * Lock I2C bus when regulators are turned on to avoid I2C error. + * Disable this feature if regulators are on the same bus. + * Otherwise deadlock occurs. +**********************************************************************/ +#define LOCK_I2C_ON_REG_ON (1) + /* Mount maxtices for mount orientation. * MTMAT_XXX_CCW_YYY * XXX : mount position. TOP for top and BOT for bottom. |