From: Grygorii Strashko <grygorii.strashko@ti.com>
To: "Wolfram Sang" <wsa@the-dreams.de>,
"Sekhar Nori" <nsekhar@ti.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: <linux-i2c@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
Mike Looijmans <milo-software@users.sourceforge.net>,
Grygorii Strashko <grygorii.strashko@ti.com>,
Kevin Hilman <khilman@deeprootsystems.com>,
Santosh Shilimkar <ssantosh@kernel.org>,
Murali Karicheri <m-karicheri2@ti.com>
Subject: [PATCH v2 2/5] i2c: davinci: query STP always when NACK is received
Date: Wed, 26 Nov 2014 15:59:50 +0200 [thread overview]
Message-ID: <1417010393-30598-3-git-send-email-grygorii.strashko@ti.com> (raw)
In-Reply-To: <1417010393-30598-1-git-send-email-grygorii.strashko@ti.com>
According to I2C specification the NACK should be handled as folows:
"When SDA remains HIGH during this ninth clock pulse, this is defined as the Not
Acknowledge signal. The master can then generate either a STOP condition to
abort the transfer, or a repeated START condition to start a new transfer."
[I2C spec Rev. 6, 3.1.6: http://www.nxp.com/documents/user_manual/UM10204.pdf]
Currently the Davinci i2c driver interrupts the transfer on receipt of a
NACK but fails to send a STOP in some situations and so makes the bus
stuck until next I2C IP reset (idle/enable).
For example, the issue will happen during SMBus read transfer which
consists from two i2c messages write command/address and read data:
S Slave Address Wr A Command Code A Sr Slave Address Rd A D1..Dn A P
<--- write -----------------------> <--- read --------------------->
The I2C client device will send NACK if it can't recognize "Command Code"
and it's expected from I2C master to query STP in this case.
But now, Davinci i2C driver will just exit with -EREMOTEIO and STP will
not be queried.
Hence, fix it by querying Stop condition (STP) always when NACK is received.
This patch fixes Davinci I2C in the same way it was done for OMAP I2C
commit cda2109a26eb ("i2c: omap: query STP always when NACK is received").
CC: Sekhar Nori <nsekhar@ti.com>
CC: Kevin Hilman <khilman@deeprootsystems.com>
CC: Santosh Shilimkar <ssantosh@kernel.org>
CC: Murali Karicheri <m-karicheri2@ti.com>
Reported-by: Hein Tibosch <hein_tibosch@yahoo.es>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
drivers/i2c/busses/i2c-davinci.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 7f54903..1990ae8 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -411,11 +411,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
if (dev->cmd_err & DAVINCI_I2C_STR_NACK) {
if (msg->flags & I2C_M_IGNORE_NAK)
return msg->len;
- if (stop) {
- w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
- w |= DAVINCI_I2C_MDR_STP;
- davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
- }
+ w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
+ w |= DAVINCI_I2C_MDR_STP;
+ davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
return -EREMOTEIO;
}
return -EIO;
--
1.9.1
next prev parent reply other threads:[~2014-11-26 14:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 13:59 [PATCH v2 0/5] i2c: davinci improvements and fixes Grygorii Strashko
2014-11-26 13:59 ` [PATCH v2 1/5] i2c: i2c-davinci: switch to use platform_get_irq Grygorii Strashko
2014-11-26 15:54 ` Uwe Kleine-König
2014-11-26 16:28 ` Grygorii Strashko
2014-11-26 13:59 ` Grygorii Strashko [this message]
2014-11-26 15:57 ` [PATCH v2 2/5] i2c: davinci: query STP always when NACK is received Uwe Kleine-König
2014-11-26 16:31 ` Grygorii Strashko
2014-11-26 17:15 ` Uwe Kleine-König
2014-11-26 13:59 ` [PATCH v2 3/5] i2c: recovery: change input parameter to i2c_adapter for prepare/unprepare_recovery Grygorii Strashko
2014-11-26 13:59 ` [PATCH v2 4/5] i2c: davinci: use bus recovery infrastructure Grygorii Strashko
2014-11-26 15:59 ` Uwe Kleine-König
2014-11-26 13:59 ` [PATCH v2 5/5] i2c: davinci: use ICPFUNC to toggle I2C as gpio for bus recovery Grygorii Strashko
2014-11-26 16:04 ` Uwe Kleine-König
2014-11-26 17:05 ` Grygorii Strashko
2015-07-07 13:37 ` Jan Lübbe
2015-07-07 13:43 ` Wolfram Sang
2015-07-07 13:48 ` Uwe Kleine-König
2015-07-07 14:13 ` Wolfram Sang
2015-07-07 14:53 ` Grygorii Strashko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417010393-30598-3-git-send-email-grygorii.strashko@ti.com \
--to=grygorii.strashko@ti.com \
--cc=khilman@deeprootsystems.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-karicheri2@ti.com \
--cc=milo-software@users.sourceforge.net \
--cc=nsekhar@ti.com \
--cc=ssantosh@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®