]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm: mediatek: add SIP platform bininfo lookups
authorDavid Lechner <dlechner@baylibre.com>
Mon, 30 Mar 2026 20:23:18 +0000 (15:23 -0500)
committerDavid Lechner <dlechner@baylibre.com>
Tue, 7 Apr 2026 18:14:29 +0000 (13:14 -0500)
Add a couple of functions to look up the segment and part name using SIP
calls. These will be used to print more accurate CPU information in
print_cpuinfo().

Reviewed-by: Macpaul Lin <macpaul.lin@mediatek.com>
Link: https://patch.msgid.link/20260330-mtk-mt8189-cpu-type-v1-1-4059c3b52761@baylibre.com
Signed-off-by: David Lechner <dlechner@baylibre.com>
arch/arm/mach-mediatek/cpu.c
arch/arm/mach-mediatek/cpu.h [new file with mode: 0644]

index 8e8bc4f9ceaa336bf1acf5ce4eed19ea02896701..56a41e42df68746eb24df0c0e202c84086605173 100644 (file)
@@ -8,6 +8,11 @@
 #include <init.h>
 #include <wdt.h>
 #include <dm/uclass-internal.h>
+#include <linux/arm-smccc.h>
+#include <linux/types.h>
+
+#define MTK_SIP_PLAT_BINFO ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_64, \
+                                             ARM_SMCCC_OWNER_SIP, 0x529)
 
 int arch_cpu_init(void)
 {
@@ -21,3 +26,53 @@ void enable_caches(void)
        /* Enable D-cache. I-cache is already enabled in start.S */
        dcache_enable();
 }
+
+/**
+ * mediatek_sip_part_name - get the part name
+ *
+ * Retrieve the part name of platform description.
+ *
+ * This only applicable to SoCs that support SIP plat binfo SMC call.
+ *
+ * Returns: the part name or 0 if error or no part name
+ */
+u32 mediatek_sip_part_name(void)
+{
+       if (CONFIG_IS_ENABLED(TARGET_MT8188) || CONFIG_IS_ENABLED(TARGET_MT8189) ||
+           CONFIG_IS_ENABLED(TARGET_MT8195) || CONFIG_IS_ENABLED(TARGET_MT8365)) {
+               struct arm_smccc_res res __maybe_unused;
+
+               arm_smccc_smc(MTK_SIP_PLAT_BINFO, 0, 0, 0, 0, 0, 0, 0, &res);
+               if (res.a0)
+                       return 0;
+
+               return res.a1;
+       }
+
+       return 0;
+}
+
+/**
+ * mediatek_sip_segment_name - get the segment name
+ *
+ * Retrieve the segment name of platform description.
+ *
+ * This only applicable to SoCs that support SIP plat binfo SMC call.
+ *
+ * Returns: the segment name or 0 if error or no segment name
+ */
+u32 mediatek_sip_segment_name(void)
+{
+       if (CONFIG_IS_ENABLED(TARGET_MT8188) || CONFIG_IS_ENABLED(TARGET_MT8189) ||
+           CONFIG_IS_ENABLED(TARGET_MT8195) || CONFIG_IS_ENABLED(TARGET_MT8365)) {
+               struct arm_smccc_res res __maybe_unused;
+
+               arm_smccc_smc(MTK_SIP_PLAT_BINFO, 1, 0, 0, 0, 0, 0, 0, &res);
+               if (res.a0)
+                       return 0;
+
+               return res.a1;
+       }
+
+       return 0;
+}
diff --git a/arch/arm/mach-mediatek/cpu.h b/arch/arm/mach-mediatek/cpu.h
new file mode 100644 (file)
index 0000000..768284e
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2026 MediaTek Inc.
+ */
+
+#ifndef _MACH_MEDIATEK_CPU_H_
+#define _MACH_MEDIATEK_CPU_H_
+
+#include <linux/types.h>
+
+u32 mediatek_sip_segment_name(void);
+u32 mediatek_sip_part_name(void);
+
+#endif /* _MACH_MEDIATEK_CPU_H_ */