[PATCH] i2c: rockchip: De-initialize the bus after start bit failure

Kever Yang kever.yang at rock-chips.com
Mon May 29 12:09:20 CEST 2023


On 2023/5/25 20:18, Ondřej Jirman wrote:
> From: Ondrej Jirman <megi at xff.cz>
>
> Failure can happen when i2c is used without initializing pinctrl properly,
> which U-Boot happily allows in SPL. Without this fix, further I2C access would
> fail, even after proper pinctrl initialization.
>
> Signed-off-by: Ondrej Jirman <megi at xff.cz>
> Cc: Heiko Schocher <hs at denx.de>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/i2c/rk_i2c.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
> index f8fac45b6ca0..9927af94a80b 100644
> --- a/drivers/i2c/rk_i2c.c
> +++ b/drivers/i2c/rk_i2c.c
> @@ -342,7 +342,7 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
>   			     int nmsgs)
>   {
>   	struct rk_i2c *i2c = dev_get_priv(bus);
> -	int ret;
> +	int ret = 0;
>   
>   	debug("i2c_xfer: %d messages\n", nmsgs);
>   	for (; nmsgs > 0; nmsgs--, msg++) {
> @@ -356,14 +356,15 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
>   		}
>   		if (ret) {
>   			debug("i2c_write: error sending\n");
> -			return -EREMOTEIO;
> +			ret = -EREMOTEIO;
> +			break;
>   		}
>   	}
>   
>   	rk_i2c_send_stop_bit(i2c);
>   	rk_i2c_disable(i2c);
>   
> -	return 0;
> +	return ret;
>   }
>   
>   int rockchip_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)


More information about the U-Boot mailing list