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 80EFBC7EE29 for ; Thu, 25 May 2023 12:18:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 723FB8600A; Thu, 25 May 2023 14:18:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=xff.cz header.i=@xff.cz header.b="RQs8RLRu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD1CA860A9; Thu, 25 May 2023 14:18:22 +0200 (CEST) Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 900168465E for ; Thu, 25 May 2023 14:18:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=megi@xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1685017100; bh=8z7oW3cCyGjTwaxnGLMEirHj0g/sw/UJZX3ST8LwKCw=; h=From:To:Cc:Subject:Date:From; b=RQs8RLRu2bhxP67gyDFV/xa7YiQNTLVJ0fDFQ2LODyessTNJ1pSSiarjVg7X94ZiP ly8Gh6a+fKPTP9Q5BYfEVPVrkoE/YkFgBu8LuUEcCi/lTkAjJ+4AYlviXB1uD6Zgje tD7CzGZZv0VkGsjPoFYLk50wNkG51CR38FT8ufvU= From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= To: u-boot@lists.denx.de Cc: Ondrej Jirman , Heiko Schocher Subject: [PATCH] i2c: rockchip: De-initialize the bus after start bit failure Date: Thu, 25 May 2023 14:18:17 +0200 Message-Id: <20230525121817.836472-1-megi@xff.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean From: Ondrej Jirman Failure can happen when i2c is used without initializing pinctrl properly, which U-Boot happily allows in SPL. Without this fix, further I2C access would fail, even after proper pinctrl initialization. Signed-off-by: Ondrej Jirman Cc: Heiko Schocher --- drivers/i2c/rk_i2c.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c index f8fac45b6ca0..9927af94a80b 100644 --- a/drivers/i2c/rk_i2c.c +++ b/drivers/i2c/rk_i2c.c @@ -342,7 +342,7 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) { struct rk_i2c *i2c = dev_get_priv(bus); - int ret; + int ret = 0; debug("i2c_xfer: %d messages\n", nmsgs); for (; nmsgs > 0; nmsgs--, msg++) { @@ -356,14 +356,15 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, } if (ret) { debug("i2c_write: error sending\n"); - return -EREMOTEIO; + ret = -EREMOTEIO; + break; } } rk_i2c_send_stop_bit(i2c); rk_i2c_disable(i2c); - return 0; + return ret; } int rockchip_i2c_set_bus_speed(struct udevice *bus, unsigned int speed) -- 2.40.1