aboutsummaryrefslogtreecommitdiff
path: root/plat/imx/common
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2019-01-18 10:43:59 +0800
committerAnson Huang <Anson.Huang@nxp.com>2019-01-18 11:23:04 +0800
commit760f794105b6923339949e58604323766870ac6c (patch)
tree80764e02f2e4062bdeef24a7301fc24b7b5afdc2 /plat/imx/common
parent869eebc39d193911da43a6a872a41568dd82890d (diff)
downloadtrusted-firmware-a-760f794105b6923339949e58604323766870ac6c.tar.gz
imx: add i.MX8 SoCs build info SIP(silicon provider) service support
This patch adds NXP i.MX8 SoCs' build info SIP support for easy debug. With this function enabled, TF-A's commit hash can be showed in u-boot debug console when booting up, when there is any issue which could be related to TF-A, users can use the commit hash value to easily identify which commit introduces the issue. Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'plat/imx/common')
-rw-r--r--plat/imx/common/imx_sip_handler.c44
-rw-r--r--plat/imx/common/imx_sip_svc.c2
-rw-r--r--plat/imx/common/include/imx_sip_svc.h6
3 files changed, 52 insertions, 0 deletions
diff --git a/plat/imx/common/imx_sip_handler.c b/plat/imx/common/imx_sip_handler.c
index 469e295325..55639cdf0e 100644
--- a/plat/imx/common/imx_sip_handler.c
+++ b/plat/imx/common/imx_sip_handler.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <std_svc.h>
+#include <string.h>
#include <platform_def.h>
#include <common/debug.h>
#include <common/runtime_svc.h>
@@ -137,3 +138,46 @@ int imx_misc_set_temp_handler(uint32_t smc_fid,
{
return sc_misc_set_temp(ipc_handle, x1, x2, x3, x4);
}
+
+static uint64_t imx_get_commit_hash(u_register_t x2,
+ u_register_t x3,
+ u_register_t x4)
+{
+ /* Parse the version_string */
+ char *parse = (char *)version_string;
+ uint64_t hash = 0;
+
+ do {
+ parse = strchr(parse, '-');
+ if (parse) {
+ parse += 1;
+ if (*(parse) == 'g') {
+ /* Default is 7 hexadecimal digits */
+ memcpy((void *)&hash, (void *)(parse + 1), 7);
+ break;
+ }
+ }
+
+ } while (parse != NULL);
+
+ return hash;
+}
+
+uint64_t imx_buildinfo_handler(uint32_t smc_fid,
+ u_register_t x1,
+ u_register_t x2,
+ u_register_t x3,
+ u_register_t x4)
+{
+ uint64_t ret;
+
+ switch (x1) {
+ case IMX_SIP_BUILDINFO_GET_COMMITHASH:
+ ret = imx_get_commit_hash(x2, x3, x4);
+ break;
+ default:
+ return SMC_UNK;
+ }
+
+ return ret;
+}
diff --git a/plat/imx/common/imx_sip_svc.c b/plat/imx/common/imx_sip_svc.c
index d66c24e095..c27fbf2e37 100644
--- a/plat/imx/common/imx_sip_svc.c
+++ b/plat/imx/common/imx_sip_svc.c
@@ -40,6 +40,8 @@ static uintptr_t imx_sip_handler(unsigned int smc_fid,
case IMX_SIP_MISC_SET_TEMP:
SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
#endif
+ case IMX_SIP_BUILDINFO:
+ SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
default:
WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK);
diff --git a/plat/imx/common/include/imx_sip_svc.h b/plat/imx/common/include/imx_sip_svc.h
index c259d23ca6..648be3773c 100644
--- a/plat/imx/common/include/imx_sip_svc.h
+++ b/plat/imx/common/include/imx_sip_svc.h
@@ -14,6 +14,9 @@
#define IMX_SIP_SRTC 0xC2000002
#define IMX_SIP_SRTC_SET_TIME 0x00
+#define IMX_SIP_BUILDINFO 0xC2000003
+#define IMX_SIP_BUILDINFO_GET_COMMITHASH 0x00
+
#define IMX_SIP_WAKEUP_SRC 0xC2000009
#define IMX_SIP_WAKEUP_SRC_SCU 0x1
#define IMX_SIP_WAKEUP_SRC_IRQSTEER 0x2
@@ -35,6 +38,9 @@ int imx_otp_handler(uint32_t smc_fid, void *handle,
int imx_misc_set_temp_handler(uint32_t smc_fid, u_register_t x1,
u_register_t x2, u_register_t x3,
u_register_t x4);
+uint64_t imx_buildinfo_handler(uint32_t smc_fid, u_register_t x1,
+ u_register_t x2, u_register_t x3,
+ u_register_t x4);
#endif
#endif /* __IMX_SIP_SVC_H__ */