From patchwork Mon Aug 15 14:52:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jorge Ramirez-Ortiz, Foundries" X-Patchwork-Id: 1666482 X-Patchwork-Delegate: patrice.chotard@st.com Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=Lm6qjlSD; dkim-atps=neutral Received: from legolas.ozlabs.org (legolas.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:8c49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M5y1c6rxDz9s07 for ; Tue, 16 Aug 2022 00:52:36 +1000 (AEST) Received: by legolas.ozlabs.org (Postfix) id 4M5y1c2Kydz1ygN; Tue, 16 Aug 2022 00:52:36 +1000 (AEST) Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=Lm6qjlSD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M5y1b5Gwdz1yf9 for ; Tue, 16 Aug 2022 00:52:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 48FD984965; Mon, 15 Aug 2022 16:52:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="Lm6qjlSD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D0AD48459D; Mon, 15 Aug 2022 16:52:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D3B2D84965 for ; Mon, 15 Aug 2022 16:52:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge@foundries.io Received: by mail-wr1-x430.google.com with SMTP id e27so4635465wra.11 for ; Mon, 15 Aug 2022 07:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=vQ6O8+7cXkxjpGaa2UKlRXQwGR4xK1zKxtcGOYvx+tY=; b=Lm6qjlSDeeday8vFVLmM9yQj4TKFPjoZX/ds8lNYiMFURRjuBqZvStYJ1DmLp/PCcx fq1ehT2/eTQSlmKstw8Ft0wmFUXqpLztqmbOH4Rpxn6b1Mi/KHzAoUJS0UgJ3CrDxNds HdBZ+Z7+YOxRR0NKGeucjQOMc7DlZMq6oeCS/bGk1O+NjePZtvav2KWW3GAcIXjctBzo sYxjSivja2b0VU43kZ2i1Bci95CXWN0+2uZjaURrgD29K/vEbTNRFMktF7JhMUgv9wHv 7u5dwCUkIty/weDhRMgHTw2XHMVblfvo6auI+1wHZwg8yfDZ8phH1J/IMpVIAMrN19BJ U4pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=vQ6O8+7cXkxjpGaa2UKlRXQwGR4xK1zKxtcGOYvx+tY=; b=eYvg7qBuJlR7BuRG7dzM/ii6q2LQPmkOppXctDulPxqGQjGu+QfUgtvw38PV4Vx5xs mVkrGdNO0ltPTRcgiV0eqfM31uU576Ax5kSUEYLtv8lBeqKWgE/sixnnL8he0amOqlBA E7c6gg2y8fM40KmdoUNMfmWlNIjLQ8D2KAQY9XoNvckIzc0RobSU5bWGt9pA96ZcI+Gu mAg6H8AwAd1C5WkstS94P1V6NYIXyROmbCUBFPGNS5t5lA8ari41UaK1s6WV+PC3O+Gy ku5x7kyW20BhGPrBW7uzsFsSk8brqh6NAc98Pf0opc0zJ5c7juEacpx5c2mL2CYUM59J e8EQ== X-Gm-Message-State: ACgBeo3PN10tz5HCYrwYOlOqoWpisMEfaKP/KFWX9YRJ4PkpjYyaafdU gZDKPKmHTsp7kVtx3UEkX9/H3Q== X-Google-Smtp-Source: AA6agR7OIHVOSCdFtktRWa9KjLAjNlH4k3RFI7nVa3QzLNMKEyAsy/kU7G6zmwTs+Ru189lHcWllAw== X-Received: by 2002:a05:6000:184a:b0:222:cdc3:257c with SMTP id c10-20020a056000184a00b00222cdc3257cmr8817858wri.604.1660575136360; Mon, 15 Aug 2022 07:52:16 -0700 (PDT) Received: from localhost.localdomain (78.red-83-60-92.dynamicip.rima-tde.net. [83.60.92.78]) by smtp.gmail.com with ESMTPSA id g6-20020a5d4886000000b0021e9fafa601sm7502114wrq.22.2022.08.15.07.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 07:52:15 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge@foundries.io, hs@denx.de, patrick.delaunay@foss.st.com, patrice.chotard@foss.st.com, oleksandr.suvorov@foundries.io Cc: uboot-stm32@st-md-mailman.stormreply.com, u-boot@lists.denx.de Subject: [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error Date: Mon, 15 Aug 2022 16:52:11 +0200 Message-Id: <20220815145211.31342-2-jorge@foundries.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220815145211.31342-1-jorge@foundries.io> References: <20220815145211.31342-1-jorge@foundries.io> MIME-Version: 1.0 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 Sending the stop condition without waiting for transfer complete has been found to lock the bus (BUSY) when NACKF is raised. Tested accessing the NXP SE05X I2C device. https://www.nxp.com/docs/en/application-note/AN12399.pdf Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Oleksandr Suvorov --- drivers/i2c/stm32f7_i2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c index 3a727e68ac..14827e5cec 100644 --- a/drivers/i2c/stm32f7_i2c.c +++ b/drivers/i2c/stm32f7_i2c.c @@ -485,9 +485,11 @@ static int stm32_i2c_message_xfer(struct stm32_i2c_priv *i2c_priv, } } - /* End of transfer, send stop condition */ - mask = STM32_I2C_CR2_STOP; - setbits_le32(®s->cr2, mask); + if (!ret) { + /* End of transfer, send stop condition */ + mask = STM32_I2C_CR2_STOP; + setbits_le32(®s->cr2, mask); + } return stm32_i2c_check_end_of_message(i2c_priv); }