aea87eaa5fd9446e7e27fab6a4216a333dce1a94
[openwrt/svn-archive/archive.git] / target / linux / imx6 / patches-3.10 / 0004-i2c-imx-retry-on-NAK.patch
1 From 0d1ee1f265cf9730feb214ddd18bc430c0800e8b Mon Sep 17 00:00:00 2001
2 From: Tim Harvey <tharvey@gateworks.com>
3 Date: Tue, 10 Sep 2013 21:42:29 +0200
4 Subject: [PATCH] i2c: imx: retry on NAK
5
6 In case of busy i2c try again to get ACK.
7
8 Signed-off-by: Tim Harvey <tharvey@gateworks.com>
9 Tested-by: Luka Perkov <luka@openwrt.org>
10 ---
11 drivers/i2c/busses/i2c-imx.c | 4 +++-
12 1 file changed, 3 insertions(+), 1 deletion(-)
13
14 --- a/drivers/i2c/busses/i2c-imx.c
15 +++ b/drivers/i2c/busses/i2c-imx.c
16 @@ -62,6 +62,7 @@
17
18 /* Default value */
19 #define IMX_I2C_BIT_RATE 100000 /* 100kHz */
20 +#define IMX_I2C_MAX_RETRIES 3 /* number of retries to attempt */
21
22 /* IMX I2C registers */
23 #define IMX_I2C_IADR 0x00 /* i2c slave address */
24 @@ -198,7 +199,7 @@ static int i2c_imx_acked(struct imx_i2c_
25 {
26 if (readb(i2c_imx->base + IMX_I2C_I2SR) & I2SR_RXAK) {
27 dev_dbg(&i2c_imx->adapter.dev, "<%s> No ACK\n", __func__);
28 - return -EIO; /* No ACK */
29 + return -EAGAIN; /* try again */
30 }
31
32 dev_dbg(&i2c_imx->adapter.dev, "<%s> ACK received\n", __func__);
33 @@ -533,6 +534,7 @@ static int __init i2c_imx_probe(struct p
34 i2c_imx->adapter.dev.parent = &pdev->dev;
35 i2c_imx->adapter.nr = pdev->id;
36 i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
37 + i2c_imx->adapter.retries = IMX_I2C_MAX_RETRIES;
38 i2c_imx->base = base;
39
40 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);