public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] misc: atsha204a: Don't check for error when waking up the device
@ 2022-08-04 11:03 Pali Rohár
  2022-08-05 10:46 ` Stefan Roese
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Pali Rohár @ 2022-08-04 11:03 UTC (permalink / raw)
  To: Stefan Roese, Marek Behún, Paweł Anikiel,
	Adrian Fiergolski, Simon Glass
  Cc: u-boot

The device ignores any levels or transitions on the SCL pin when the device
is idle, asleep or during waking up.

Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return
value from i2c wakeup send command, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174

And also userspace Turris libatsha204 library ignores return value from
wakeup send command, see:
https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76

U-Boot driver should do same thing.

Fixes waking up ATSHA204 on Turris 1.x boards.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 drivers/misc/atsha204a-i2c.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
index 81ecb5b6177b..fa2d5948f128 100644
--- a/drivers/misc/atsha204a-i2c.c
+++ b/drivers/misc/atsha204a-i2c.c
@@ -103,12 +103,13 @@ int atsha204a_wakeup(struct udevice *dev)
 	for (try = 1; try <= 10; ++try) {
 		debug("Try %i... ", try);
 
+		/*
+		 * The device ignores any levels or transitions on the SCL pin
+		 * when the device is idle, asleep or during waking up.
+		 * Don't check for error when waking up the device.
+		 */
 		memset(req, 0, 4);
-		res = atsha204a_send(dev, req, 4);
-		if (res) {
-			debug("failed on I2C send, trying again\n");
-			continue;
-		}
+		atsha204a_send(dev, req, 4);
 
 		udelay(ATSHA204A_TWLO_US + ATSHA204A_TWHI_US);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] misc: atsha204a: Don't check for error when waking up the device
  2022-08-04 11:03 [PATCH] misc: atsha204a: Don't check for error when waking up the device Pali Rohár
@ 2022-08-05 10:46 ` Stefan Roese
  2022-08-07 19:30 ` Pali Rohár
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2022-08-05 10:46 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún, Paweł Anikiel,
	Adrian Fiergolski, Simon Glass
  Cc: u-boot

On 04.08.22 13:03, Pali Rohár wrote:
> The device ignores any levels or transitions on the SCL pin when the device
> is idle, asleep or during waking up.
> 
> Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return
> value from i2c wakeup send command, see:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174
> 
> And also userspace Turris libatsha204 library ignores return value from
> wakeup send command, see:
> https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76
> 
> U-Boot driver should do same thing.
> 
> Fixes waking up ATSHA204 on Turris 1.x boards.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   drivers/misc/atsha204a-i2c.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
> index 81ecb5b6177b..fa2d5948f128 100644
> --- a/drivers/misc/atsha204a-i2c.c
> +++ b/drivers/misc/atsha204a-i2c.c
> @@ -103,12 +103,13 @@ int atsha204a_wakeup(struct udevice *dev)
>   	for (try = 1; try <= 10; ++try) {
>   		debug("Try %i... ", try);
>   
> +		/*
> +		 * The device ignores any levels or transitions on the SCL pin
> +		 * when the device is idle, asleep or during waking up.
> +		 * Don't check for error when waking up the device.
> +		 */
>   		memset(req, 0, 4);
> -		res = atsha204a_send(dev, req, 4);
> -		if (res) {
> -			debug("failed on I2C send, trying again\n");
> -			continue;
> -		}
> +		atsha204a_send(dev, req, 4);
>   
>   		udelay(ATSHA204A_TWLO_US + ATSHA204A_TWHI_US);
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] misc: atsha204a: Don't check for error when waking up the device
  2022-08-04 11:03 [PATCH] misc: atsha204a: Don't check for error when waking up the device Pali Rohár
  2022-08-05 10:46 ` Stefan Roese
@ 2022-08-07 19:30 ` Pali Rohár
  2022-08-08  9:29   ` Paweł Anikiel
  2022-08-09  7:56 ` Marek Behún
  2022-08-09 11:36 ` Stefan Roese
  3 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2022-08-07 19:30 UTC (permalink / raw)
  To: Paweł Anikiel
  Cc: Stefan Roese, Marek Behún, Adrian Fiergolski, Simon Glass,
	u-boot

Paweł, could you please test this change if it works on your board? I
was that you were fixing another wakeup issue in patch "misc: atsha204a:
Increase wake delay by tWHI".

