Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1438636

[PATCH] i2c: imx: add retries for i2c-0 on Ventana boards

From Tim Harvey <tharvey@gateworks.com>
Newsgroups linux.kernel
Subject [PATCH] i2c: imx: add retries for i2c-0 on Ventana boards
Date 2016-07-07 16:00 +0200
Message-ID <rSi0p-7C9-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Gateworks Ventana IMX6 based boards have a Gateworks System Controller [1]
(gsc) device that can NAK i2c transactions when its busy in an ADC loop. As
this is always on i2c-0 we will add retries for that bus for any Ventana
board.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 drivers/i2c/busses/i2c-imx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 1844bc9..aec71c3 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -460,6 +460,8 @@ static int i2c_imx_acked(struct imx_i2c_struct *i2c_imx)
 {
 	if (imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR) & I2SR_RXAK) {
 		dev_dbg(&i2c_imx->adapter.dev, "<%s> No ACK\n", __func__);
+		if (i2c_imx->adapter.retries)
+			return -EAGAIN;
 		return -ENXIO;  /* No ACK */
 	}
 
@@ -1068,6 +1070,16 @@ static int i2c_imx_probe(struct platform_device *pdev)
 	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
 	i2c_imx->base			= base;
 
+	/*
+	 * The Gateworks Ventana has an i2c based system controller on i2c-0
+	 * which emulates several standard i2c devices with existing drivers.
+	 * That device can NAK when its in an ADC loop. Add bus retries.
+	 */
+	if (of_machine_is_compatible("gw,ventana") && phy_addr == 0x021a0000) {
+		dev_info(&pdev->dev, "Adding retries for Ventana GSC\n");
+		i2c_imx->adapter.retries = 3;
+	}
+
 	/* Get I2C clock */
 	i2c_imx->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(i2c_imx->clk)) {
-- 
1.9.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] i2c: imx: add retries for i2c-0 on Ventana boards Tim Harvey <tharvey@gateworks.com> - 2016-07-07 16:00 +0200
  Re: [PATCH] i2c: imx: add retries for i2c-0 on Ventana boards Uwe Kleine-König   <u.kleine-koenig@pengutronix.de> - 2016-07-08 08:30 +0200
    Re: [PATCH] i2c: imx: add retries for i2c-0 on Ventana boards Tim Harvey <tharvey@gateworks.com> - 2016-07-08 21:50 +0200
      Re: [PATCH] i2c: imx: add retries for i2c-0 on Ventana boards Uwe Kleine-König   <u.kleine-koenig@pengutronix.de> - 2016-07-08 23:10 +0200
        Re: [PATCH] i2c: imx: add retries for i2c-0 on Ventana boards Wolfram Sang <wsa@the-dreams.de> - 2016-07-09 04:40 +0200

csiph-web