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>,
Aurelien Jarno <aurelien@aurel32.net>
Subject: [PATCH v2 3/6] i2c: spacemit: disable SDA glitch fix to avoid restart delay
Date: Thu, 25 Sep 2025 10:02:27 +0800 [thread overview]
Message-ID: <20250925-k1-i2c-atomic-v2-3-46dc13311cda@linux.spacemit.com> (raw)
In-Reply-To: <20250925-k1-i2c-atomic-v2-0-46dc13311cda@linux.spacemit.com>
The K1 I2C controller has an SDA glitch fix that introduces a small
delay on restart signals. While this feature can suppress glitches
on SDA when SCL = 0, it also delays the restart signal, which may
cause unexpected behavior in some transfers.
The glitch itself does not affect normal I2C operation, because
the I2C specification allows SDA to change while SCL is low.
To ensure correct transmission for every message, we disable the
SDA glitch fix by setting the RCR.SDA_GLITCH_NOFIX bit during
initialization.
This guarantees that restarts are issued promptly without
unintended delays.
---
There are the restart waveforms before [1] and after [2] disabling the fix.
Link:
https://psce.pw/839rzq [1]
https://psce.pw/839s4q [2]
Fixes: 5ea558473fa31 ("i2c: spacemit: add support for SpacemiT K1 SoC")
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
---
drivers/i2c/busses/i2c-k1.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
index 84f132d0504dc992f2f961253b011b86afcc2bbc..9bf9f01aa68bde6460e50c6983edc3f705b12eea 100644
--- a/drivers/i2c/busses/i2c-k1.c
+++ b/drivers/i2c/busses/i2c-k1.c
@@ -14,6 +14,7 @@
#define SPACEMIT_ICR 0x0 /* Control register */
#define SPACEMIT_ISR 0x4 /* Status register */
#define SPACEMIT_IDBR 0xc /* Data buffer register */
+#define SPACEMIT_IRCR 0x18 /* Reset cycle counter */
#define SPACEMIT_IBMR 0x1c /* Bus monitor register */
/* SPACEMIT_ICR register fields */
@@ -76,6 +77,8 @@
SPACEMIT_SR_GCAD | SPACEMIT_SR_IRF | SPACEMIT_SR_ITE | \
SPACEMIT_SR_ALD)
+#define SPACEMIT_RCR_SDA_GLITCH_NOFIX BIT(7) /* bypass the SDA glitch fix */
+
/* SPACEMIT_IBMR register fields */
#define SPACEMIT_BMR_SDA BIT(0) /* SDA line level */
#define SPACEMIT_BMR_SCL BIT(1) /* SCL line level */
@@ -237,6 +240,14 @@ static void spacemit_i2c_init(struct spacemit_i2c_dev *i2c)
val |= SPACEMIT_CR_MSDE | SPACEMIT_CR_MSDIE;
writel(val, i2c->base + SPACEMIT_ICR);
+
+ /*
+ * The glitch fix in the K1 I2C controller introduces a delay
+ * on restart signals, so we disable the fix here.
+ */
+ val = readl(i2c->base + SPACEMIT_IRCR);
+ val |= SPACEMIT_RCR_SDA_GLITCH_NOFIX;
+ writel(val, i2c->base + SPACEMIT_IRCR);
}
static inline void
--
2.51.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-09-25 2:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 2:02 [PATCH v2 0/6] i2c: spacemit: fix and introduce pio Troy Mitchell
2025-09-25 2:02 ` [PATCH v2 1/6] i2c: spacemit: ensure bus release check runs when wait_bus_idle() fails Troy Mitchell
2025-09-25 2:02 ` [PATCH v2 2/6] i2c: spacemit: remove stop function to avoid bus error Troy Mitchell
2025-09-25 20:11 ` Aurelien Jarno
2025-09-25 2:02 ` Troy Mitchell [this message]
2025-09-25 2:02 ` [PATCH v2 4/6] i2c: spacemit: check SDA instead of SCL after bus reset Troy Mitchell
2025-09-25 2:02 ` [PATCH v2 5/6] i2c: spacemit: ensure SDA is released " Troy Mitchell
2025-09-25 20:43 ` Aurelien Jarno
2025-09-25 2:02 ` [PATCH v2 6/6] i2c: spacemit: introduce pio for k1 Troy Mitchell
2025-09-26 11:10 ` Yixun Lan
2025-09-26 13:13 ` Troy Mitchell
2025-09-26 14:28 ` Wolfram Sang
2025-09-27 1:24 ` Yixun Lan
2025-09-27 3:57 ` Troy Mitchell
2025-09-28 6:06 ` Troy Mitchell
2025-09-26 16:47 ` Aurelien Jarno
2025-09-27 4:05 ` Troy Mitchell
2025-09-27 1:45 ` Yixun Lan
2025-09-27 4:04 ` Troy Mitchell
2025-09-27 10:16 ` Yixun Lan
2025-09-27 10:24 ` Troy Mitchell
2025-09-27 10:56 ` Yixun Lan
2025-09-28 1:17 ` Troy Mitchell
2025-09-28 2:54 ` Yixun Lan
2025-09-28 8:09 ` Troy Mitchell
2025-09-28 11:22 ` Yixun Lan
2025-09-25 21:50 ` [PATCH v2 0/6] i2c: spacemit: fix and introduce pio Wolfram Sang
2025-09-26 1:47 ` 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=20250925-k1-i2c-atomic-v2-3-46dc13311cda@linux.spacemit.com \
--to=troy.mitchell@linux.spacemit.com \
--cc=andi.shyti@kernel.org \
--cc=aurelien@aurel32.net \
--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