[PATCH] Revert "i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer"
Heiko Schocher
hs at denx.de
Wed Sep 30 09:17:56 CEST 2020
Hello Lad,
Am 21.09.2020 um 18:33 schrieb Lad Prabhakar:
> This reverts commit 7c8f821e ("i2c: rcar_i2c: Set the
> slave address from rcar_i2c_xfer"), as it blindly called
> rcar_i2c_set_addr() with read argument always set to 1
> during xfer which introduced read 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.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj at bp.renesas.com>
> Reviewed-by: Biju Das <biju.das.jz at bp.renesas.com>
> ---
> drivers/i2c/rcar_i2c.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
> index 4267bbfa5a..75448c8368 100644
> --- a/drivers/i2c/rcar_i2c.c
> +++ b/drivers/i2c/rcar_i2c.c
> @@ -162,6 +162,10 @@ static int rcar_i2c_read_common(struct udevice *dev, struct i2c_msg *msg)
> u32 icmcr = RCAR_I2C_ICMCR_MDBS | RCAR_I2C_ICMCR_MIE;
> int i, ret = -EREMOTEIO;
>
> + ret = rcar_i2c_set_addr(dev, msg->addr, 1);
> + if (ret)
> + return ret;
> +
> for (i = 0; i < msg->len; i++) {
> if (msg->len - 1 == i)
> icmcr |= RCAR_I2C_ICMCR_FSB;
> @@ -188,6 +192,10 @@ static int rcar_i2c_write_common(struct udevice *dev, struct i2c_msg *msg)
> u32 icmcr = RCAR_I2C_ICMCR_MDBS | RCAR_I2C_ICMCR_MIE;
> int i, ret = -EREMOTEIO;
>
> + ret = rcar_i2c_set_addr(dev, msg->addr, 0);
> + if (ret)
> + return ret;
> +
> for (i = 0; i < msg->len; i++) {
> writel(msg->buf[i], priv->base + RCAR_I2C_ICRXD_ICTXD);
> writel(icmcr, priv->base + RCAR_I2C_ICMCR);
> @@ -211,10 +219,6 @@ 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);
Instead of reverting, can you do:
rcar_i2c_set_addr(dev, msg->addr, msg->flags & I2C_M_RD);
> - if (ret)
> - return ret;
> -
> if (msg->flags & I2C_M_RD)
> ret = rcar_i2c_read_common(dev, msg);
> else
> @@ -224,7 +228,7 @@ static int rcar_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs)
> return ret;
> }
>
> - return 0;
> + return ret;
> }
>
> static int rcar_i2c_probe_chip(struct udevice *dev, uint addr, uint flags)
bye,
Heiko
--
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
More information about the U-Boot
mailing list