From: Alexander Kochetkov <al.kochet@gmail.com>
To: Kevin Hilman <khilman@kernel.org>,
Tony Lindgren <tony@atomide.com>, Felipe Balbi <balbi@ti.com>,
Wolfram Sang <wsa@the-dreams.de>,
Alexander Kochetkov <al.kochet@gmail.com>
Cc: linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [RFC 3/5] i2c: omap: move STP generation logic into ISR thread
Date: Wed, 3 Dec 2014 18:34:00 +0400 [thread overview]
Message-ID: <1417617242-16869-4-git-send-email-al.kochet@gmail.com> (raw)
In-Reply-To: <1417617242-16869-1-git-send-email-al.kochet@gmail.com>
The main reason is to avoid CON register access by omap_i2c_xfer_msg()
function, after transfer was submitted to IP.
Also changed NACK logic to wait ARDY so we can be sure what STP has
been sent on back to back transfers.
Tested on dm3730 (Beagleboard XM C).
Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
drivers/i2c/busses/i2c-omap.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 8591c0c..9e0d359 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -725,12 +725,9 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
return -EAGAIN;
if (dev->cmd_err & OMAP_I2C_STAT_NACK) {
+ /* NOTE: IP always send stop on NACK */
if (msg->flags & I2C_M_IGNORE_NAK)
return 0;
-
- w = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
- w |= OMAP_I2C_CON_STP;
- omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
return -EREMOTEIO;
}
return -EIO;
@@ -1022,8 +1019,24 @@ omap_i2c_isr_thread(int this_irq, void *dev_id)
}
if (stat & OMAP_I2C_STAT_NACK) {
- err |= OMAP_I2C_STAT_NACK;
+ u16 con;
+
+ dev->cmd_err |= OMAP_I2C_STAT_NACK;
omap_i2c_ack_stat(dev, OMAP_I2C_STAT_NACK);
+
+ /*
+ * According to the TRM, IP *always* send STP and reset
+ * MST in NACK cases. But for NACK in the middle of
+ * transfer IP doesn't do it. So, here is workaround.
+ */
+ con = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
+ if (con & OMAP_I2C_CON_MST) {
+ con |= OMAP_I2C_CON_STP;
+ omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, con);
+ }
+
+ /* Wait for ARDY */
+ continue;
}
if (stat & OMAP_I2C_STAT_AL) {
@@ -1038,8 +1051,7 @@ omap_i2c_isr_thread(int this_irq, void *dev_id)
if (stat & OMAP_I2C_STAT_ARDY)
omap_i2c_ack_stat(dev, OMAP_I2C_STAT_ARDY);
- if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
- OMAP_I2C_STAT_AL)) {
+ if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_AL)) {
/*
* These are pending events not handled in time
* due to ISR latency.
--
1.7.9.5
next prev parent reply other threads:[~2014-12-03 14:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 14:33 [RFC 0/5] i2c: omap: new fixes 2 Alexander Kochetkov
2014-12-03 14:33 ` [RFC 1/5] i2c: omap: ack only reported events Alexander Kochetkov
2014-12-03 14:33 ` [RFC 2/5] i2c: omap: simplify i462 errata handling for NACK and AL cases Alexander Kochetkov
2014-12-03 14:34 ` Alexander Kochetkov [this message]
2014-12-03 14:34 ` [RFC 4/5] i2c: omap: reimpelement STP hack via 2-phases transfer Alexander Kochetkov
2014-12-03 14:34 ` [RFC 5/5] i2c: omap: add trace Alexander Kochetkov
[not found] ` <1417617242-16869-6-git-send-email-al.kochet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-03 14:49 ` Felipe Balbi
2014-12-03 14:52 ` Alexander Kochetkov
[not found] ` <2E40A984-A6AA-4D17-AB1D-725004EF845F-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-03 14:55 ` Felipe Balbi
[not found] ` <1417617242-16869-1-git-send-email-al.kochet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-04 18:23 ` [RFC 0/5] i2c: omap: new fixes 2 Tony Lindgren
2015-01-13 10:04 ` Wolfram Sang
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=1417617242-16869-4-git-send-email-al.kochet@gmail.com \
--to=al.kochet@gmail.com \
--cc=balbi@ti.com \
--cc=khilman@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
--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;
as well as URLs for NNTP newsgroup(s).