mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Gerald Loacker <gerald.loacker@wolfvision.net>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/4] i2c: rockchip: fix i2c stop condition
Date: Fri, 8 Sep 2023 15:53:23 +0200	[thread overview]
Message-ID: <20230908135323.GK637806@pengutronix.de> (raw)
In-Reply-To: <20230908-bugfix-i2c-rockchip-v1-1-f8235d811f6b@wolfvision.net>

On Fri, Sep 08, 2023 at 12:16:46PM +0200, Gerald Loacker wrote:
> The i2c bus gets disabled without sending a stop condition. This violates
> i2c timing on the clock line. Fix this and include all related functions
> (rk_i2c_send_start_bit, rk_i2c_send_stop_bit, rk_i2c_disable) onto the same
> level.
> 
> Signed-off-by: Gerald Loacker <gerald.loacker@wolfvision.net>
> ---
>  drivers/i2c/busses/i2c-rockchip.c | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)
> 
> @@ -387,6 +376,11 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
>  		struct i2c_msg *msg = &msgs[i];
>  
>  		dev_dbg(dev, "i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
> +
> +		ret = rk_i2c_send_start_bit(i2c);
> +		if (ret)
> +			break;
> +
>  		if (msg->flags & I2C_M_RD) {
>  			ret = rk_i2c_read(i2c, msg->addr, 0, 0, msg->buf,
>  					  msg->len);
> @@ -394,6 +388,9 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
>  			ret = rk_i2c_write(i2c, msg->addr, 0, 0, msg->buf,
>  					   msg->len);
>  		}
> +
> +		rk_i2c_send_stop_bit(i2c);
> +
>  		if (ret) {
>  			dev_dbg(dev, "i2c_write: error sending: %pe\n",
>  				ERR_PTR(ret));
> @@ -402,9 +399,7 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
>  		}
>  	}
>  
> -	rk_i2c_send_stop_bit(i2c);

I believe this is wrong. A stop bit should only be sent after the last
message, not after all messages.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2023-09-08 13:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 10:16 [PATCH 0/4] Fix rockchip I2C bus Gerald Loacker
2023-09-08 10:16 ` [PATCH 1/4] i2c: rockchip: fix i2c stop condition Gerald Loacker
2023-09-08 13:53   ` Sascha Hauer [this message]
2023-09-12  5:45     ` Gerald Loacker
2023-09-12  6:03       ` Sascha Hauer
2023-09-08 10:16 ` [PATCH 2/4] i2c: rockchip: ignore i2c transfers when another transfer is running Gerald Loacker
2023-09-08 11:51   ` Sascha Hauer
2023-09-08 11:55     ` Sascha Hauer
2023-09-08 13:13       ` Sascha Hauer
2023-09-11 11:46         ` Gerald Loacker
2023-09-08 10:16 ` [PATCH 3/4] net: ksz9477: propagate phy read error Gerald Loacker
2023-09-08 11:59   ` Ahmad Fatoum
2023-09-08 12:32     ` Oleksij Rempel
2023-09-08 10:16 ` [PATCH 4/4] net: ksz9477: propagate phy write error Gerald Loacker

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=20230908135323.GK637806@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=gerald.loacker@wolfvision.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox