All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Cvek <petr.cvek-qphu/3gb4gc@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] Add support for SCCB devices into PXA27x I2C controller
Date: Sat, 22 Nov 2014 23:52:07 +0100	[thread overview]
Message-ID: <54711397.9060601@tul.cz> (raw)

Add support for SCCB devices into PXA27x I2C controller.

Fix generated START but no STOP for message without I2C_M_NOSTART flag. 
Add support for I2C_M_IGNORE_NAK flag.

Signed-off-by: Petr Cvek <petr.cvek-qphu/3gb4gc@public.gmane.org>
---
  drivers/i2c/busses/i2c-pxa.c | 22 ++++++++++++++++------
  1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index be671f7..adad044 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -885,7 +885,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c 
*i2c, u32 isr)
          return; /* ignore */
      }

-    if (isr & ISR_BED) {
+    /*
+     * Ignore NAK when flag I2C_M_IGNORE_NAK is present,
+     * this enables use of SCCB devices
+     */
+    if ((isr & ISR_BED) &&
+        (!((i2c->msg->flags & I2C_M_IGNORE_NAK) &&
+            (isr & ISR_ACKNAK)))) {
+
          int ret = BUS_ERROR;

          /*
@@ -919,12 +926,15 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c 
*i2c, u32 isr)
          icr |= ICR_ALDIE | ICR_TB;

          /*
-         * If this is the last byte of the last message, send
-         * a STOP.
+         * If this is the last byte of the last message or last byte
+         * or any message without I2C_M_NOSTART, send a STOP.
           */
-        if (i2c->msg_ptr == i2c->msg->len &&
-            i2c->msg_idx == i2c->msg_num - 1)
-            icr |= ICR_STOP;
+        if (((i2c->msg_ptr == i2c->msg->len) &&
+            (!(i2c->msg->flags & I2C_M_NOSTART))) ||
+            ((i2c->msg_ptr == i2c->msg->len) &&
+            (i2c->msg_idx == i2c->msg_num - 1)))
+                icr |= ICR_STOP;
+
      } else if (i2c->msg_idx < i2c->msg_num - 1) {
          /*
           * Next segment of the message.
-- 
1.7.12.1

WARNING: multiple messages have this Message-ID (diff)
From: petr.cvek@tul.cz (Petr Cvek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Add support for SCCB devices into PXA27x I2C controller
Date: Sat, 22 Nov 2014 23:52:07 +0100	[thread overview]
Message-ID: <54711397.9060601@tul.cz> (raw)

Add support for SCCB devices into PXA27x I2C controller.

Fix generated START but no STOP for message without I2C_M_NOSTART flag. 
Add support for I2C_M_IGNORE_NAK flag.

Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
---
  drivers/i2c/busses/i2c-pxa.c | 22 ++++++++++++++++------
  1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index be671f7..adad044 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -885,7 +885,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c 
*i2c, u32 isr)
          return; /* ignore */
      }

-    if (isr & ISR_BED) {
+    /*
+     * Ignore NAK when flag I2C_M_IGNORE_NAK is present,
+     * this enables use of SCCB devices
+     */
+    if ((isr & ISR_BED) &&
+        (!((i2c->msg->flags & I2C_M_IGNORE_NAK) &&
+            (isr & ISR_ACKNAK)))) {
+
          int ret = BUS_ERROR;

          /*
@@ -919,12 +926,15 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c 
*i2c, u32 isr)
          icr |= ICR_ALDIE | ICR_TB;

          /*
-         * If this is the last byte of the last message, send
-         * a STOP.
+         * If this is the last byte of the last message or last byte
+         * or any message without I2C_M_NOSTART, send a STOP.
           */
-        if (i2c->msg_ptr == i2c->msg->len &&
-            i2c->msg_idx == i2c->msg_num - 1)
-            icr |= ICR_STOP;
+        if (((i2c->msg_ptr == i2c->msg->len) &&
+            (!(i2c->msg->flags & I2C_M_NOSTART))) ||
+            ((i2c->msg_ptr == i2c->msg->len) &&
+            (i2c->msg_idx == i2c->msg_num - 1)))
+                icr |= ICR_STOP;
+
      } else if (i2c->msg_idx < i2c->msg_num - 1) {
          /*
           * Next segment of the message.
-- 
1.7.12.1

             reply	other threads:[~2014-11-22 22:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-22 22:52 Petr Cvek [this message]
2014-11-22 22:52 ` [PATCH] Add support for SCCB devices into PXA27x I2C controller Petr Cvek
     [not found] ` <54711397.9060601-qphu/3gb4gc@public.gmane.org>
2014-11-23  8:31   ` Wolfram Sang
2014-11-23  8:31     ` Wolfram Sang
2014-11-23 22:21     ` [PATCH v2] " Petr Cvek
2014-11-23 22:21       ` Petr Cvek
     [not found]       ` <54725DE2.9090800-qphu/3gb4gc@public.gmane.org>
2014-11-24 17:27         ` Wolfram Sang
2014-11-24 17:27           ` Wolfram Sang
2014-11-25  5:05           ` [PATCH v3] i2c-pxa: add support for SCCB devices Petr Cvek
2014-11-25  5:05             ` Petr Cvek
     [not found]             ` <54740E1D.9060508-qphu/3gb4gc@public.gmane.org>
2014-11-25 14:26               ` Wolfram Sang
2014-11-25 14:26                 ` Wolfram Sang
2014-11-23 16:23   ` [PATCH] Add support for SCCB devices into PXA27x I2C controller Sergei Shtylyov
2014-11-23 16:23     ` Sergei Shtylyov

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=54711397.9060601@tul.cz \
    --to=petr.cvek-qphu/3gb4gc@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.