Chain of Trust is enabled for ARM platforms (LS1021 and LS1043).
In board_late_init(), fsl_setenv_chain_of_trust() is called which
will perform the following:
- If boot mode is non-secure, return (No Change)
- If boot mode is secure, set the following environmet variables:
   bootdelay = 0 (To disable Boot Prompt)
   bootcmd = CONFIG_CHAIN_BOOT_CMD (Validate and execute Boot script)
Signed-off-by: Aneesh Bansal <aneesh.bansal@nxp.com>
Acked-by: Ruchika Gupta <ruchika.gupta@nxp.com>
Reviewed-by: York Sun <york.sun@nxp.com>
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/arch-fsl-layerscape/config.h>
+#ifdef CONFIG_CHAIN_OF_TRUST
+#include <fsl_validate.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_SCSI_AHCI_PLAT
        sata_init();
 #endif
+#ifdef CONFIG_CHAIN_OF_TRUST
+       fsl_setenv_chain_of_trust();
+#endif
 
        return 0;
 }
 
 ifdef CONFIG_SECURE_BOOT
 obj-$(CONFIG_CMD_ESBC_VALIDATE) += fsl_validate.o cmd_esbc_validate.o
 endif
+obj-$(CONFIG_CHAIN_OF_TRUST) += fsl_chain_of_trust.o
 
 endif
 
 #endif
        return 0;
 }
+
+int fsl_setenv_chain_of_trust(void)
+{
+       /* Check Boot Mode
+        * If Boot Mode is Non-Secure, no changes are required
+        */
+       if (fsl_check_boot_mode_secure() == 0)
+               return 0;
+
+       /* If Boot mode is Secure, set the environment variables
+        * bootdelay = 0 (To disable Boot Prompt)
+        * bootcmd = CONFIG_CHAIN_BOOT_CMD (Validate and execute Boot script)
+        */
+       setenv("bootdelay", "0");
+       setenv("bootcmd", CONFIG_CHAIN_BOOT_CMD);
+       return 0;
+}
 
 #include <fsl_sec.h>
 #include <spl.h>
 #include <fsl_devdis.h>
+#include <fsl_validate.h>
 
 #include "../common/sleep.h"
 #include "../common/qixis.h"
 #ifdef CONFIG_SCSI_AHCI_PLAT
        ls1021a_sata_init();
 #endif
+#ifdef CONFIG_CHAIN_OF_TRUST
+       fsl_setenv_chain_of_trust();
+#endif
 
        return 0;
 }
 
 #ifdef CONFIG_U_QE
 #include "../../../drivers/qe/qe.h"
 #endif
+#include <fsl_validate.h>
 
 
 DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_SCSI_AHCI_PLAT
        ls1021a_sata_init();
 #endif
+#ifdef CONFIG_CHAIN_OF_TRUST
+       fsl_setenv_chain_of_trust();
+#endif
 
        return 0;
 }
 
 int fsl_secboot_blob_decap(cmd_tbl_t *cmdtp, int flag, int argc,
        char * const argv[]);
 
+int fsl_check_boot_mode_secure(void);
+int fsl_setenv_chain_of_trust(void);
 #endif