From patchwork Wed Sep 30 12:24:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 1374336 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C1b6R5pdkz9sS8 for ; Wed, 30 Sep 2020 22:24:31 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0637681B45; Wed, 30 Sep 2020 14:24:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 6435781BD2; Wed, 30 Sep 2020 14:24:25 +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=-1.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by phobos.denx.de (Postfix) with ESMTP id 535328174F for ; Wed, 30 Sep 2020 14:24:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prabhakar.mahadev-lad.rj@bp.renesas.com X-IronPort-AV: E=Sophos;i="5.77,322,1596466800"; d="scan'208";a="58571767" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 30 Sep 2020 21:24:19 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 3CD6F400A8A3; Wed, 30 Sep 2020 21:24:18 +0900 (JST) From: Lad Prabhakar To: u-boot@lists.denx.de, Heiko Schocher , Marek Vasut Cc: Prabhakar , Biju Das , Ismael Luceno , Lad Prabhakar Subject: [PATCH v3] i2c: rcar_i2c: Fix i2c read/write errors Date: Wed, 30 Sep 2020 13:24:12 +0100 Message-Id: <20200930122412.31156-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean commit 7c8f821e ("i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer") blindly called rcar_i2c_set_addr() with read argument always set to 1 during xfer which introduced read/write errors, whereas earlier rcar_i2c_read_common() called rcar_i2c_set_addr() with read set to 1 and rcar_i2c_write_common() called rcar_i2c_set_addr() with read set 0. Fixes: 7c8f821e ("i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer") Signed-off-by: Lad Prabhakar Reviewed-by: Marek Vasut Reviewed-by: Heiko Schocher --- v2->v3 * Made sure value of read is ether 0/1 as pointed by Marek v1->v2 * Incorporated suggestion from Heiko v1: https://patchwork.ozlabs.org/project/uboot/patch/ 20200921163353.5540-1-prabhakar.mahadev-lad.rj@bp.renesas.com/ Without this patch below errors are seen: => i2c probe Valid chip addresses: 34 47 68 => i2c md 0x47 0 100 Error reading the chip: -110 => i2c mw 0x47 0x0a 0x06 Error writing the chip: -110 => --- drivers/i2c/rcar_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c index 4267bbfa5a..663c342cd8 100644 --- a/drivers/i2c/rcar_i2c.c +++ b/drivers/i2c/rcar_i2c.c @@ -211,7 +211,7 @@ static int rcar_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs) int ret; for (; nmsgs > 0; nmsgs--, msg++) { - ret = rcar_i2c_set_addr(dev, msg->addr, 1); + ret = rcar_i2c_set_addr(dev, msg->addr, !!(msg->flags & I2C_M_RD)); if (ret) return ret;