All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Glauber <jglauber@cavium.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	Dmitry Bazhenov <dmitry.bazhenov@auriga.com>,
	Jan Glauber <jglauber@cavium.com>
Subject: [PATCH 2/5] i2c: octeon,thunderx: Avoid sending STOP during recovery
Date: Wed, 21 Sep 2016 08:51:03 +0200	[thread overview]
Message-ID: <9791f6fb5fba70ddf9bd6b92e113e97bc0483317.1474439371.git.jglauber@cavium.com> (raw)
In-Reply-To: <cover.1474439371.git.jglauber@cavium.com>
In-Reply-To: <cover.1474439371.git.jglauber@cavium.com>

From: Dmitry Bazhenov <dmitry.bazhenov@auriga.com>

Due to a bug in the ThunderX I2C hardware sending STOP during
a recovery attempt could lock up the hardware. To work around
this problem do not send STOP at the beginning of the recovery
but use the override registers to bring the TWSI including
the high-level controller out of the bad state.

Signed-off-by: Dmitry Bazhenov <dmitry.bazhenov@auriga.com>
Signed-off-by: Jan Glauber <jglauber@cavium.com>
[Changed commit message]
---
 drivers/i2c/busses/i2c-octeon-core.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-octeon-core.c b/drivers/i2c/busses/i2c-octeon-core.c
index f322242..7d4df83 100644
--- a/drivers/i2c/busses/i2c-octeon-core.c
+++ b/drivers/i2c/busses/i2c-octeon-core.c
@@ -783,13 +783,14 @@ static void octeon_i2c_prepare_recovery(struct i2c_adapter *adap)
 {
 	struct octeon_i2c *i2c = i2c_get_adapdata(adap);
 
+	octeon_i2c_hlc_disable(i2c);
+
 	/*
-	 * The stop resets the state machine, does not _transmit_ STOP unless
-	 * engine was active.
+	 * Bring control register to a good state regardless
+	 * of HLC state.
 	 */
-	octeon_i2c_stop(i2c);
+	octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
 
-	octeon_i2c_hlc_disable(i2c);
 	octeon_i2c_write_int(i2c, 0);
 }
 
@@ -797,6 +798,15 @@ static void octeon_i2c_unprepare_recovery(struct i2c_adapter *adap)
 {
 	struct octeon_i2c *i2c = i2c_get_adapdata(adap);
 
+	/*
+	 * Generate STOP to finish the unfinished transaction.
+	 * Can't generate STOP via the TWSI CTL register
+	 * since it could bring the TWSI controller into an inoperable state.
+	 */
+	octeon_i2c_write_int(i2c, TWSI_INT_SDA_OVR | TWSI_INT_SCL_OVR);
+	udelay(5);
+	octeon_i2c_write_int(i2c, TWSI_INT_SDA_OVR);
+	udelay(5);
 	octeon_i2c_write_int(i2c, 0);
 }
 
-- 
1.9.1

  parent reply	other threads:[~2016-09-21  6:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21  6:51 [PATCH 0/5] i2c: octeon,thunderx: Recovery fixes and improvements Jan Glauber
2016-09-21  6:51 ` [PATCH 1/5] i2c: octeon,thunderx: Fix set SCL recovery function Jan Glauber
2016-09-21 21:00   ` Wolfram Sang
2016-09-21  6:51 ` Jan Glauber [this message]
2016-09-21 21:00   ` [PATCH 2/5] i2c: octeon,thunderx: Avoid sending STOP during recovery Wolfram Sang
2016-09-21  6:51 ` [PATCH 3/5] i2c: octeon,thunderx: Fix high-level controller status check Jan Glauber
2016-09-21 21:01   ` Wolfram Sang
2016-09-21  6:51 ` [PATCH 4/5] i2c: octeon,thunderx: Check bus state before starting a transaction Jan Glauber
2016-09-21 20:55   ` Wolfram Sang
2016-09-22 16:08     ` Jan Glauber
2016-09-22 16:08       ` Jan Glauber
2016-09-21  6:51 ` [PATCH 5/5] i2c: octeon,thunderx: Limit register access retries Jan Glauber
2016-09-21 21:03   ` Wolfram Sang
2016-09-22 16:40     ` Jan Glauber
2016-09-22 16:40       ` Jan Glauber

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=9791f6fb5fba70ddf9bd6b92e113e97bc0483317.1474439371.git.jglauber@cavium.com \
    --to=jglauber@cavium.com \
    --cc=dmitry.bazhenov@auriga.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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.