]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
toradex: common: unify behaviour when config block is missing
authorBhuvanchandra DV <bhuvanchandra.dv@toradex.com>
Mon, 25 Mar 2019 16:18:28 +0000 (17:18 +0100)
committerStefano Babic <sbabic@denx.de>
Sat, 13 Apr 2019 18:30:10 +0000 (20:30 +0200)
If the config block is missing, various things may fail or behave
strangely on certain modules. This patch unifies that behaviour by
using a fake MAC address, until user updates the config block.

Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>
board/toradex/common/tdx-common.c

index fde230c955a4cd960e2119f57d46dd11f42a0f3e..2d560cceaf53fccb6067bec719b50288853bc020 100644 (file)
@@ -12,6 +12,8 @@
 #include <asm/setup.h>
 #include "tdx-common.h"
 
+#define TORADEX_OUI 0x00142dUL
+
 #ifdef CONFIG_TDX_CFG_BLOCK
 static char tdx_serial_str[9];
 static char tdx_board_rev_str[6];
@@ -68,20 +70,25 @@ int show_board_info(void)
        unsigned char ethaddr[6];
 
        if (read_tdx_cfg_block()) {
-               printf("Missing Toradex config block\n");
+               printf("MISSING TORADEX CONFIG BLOCK\n");
+               tdx_eth_addr.oui = htonl(TORADEX_OUI << 8);
+               tdx_eth_addr.nic = htonl(tdx_serial << 8);
                checkboard();
-               return 0;
+       } else {
+               sprintf(tdx_serial_str, "%08u", tdx_serial);
+               sprintf(tdx_board_rev_str, "V%1d.%1d%c",
+                       tdx_hw_tag.ver_major,
+                       tdx_hw_tag.ver_minor,
+                       (char)tdx_hw_tag.ver_assembly + 'A');
+
+               env_set("serial#", tdx_serial_str);
+
+               printf("Model: Toradex %s %s, Serial# %s\n",
+                      toradex_modules[tdx_hw_tag.prodid],
+                      tdx_board_rev_str,
+                      tdx_serial_str);
        }
 
-       /* board serial-number */
-       sprintf(tdx_serial_str, "%08u", tdx_serial);
-       sprintf(tdx_board_rev_str, "V%1d.%1d%c",
-               tdx_hw_tag.ver_major,
-               tdx_hw_tag.ver_minor,
-               (char)tdx_hw_tag.ver_assembly + 'A');
-
-       env_set("serial#", tdx_serial_str);
-
        /*
         * Check if environment contains a valid MAC address,
         * set the one from config block if not
@@ -101,11 +108,6 @@ int show_board_info(void)
        }
 #endif
 
-       printf("Model: Toradex %s %s, Serial# %s\n",
-              toradex_modules[tdx_hw_tag.prodid],
-              tdx_board_rev_str,
-              tdx_serial_str);
-
        return 0;
 }