u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Alain Volmat <alain.volmat@foss.st.com>
To: Patrice CHOTARD <patrice.chotard@foss.st.com>
Cc: Jorge Ramirez-Ortiz <jorge@foundries.io>, <hs@denx.de>,
	<patrick.delaunay@foss.st.com>, <oleksandr.suvorov@foundries.io>,
	<uboot-stm32@st-md-mailman.stormreply.com>,
	<u-boot@lists.denx.de>
Subject: Re: [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error
Date: Wed, 7 Sep 2022 11:20:00 +0200	[thread overview]
Message-ID: <20220907092000.GA1713256@gnbcxd0016.gnb.st.com> (raw)
In-Reply-To: <80f7f6f4-22bf-7ece-2a6e-0ae34c493cd9@foss.st.com>

Hi,

I confirm that a fix is necessary regarding this setting of the stop
condition.  As a matter of fact, the controller is already sending
the stop condition in case of NACK so there is no need to send the
stop condition.
However, this fix is not enough since the nack could be detected
few lines above 

	if (status & (STM32_I2C_ISR_NACKF | STM32_I2C_ISR_ERRORS))
		break;

and in this case the current check would not catch it.

I propose to set the STOP condition upon handling of the transfer
complete.

I've put this fix within a small 3 patches series that I'm going to
send, could you check it to confirm this fixes the issue ?

Regards,
Alain

On Thu, Aug 25, 2022 at 03:36:36PM +0200, Patrice CHOTARD wrote:
> +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@foundries.io>
> > Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@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);
> >  }

  reply	other threads:[~2022-09-07 11:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 14:52 [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register Jorge Ramirez-Ortiz
2022-08-15 14:52 ` [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error Jorge Ramirez-Ortiz
2022-08-25  8:52   ` Patrice CHOTARD
2022-08-25 13:36   ` Patrice CHOTARD
2022-09-07  9:20     ` Alain Volmat [this message]
2022-09-09  9:35       ` Patrick DELAUNAY
2022-08-24 15:35 ` [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register Patrice CHOTARD
2022-08-30  7:43 ` Patrick DELAUNAY
2022-09-15 15:14 ` Patrick DELAUNAY

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=20220907092000.GA1713256@gnbcxd0016.gnb.st.com \
    --to=alain.volmat@foss.st.com \
    --cc=hs@denx.de \
    --cc=jorge@foundries.io \
    --cc=oleksandr.suvorov@foundries.io \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-stm32@st-md-mailman.stormreply.com \
    /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;
as well as URLs for NNTP newsgroup(s).