On Thursday 04 August 2022 13:03:44 Pali Rohár wrote:
> The device ignores any levels or transitions on the SCL pin when the device
> is idle, asleep or during waking up.
> 
> Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return
> value from i2c wakeup send command, see:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174
> 
> And also userspace Turris libatsha204 library ignores return value from
> wakeup send command, see:
> https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76
> 
> U-Boot driver should do same thing.
> 
> Fixes waking up ATSHA204 on Turris 1.x boards.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>  drivers/misc/atsha204a-i2c.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
> index 81ecb5b6177b..fa2d5948f128 100644
> --- a/drivers/misc/atsha204a-i2c.c
> +++ b/drivers/misc/atsha204a-i2c.c
> @@ -103,12 +103,13 @@ int atsha204a_wakeup(struct udevice *dev)
>  	for (try = 1; try <= 10; ++try) {
>  		debug("Try %i... ", try);
>  
> +		/*
> +		 * The device ignores any levels or transitions on the SCL pin
> +		 * when the device is idle, asleep or during waking up.
> +		 * Don't check for error when waking up the device.
> +		 */
>  		memset(req, 0, 4);
> -		res = atsha204a_send(dev, req, 4);
> -		if (res) {
> -			debug("failed on I2C send, trying again\n");
> -			continue;
> -		}
> +		atsha204a_send(dev, req, 4);
>  
>  		udelay(ATSHA204A_TWLO_US + ATSHA204A_TWHI_US);
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] misc: atsha204a: Don't check for error when waking up the device
  2022-08-07 19:30 ` Pali Rohár
@ 2022-08-08  9:29   ` Paweł Anikiel
  0 siblings, 0 replies; 7+ messages in thread
From: Paweł Anikiel @ 2022-08-08  9:29 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Stefan Roese, Marek Behún, Adrian Fiergolski, Simon Glass,
	U-Boot Mailing List

Hi Pali,

I applied the patch and it works fine on my board. Log from atsha204a_wakeup():
  Waking up ATSHA204A
  Try 1... success

Tested-by: Paweł Anikiel <pan@semihalf.com>

Regards,
Paweł

On Sun, Aug 7, 2022 at 9:30 PM Pali Rohár <pali@kernel.org> wrote:
>
> Paweł, could you please test this change if it works on your board? I
> was that you were fixing another wakeup issue in patch "misc: atsha204a:
> Increase wake delay by tWHI".
>
> On Thursday 04 August 2022 13:03:44 Pali Rohár wrote:
> > The device ignores any levels or transitions on the SCL pin when the device
> > is idle, asleep or during waking up.
> >
> > Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return
> > value from i2c wakeup send command, see:
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174
> >
> > And also userspace Turris libatsha204 library ignores return value from
> > wakeup send command, see:
> > https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76
> >
> > U-Boot driver should do same thing.
> >
> > Fixes waking up ATSHA204 on Turris 1.x boards.
> >
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > ---
> >  drivers/misc/atsha204a-i2c.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
> > index 81ecb5b6177b..fa2d5948f128 100644
> > --- a/drivers/misc/atsha204a-i2c.c
> > +++ b/drivers/misc/atsha204a-i2c.c
> > @@ -103,12 +103,13 @@ int atsha204a_wakeup(struct udevice *dev)
> >       for (try = 1; try <= 10; ++try) {
> >               debug("Try %i... ", try);
> >
> > +             /*
> > +              * The device ignores any levels or transitions on the SCL pin
> > +              * when the device is idle, asleep or during waking up.
> > +              * Don't check for error when waking up the device.
> > +              */
> >               memset(req, 0, 4);
> > -             res = atsha204a_send(dev, req, 4);
> > -             if (res) {
> > -                     debug("failed on I2C send, trying again\n");
> > -                     continue;
> > -             }
> > +             atsha204a_send(dev, req, 4);
> >
> >               udelay(ATSHA204A_TWLO_US + ATSHA204A_TWHI_US);
> >
> > --
> > 2.20.1
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] misc: atsha204a: Don't check for error when waking up the device
  2022-08-04 11:03 [PATCH] misc: atsha204a: Don't check for error when waking up the device Pali Rohár
  2022-08-05 10:46 ` Stefan Roese
  2022-08-07 19:30 ` Pali Rohár
