From nobody Wed Nov 5 20:13:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15369071762041019.1644628548406; Thu, 13 Sep 2018 23:39:36 -0700 (PDT) Received: from localhost ([::1]:48208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0hlL-0005qA-JQ for importer@patchew.org; Fri, 14 Sep 2018 02:39:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0hhj-0003Uy-4f for qemu-devel@nongnu.org; Fri, 14 Sep 2018 02:35:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0hhf-00045M-Uo for qemu-devel@nongnu.org; Fri, 14 Sep 2018 02:35:47 -0400 Received: from 20.mo7.mail-out.ovh.net ([46.105.49.208]:60099) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g0hhf-00043r-Jf for qemu-devel@nongnu.org; Fri, 14 Sep 2018 02:35:43 -0400 Received: from player759.ha.ovh.net (unknown [10.109.146.5]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 57607D834B for ; Fri, 14 Sep 2018 08:35:42 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-1-10605-110.w90-89.abo.wanadoo.fr [90.89.196.110]) (Authenticated sender: clg@kaod.org) by player759.ha.ovh.net (Postfix) with ESMTPSA id 0C88E6400B3; Fri, 14 Sep 2018 08:35:35 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 08:35:06 +0200 Message-Id: <20180914063506.20815-4-clg@kaod.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180914063506.20815-1-clg@kaod.org> References: <20180914063506.20815-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 6250433333486717760 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtjedrjeejgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.49.208 Subject: [Qemu-devel] [PATCH 3/3] aspeed/i2c: Fix receive done interrupt handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jeffery , qemu-arm@nongnu.org, Joel Stanley , Guenter Roeck , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Guenter Roeck The AST2500 datasheet says: I2CD10 Interrupt Status Register bit 2 Receive Done Interrupt status S/W needs to clear this status bit to allow next data receiving The Rx interrrupt done interrupt status bit needs to be cleared explicitly before the next byte can be received, and must therefore not be auto-cleared. Also, receiving the next byte must be delayed until the bit has been cleared. Signed-off-by: Guenter Roeck Signed-off-by: C=C3=A9dric Le Goater --- hw/i2c/aspeed_i2c.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index d81f86587af7..7ae99bc8baec 100644 --- a/hw/i2c/aspeed_i2c.c +++ b/hw/i2c/aspeed_i2c.c @@ -257,7 +257,8 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus= , uint64_t value) aspeed_i2c_set_state(bus, I2CD_MACTIVE); } =20 - if (bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST)) { + if ((bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST)) && + !(bus->intr_status & I2CD_INTR_RX_DONE)) { aspeed_i2c_handle_rx_cmd(bus); } =20 @@ -279,6 +280,7 @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr o= ffset, uint64_t value, unsigned size) { AspeedI2CBus *bus =3D opaque; + bool handle_rx; =20 switch (offset) { case I2CD_FUN_CTRL_REG: @@ -299,11 +301,17 @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr= offset, bus->intr_ctrl =3D value & 0x7FFF; break; case I2CD_INTR_STS_REG: + handle_rx =3D (bus->intr_status & I2CD_INTR_RX_DONE) && + (value & I2CD_INTR_RX_DONE); bus->intr_status &=3D ~(value & 0x7FFF); if (!bus->intr_status) { bus->controller->intr_status &=3D ~(1 << bus->id); qemu_irq_lower(bus->controller->irq); } + if (handle_rx && (bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST= ))) { + aspeed_i2c_handle_rx_cmd(bus); + aspeed_i2c_bus_raise_interrupt(bus); + } break; case I2CD_DEV_ADDR_REG: qemu_log_mask(LOG_UNIMP, "%s: slave mode not implemented\n", --=20 2.17.1