diff options
author | Ye Li <ye.li@nxp.com> | 2017-09-11 04:27:13 -0500 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2017-09-12 20:59:38 -0500 |
commit | 4f699dbc3102814f47b9109bd5c52433573e3afe (patch) | |
tree | 45de5970948b345dfaff8f4a4eb0054daa585376 | |
parent | 1dd249381d5fdfb5fa4f2c10e6445ba0677001bb (diff) |
MLK-16441-2 imx8qm/qxp: print commit hash for SCFW, IMX-MKIMAGE and ATF
Since we have many software running on QM/QXP, it is better to print their
commit ids in u-boot to know their versions.
This patch enables the CONFIG_ARCH_MISC_INIT. In arch_misc_init to gets the
commit ids for SCFW and ATF via their APIs and get the commit for imx-mkimage
at the end of u-boot.bin loading address.
Once the commit ids are acquired, show them in console like:
BuildInfo: SCFW 45c567e8, IMX-MKIMAGE cc994971, ATF 0a9efa7
and set them to environment variables like:
commit_atf=0a9efa7
commit_mkimage=cc994971
commit_scfw=45c567e8
If old software are running which does not support provide commit it, the patch
use 0 instead.
Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r-- | arch/arm/cpu/armv8/imx8/cpu.c | 77 | ||||
-rw-r--r-- | include/configs/imx8qm_arm2.h | 1 | ||||
-rw-r--r-- | include/configs/imx8qxp_arm2.h | 1 | ||||
-rw-r--r-- | include/configs/imx8qxp_mek.h | 1 |
4 files changed, 80 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv8/imx8/cpu.c b/arch/arm/cpu/armv8/imx8/cpu.c index 4b32852f81..df165c663f 100644 --- a/arch/arm/cpu/armv8/imx8/cpu.c +++ b/arch/arm/cpu/armv8/imx8/cpu.c @@ -636,6 +636,83 @@ bool is_usb_boot(void) return get_boot_device() == USB_BOOT; } +#define FSL_SIP_BUILDINFO 0xC2000003 +#define FSL_SIP_BUILDINFO_GET_COMMITHASH 0x00 +extern uint32_t _end_ofs; + +static unsigned long call_imx_sip(unsigned long id, unsigned long reg0, unsigned long reg1, unsigned long reg2) +{ + struct pt_regs regs; + regs.regs[0] = id; + regs.regs[1] = reg0; + regs.regs[2] = reg1; + regs.regs[3] = reg2; + + smc_call(®s); + + return regs.regs[0]; +} + +static void set_buildinfo_to_env(uint32_t scfw, char *mkimage, char *atf) +{ + if (!mkimage || !atf) + return; + + setenv("commit_mkimage", mkimage); + setenv("commit_atf", atf); + setenv_hex("commit_scfw", (ulong)scfw); +} + +static void acquire_buildinfo(void) +{ + sc_ipc_t ipc; + uint32_t sc_build = 0, sc_commit = 0; + char *mkimage_commit, *temp; + uint64_t atf_commit = 0; + + ipc = gd->arch.ipc_channel_handle; + + /* Get SCFW build and commit id */ + sc_misc_build_info(ipc, &sc_build, &sc_commit); + if (sc_build == 0) { + debug("SCFW does not support build info\n"); + sc_commit = 0; /* Display 0 when the build info is not supported*/ + } + + /* Get imx-mkimage commit id. + * The imx-mkimage puts the commit hash behind the end of u-boot.bin + */ + mkimage_commit = (char *)(ulong)(CONFIG_SYS_TEXT_BASE + _end_ofs + fdt_totalsize(gd->fdt_blob)); + temp = mkimage_commit + 8; + *temp = '\0'; + + if (strlen(mkimage_commit) == 0) { + debug("IMX-MKIMAGE does not support build info\n"); + mkimage_commit = "0"; /* Display 0 */ + } + + /* Get ARM Trusted Firmware commit id */ + atf_commit = call_imx_sip(FSL_SIP_BUILDINFO, FSL_SIP_BUILDINFO_GET_COMMITHASH, 0, 0); + if (atf_commit == 0xffffffff) { + debug("ATF does not support build info\n"); + atf_commit = 0x30; /* Display 0, 0 ascii is 0x30 */ + } + + /* Set all to env */ + set_buildinfo_to_env(sc_commit, mkimage_commit, (char *)&atf_commit); + + printf("BuildInfo: SCFW %x, IMX-MKIMAGE %s, ATF %s\n", sc_commit, mkimage_commit, (char *)&atf_commit); +} + +#if defined(CONFIG_ARCH_MISC_INIT) +int arch_misc_init(void) +{ + acquire_buildinfo(); + + return 0; +} +#endif + int print_bootinfo(void) { enum boot_device bt_dev; diff --git a/include/configs/imx8qm_arm2.h b/include/configs/imx8qm_arm2.h index 98561226cd..4714311251 100644 --- a/include/configs/imx8qm_arm2.h +++ b/include/configs/imx8qm_arm2.h @@ -13,6 +13,7 @@ #define CONFIG_REMAKE_ELF #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_ARCH_MISC_INIT /* Flat Device Tree Definitions */ #define CONFIG_OF_BOARD_SETUP diff --git a/include/configs/imx8qxp_arm2.h b/include/configs/imx8qxp_arm2.h index 84c5796418..67988c8bcb 100644 --- a/include/configs/imx8qxp_arm2.h +++ b/include/configs/imx8qxp_arm2.h @@ -13,6 +13,7 @@ #define CONFIG_REMAKE_ELF #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_ARCH_MISC_INIT /* Flat Device Tree Definitions */ #define CONFIG_OF_BOARD_SETUP diff --git a/include/configs/imx8qxp_mek.h b/include/configs/imx8qxp_mek.h index f81096618f..c9bfce50e4 100644 --- a/include/configs/imx8qxp_mek.h +++ b/include/configs/imx8qxp_mek.h @@ -13,6 +13,7 @@ #define CONFIG_REMAKE_ELF #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_ARCH_MISC_INIT /* Flat Device Tree Definitions */ #define CONFIG_OF_BOARD_SETUP |