diff options
author | Imre Kaloz <kaloz@openwrt.org> | 2012-09-27 08:06:13 +0000 |
---|---|---|
committer | Imre Kaloz <kaloz@openwrt.org> | 2012-09-27 08:06:13 +0000 |
commit | eec34ef0323d1352f685a6cdfdec70ea8cee2b38 (patch) | |
tree | d4c4dbb565d1f363fc48500f1032b03fbe767f09 | |
parent | 4f0ecc3ff50be641e66cb8ad644f280a9db02a2c (diff) | |
download | master-187ad058-eec34ef0323d1352f685a6cdfdec70ea8cee2b38.tar.gz master-187ad058-eec34ef0323d1352f685a6cdfdec70ea8cee2b38.tar.bz2 master-187ad058-eec34ef0323d1352f685a6cdfdec70ea8cee2b38.zip |
[cns3xxx]: add i2c retries
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33565 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | target/linux/cns3xxx/patches-3.3/440-i2c_retry.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/target/linux/cns3xxx/patches-3.3/440-i2c_retry.patch b/target/linux/cns3xxx/patches-3.3/440-i2c_retry.patch new file mode 100644 index 0000000000..707de82bab --- /dev/null +++ b/target/linux/cns3xxx/patches-3.3/440-i2c_retry.patch @@ -0,0 +1,72 @@ +--- a/drivers/i2c/busses/i2c-cns3xxx.c ++++ b/drivers/i2c/busses/i2c-cns3xxx.c +@@ -2,8 +2,9 @@ + * Cavium CNS3xxx I2C Host Controller + * + * Copyright 2010 Cavium Network +- * Copyright 2011 Gateworks Corporation ++ * Copyright 2012 Gateworks Corporation + * Chris Lang <clang@gateworks.com> ++ * Tim Harvey <tharvey@gateworks.com> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, as +@@ -63,13 +64,15 @@ + #define STATE_ERROR 2 + + struct cns3xxx_i2c { +- void __iomem *base; +- wait_queue_head_t wait; +- struct i2c_adapter adap; +- struct i2c_msg *msg; +- int state; /* see STATE_ */ +- int rd_wr_len; +- u8 *buf; ++ struct device *dev; ++ void __iomem *base; /* virtual */ ++ wait_queue_head_t wait; ++ struct i2c_adapter adap; ++ struct i2c_msg *msg; ++ u8 state; /* see STATE_ */ ++ u8 error; /* see TWI_STATUS register */ ++ int rd_wr_len; ++ u8 *buf; + }; + + static u32 cns3xxx_i2c_func(struct i2c_adapter *adap) +@@ -150,14 +153,18 @@ cns3xxx_i2c_xfer_msg(struct i2c_adapter + + // Start the Transfer + i2c->state = 0; // Clear out the State ++ i2c->error = 0; + I2C_CONTROLLER_REG |= (1 << 6); + + if (wait_event_timeout(i2c->wait, (i2c->state == STATE_ERROR) || + (i2c->state == STATE_DONE), TWI_TIMEOUT)) { + if (i2c->state == STATE_ERROR) { +- return -EIO; ++ dev_dbg(i2c->dev, "controller error: 0x%2x", i2c->error); ++ return -EAGAIN; // try again + } + } else { ++ dev_err(i2c->dev, "controller timed out " ++ "waiting for start condition to finish\n"); + return -ETIMEDOUT; + } + } +@@ -238,6 +245,7 @@ static irqreturn_t cns3xxx_i2c_isr(int i + + if (stat & I2C_BUS_ERROR_FLAG) { + i2c->state = STATE_ERROR; ++ i2c->error = (I2C_INTERRUPT_STATUS_REG & 0xff00)>>8; + } else { + if (i2c->msg->flags & I2C_M_RD) { + for (i = 0; i <= i2c->rd_wr_len; i++) +@@ -280,6 +288,7 @@ static int __devinit cns3xxx_i2c_probe(s + goto request_mem_failed; + } + ++ i2c->dev = &pdev->dev; + i2c->base = ioremap(res->start, res->end - res->start + 1); + if (!i2c->base) { + dev_err(&pdev->dev, "Unable to map registers\n"); |