Skip to content

Commit 11f4068

Browse files
TroyMitchell911Wolfram Sang
authored andcommitted
i2c: spacemit: disable SDA glitch fix to avoid restart delay
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. Fixes: 5ea5584 ("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> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
1 parent 445522f commit 11f4068

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

drivers/i2c/busses/i2c-k1.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SPACEMIT_ICR 0x0 /* Control register */
1515
#define SPACEMIT_ISR 0x4 /* Status register */
1616
#define SPACEMIT_IDBR 0xc /* Data buffer register */
17+
#define SPACEMIT_IRCR 0x18 /* Reset cycle counter */
1718
#define SPACEMIT_IBMR 0x1c /* Bus monitor register */
1819

1920
/* SPACEMIT_ICR register fields */
@@ -76,6 +77,8 @@
7677
SPACEMIT_SR_GCAD | SPACEMIT_SR_IRF | SPACEMIT_SR_ITE | \
7778
SPACEMIT_SR_ALD)
7879

80+
#define SPACEMIT_RCR_SDA_GLITCH_NOFIX BIT(7) /* bypass the SDA glitch fix */
81+
7982
/* SPACEMIT_IBMR register fields */
8083
#define SPACEMIT_BMR_SDA BIT(0) /* SDA line level */
8184
#define SPACEMIT_BMR_SCL BIT(1) /* SCL line level */
@@ -237,6 +240,14 @@ static void spacemit_i2c_init(struct spacemit_i2c_dev *i2c)
237240
val |= SPACEMIT_CR_MSDE | SPACEMIT_CR_MSDIE;
238241

239242
writel(val, i2c->base + SPACEMIT_ICR);
243+
244+
/*
245+
* The glitch fix in the K1 I2C controller introduces a delay
246+
* on restart signals, so we disable the fix here.
247+
*/
248+
val = readl(i2c->base + SPACEMIT_IRCR);
249+
val |= SPACEMIT_RCR_SDA_GLITCH_NOFIX;
250+
writel(val, i2c->base + SPACEMIT_IRCR);
240251
}
241252

242253
static inline void

0 commit comments

Comments
 (0)