@ 2022-08-09  7:56 ` Marek Behún
  2022-08-09  7:58   ` Stefan Roese
  2022-08-09 11:36 ` Stefan Roese
  3 siblings, 1 reply; 7+ messages in thread
From: Marek Behún @ 2022-08-09  7:56 UTC (permalink / raw)
  To: Pali Rohár, Stefan Roese
  Cc: Paweł Anikiel, Adrian Fiergolski, Simon Glass, u-boot

On Thu,  4 Aug 2022 13:03:44 +0200
Pali Rohár <pali@kernel.org> wrote:

> The device ignores any levels or transitions on the SCL pin when the device
> is idle, asleep or during waking up.
> 
> Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return
> value from i2c wakeup send command, see:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174
> 
> And also userspace Turris libatsha204 library ignores return value from
> wakeup send command, see:
> https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76
> 
> U-Boot driver should do same thing.
> 
> Fixes waking up ATSHA204 on Turris 1.x boards.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Marek Behún <kabel@kernel.org>

Stefan, will you apply this via marvell?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] misc: atsha204a: Don't check for error when waking up the device
  2022-08-09  7:56 ` Marek Behún
@ 2022-08-09  7:58   ` Stefan Roese
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2022-08-09  7:58 UTC (permalink / raw)
  To: Marek Behún, Pali Rohár
  Cc: Paweł Anikiel, Adrian Fiergolski, Simon Glass, u-boot

On 09.08.22 09:56, Marek Behún wrote:
> On Thu,  4 Aug 2022 13:03:44 +0200
> Pali Rohár <pali@kernel.org> wrote:
> 
>> The device ignores any levels or transitions on the SCL pin when the device
>> is idle, asleep or during waking up.
>>
>> Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return
>> value from i2c wakeup send command, see:
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174
>>
>> And also userspace Turris libatsha204 library ignores return value from
>> wakeup send command, see:
>> https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76
>>
>> U-Boot driver should do same thing.
>>
>> Fixes waking up ATSHA204 on Turris 1.x boards.
>>
>> Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> Reviewed-by: Marek Behún <kabel@kernel.org>
> 
> Stefan, will you apply this via marvell?

I can do this, let me check. I plan to send a pull request soon anyways.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] misc: atsha204a: Don't check for error when waking up the device
  2022-08-04 11:03 [PATCH] misc: atsha204a: Don't check for error when waking up the device Pali Rohár
                   ` (2 preceding siblings ...)
  2022-08-09  7:56 ` Marek Behún
@ 2022-08-09 11:36 ` Stefan Roese
  3 siblings, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2022-08-09 11:36 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún, Paweł Anikiel,
	Adrian Fiergolski, Simon Glass
  Cc: u-boot

On 04.08.22 13:03, Pali Rohár wrote:
> The device ignores any levels or transitions on the SCL pin when the device
> is idle, asleep or during waking up.
> 
> Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return
> value from i2c wakeup send command, see:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174
> 
> And also userspace Turris libatsha204 library ignores return value from
> wakeup send command, see:
> https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76
> 
> U-Boot driver should do same thing.
> 
> Fixes waking up ATSHA204 on Turris 1.x boards.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   drivers/misc/atsha204a-i2c.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
> index 81ecb5b6177b..fa2d5948f128 100644
> --- a/drivers/misc/atsha204a-i2c.c
> +++ b/drivers/misc/atsha204a-i2c.c
> @@ -103,12 +103,13 @@ int atsha204a_wakeup(struct udevice *dev)
>   	for (try = 1; try <= 10; ++try) {
>   		debug("Try %i... ", try);
>   
> +		/*
> +		 * The device ignores any levels or transitions on the SCL pin
> +		 * when the device is idle, asleep or during waking up.
> +		 * Don't check for error when waking up the device.
> +		 */
>   		memset(req, 0, 4);
> -		res = atsha204a_send(dev, req, 4);
> -		if (res) {
> -			debug("failed on I2C send, trying again\n");
> -			continue;
> -		}
> +		atsha204a_send(dev, req, 4);
>   
>   		udelay(ATSHA204A_TWLO_US + ATSHA204A_TWHI_US);
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-09 11:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-04 11:03 [PATCH] misc: atsha204a: Don't check for error when waking up the device Pali Rohár
2022-08-05 10:46 ` Stefan Roese
2022-08-07 19:30 ` Pali Rohár
2022-08-08  9:29   ` Paweł Anikiel
2022-08-09  7:56 ` Marek Behún
2022-08-09  7:58   ` Stefan Roese
2022-08-09 11:36 ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox