* [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register
@ 2022-08-15 14:52 Jorge Ramirez-Ortiz
2022-08-15 14:52 ` [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error Jorge Ramirez-Ortiz
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Jorge Ramirez-Ortiz @ 2022-08-15 14:52 UTC (permalink / raw)
To: jorge, hs, patrick.delaunay, patrice.chotard, oleksandr.suvorov
Cc: uboot-stm32, u-boot
Bits should be set to 0, not 1.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
---
drivers/i2c/stm32f7_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
index bf2a6c9b4b..3a727e68ac 100644
--- a/drivers/i2c/stm32f7_i2c.c
+++ b/drivers/i2c/stm32f7_i2c.c
@@ -413,7 +413,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
setbits_le32(®s->icr, STM32_I2C_ICR_STOPCF);
/* Clear control register 2 */
- setbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
+ clrbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
}
return ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error
2022-08-15 14:52 [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register Jorge Ramirez-Ortiz
@ 2022-08-15 14:52 ` Jorge Ramirez-Ortiz
2022-08-25 8:52 ` Patrice CHOTARD
2022-08-25 13:36 ` Patrice CHOTARD
2022-08-24 15:35 ` [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register Patrice CHOTARD
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Jorge Ramirez-Ortiz @ 2022-08-15 14:52 UTC (permalink / raw)
To: jorge, hs, patrick.delaunay, patrice.chotard, oleksandr.suvorov
Cc: uboot-stm32, u-boot
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(®s->cr2, mask);
+ if (!ret) {
+ /* End of transfer, send stop condition */
+ mask = STM32_I2C_CR2_STOP;
+ setbits_le32(®s->cr2, mask);
+ }
return stm32_i2c_check_end_of_message(i2c_priv);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register
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-24 15:35 ` Patrice CHOTARD
2022-08-30 7:43 ` Patrick DELAUNAY
2022-09-15 15:14 ` Patrick DELAUNAY
3 siblings, 0 replies; 10+ messages in thread
From: Patrice CHOTARD @ 2022-08-24 15:35 UTC (permalink / raw)
To: Jorge Ramirez-Ortiz, hs, patrick.delaunay, oleksandr.suvorov
Cc: uboot-stm32, u-boot
Hi Jorge
On 8/15/22 16:52, Jorge Ramirez-Ortiz wrote:
> Bits should be set to 0, not 1.
>
> Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
> ---
> drivers/i2c/stm32f7_i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
> index bf2a6c9b4b..3a727e68ac 100644
> --- a/drivers/i2c/stm32f7_i2c.c
> +++ b/drivers/i2c/stm32f7_i2c.c
> @@ -413,7 +413,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
> setbits_le32(®s->icr, STM32_I2C_ICR_STOPCF);
>
> /* Clear control register 2 */
> - setbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
> + clrbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
> }
>
> return ret;
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error
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
1 sibling, 0 replies; 10+ messages in thread
From: Patrice CHOTARD @ 2022-08-25 8:52 UTC (permalink / raw)
To: Jorge Ramirez-Ortiz, hs, patrick.delaunay, oleksandr.suvorov,
Alain Volmat
Cc: uboot-stm32, u-boot
+Alain
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(®s->cr2, mask);
> + if (!ret) {
> + /* End of transfer, send stop condition */
> + mask = STM32_I2C_CR2_STOP;
> + setbits_le32(®s->cr2, mask);
> + }
>
> return stm32_i2c_check_end_of_message(i2c_priv);
> }
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error
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
1 sibling, 1 reply; 10+ messages in thread
From: Patrice CHOTARD @ 2022-08-25 13:36 UTC (permalink / raw)
To: Jorge Ramirez-Ortiz, hs, patrick.delaunay, oleksandr.suvorov,
alain.volmat
Cc: uboot-stm32, u-boot
+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(®s->cr2, mask);
> + if (!ret) {
> + /* End of transfer, send stop condition */
> + mask = STM32_I2C_CR2_STOP;
> + setbits_le32(®s->cr2, mask);
> + }
>
> return stm32_i2c_check_end_of_message(i2c_priv);
> }
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register
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-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
3 siblings, 0 replies; 10+ messages in thread
From: Patrick DELAUNAY @ 2022-08-30 7:43 UTC (permalink / raw)
To: Jorge Ramirez-Ortiz, hs, patrice.chotard, oleksandr.suvorov
Cc: uboot-stm32, u-boot
Hi,
On 8/15/22 16:52, Jorge Ramirez-Ortiz wrote:
> Bits should be set to 0, not 1.
>
> Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
> ---
> drivers/i2c/stm32f7_i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
> index bf2a6c9b4b..3a727e68ac 100644
> --- a/drivers/i2c/stm32f7_i2c.c
> +++ b/drivers/i2c/stm32f7_i2c.c
> @@ -413,7 +413,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
> setbits_le32(®s->icr, STM32_I2C_ICR_STOPCF);
>
> /* Clear control register 2 */
> - setbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
> + clrbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
> }
>
> return ret;
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Thanks
Patrick
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error
2022-08-25 13:36 ` Patrice CHOTARD
@ 2022-09-07 9:20 ` Alain Volmat
2022-09-09 9:35 ` Patrick DELAUNAY
0 siblings, 1 reply; 10+ messages in thread
From: Alain Volmat @ 2022-09-07 9:20 UTC (permalink / raw)
To: Patrice CHOTARD
Cc: Jorge Ramirez-Ortiz, hs, patrick.delaunay, oleksandr.suvorov,
uboot-stm32, u-boot
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(®s->cr2, mask);
> > + if (!ret) {
> > + /* End of transfer, send stop condition */
> > + mask = STM32_I2C_CR2_STOP;
> > + setbits_le32(®s->cr2, mask);
> > + }
> >
> > return stm32_i2c_check_end_of_message(i2c_priv);
> > }
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCHv2 2/2] i2c: stm32f7: do not set the STOP condition on error
2022-09-07 9:20 ` Alain Volmat
@ 2022-09-09 9:35 ` Patrick DELAUNAY
0 siblings, 0 replies; 10+ messages in thread
From: Patrick DELAUNAY @ 2022-09-09 9:35 UTC (permalink / raw)
To: Alain Volmat, Patrice CHOTARD
Cc: Jorge Ramirez-Ortiz, hs, oleksandr.suvorov, uboot-stm32, u-boot
Hi,
On 9/7/22 11:20, Alain Volmat wrote:
> 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(-)
>>>
For reference, this patch is superseded by Alain Volmat patch:
[v2,1/3] i2c: stm32: fix comment and remove unused AUTOEND bit
http://patchwork.ozlabs.org/project/uboot/patch/20220908105934.1764482-2-alain.volmat@foss.st.com/
in the serie "i2c: stm32: cleanup & stop handling fix"
http://patchwork.ozlabs.org/project/uboot/list/?series=317443&state=*
Regards
Patrick
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register
2022-08-15 14:52 [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register Jorge Ramirez-Ortiz
` (2 preceding siblings ...)
2022-08-30 7:43 ` Patrick DELAUNAY
@ 2022-09-15 15:14 ` Patrick DELAUNAY
3 siblings, 0 replies; 10+ messages in thread
From: Patrick DELAUNAY @ 2022-09-15 15:14 UTC (permalink / raw)
To: Jorge Ramirez-Ortiz, hs, patrice.chotard, oleksandr.suvorov
Cc: uboot-stm32, u-boot, Alain Volmat
Hi,
On 8/15/22 16:52, Jorge Ramirez-Ortiz wrote:
> Bits should be set to 0, not 1.
>
> Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
> ---
> drivers/i2c/stm32f7_i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
> index bf2a6c9b4b..3a727e68ac 100644
> --- a/drivers/i2c/stm32f7_i2c.c
> +++ b/drivers/i2c/stm32f7_i2c.c
> @@ -413,7 +413,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
> setbits_le32(®s->icr, STM32_I2C_ICR_STOPCF);
>
> /* Clear control register 2 */
> - setbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
> + clrbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
> }
>
> return ret;
Applied to u-boot-stm/master, thanks!
Regards
Patrick
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register
@ 2022-08-24 15:56 Jorge Ramirez-Ortiz
0 siblings, 0 replies; 10+ messages in thread
From: Jorge Ramirez-Ortiz @ 2022-08-24 15:56 UTC (permalink / raw)
To: jorge, patrice.chotard, hs, patrick.delaunay, oleksandr.suvorov
Cc: uboot-stm32, u-boot
Bits should be set to 0, not 1.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
drivers/i2c/stm32f7_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
index bf2a6c9b4b..3a727e68ac 100644
--- a/drivers/i2c/stm32f7_i2c.c
+++ b/drivers/i2c/stm32f7_i2c.c
@@ -413,7 +413,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
setbits_le32(®s->icr, STM32_I2C_ICR_STOPCF);
/* Clear control register 2 */
- setbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
+ clrbits_le32(®s->cr2, STM32_I2C_CR2_RESET_MASK);
}
return ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-09-15 15:14 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
2022-08-24 15:56 Jorge Ramirez-Ortiz
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).