summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFugang Duan <b38611@freescale.com>2014-08-11 15:14:50 +0800
committerhaibo.chen <haibo.chen@freescale.com>2014-08-25 11:30:25 +0800
commit53118db42d201d36ca9067b4bb0e2702399e100b (patch)
treec56f7730e1eff5012f5a64fe3b3b9e32c0a8f5d0
parent01996acd7788c831fc06872c59af99f3bd6f6b03 (diff)
downloadu-boot-imx-53118db42d201d36ca9067b4bb0e2702399e100b.zip
u-boot-imx-53118db42d201d36ca9067b4bb0e2702399e100b.tar.gz
u-boot-imx-53118db42d201d36ca9067b4bb0e2702399e100b.tar.bz2
ENGR00328312 i2c: imx: Optimize the i2c device recovery solution
From i2c spec, if device pull down the SDA line that causes i2c bus dead, host can send out 9 clock to let device release SDA. But for some special device like pfuze100, it pull down SDA line and the solution cannot take effort. The patch just add NACK and STOP signal after 8 dummy clock, and pmic can release SDA line after the recovery. Test case catch 375 times of i2c hang, and all are recovered. Signed-off-by: Fugang Duan <B38611@freescale.com>
-rw-r--r--arch/arm/imx-common/i2c-mxv7.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/arch/arm/imx-common/i2c-mxv7.c b/arch/arm/imx-common/i2c-mxv7.c
index a580873..5ef1530 100644
--- a/arch/arm/imx-common/i2c-mxv7.c
+++ b/arch/arm/imx-common/i2c-mxv7.c
@@ -32,13 +32,36 @@ static int force_idle_bus(void *priv)
printf("%s: sda=%d scl=%d sda.gp=0x%x scl.gp=0x%x\n", __func__,
sda, scl, p->sda.gp, p->scl.gp);
+ gpio_direction_output(p->scl.gp, 1);
+ udelay(1000);
/* Send high and low on the SCL line */
for (i = 0; i < 9; i++) {
- gpio_direction_output(p->scl.gp, 0);
+ gpio_direction_output(p->scl.gp, 1);
udelay(50);
- gpio_direction_input(p->scl.gp);
+ gpio_direction_output(p->scl.gp, 0);
udelay(50);
}
+
+ /* Simulate the NACK */
+ gpio_direction_output(p->sda.gp, 1);
+ udelay(50);
+ gpio_direction_output(p->scl.gp, 1);
+ udelay(50);
+ gpio_direction_output(p->scl.gp, 0);
+ udelay(50);
+
+ /* Simulate the STOP signal */
+ gpio_direction_output(p->sda.gp, 0);
+ udelay(50);
+ gpio_direction_output(p->scl.gp, 1);
+ udelay(50);
+ gpio_direction_output(p->sda.gp, 1);
+ udelay(50);
+
+ /* Get the bus status */
+ gpio_direction_input(p->sda.gp);
+ gpio_direction_input(p->scl.gp);
+
start_time = get_timer(0);
for (;;) {
sda = gpio_get_value(p->sda.gp);