From nobody Wed Dec 22 07:32:36 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1388719027E5; Wed, 22 Dec 2021 07:32:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JJlQr4hbfz3mG5; Wed, 22 Dec 2021 07:32:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7FF4C193EA; Wed, 22 Dec 2021 07:32:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BM7WaE1090076; Wed, 22 Dec 2021 07:32:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BM7Wa6R090075; Wed, 22 Dec 2021 07:32:36 GMT (envelope-from git) Date: Wed, 22 Dec 2021 07:32:36 GMT Message-Id: <202112220732.1BM7Wa6R090075@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: e50e5090c165 - stable/12 - o Fix i2c read operation for large transfers (more than 32 bytes). List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e50e5090c165b2eb32ecc3957ff24e5cfab182bf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640158356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CWSvm0EoxHLs59lgyh7klb1QQogtnqAdnWK83aIYxbU=; b=GQhRYlnJUbt9lmMjfqFkbRZi2RoI156bRZEz7RQ5iEJ/J5RvP1QSsh+e7MhTCUTQsvytz2 BooYzDms3R73JHTNJ8WLesbmAuMy/b+ShYWGgjW1G2U4vj+aVD2YU5tuqry5qHdRl4L7OA klT8Vic0vt6C/whqdX75TxxafEHQe9Cx+ZCmxn3c6bkRMHKxsp6AqRDztfwcp1JcEyWbVX ohhc1P+qzmbW7LfB9Zujd4S9KoDJjis7tJhr0ngqbH6KHc/4DAwUe0ArkdjaOJBoq0UUzF s2S6AKJQsQfL0DewpKW1hszHXxd8N/B/8u39t6BbIk8dJ1Z0cgBKfmnrn1r3AQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640158356; a=rsa-sha256; cv=none; b=aVwqAWB6sZ6LaVfuHYCb8VPitRZWJGrOU9kxvaoBGpXE83TZuDJRJT7Q1ucfkkVsMqyEWW MJtnd9wGJ8jiKpTzf0InB7unjcXJoLy76qVi3kFjx6PzvAbZa6I7q4RdzfHes8viq0mdNo DF5Iy7N0g6BflbiwbT8Fzkl/UYbetAP+lNpRJzTwX1cR+NHzF/nzUayh7sbYYjtBxaZA6d JqfoV/75iz5V4T6+T5PYm+G34uPUpod2jW5Kronu/w8BfhNSgEPyhdNgbIAWIRQJA65EbD RZE+9ZNoCaRaIXguUUZJooObTa9jsv9VsZJZnFjNv8VMGi82quhgPr59R94cCQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=e50e5090c165b2eb32ecc3957ff24e5cfab182bf commit e50e5090c165b2eb32ecc3957ff24e5cfab182bf Author: Ruslan Bukin AuthorDate: 2021-05-26 09:55:23 +0000 Commit: Andriy Gapon CommitDate: 2021-12-22 07:32:22 +0000 o Fix i2c read operation for large transfers (more than 32 bytes). o Fix slave address setting. This allows to read the EDID from an HDMI monitor. (cherry picked from commit 38e7025a60b28623b5991622a6efd1b8a329ccb2) --- sys/arm64/rockchip/rk_i2c.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/sys/arm64/rockchip/rk_i2c.c b/sys/arm64/rockchip/rk_i2c.c index 56d3e6cb2a1c..8edfaad771bf 100644 --- a/sys/arm64/rockchip/rk_i2c.c +++ b/sys/arm64/rockchip/rk_i2c.c @@ -298,6 +298,7 @@ static void rk_i2c_intr_locked(struct rk_i2c_softc *sc) { uint32_t reg; + int transfer_len; sc->ipd = RK_I2C_READ(sc, RK_I2C_IPD); @@ -331,11 +332,16 @@ rk_i2c_intr_locked(struct rk_i2c_softc *sc) RK_I2C_WRITE(sc, RK_I2C_IEN, RK_I2C_IEN_MBRFIEN | RK_I2C_IEN_NAKRCVIEN); - reg = RK_I2C_READ(sc, RK_I2C_CON); - reg |= RK_I2C_CON_LASTACK; - RK_I2C_WRITE(sc, RK_I2C_CON, reg); + if ((sc->msg->len - sc->cnt) > 32) + transfer_len = 32; + else { + transfer_len = sc->msg->len - sc->cnt; + reg = RK_I2C_READ(sc, RK_I2C_CON); + reg |= RK_I2C_CON_LASTACK; + RK_I2C_WRITE(sc, RK_I2C_CON, reg); + } - RK_I2C_WRITE(sc, RK_I2C_MRXCNT, sc->msg->len); + RK_I2C_WRITE(sc, RK_I2C_MRXCNT, transfer_len); } else { sc->state = STATE_WRITE; RK_I2C_WRITE(sc, RK_I2C_IEN, RK_I2C_IEN_MBTFIEN | @@ -350,6 +356,23 @@ rk_i2c_intr_locked(struct rk_i2c_softc *sc) if (sc->cnt == sc->msg->len) rk_i2c_send_stop(sc); + else { + sc->mode = RK_I2C_CON_MODE_RX; + reg = RK_I2C_READ(sc, RK_I2C_CON) & \ + ~RK_I2C_CON_CTRL_MASK; + reg |= sc->mode << RK_I2C_CON_MODE_SHIFT; + reg |= RK_I2C_CON_EN; + + if ((sc->msg->len - sc->cnt) > 32) + transfer_len = 32; + else { + transfer_len = sc->msg->len - sc->cnt; + reg |= RK_I2C_CON_LASTACK; + } + + RK_I2C_WRITE(sc, RK_I2C_CON, reg); + RK_I2C_WRITE(sc, RK_I2C_MRXCNT, transfer_len); + } break; case STATE_WRITE: @@ -520,7 +543,7 @@ rk_i2c_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) sc->mode = RK_I2C_CON_MODE_RX; } else { sc->mode = RK_I2C_CON_MODE_RRX; - reg = msgs[i].slave & LSB; + reg = msgs[i].slave & ~LSB; reg |= RK_I2C_MRXADDR_VALID(0); RK_I2C_WRITE(sc, RK_I2C_MRXADDR, reg); RK_I2C_WRITE(sc, RK_I2C_MRXRADDR, 0);