[PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error

Patrice CHOTARD patrice.chotard at foss.st.com
Thu Aug 25 15:36:36 CEST 2022


+Alain (with the correct email address ;-))

Alain, can you have a look a this patch and give your feedback on it.

On my side i tested it on stm32mp157c-ev1 and stm32mp157c-dk2, i didn't see any regression
but i prefer to get expert feedback 

Thanks
Patrice

On 8/15/22 16:52, Jorge Ramirez-Ortiz wrote:
> Sending the stop condition without waiting for transfer complete
> has been found to lock the bus (BUSY) when NACKF is raised.
> 
> Tested accessing the NXP SE05X I2C device.
> https://www.nxp.com/docs/en/application-note/AN12399.pdf
> 
> Signed-off-by: Jorge Ramirez-Ortiz <jorge at foundries.io>
> Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov at foundries.io>
> ---
>  drivers/i2c/stm32f7_i2c.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
> index 3a727e68ac..14827e5cec 100644
> --- a/drivers/i2c/stm32f7_i2c.c
> +++ b/drivers/i2c/stm32f7_i2c.c
> @@ -485,9 +485,11 @@ static int stm32_i2c_message_xfer(struct stm32_i2c_priv *i2c_priv,
>  		}
>  	}
>  
> -	/* End of transfer, send stop condition */
> -	mask = STM32_I2C_CR2_STOP;
> -	setbits_le32(&regs->cr2, mask);
> +	if (!ret) {
> +		/* End of transfer, send stop condition */
> +		mask = STM32_I2C_CR2_STOP;
> +		setbits_le32(&regs->cr2, mask);
> +	}
>  
>  	return stm32_i2c_check_end_of_message(i2c_priv);
>  }


More information about the U-Boot mailing list