public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits
@ 2015-03-28 17:35 Paul Kocialkowski
  2015-03-28 17:35 ` [U-Boot] [PATCH v4 2/2] sunxi: Pass serial number through ATAG Paul Kocialkowski
  2015-03-29 12:47 ` [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits Hans de Goede
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Kocialkowski @ 2015-03-28 17:35 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 board/sunxi/board.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 01b654e..79516bf 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -372,20 +372,31 @@ int g_dnl_board_usb_cable_connected(void)
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	unsigned int sid[4];
+	uint8_t mac_addr[6];
+	int ret;
+
+	ret = sunxi_get_sid(sid);
+	if (ret == 0 && sid[0] != 0 && sid[3] != 0) {
+		if (!getenv("ethaddr")) {
+			/* Non OUI / registered MAC address */
+			mac_addr[0] = 0x02;
+			mac_addr[1] = (sid[0] >>  0) & 0xff;
+			mac_addr[2] = (sid[3] >> 24) & 0xff;
+			mac_addr[3] = (sid[3] >> 16) & 0xff;
+			mac_addr[4] = (sid[3] >>  8) & 0xff;
+			mac_addr[5] = (sid[3] >>  0) & 0xff;
+
+			eth_setenv_enetaddr("ethaddr", mac_addr);
+		}
 
-	if (!getenv("ethaddr") && sunxi_get_sid(sid) == 0 &&
-			sid[0] != 0 && sid[3] != 0) {
-		uint8_t mac_addr[6];
-
-		mac_addr[0] = 0x02; /* Non OUI / registered MAC address */
-		mac_addr[1] = (sid[0] >>  0) & 0xff;
-		mac_addr[2] = (sid[3] >> 24) & 0xff;
-		mac_addr[3] = (sid[3] >> 16) & 0xff;
-		mac_addr[4] = (sid[3] >>  8) & 0xff;
-		mac_addr[5] = (sid[3] >>  0) & 0xff;
+		if (!getenv("serial#")) {
+			snprintf(serial_string, sizeof(serial_string),
+				"%08x%08x", sid[0], sid[3]);
 
-		eth_setenv_enetaddr("ethaddr", mac_addr);
+			setenv("serial#", serial_string);
+		}
 	}
 
 #if defined(CONFIG_MUSB_HOST) || defined(CONFIG_MUSB_GADGET)
-- 
1.9.1

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

* [U-Boot] [PATCH v4 2/2] sunxi: Pass serial number through ATAG
  2015-03-28 17:35 [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits Paul Kocialkowski
@ 2015-03-28 17:35 ` Paul Kocialkowski
  2015-03-29 12:49   ` Hans de Goede
  2015-03-29 12:47 ` [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits Hans de Goede
  1 sibling, 1 reply; 4+ messages in thread
From: Paul Kocialkowski @ 2015-03-28 17:35 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 board/sunxi/board.c            | 20 ++++++++++++++++++++
 include/configs/sunxi-common.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 79516bf..d1b3c5e 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -369,6 +369,26 @@ int g_dnl_board_usb_cable_connected(void)
 }
 #endif
 
+#ifdef CONFIG_SERIAL_TAG
+void get_board_serial(struct tag_serialnr *serialnr)
+{
+	char *serial_string;
+	unsigned long long serial;
+
+	serial_string = getenv("serial#");
+
+	if (serial_string) {
+		serial = simple_strtoull(serial_string, NULL, 16);
+
+		serialnr->high = (unsigned int) (serial >> 32);
+		serialnr->low = (unsigned int) (serial & 0xffffffff);
+	} else {
+		serialnr->high = 0;
+		serialnr->low = 0;
+	}
+}
+#endif
+
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 1f7a1cb..b9bb971 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -98,6 +98,7 @@
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
+#define CONFIG_SERIAL_TAG
 
 /* mmc config */
 #if !defined(CONFIG_UART0_PORT_F)
-- 
1.9.1

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

* [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits
  2015-03-28 17:35 [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits Paul Kocialkowski
  2015-03-28 17:35 ` [U-Boot] [PATCH v4 2/2] sunxi: Pass serial number through ATAG Paul Kocialkowski
@ 2015-03-29 12:47 ` Hans de Goede
  1 sibling, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2015-03-29 12:47 UTC (permalink / raw)
  To: u-boot

Hi,

On 28-03-15 18:35, Paul Kocialkowski wrote:
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

Thanks, I'm currently busy merging some more patches, once that
is done this patch should show up in u-boot-sunxi/next, and
it will be included in u-boot/master once the merge window
for v2015.07 opens.

Regards,

Hans

> ---
>   board/sunxi/board.c | 33 ++++++++++++++++++++++-----------
>   1 file changed, 22 insertions(+), 11 deletions(-)
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 01b654e..79516bf 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -372,20 +372,31 @@ int g_dnl_board_usb_cable_connected(void)
>   #ifdef CONFIG_MISC_INIT_R
>   int misc_init_r(void)
>   {
> +	char serial_string[17] = { 0 };
>   	unsigned int sid[4];
> +	uint8_t mac_addr[6];
> +	int ret;
> +
> +	ret = sunxi_get_sid(sid);
> +	if (ret == 0 && sid[0] != 0 && sid[3] != 0) {
> +		if (!getenv("ethaddr")) {
> +			/* Non OUI / registered MAC address */
> +			mac_addr[0] = 0x02;
> +			mac_addr[1] = (sid[0] >>  0) & 0xff;
> +			mac_addr[2] = (sid[3] >> 24) & 0xff;
> +			mac_addr[3] = (sid[3] >> 16) & 0xff;
> +			mac_addr[4] = (sid[3] >>  8) & 0xff;
> +			mac_addr[5] = (sid[3] >>  0) & 0xff;
> +
> +			eth_setenv_enetaddr("ethaddr", mac_addr);
> +		}
>
> -	if (!getenv("ethaddr") && sunxi_get_sid(sid) == 0 &&
> -			sid[0] != 0 && sid[3] != 0) {
> -		uint8_t mac_addr[6];
> -
> -		mac_addr[0] = 0x02; /* Non OUI / registered MAC address */
> -		mac_addr[1] = (sid[0] >>  0) & 0xff;
> -		mac_addr[2] = (sid[3] >> 24) & 0xff;
> -		mac_addr[3] = (sid[3] >> 16) & 0xff;
> -		mac_addr[4] = (sid[3] >>  8) & 0xff;
> -		mac_addr[5] = (sid[3] >>  0) & 0xff;
> +		if (!getenv("serial#")) {
> +			snprintf(serial_string, sizeof(serial_string),
> +				"%08x%08x", sid[0], sid[3]);
>
> -		eth_setenv_enetaddr("ethaddr", mac_addr);
> +			setenv("serial#", serial_string);
> +		}
>   	}
>
>   #if defined(CONFIG_MUSB_HOST) || defined(CONFIG_MUSB_GADGET)
>

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

* [U-Boot] [PATCH v4 2/2] sunxi: Pass serial number through ATAG
  2015-03-28 17:35 ` [U-Boot] [PATCH v4 2/2] sunxi: Pass serial number through ATAG Paul Kocialkowski
@ 2015-03-29 12:49   ` Hans de Goede
  0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2015-03-29 12:49 UTC (permalink / raw)
  To: u-boot

Hi,

On 28-03-15 18:35, Paul Kocialkowski wrote:
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

Thanks, I've added this to my personal git repo, sunxi-wip
branch. I'll move it over to u-boot-sunxi/next once it
is clear that the kernel patch to show the devicetree
serial-number string /proc/cpuinfo is going to be accepted.

Regards,

Hans



> ---
>   board/sunxi/board.c            | 20 ++++++++++++++++++++
>   include/configs/sunxi-common.h |  1 +
>   2 files changed, 21 insertions(+)
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 79516bf..d1b3c5e 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -369,6 +369,26 @@ int g_dnl_board_usb_cable_connected(void)
>   }
>   #endif
>
> +#ifdef CONFIG_SERIAL_TAG
> +void get_board_serial(struct tag_serialnr *serialnr)
> +{
> +	char *serial_string;
> +	unsigned long long serial;
> +
> +	serial_string = getenv("serial#");
> +
> +	if (serial_string) {
> +		serial = simple_strtoull(serial_string, NULL, 16);
> +
> +		serialnr->high = (unsigned int) (serial >> 32);
> +		serialnr->low = (unsigned int) (serial & 0xffffffff);
> +	} else {
> +		serialnr->high = 0;
> +		serialnr->low = 0;
> +	}
> +}
> +#endif
> +
>   #ifdef CONFIG_MISC_INIT_R
>   int misc_init_r(void)
>   {
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 1f7a1cb..b9bb971 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -98,6 +98,7 @@
>   #define CONFIG_SETUP_MEMORY_TAGS
>   #define CONFIG_CMDLINE_TAG
>   #define CONFIG_INITRD_TAG
> +#define CONFIG_SERIAL_TAG
>
>   /* mmc config */
>   #if !defined(CONFIG_UART0_PORT_F)
>

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

end of thread, other threads:[~2015-03-29 12:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-28 17:35 [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits Paul Kocialkowski
2015-03-28 17:35 ` [U-Boot] [PATCH v4 2/2] sunxi: Pass serial number through ATAG Paul Kocialkowski
2015-03-29 12:49   ` Hans de Goede
2015-03-29 12:47 ` [U-Boot] [PATCH v4 1/2] sunxi: Serial number support, obtained from SID bits Hans de Goede

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