Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6286C433FE for ; Wed, 26 Oct 2022 07:50:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9160584F97; Wed, 26 Oct 2022 09:50:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.b="p8m03iiA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 737D680339; Wed, 26 Oct 2022 09:50:08 +0200 (CEST) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C14F584F9D for ; Wed, 26 Oct 2022 09:49:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=Conor.Dooley@microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1666770596; x=1698306596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D0RdgZspWxnB6w/78C7f33LZbx737asNxzpsFhPBUaA=; b=p8m03iiAeV2+VMjgWd5nm/7X9EM5yEnGBZp9WZ+ufGc33ptiL3IrqNzM MCpzyOa+copYMA0tvLSw+HaC4wQZCXspo1Gy4s5/2n559oLj599vl/V73 9twZYWvQQuVWwMQ9Fp5Wvz73/kptnQR9D7tAUZzNcoCKd5M/zZRvLVUff ZbEUzZWldrWeYnUvajy8RyRcq688Au3BeIub547FzFuzkXCff4+slgD3Y Zt2QxI96PxvMRPil4hnjIeujYhcQsmzxhcPMpuCYjggPLVJaUGWOBbvuP AJpyL6pfxJHP8D53aftpoou+0xCydPO1wqZpuWAGf9Ery8KhwbE+R8D6C w==; X-IronPort-AV: E=Sophos;i="5.95,214,1661842800"; d="scan'208";a="183955436" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 26 Oct 2022 00:49:51 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 26 Oct 2022 00:49:49 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 26 Oct 2022 00:49:48 -0700 From: Conor Dooley To: Heiko Schocher , Leo Yu-Chi Liang , Padmarao Begari , Conor Dooley , CC: Andreas Buerkler Subject: [PATCH v1 2/2] i2c: microchip: fix erroneous late ack send Date: Wed, 26 Oct 2022 08:49:19 +0100 Message-ID: <20221026074918.3657055-3-conor.dooley@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221026074918.3657055-1-conor.dooley@microchip.com> References: <20221026074918.3657055-1-conor.dooley@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean A late ack is currently being sent at the end of a transfer due to incorrect logic in mchp_corei2c_empty_rx(). Currently the Assert Ack bit is being written to the controller's control reg after the last byte has been received, causing it to sent another byte with the ack. Instead, the AA flag should be written to the control register when the penultimate byte is read so it is sent out for the last byte. Reported-by: Andreas Buerkler Fixes: 0dc0d1e094 ("i2c: Add Microchip PolarFire SoC I2C driver") Fixes: 0190d48488 ("i2c: microchip: fix ack sending logic") Signed-off-by: Conor Dooley --- drivers/i2c/i2c-microchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-microchip.c b/drivers/i2c/i2c-microchip.c index 3a27459386..d82b80f535 100644 --- a/drivers/i2c/i2c-microchip.c +++ b/drivers/i2c/i2c-microchip.c @@ -224,7 +224,7 @@ static void mpfs_i2c_empty_rx(struct mpfs_i2c_bus *bus) bus->msg_len--; } - if (bus->msg_len == 0) { + if (bus->msg_len <= 1) { ctrl = readl(bus->base + MPFS_I2C_CTRL); ctrl &= ~CTRL_AA; writel(ctrl, bus->base + MPFS_I2C_CTRL); -- 2.38.0