toradex: tdx-cfg-block: rework modules pid4 handling
The module pid4 currently corresponds to the index of the toradex_module
array. If a new pid4 is introduced that does not follow the sequence of
the previous entries, it will create a gap in the array.
To address this, embed pid4 within the toradex_som structure and
implement a function to retrieve the index corresponding to pid4.
Signed-off-by: Vitor Soares <vitor.soares@toradex.com>
Acked-by: Francesco Dolcini <francesco.dolcini@toradex.com>
diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
index 3badeeb..f01fb36 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -191,13 +191,16 @@
static int tdx_get_str(struct udevice *dev, int id, size_t size, char *val)
{
int ret = -ENOTSUPP;
+ int idx;
switch (id) {
case SYSID_BOARD_MODEL:
+ idx = get_toradex_modules_idx(tdx_hw_tag.prodid);
+
snprintf(val, size,
"Toradex %04d %s %s",
tdx_hw_tag.prodid,
- toradex_modules[tdx_hw_tag.prodid].name,
+ toradex_modules[idx].name,
tdx_board_rev_str);
ret = 0;