summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2018-06-05 03:30:37 -0700
committerYe Li <ye.li@nxp.com>2020-04-26 23:26:26 -0700
commite94fde4df06e0e8fb997235ffa4dc446c94ace33 (patch)
treeb21a661688806c22ad83b7fba9e09639bfe5e6ea /common
parent7abd2f7699ded924e2e50b3e4f4c6826ec888dbb (diff)
MLK-18591-6 android: iot: Add boot Trusty OS codes for i.MX SoCs
Use trusty_os_init to load Trusty OS from CONFIG_TRUSTY_OS_ENTRY before u-boot ready. Add Trusty OS SOC level codes and u-boot/SPL common codes. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Haoran.Wang <elven.wang@nxp.com> (cherry picked from commit 1ae9ecc73f5001b8bd743011c06a7d07861be64e) (cherry picked from commit 6fa4f4a42fd90631f8dc8303b17f600c085d8595)
Diffstat (limited to 'common')
-rw-r--r--common/board_r.c12
-rw-r--r--common/spl/spl_fit.c24
-rw-r--r--common/spl/spl_mmc.c25
3 files changed, 59 insertions, 2 deletions
diff --git a/common/board_r.c b/common/board_r.c
index ed4dc4edb0..96eb12c20e 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -680,6 +680,15 @@ static int initr_check_fastboot(void)
}
#endif
+#ifdef CONFIG_IMX_TRUSTY_OS
+extern void tee_setup(void);
+static int initr_tee_setup(void)
+{
+ tee_setup();
+ return 0;
+}
+#endif
+
static int run_main_loop(void)
{
#ifdef CONFIG_SANDBOX
@@ -899,6 +908,9 @@ static init_fnc_t init_sequence_r[] = {
#if defined(AVB_RPMB) && !defined(CONFIG_SPL)
initr_avbkey,
#endif
+#ifdef CONFIG_IMX_TRUSTY_OS
+ initr_tee_setup,
+#endif
#ifdef CONFIG_FSL_FASTBOOT
initr_check_fastboot,
#endif
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 69dabd27f6..96136e7795 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -217,6 +217,15 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
return (data_size + info->bl_len - 1) / info->bl_len;
}
+#if defined(CONFIG_DUAL_BOOTLOADER) && defined(CONFIG_IMX_TRUSTY_OS)
+__weak int get_tee_load(ulong *load)
+{
+ /* default return ok */
+ return 0;
+}
+
+#endif
+
/**
* spl_load_fit_image(): load the image described in a certain FIT node
* @info: points to information about the device to load data from
@@ -267,6 +276,21 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
if (fit_image_get_load(fit, node, &load_addr))
load_addr = image_info->load_addr;
+#if defined(CONFIG_DUAL_BOOTLOADER) && defined(CONFIG_IMX_TRUSTY_OS)
+ char *desc = NULL;
+
+ if (fit_get_desc(fit, node, &desc)) {
+ printf("can't found node description!\n");
+ return -ENOENT;
+ } else if (!strncmp(desc, "TEE firmware",
+ strlen("TEE firmware"))) {
+ if (get_tee_load(&load_addr)) {
+ printf("Failed to get TEE load address!\n");
+ return -ENOENT;
+ }
+ }
+#endif
+
if (!fit_image_get_data_position(fit, node, &offset)) {
external_data = true;
} else if (!fit_image_get_data_offset(fit, node, &offset)) {
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index a2ea363e96..af9f6f96ff 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -59,6 +59,11 @@ static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part)
return 0;
}
+#if defined(CONFIG_IMX_TRUSTY_OS)
+/* Pre-declaration of check_rpmb_blob. */
+int check_rpmb_blob(struct mmc *mmc);
+#endif
+
static __maybe_unused
int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
struct mmc *mmc, unsigned long sector)
@@ -111,7 +116,23 @@ end:
return -1;
}
- return 0;
+ /* Images loaded, now check the rpmb keyblob for Trusty OS.
+ * Skip this step when the dual bootloader feature is enabled
+ * since the blob should be checked earlier.
+ */
+#if defined(CONFIG_IMX_TRUSTY_OS)
+ if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
+#if !defined(CONFIG_DUAL_BOOTLOADER)
+ ret = check_rpmb_blob(mmc);
+#endif
+ } else {
+#if !defined(CONFIG_AVB_ATX)
+ ret = check_rpmb_blob(mmc);
+#endif
+ }
+#endif
+
+ return ret;
}
static int spl_mmc_get_device_index(u32 boot_device)
@@ -178,7 +199,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
err = part_get_info(mmc_get_blk_desc(mmc), type_part, &info);
if (err)
continue;
- if (info.sys_ind ==
+ if (info.sys_ind ==
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE) {
partition = type_part;
break;