mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Troy Mitchell <troy.mitchell@linux.spacemit.com>
To: Andi Shyti <andi.shyti@kernel.org>, Yixun Lan <dlan@gentoo.org>,
	 Alex Elder <elder@riscstar.com>,
	Troy Mitchell <troymitchell988@gmail.com>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-riscv@lists.infradead.org, spacemit@lists.linux.dev,
	 Troy Mitchell <troy.mitchell@linux.spacemit.com>
Subject: [PATCH 4/6] i2c: spacemit: check SDA instead of SCL after bus reset
Date: Wed, 27 Aug 2025 15:39:11 +0800	[thread overview]
Message-ID: <20250827-k1-i2c-atomic-v1-4-e59bea02d680@linux.spacemit.com> (raw)
In-Reply-To: <20250827-k1-i2c-atomic-v1-0-e59bea02d680@linux.spacemit.com>

After calling spacemit_i2c_conditionally_reset_bus(),
the controller should ensure that the SDA line is release
before proceeding.

Previously, the driver checked the SCL line instead,
which does not guarantee that the bus is truly idle.

This patch changes the check to verify SDA. This ensures
proper bus recovery and avoids potential communication errors
after a conditional reset.

Fixes: 5ea558473fa31 ("i2c: spacemit: add support for SpacemiT K1 SoC")
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
---
 drivers/i2c/busses/i2c-k1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
index c1656b78f1681729ccc2ebca6e290259d14889d9..4d78ee7b6929ee43771e500d4f85d9e55e68b221 100644
--- a/drivers/i2c/busses/i2c-k1.c
+++ b/drivers/i2c/busses/i2c-k1.c
@@ -172,9 +172,9 @@ static void spacemit_i2c_conditionally_reset_bus(struct spacemit_i2c_dev *i2c)
 	spacemit_i2c_reset(i2c);
 	usleep_range(10, 20);
 
-	/* check scl status again */
+	/* check sda again here */
 	status = readl(i2c->base + SPACEMIT_IBMR);
-	if (!(status & SPACEMIT_BMR_SCL))
+	if (!(status & SPACEMIT_BMR_SDA))
 		dev_warn_ratelimited(i2c->dev, "unit reset failed\n");
 }
 

-- 
2.50.1


  parent reply	other threads:[~2025-08-27  7:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27  7:39 [PATCH 0/6] i2c: spacemit: fix and introduce pio Troy Mitchell
2025-08-27  7:39 ` [PATCH 1/6] i2c: spacemit: ensure bus release check runs when wait_bus_idle() fails Troy Mitchell
2025-09-22 20:55   ` Aurelien Jarno
2025-08-27  7:39 ` [PATCH 2/6] i2c: spacemit: remove stop function to avoid bus error Troy Mitchell
2025-09-22 20:55   ` Aurelien Jarno
2025-09-23  0:44     ` Troy Mitchell
2025-08-27  7:39 ` [PATCH 3/6] i2c: spacemit: disable SDA glitch fix to avoid restart delay Troy Mitchell
2025-08-27  9:32   ` Troy Mitchell
2025-09-22 20:56   ` Aurelien Jarno
2025-09-23  0:46     ` Troy Mitchell
2025-08-27  7:39 ` Troy Mitchell [this message]
2025-09-22 20:56   ` [PATCH 4/6] i2c: spacemit: check SDA instead of SCL after bus reset Aurelien Jarno
2025-09-23  0:47     ` Troy Mitchell
2025-08-27  7:39 ` [PATCH 5/6] i2c: spacemit: ensure SDA is released " Troy Mitchell
2025-09-22 20:56   ` Aurelien Jarno
2025-09-23  0:49     ` Troy Mitchell
2025-08-27  7:39 ` [PATCH 6/6] i2c: spacemit: introduce pio for k1 Troy Mitchell
2025-09-22 20:56   ` Aurelien Jarno
2025-09-23  1:14     ` Troy Mitchell
2025-09-23  1:21       ` Troy Mitchell
2025-09-22 20:55 ` [PATCH 0/6] i2c: spacemit: fix and introduce pio Aurelien Jarno
2025-09-23  1:24   ` Troy Mitchell

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=20250827-k1-i2c-atomic-v1-4-e59bea02d680@linux.spacemit.com \
    --to=troy.mitchell@linux.spacemit.com \
    --cc=andi.shyti@kernel.org \
    --cc=dlan@gentoo.org \
    --cc=elder@riscstar.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=spacemit@lists.linux.dev \
    --cc=troymitchell988@gmail.com \
    /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®