From f67504a486e7a87a405be7149cbf8a1f0dfb6728 Mon Sep 17 00:00:00 2001 From: David Wu Date: Sun, 8 Oct 2023 19:22:41 +0800 Subject: [PATCH] i2c: busses: i2c-rk3x: Fix msg length 32 for autostop tx only mode If autostop mode is enabled, such as RK3588, autostop mode requires statistics on the transmission length; for tx only mode, the device address is also counted as one byte, so the judgment conditions become different. Signed-off-by: David Wu Change-Id: I91c0b68fabb60952f630a98133423aa4cb1b9b48 --- drivers/i2c/busses/i2c-rk3x.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 71592edcf792..0d6dcece3a45 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -307,6 +307,13 @@ static bool rk3x_i2c_auto_stop(struct rk3x_i2c *i2c) if (len > 32) goto out; + /* For tx mode, one byte of the device address also needs to be counted, + * if the data length is equal to 32, which is actually 33 bytes, it would + * need to be divided into two parts, and needs to jump out of autostop. + */ + if (i2c->msg->len == 32 && i2c->mode == REG_CON_MOD_TX && !i2c->processed) + goto out; + i2c->state = STATE_STOP; con1 |= REG_CON1_TRANSFER_AUTO_STOP | REG_CON1_AUTO_STOP;