[PATCH V3 3/3] board: dhelectronics: Sync env variable dh_som_serial_number with SN
Christoph Niedermaier
cniedermaier at dh-electronics.com
Thu Nov 21 18:21:54 CET 2024
The env variable "SN" is used to store the serial number on DH electronics
SoMs. New SoMs will use the variable "dh_som_serial_number". To ensure
compatibility, these env variables are synchronized. This is achieved
using callback functions. To avoid recursive calls, these are locked
against each other.
Signed-off-by: Christoph Niedermaier <cniedermaier at dh-electronics.com>
---
Cc: "NXP i.MX U-Boot Team" <uboot-imx at nxp.com>
Cc: Marek Vasut <marex at denx.de>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Stefano Babic <sbabic at denx.de>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at dh-electronics.com
---
V3: - Add this patch to the series
---
board/dhelectronics/common/dh_common.c | 26 ++++++++++++++++++++++++++
configs/imx8mp_dhsom.config | 1 +
2 files changed, 27 insertions(+)
diff --git a/board/dhelectronics/common/dh_common.c b/board/dhelectronics/common/dh_common.c
index a7b0472a09..2e3e5c483b 100644
--- a/board/dhelectronics/common/dh_common.c
+++ b/board/dhelectronics/common/dh_common.c
@@ -45,6 +45,32 @@ struct eeprom_id_page {
#define DH_EEPROM_ID_PAGE_V1_0_DATA_LEN (sizeof(struct eeprom_id_page) - \
offsetof(struct eeprom_id_page, mac0))
+static bool in_dh_som_serial_number;
+static bool in_SN;
+
+static int on_dh_som_serial_number(const char *name, const char *value, enum env_op op,
+ int flags)
+{
+ in_dh_som_serial_number = true;
+ if (!in_SN)
+ env_set("SN", value);
+ in_dh_som_serial_number = false;
+ return 0;
+}
+
+U_BOOT_ENV_CALLBACK(dh_som_serial_number, on_dh_som_serial_number);
+
+static int on_SN(const char *name, const char *value, enum env_op op, int flags)
+{
+ in_SN = true;
+ if (!in_dh_som_serial_number)
+ env_set("dh_som_serial_number", value);
+ in_SN = false;
+ return 0;
+}
+
+U_BOOT_ENV_CALLBACK(SN, on_SN);
+
bool dh_mac_is_in_env(const char *env)
{
unsigned char enetaddr[6];
diff --git a/configs/imx8mp_dhsom.config b/configs/imx8mp_dhsom.config
index 416143178c..87bf3bf65e 100644
--- a/configs/imx8mp_dhsom.config
+++ b/configs/imx8mp_dhsom.config
@@ -59,6 +59,7 @@ CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=20
CONFIG_SYS_EEPROM_SIZE=16384
CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2
+CONFIG_ENV_CALLBACK_LIST_STATIC="dh_som_serial_number:dh_som_serial_number,SN:SN,"
CONFIG_ENV_OFFSET=0xFE0000
CONFIG_ENV_OFFSET_REDUND=0xFF0000
CONFIG_ENV_SECT_SIZE=0x1000
--
2.30.2
More information about the U-Boot
mailing list