i2c: spacemit: ensure SDA is released after bus reset
authorTroy Mitchell <troy.mitchell@linux.spacemit.com>
Thu, 25 Sep 2025 02:02:29 +0000 (10:02 +0800)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 25 Sep 2025 21:49:08 +0000 (23:49 +0200)
commit0de61943244dec418d396633a587adca1c350b55
tree42bfba1707c4874d0f5b1f5fd8d499668c32bf24
parentdb7720ef50e0103be70a3887bc66e9c909933ad9
i2c: spacemit: ensure SDA is released after bus reset

After performing a conditional bus reset, the controller must ensure
that the SDA line is actually released.

Previously, the reset routine only performed a single check,
which could leave the bus in a locked state in some situations.

This patch introduces a loop that toggles the reset cycle and issues
a reset request up to SPACEMIT_BUS_RESET_CLK_CNT_MAX times, checking
SDA after each attempt. If SDA is released before the maximum count,
the function returns early. Otherwise, a warning is emitted.

This change improves bus recovery reliability.

Fixes: 5ea558473fa31 ("i2c: spacemit: add support for SpacemiT K1 SoC")
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/i2c/busses/i2c-k1.c