Commit 760f7941 authored by Anson Huang's avatar Anson Huang
Browse files

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: default avatarAnson Huang <Anson.Huang@nxp.com>
parent 869eebc3
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <std_svc.h> #include <std_svc.h>
#include <string.h>
#include <platform_def.h> #include <platform_def.h>
#include <common/debug.h> #include <common/debug.h>
#include <common/runtime_svc.h> #include <common/runtime_svc.h>
...@@ -137,3 +138,46 @@ int imx_misc_set_temp_handler(uint32_t smc_fid, ...@@ -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); 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;
}
...@@ -40,6 +40,8 @@ static uintptr_t imx_sip_handler(unsigned int smc_fid, ...@@ -40,6 +40,8 @@ static uintptr_t imx_sip_handler(unsigned int smc_fid,
case IMX_SIP_MISC_SET_TEMP: case IMX_SIP_MISC_SET_TEMP:
SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4)); SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
#endif #endif
case IMX_SIP_BUILDINFO:
SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
default: default:
WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid); WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK); SMC_RET1(handle, SMC_UNK);
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
#define IMX_SIP_SRTC 0xC2000002 #define IMX_SIP_SRTC 0xC2000002
#define IMX_SIP_SRTC_SET_TIME 0x00 #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 0xC2000009
#define IMX_SIP_WAKEUP_SRC_SCU 0x1 #define IMX_SIP_WAKEUP_SRC_SCU 0x1
#define IMX_SIP_WAKEUP_SRC_IRQSTEER 0x2 #define IMX_SIP_WAKEUP_SRC_IRQSTEER 0x2
...@@ -35,6 +38,9 @@ int imx_otp_handler(uint32_t smc_fid, void *handle, ...@@ -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, 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 x2, u_register_t x3,
u_register_t x4); 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
#endif /* __IMX_SIP_SVC_H__ */ #endif /* __IMX_SIP_SVC_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment