summaryrefslogtreecommitdiff
path: root/board/toradex/common/tdx-cfg-block.c
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2023-07-17 12:53:11 +0200
committerAndrejs Cainikovs <andrejs.cainikovs@toradex.com>2023-07-18 13:58:37 +0200
commit7297241f395a1c43e974c00a01e029240af789e1 (patch)
tree9a07304ec1d413d54dc6f4b5ae9d7587bce72a21 /board/toradex/common/tdx-cfg-block.c
parent2eb7e98e8265e0eec3bccfe68eef4dcfe876d15d (diff)
toradex: tdx-cfg-block: rework carrier board name handling
Rework the rather big array of zero length strings with 4 entries of actual carrier board names to a array of structs which ties a pid4 to its correspondent human readable string. Provide an accessor to get the string for a given PID4. Rework the user of the information to use the accessor. Note that check_pid8_sanity() is used for early samples of Dahlia and the development board. Yavia isn't affected. Upstream-Status: Submitted [https://lore.kernel.org/all/20230718090734.20357-3-andrejs.cainikovs@toradex.com/] Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
Diffstat (limited to 'board/toradex/common/tdx-cfg-block.c')
-rw-r--r--board/toradex/common/tdx-cfg-block.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index e792e05f3e..8067ebc1a0 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -145,11 +145,17 @@ const struct toradex_som toradex_modules[] = {
[76] = { "Verdin AM62 Quad 2GB WB IT", TARGET_IS_ENABLED(VERDIN_AM62_A53) },
};
-const char * const toradex_carrier_boards[] = {
- [0] = "UNKNOWN CARRIER BOARD",
- [155] = "Dahlia",
- [156] = "Verdin Development Board",
- [173] = "Yavia",
+struct pid4list {
+ int pid4;
+ char * const name;
+};
+
+const struct pid4list toradex_carrier_boards[] = {
+ /* the code assumes unknown at index 0 */
+ {0, "UNKNOWN CARRIER BOARD"},
+ {DAHLIA, "Dahlia"},
+ {VERDIN_DEVELOPMENT_BOARD, "Verdin Development Board"},
+ {YAVIA, "Yavia"},
};
const char * const toradex_display_adapters[] = {
@@ -163,6 +169,19 @@ const u32 toradex_ouis[] = {
[1] = 0x8c06cbUL,
};
+const char * const get_toradex_carrier_boards(int pid4)
+{
+ int i, index = 0;
+
+ for (i = 1; i < ARRAY_SIZE(toradex_carrier_boards); i++) {
+ if (pid4 == toradex_carrier_boards[i].pid4) {
+ index = i;
+ break;
+ }
+ }
+ return toradex_carrier_boards[index].name;
+}
+
static u32 get_serial_from_mac(struct toradex_eth_addr *eth_addr)
{
int i;
@@ -642,10 +661,11 @@ static int get_cfgblock_carrier_interactive(void)
int ret = 0;
printf("Supported carrier boards:\n");
- printf("CARRIER BOARD NAME\t\t [ID]\n");
+ printf("%30s\t[ID]\n", "CARRIER BOARD NAME");
for (int i = 0; i < ARRAY_SIZE(toradex_carrier_boards); i++)
- if (toradex_carrier_boards[i])
- printf("%s \t\t [%d]\n", toradex_carrier_boards[i], i);
+ printf("%30s\t[%d]\n",
+ toradex_carrier_boards[i].name,
+ toradex_carrier_boards[i].pid4);
sprintf(message, "Choose your carrier board (provide ID): ");
len = cli_readline(message);