mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-12-26 00:26:47 +02:00
343c185b7d
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@16547 3c298f89-4303-0410-b956-a3cf2f4a3e73
124 lines
2.8 KiB
Diff
124 lines
2.8 KiB
Diff
From b9607c9083b767eac26df1d39a030f3cba5d3ae3 Mon Sep 17 00:00:00 2001
|
|
From: Kurt Mahan <kmahan@freescale.com>
|
|
Date: Fri, 18 Jul 2008 12:40:04 -0600
|
|
Subject: [PATCH] Increase timeouts on I2C bus.
|
|
|
|
LTIBName: m547x-8x-i2c-timeout-fix
|
|
Signed-off-by: Shrek Wu <b16972@freescale.com>
|
|
---
|
|
drivers/i2c/busses/i2c-mcf548x.c | 40 +++++++++++++++++++++++++++++--------
|
|
1 files changed, 31 insertions(+), 9 deletions(-)
|
|
|
|
--- a/drivers/i2c/busses/i2c-mcf548x.c
|
|
+++ b/drivers/i2c/busses/i2c-mcf548x.c
|
|
@@ -43,8 +43,8 @@ static struct i2c_adapter i2c_mcf_board_
|
|
.id = I2C_HW_MPC107,
|
|
.algo_data = &i2c_mcf_board_data,
|
|
.class = I2C_CLASS_HWMON,
|
|
- .timeout = 1,
|
|
- .retries = 1
|
|
+ .timeout = 100,
|
|
+ .retries = 2
|
|
};
|
|
/*
|
|
* static void i2c_start()
|
|
@@ -105,7 +105,7 @@ wait_for_bb(
|
|
for (i = 0; i < adap->timeout; i++) {
|
|
if (!(MCF_I2SR & MCF_I2SR_IBB))
|
|
return 0;
|
|
- udelay(10);
|
|
+ udelay(100);
|
|
}
|
|
printk(KERN_ERR "%s: timeout", __FUNCTION__);
|
|
return -ETIMEDOUT;
|
|
@@ -124,7 +124,7 @@ wait_for_not_bb(
|
|
for (i = 0; i < adap->timeout; i++) {
|
|
if (MCF_I2SR & MCF_I2SR_IBB)
|
|
return 0;
|
|
- udelay(10);
|
|
+ udelay(100);
|
|
}
|
|
printk(KERN_ERR "%s: timeout", __FUNCTION__);
|
|
return -ETIMEDOUT;
|
|
@@ -146,7 +146,7 @@ wait_xfer_done(
|
|
MCF_I2SR &= ~MCF_I2SR_IIF;
|
|
return 0;
|
|
}
|
|
- udelay(1);
|
|
+ udelay(10);
|
|
}
|
|
printk(KERN_ERR "%s: timeout", __FUNCTION__);
|
|
return -ETIMEDOUT;
|
|
@@ -166,7 +166,7 @@ i2c_set_addr(
|
|
) {
|
|
unsigned short flags = msg->flags;
|
|
unsigned char addr;
|
|
-
|
|
+ MCF_I2CR |= MCF_I2CR_MTX;
|
|
if ((flags & I2C_M_TEN)) {
|
|
/* 10 bit address not supported yet */
|
|
return -EIO;
|
|
@@ -269,7 +269,7 @@ mcf_sendbytes(
|
|
i2c_stop(adap);
|
|
wait_for_bb(adap);
|
|
} else {
|
|
- i2c_repstart(adap);
|
|
+ /* i2c_repstart(adap);*/
|
|
}
|
|
|
|
return (i);
|
|
@@ -330,7 +330,7 @@ mcf_readbytes(
|
|
i2c_stop(adap);
|
|
wait_for_bb(adap);
|
|
} else {
|
|
- i2c_repstart(adap);
|
|
+ /* i2c_repstart(adap);*/
|
|
}
|
|
|
|
return (i+1);
|
|
@@ -380,6 +380,27 @@ mcf_xfer(
|
|
wait_for_bb(adap);
|
|
|
|
for (i = 0; ret >= 0 && i < num; i++) {
|
|
+ if (MCF_I2SR & MCF_I2SR_IBB) {
|
|
+ MCF_I2ICR = 0x00;
|
|
+ MCF_I2CR = 0x00;
|
|
+ MCF_I2CR = 0x0A;
|
|
+ timeout = MCF_I2DR;
|
|
+ MCF_I2SR = 0x00;
|
|
+ MCF_I2CR = 0x00;
|
|
+ MCF_I2ICR = 0x01;
|
|
+ }
|
|
+ /* setup SCL clock */
|
|
+ MCF_I2FDR = get_clock(adap);
|
|
+ /* set slave address */
|
|
+ MCF_I2AR = get_own(adap);
|
|
+ /* enable I2C module */
|
|
+ MCF_I2CR = MCF_I2CR_IEN;
|
|
+
|
|
+ MCF_I2CR |= MCF_I2CR_TXAK;
|
|
+
|
|
+ /* Check for bus busy */
|
|
+ wait_for_bb(adap);
|
|
+
|
|
pmsg = &msgs[i];
|
|
|
|
printk(KERN_DEBUG "i2c-algo-mcf: Doing %s %d bytes "
|
|
@@ -388,7 +409,7 @@ mcf_xfer(
|
|
pmsg->len, pmsg->addr, i + 1, num);
|
|
|
|
/* Send START */
|
|
- if (i == 0)
|
|
+ /*if (i == 0)*/
|
|
i2c_start(adap);
|
|
|
|
/* Wait for Bus Busy */
|
|
@@ -440,6 +461,7 @@ mcf_xfer(
|
|
"%d bytes.\n", ret);
|
|
}
|
|
}
|
|
+ MCF_I2CR = 0;
|
|
}
|
|
|
|
/* Disable I2C module */
|