All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3] i2c: rcar_i2c: Fix i2c read/write errors
Date: Wed, 30 Sep 2020 13:24:12 +0100	[thread overview]
Message-ID: <20200930122412.31156-1-prabhakar.mahadev-lad.rj@bp.renesas.com> (raw)

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 <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
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 at 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;
 
-- 
2.17.1

             reply	other threads:[~2020-09-30 12:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30 12:24 Lad Prabhakar [this message]
2020-09-30 23:02 ` [PATCH v3] i2c: rcar_i2c: Fix i2c read/write errors Marek Vasut
2020-10-01  3:37 ` Heiko Schocher
2020-10-01  3:47 ` Heiko Schocher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200930122412.31156-1-prabhakar.mahadev-lad.rj@bp.renesas.com \
    --to=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.