[PATCH] arch: snapdragon: Improve serial number detection using SMEM interface
Balaji Selvanathan
balaji.selvanathan at oss.qualcomm.com
Wed Apr 22 06:11:18 CEST 2026
Enhance serial number detection by prioritizing SMEM-based retrieval
over bootargs parsing for better reliability and consistency across
Qualcomm Snapdragon platforms.
Add board_serial_num() function to retrieve serial number directly
from SMEM using the socinfo interface. This provides access to the
hardware-stored serial number in shared memory, eliminating the
dependency on kernel command line parsing.
This patch depends on the following patch [1], which adds the
socinfo header file.
[1] https://lore.kernel.org/all/20260106122134.2047864-3-aswin.murugan@oss.qualcomm.com/
Signed-off-by: Balaji Selvanathan <balaji.selvanathan at oss.qualcomm.com>
---
arch/arm/mach-snapdragon/board.c | 31 +++++++++++++++++++++++++++++++
arch/arm/mach-snapdragon/qcom-priv.h | 2 ++
2 files changed, 33 insertions(+)
diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index 5fb3240acc5..2f058038b25 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -32,6 +32,8 @@
#include <usb.h>
#include <sort.h>
#include <time.h>
+#include <smem.h>
+#include <soc/qcom/socinfo.h>
#include "qcom-priv.h"
@@ -363,10 +365,39 @@ static const char *get_cmdline(void)
return cmdline;
}
+/**
+ * board_serial_num() - Retrieves the board serial number from SMEM
+ * @serial_num_ptr: Pointer to store the serial number
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+int board_serial_num(u32 *serial_num_ptr)
+{
+ struct socinfo *soc_info_ptr;
+ struct udevice *dev_ptr;
+ size_t total_size;
+
+ if (uclass_get_device(UCLASS_SMEM, 0, &dev_ptr) != 0)
+ return -ENODEV;
+
+ soc_info_ptr = smem_get(dev_ptr, 0, SMEM_HW_SW_BUILD_ID, &total_size);
+ if (!soc_info_ptr)
+ return -ENODATA;
+
+ *serial_num_ptr = soc_info_ptr->serial_num;
+ return 0;
+}
+
void qcom_set_serialno(void)
{
const char *cmdline = get_cmdline();
char serial[32];
+ u32 serial_num;
+
+ if (board_serial_num(&serial_num) == 0) {
+ env_set_hex("serial#", serial_num);
+ return;
+ }
if (!cmdline) {
log_debug("Failed to get bootargs\n");
diff --git a/arch/arm/mach-snapdragon/qcom-priv.h b/arch/arm/mach-snapdragon/qcom-priv.h
index b8bf574e8bb..3da841b8cda 100644
--- a/arch/arm/mach-snapdragon/qcom-priv.h
+++ b/arch/arm/mach-snapdragon/qcom-priv.h
@@ -17,6 +17,8 @@ enum qcom_boot_source {
extern enum qcom_boot_source qcom_boot_source;
+int board_serial_num(u32 *serial_num_ptr);
+
#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
void qcom_configure_capsule_updates(void);
#else
---
base-commit: 052988aa29bfd506d7ce207fbb3f5374a5dbecbb
change-id: 20260422-serial-93231b32b7b1
Best regards,
--
Balaji Selvanathan <balaji.selvanathan at oss.qualcomm.com>
More information about the U-Boot
mailing list