summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2015-03-28 18:35:35 +0100
committerHans de Goede <hdegoede@redhat.com>2015-04-15 16:17:18 +0200
commit8c8165739baebbcd5fbf3db9030a3f180e4ef580 (patch)
treeca86b9e2658b7c069069e07f153189d01a078850
parent9816d52d8ebca543bd0a42e1e9d009765c2ab476 (diff)
downloadu-boot-8c8165739baebbcd5fbf3db9030a3f180e4ef580.tar.gz
u-boot-8c8165739baebbcd5fbf3db9030a3f180e4ef580.tar.xz
u-boot-8c8165739baebbcd5fbf3db9030a3f180e4ef580.zip
sunxi: Serial number support, obtained from SID bits
Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--board/sunxi/board.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 0c9d3b8029..7633d65e6c 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)