Skip to contentSkip to conversation

i2c: rcar_i2c: Fix i2c read/write errors

PATCH New Lad Prabhakar 3 participants 4 messages Sep 30, 2020 – Oct 1, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 i2c: rcar_i2c: Fix i2c read/write errors

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")

---
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(-)
drivers/i2c/rcar_i2c.c +1 -1
index 4267bbfa5a..663c342cd8 100644
@@ -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;
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/1 i2c: rcar_i2c: Fix i2c read/write errors

Quoted 5 lines · Lad Prabhakar

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.

It would be good to explain in the commit message why the previous code was correct.

Quoted 2 lines
Fixes 7c8f821e ("i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer")

[...]

#2 lore raw

PATCH v3 1/1 i2c: rcar_i2c: Fix i2c read/write errors

In reply to Lad Prabhakar

Hello Lad,

Am 30.09.2020 um 14:24 schrieb Lad Prabhakar:

Quoted 12 lines

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")

---
v2->v3
* Made sure value of read is ether 0/1 as pointed by Marek

Quoted 6 lines

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/

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#3 lore raw

PATCH v3 1/1 i2c: rcar_i2c: Fix i2c read/write errors

In reply to Lad Prabhakar

Hello Lad,

Am 30.09.2020 um 14:24 schrieb Lad Prabhakar:

Quoted 27 lines

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")

---
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
=>

Quoted 3 lines
---
  drivers/i2c/rcar_i2c.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-i2c master after fixing the commit id length to 12 digits.

@Tom: I started travis build and if all build fine I think, this patch should go into 2020.10 (Late I know....) is this okay for you?

bye,
Heiko

Quoted 15 lines
drivers/i2c/rcar_i2c.c +1 -1
index 4267bbfa5a..663c342cd8 100644
@@ -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;
 
Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de