summaryrefslogtreecommitdiff
path: root/drivers/i2c/fsl_i2c.c
diff options
context:
space:
mode:
authorMarkus Klotzbuecher <mk@denx.de>2008-08-04 19:18:14 +0200
committerMarkus Klotzbuecher <mk@denx.de>2008-08-04 19:18:14 +0200
commit0f2b5d8ec0969a5b0992f5031bf3c61117a41d59 (patch)
treefc05bf5db93e5a9c1712d24a5efdff94685063c2 /drivers/i2c/fsl_i2c.c
parentab06bddb04ed4be50a8f9ad5f94fa23953a734e3 (diff)
parent81091f58f0c58ecd26c5b05de2ae20ca6cdb521c (diff)
downloadu-boot-imx-0f2b5d8ec0969a5b0992f5031bf3c61117a41d59.zip
u-boot-imx-0f2b5d8ec0969a5b0992f5031bf3c61117a41d59.tar.gz
u-boot-imx-0f2b5d8ec0969a5b0992f5031bf3c61117a41d59.tar.bz2
Merge branch 'master' of git://www.denx.de/git/u-boot
Diffstat (limited to 'drivers/i2c/fsl_i2c.c')
-rw-r--r--drivers/i2c/fsl_i2c.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index 9f2c1ec..3f78e2f 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -143,12 +143,15 @@ void
i2c_init(int speed, int slaveadd)
{
struct fsl_i2c *dev;
+ unsigned int temp;
dev = (struct fsl_i2c *) (CFG_IMMR + CFG_I2C_OFFSET);
writeb(0, &dev->cr); /* stop I2C controller */
udelay(5); /* let it shutdown in peace */
- i2c_bus_speed[0] = set_i2c_bus_speed(dev, gd->i2c1_clk, speed);
+ temp = set_i2c_bus_speed(dev, gd->i2c1_clk, speed);
+ if (gd->flags & GD_FLG_RELOC)
+ i2c_bus_speed[0] = temp;
writeb(slaveadd << 1, &dev->adr); /* write slave address */
writeb(0x0, &dev->sr); /* clear status register */
writeb(I2C_CR_MEN, &dev->cr); /* start I2C controller */
@@ -158,7 +161,9 @@ i2c_init(int speed, int slaveadd)
writeb(0, &dev->cr); /* stop I2C controller */
udelay(5); /* let it shutdown in peace */
- i2c_bus_speed[1] = set_i2c_bus_speed(dev, gd->i2c2_clk, speed);
+ temp = set_i2c_bus_speed(dev, gd->i2c2_clk, speed);
+ if (gd->flags & GD_FLG_RELOC)
+ i2c_bus_speed[1] = temp;
writeb(slaveadd << 1, &dev->adr); /* write slave address */
writeb(0x0, &dev->sr); /* clear status register */
writeb(I2C_CR_MEN, &dev->cr); /* start I2C controller */
@@ -168,12 +173,11 @@ i2c_init(int speed, int slaveadd)
static __inline__ int
i2c_wait4bus(void)
{
- ulong timeval = get_timer(0);
+ unsigned long long timeval = get_ticks();
while (readb(&i2c_dev[i2c_bus_num]->sr) & I2C_SR_MBB) {
- if (get_timer(timeval) > I2C_TIMEOUT) {
+ if ((get_ticks() - timeval) > usec2ticks(I2C_TIMEOUT))
return -1;
- }
}
return 0;
@@ -183,7 +187,7 @@ static __inline__ int
i2c_wait(int write)
{
u32 csr;
- ulong timeval = get_timer(0);
+ unsigned long long timeval = get_ticks();
do {
csr = readb(&i2c_dev[i2c_bus_num]->sr);
@@ -208,7 +212,7 @@ i2c_wait(int write)
}
return 0;
- } while (get_timer (timeval) < I2C_TIMEOUT);
+ } while ((get_ticks() - timeval) < usec2ticks(I2C_TIMEOUT));
debug("i2c_wait: timed out\n");
return -1;