All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] board: turris: Find atsha device by atsha driver
@ 2022-05-19  9:11 Pali Rohár
  2022-05-20  5:05 ` Stefan Roese
  2022-07-21 12:22 ` Stefan Roese
  0 siblings, 2 replies; 4+ messages in thread
From: Pali Rohár @ 2022-05-19  9:11 UTC (permalink / raw)
  To: Marek Behun, Stefan Roese; +Cc: u-boot

It does not matter what is DT node name of atsha device. So find it via
atsha driver and not by DT node name.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 board/CZ.NIC/turris_atsha_otp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
index 8c39f5e52414..e62b7ee2a49a 100644
--- a/board/CZ.NIC/turris_atsha_otp.c
+++ b/board/CZ.NIC/turris_atsha_otp.c
@@ -6,6 +6,7 @@
 
 #include <env.h>
 #include <net.h>
+#include <dm/device.h>
 #include <dm/uclass.h>
 #include <atsha204a-i2c.h>
 
@@ -16,12 +17,14 @@
 #define TURRIS_ATSHA_OTP_MAC0		3
 #define TURRIS_ATSHA_OTP_MAC1		4
 
+extern U_BOOT_DRIVER(atsha204);
+
 static struct udevice *get_atsha204a_dev(void)
 {
 	/* Cannot be static because BSS does not have to be ready at this early stage */
 	struct udevice *dev;
 
-	if (uclass_get_device_by_name(UCLASS_MISC, "crypto@64", &dev)) {
+	if (uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(atsha204), &dev)) {
 		puts("Cannot find ATSHA204A on I2C bus!\n");
 		dev = NULL;
 	}
-- 
2.20.1


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

* Re: [PATCH] board: turris: Find atsha device by atsha driver
  2022-05-19  9:11 [PATCH] board: turris: Find atsha device by atsha driver Pali Rohár
@ 2022-05-20  5:05 ` Stefan Roese
  2022-05-20  8:12   ` Pali Rohár
  2022-07-21 12:22 ` Stefan Roese
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2022-05-20  5:05 UTC (permalink / raw)
  To: Pali Rohár, Marek Behun; +Cc: u-boot

On 19.05.22 11:11, Pali Rohár wrote:
> It does not matter what is DT node name of atsha device. So find it via
> atsha driver and not by DT node name.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Just curious: What exactly does this patch fix? Is there a turris
board with a differently named atsha DT entry?

Still:

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

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_atsha_otp.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
> index 8c39f5e52414..e62b7ee2a49a 100644
> --- a/board/CZ.NIC/turris_atsha_otp.c
> +++ b/board/CZ.NIC/turris_atsha_otp.c
> @@ -6,6 +6,7 @@
>   
>   #include <env.h>
>   #include <net.h>
> +#include <dm/device.h>
>   #include <dm/uclass.h>
>   #include <atsha204a-i2c.h>
>   
> @@ -16,12 +17,14 @@
>   #define TURRIS_ATSHA_OTP_MAC0		3
>   #define TURRIS_ATSHA_OTP_MAC1		4
>   
> +extern U_BOOT_DRIVER(atsha204);
> +
>   static struct udevice *get_atsha204a_dev(void)
>   {
>   	/* Cannot be static because BSS does not have to be ready at this early stage */
>   	struct udevice *dev;
>   
> -	if (uclass_get_device_by_name(UCLASS_MISC, "crypto@64", &dev)) {
> +	if (uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(atsha204), &dev)) {
>   		puts("Cannot find ATSHA204A on I2C bus!\n");
>   		dev = NULL;
>   	}

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] 4+ messages in thread

* Re: [PATCH] board: turris: Find atsha device by atsha driver
  2022-05-20  5:05 ` Stefan Roese
@ 2022-05-20  8:12   ` Pali Rohár
  0 siblings, 0 replies; 4+ messages in thread
From: Pali Rohár @ 2022-05-20  8:12 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behun, u-boot

On Friday 20 May 2022 07:05:50 Stefan Roese wrote:
> On 19.05.22 11:11, Pali Rohár wrote:
> > It does not matter what is DT node name of atsha device. So find it via
> > atsha driver and not by DT node name.
> > 
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> Just curious: What exactly does this patch fix? Is there a turris
> board with a differently named atsha DT entry?

Currently is not. In patch for Turris 1.x support I use same "crypto@64"
node name, so code would work correctly:
https://lore.kernel.org/u-boot/20220516090119.20217-1-pali@kernel.org/#Z31arch:powerpc:dts:turris1x-u-boot.dtsi

But I think that U-Boot code should be independent of the node names and
this file calls functions exported from atsha204 driver. So it is better
to find udevice based on driver which export those functions than DTS
node name.

> Still:
> 
> Reviewed-by: Stefan Roese <sr@denx.de>
> 
> Thanks,
> Stefan
> 
> > ---
> >   board/CZ.NIC/turris_atsha_otp.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
> > index 8c39f5e52414..e62b7ee2a49a 100644
> > --- a/board/CZ.NIC/turris_atsha_otp.c
> > +++ b/board/CZ.NIC/turris_atsha_otp.c
> > @@ -6,6 +6,7 @@
> >   #include <env.h>
> >   #include <net.h>
> > +#include <dm/device.h>
> >   #include <dm/uclass.h>
> >   #include <atsha204a-i2c.h>
> > @@ -16,12 +17,14 @@
> >   #define TURRIS_ATSHA_OTP_MAC0		3
> >   #define TURRIS_ATSHA_OTP_MAC1		4
> > +extern U_BOOT_DRIVER(atsha204);
> > +
> >   static struct udevice *get_atsha204a_dev(void)
> >   {
> >   	/* Cannot be static because BSS does not have to be ready at this early stage */
> >   	struct udevice *dev;
> > -	if (uclass_get_device_by_name(UCLASS_MISC, "crypto@64", &dev)) {
> > +	if (uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(atsha204), &dev)) {
> >   		puts("Cannot find ATSHA204A on I2C bus!\n");
> >   		dev = NULL;
> >   	}
> 
> 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] 4+ messages in thread

* Re: [PATCH] board: turris: Find atsha device by atsha driver
  2022-05-19  9:11 [PATCH] board: turris: Find atsha device by atsha driver Pali Rohár
  2022-05-20  5:05 ` Stefan Roese
@ 2022-07-21 12:22 ` Stefan Roese
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2022-07-21 12:22 UTC (permalink / raw)
  To: Pali Rohár, Marek Behun; +Cc: u-boot

On 19.05.22 11:11, Pali Rohár wrote:
> It does not matter what is DT node name of atsha device. So find it via
> atsha driver and not by DT node name.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_atsha_otp.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
> index 8c39f5e52414..e62b7ee2a49a 100644
> --- a/board/CZ.NIC/turris_atsha_otp.c
> +++ b/board/CZ.NIC/turris_atsha_otp.c
> @@ -6,6 +6,7 @@
>   
>   #include <env.h>
>   #include <net.h>
> +#include <dm/device.h>
>   #include <dm/uclass.h>
>   #include <atsha204a-i2c.h>
>   
> @@ -16,12 +17,14 @@
>   #define TURRIS_ATSHA_OTP_MAC0		3
>   #define TURRIS_ATSHA_OTP_MAC1		4
>   
> +extern U_BOOT_DRIVER(atsha204);
> +
>   static struct udevice *get_atsha204a_dev(void)
>   {
>   	/* Cannot be static because BSS does not have to be ready at this early stage */
>   	struct udevice *dev;
>   
> -	if (uclass_get_device_by_name(UCLASS_MISC, "crypto@64", &dev)) {
> +	if (uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(atsha204), &dev)) {
>   		puts("Cannot find ATSHA204A on I2C bus!\n");
>   		dev = NULL;
>   	}

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] 4+ messages in thread

end of thread, other threads:[~2022-07-21 12:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19  9:11 [PATCH] board: turris: Find atsha device by atsha driver Pali Rohár
2022-05-20  5:05 ` Stefan Roese
2022-05-20  8:12   ` Pali Rohár
2022-07-21 12:22 ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.