Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Dec 2021 06:59:20 GMT
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 7d47f5aae8b3 - stable/12 - rk_i2c: keep sending bytes until all bytes are sent
Message-ID:  <202112220659.1BM6xKoH036910@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by avg:

URL: https://cgit.FreeBSD.org/src/commit/?id=7d47f5aae8b3080858e5bad6379d2cb54d0d40a1

commit 7d47f5aae8b3080858e5bad6379d2cb54d0d40a1
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2021-12-15 08:51:24 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-12-22 06:57:15 +0000

    rk_i2c: keep sending bytes until all bytes are sent
    
    Previously the code would decalre the transfer complete after sending
    first 31 bytes (plus the slave address) of a larger I2C write transfer.
    
    That was tested using a large write to an EEPROM with 32-byte write page
    size and a 2-byte address type.  Such a transaction needed to send 34
    bytes, 2 bytes for an offset and 32 bytes of actual data.
    
    (cherry picked from commit 7dc8a0e5dff4ad4c9c10442bef5228a91a98d5d6)
---
 sys/arm64/rockchip/rk_i2c.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/arm64/rockchip/rk_i2c.c b/sys/arm64/rockchip/rk_i2c.c
index 13fd5cebaf2d..078f0be52ec0 100644
--- a/sys/arm64/rockchip/rk_i2c.c
+++ b/sys/arm64/rockchip/rk_i2c.c
@@ -348,8 +348,14 @@ rk_i2c_intr_locked(struct rk_i2c_softc *sc)
 
 		break;
 	case STATE_WRITE:
-		if (sc->cnt == sc->msg->len &&
-		     !(sc->msg->flags & IIC_M_NOSTOP)) {
+		if (sc->cnt < sc->msg->len) {
+			/* Keep writing. */
+			RK_I2C_WRITE(sc, RK_I2C_IEN, RK_I2C_IEN_MBTFIEN |
+			    RK_I2C_IEN_NAKRCVIEN);
+			transfer_len = rk_i2c_fill_tx(sc);
+			RK_I2C_WRITE(sc, RK_I2C_MTXCNT, transfer_len);
+			break;
+		} else if (!(sc->msg->flags & IIC_M_NOSTOP)) {
 			rk_i2c_send_stop(sc);
 			break;
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112220659.1BM6xKoH036910>