summaryrefslogtreecommitdiff
path: root/board/toradex/common/tdx-cfg-block.c
diff options
context:
space:
mode:
authorPhilippe Schenker <philippe.schenker@toradex.com>2022-06-03 16:09:14 +0200
committerPhilippe Schenker <philippe.schenker@toradex.com>2022-06-14 10:51:24 +0200
commit32957d21729fe2dc7ab12a42d751d1aa34c80618 (patch)
tree362427cae4e76bb87768444b604c11438713d97c /board/toradex/common/tdx-cfg-block.c
parent7eccd74f8ba64849398c6a994a2e6a099f926750 (diff)
toradex: tdx-cfg-block: extend assembly version
i[ backport https://lists.denx.de/pipermail/u-boot/2022-June/486350.html ] There are two decimal digits reserved to encode the module version and revision. This code so far implemented A-Z which used 0-25 of this range. This commit extends the range to make use of all 99 numbers. After capital letters the form with a hashtag and number (e.g. #26) is used. Examples: If the assembly version is between zero and 25 the numbering is as follows, as it also has been before this commit: 0: V0.0A 1: V0.0B ... 25: V0.0Z New numbering of assembly version: If the number is between 26 and 99 the new assembly version name is: 26: V0.0#26 27: V0.0#27 ... 99: V0.0#99 Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com> [ps: backport: replace dectoul() with simple_strtoul()]
Diffstat (limited to 'board/toradex/common/tdx-cfg-block.c')
-rw-r--r--board/toradex/common/tdx-cfg-block.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index b210019106..a74707208d 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -358,6 +358,18 @@ out:
return ret;
}
+static int parse_assembly_string(char *string_to_parse, u16 *assembly)
+{
+ if (string_to_parse[3] >= 'A' && string_to_parse[3] <= 'Z')
+ *assembly = string_to_parse[3] - 'A';
+ else if (string_to_parse[3] == '#')
+ *assembly = simple_strtoul(&string_to_parse[4], NULL, 10);
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
static int get_cfgblock_interactive(void)
{
char message[CONFIG_SYS_CBSIZE];
@@ -365,6 +377,7 @@ static int get_cfgblock_interactive(void)
char it = 'n';
char wb = 'n';
int len = 0;
+ int ret = 0;
/* Unknown module by default */
tdx_hw_tag.prodid = 0;
@@ -541,13 +554,18 @@ static int get_cfgblock_interactive(void)
}
while (len < 4) {
- sprintf(message, "Enter the module version (e.g. V1.1B): V");
+ sprintf(message, "Enter the module version (e.g. V1.1B or V1.1#26): V");
len = cli_readline(message);
}
tdx_hw_tag.ver_major = console_buffer[0] - '0';
tdx_hw_tag.ver_minor = console_buffer[2] - '0';
- tdx_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+ ret = parse_assembly_string(console_buffer, &tdx_hw_tag.ver_assembly);
+ if (ret) {
+ printf("Parsing module version failed\n");
+ return ret;
+ }
if (cpu_is_pxa27x() && tdx_hw_tag.ver_major == 1)
tdx_hw_tag.prodid -= (COLIBRI_PXA270_312MHZ -
@@ -754,6 +772,7 @@ static int get_cfgblock_carrier_interactive(void)
{
char message[CONFIG_SYS_CBSIZE];
int len;
+ int ret = 0;
printf("Supported carrier boards:\n");
printf("CARRIER BOARD NAME\t\t [ID]\n");
@@ -767,13 +786,18 @@ static int get_cfgblock_carrier_interactive(void)
tdx_car_hw_tag.prodid = simple_strtoul(console_buffer, NULL, 10);
do {
- sprintf(message, "Enter carrier board version (e.g. V1.1B): V");
+ sprintf(message, "Enter carrier board version (e.g. V1.1B or V1.1#26): V");
len = cli_readline(message);
} while (len < 4);
tdx_car_hw_tag.ver_major = console_buffer[0] - '0';
tdx_car_hw_tag.ver_minor = console_buffer[2] - '0';
- tdx_car_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+ ret = parse_assembly_string(console_buffer, &tdx_car_hw_tag.ver_assembly);
+ if (ret) {
+ printf("Parsing module version failed\n");
+ return ret;
+ }
while (len < 8) {
sprintf(message, "Enter carrier board serial number: ");