summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Ghidoli <emanuele.ghidoli@toradex.com>2024-02-23 10:11:39 +0100
committerTom Rini <trini@konsulko.com>2024-03-01 09:10:44 -0500
commit118b17b84fc77890379a45d772d9ead38e016fc5 (patch)
treeee7269f9779ab9c26e74b0ac6e33726ec96357ad
parent28138dea7b3b3ab2175d76a5fbac2ba61967c967 (diff)
downloadu-boot-118b17b84fc77890379a45d772d9ead38e016fc5.tar.gz
u-boot-118b17b84fc77890379a45d772d9ead38e016fc5.tar.bz2
u-boot-118b17b84fc77890379a45d772d9ead38e016fc5.zip
toradex: common: Use SETTINGS_R event to read toradex config block
Use SETTINGS_R event to read toradex config block and checkboard() to print board info. Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> # Verdin iMX8M Plus Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> Reviewed-by: Fabio Estevam <festevam@gmail.com>
-rw-r--r--board/toradex/common/tdx-common.c92
1 files changed, 54 insertions, 38 deletions
diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
index cdf645b141..6084436b48 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -103,54 +103,69 @@ __weak int print_bootinfo(void)
int checkboard(void)
{
- unsigned char ethaddr[6];
-
- if (read_tdx_cfg_block()) {
- printf("MISSING TORADEX CONFIG BLOCK\n");
- get_mac_from_serial(tdx_serial, &tdx_eth_addr);
- } else {
- snprintf(tdx_serial_str, sizeof(tdx_serial_str),
- "%08u", tdx_serial);
- snprintf(tdx_board_rev_str, sizeof(tdx_board_rev_str),
- "V%1d.%1d%s",
- tdx_hw_tag.ver_major,
- tdx_hw_tag.ver_minor,
- get_board_assembly(tdx_hw_tag.ver_assembly));
-
- env_set("serial#", tdx_serial_str);
-
+ if (valid_cfgblock) {
printf("Model: Toradex %04d %s %s\n",
tdx_hw_tag.prodid,
toradex_modules[tdx_hw_tag.prodid].name,
tdx_board_rev_str);
printf("Serial#: %s\n", tdx_serial_str);
+ }
+
#ifdef CONFIG_TDX_CFG_BLOCK_EXTRA
- if (read_tdx_cfg_block_carrier()) {
- printf("MISSING TORADEX CARRIER CONFIG BLOCKS\n");
- try_migrate_tdx_cfg_block_carrier();
- } else {
- tdx_carrier_board_name =
- get_toradex_carrier_boards(tdx_car_hw_tag.prodid);
-
- snprintf(tdx_car_serial_str, sizeof(tdx_car_serial_str),
- "%08u", tdx_car_serial);
- snprintf(tdx_car_rev_str, sizeof(tdx_car_rev_str),
- "V%1d.%1d%s",
- tdx_car_hw_tag.ver_major,
- tdx_car_hw_tag.ver_minor,
- get_board_assembly(tdx_car_hw_tag.ver_assembly));
-
- env_set("carrier_serial#", tdx_car_serial_str);
- printf("Carrier: Toradex %s %s, Serial# %s\n",
- tdx_carrier_board_name,
- tdx_car_rev_str,
- tdx_car_serial_str);
- }
+ if (tdx_carrier_board_name)
+ printf("Carrier: Toradex %s %s, Serial# %s\n",
+ tdx_carrier_board_name,
+ tdx_car_rev_str,
+ tdx_car_serial_str);
#endif
- }
print_bootinfo();
+ return 0;
+}
+
+static int settings_r(void)
+{
+ unsigned char ethaddr[6];
+
+ if (read_tdx_cfg_block()) {
+ printf("MISSING TORADEX CONFIG BLOCK\n");
+ get_mac_from_serial(tdx_serial, &tdx_eth_addr);
+
+ /* Board can run even if config block is not present */
+ return 0;
+ }
+
+ snprintf(tdx_serial_str, sizeof(tdx_serial_str),
+ "%08u", tdx_serial);
+ snprintf(tdx_board_rev_str, sizeof(tdx_board_rev_str),
+ "V%1d.%1d%s",
+ tdx_hw_tag.ver_major,
+ tdx_hw_tag.ver_minor,
+ get_board_assembly(tdx_hw_tag.ver_assembly));
+
+ env_set("serial#", tdx_serial_str);
+
+#ifdef CONFIG_TDX_CFG_BLOCK_EXTRA
+ if (read_tdx_cfg_block_carrier()) {
+ printf("MISSING TORADEX CARRIER CONFIG BLOCKS\n");
+ try_migrate_tdx_cfg_block_carrier();
+ } else {
+ tdx_carrier_board_name =
+ get_toradex_carrier_boards(tdx_car_hw_tag.prodid);
+
+ snprintf(tdx_car_serial_str, sizeof(tdx_car_serial_str),
+ "%08u", tdx_car_serial);
+ snprintf(tdx_car_rev_str, sizeof(tdx_car_rev_str),
+ "V%1d.%1d%s",
+ tdx_car_hw_tag.ver_major,
+ tdx_car_hw_tag.ver_minor,
+ get_board_assembly(tdx_car_hw_tag.ver_assembly));
+
+ env_set("carrier_serial#", tdx_car_serial_str);
+ }
+#endif
+
/*
* Check if environment contains a valid MAC address,
* set the one from config block if not
@@ -171,6 +186,7 @@ int checkboard(void)
return 0;
}
+EVENT_SPY_SIMPLE(EVT_SETTINGS_R, settings_r);
#ifdef CONFIG_TDX_CFG_BLOCK_USB_GADGET_PID
int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)