blob: 380c906ba834055ee8a51cca1a9804fb57905cd1 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
gaurav rana98cb0ef2015-03-10 14:08:50 +05302/*
3 * Copyright 2015 Freescale Semiconductor, Inc.
gaurav rana98cb0ef2015-03-10 14:08:50 +05304 */
5
Aneesh Bansalbdc22072016-01-22 16:37:24 +05306#ifndef __CONFIG_FSL_CHAIN_TRUST_H
7#define __CONFIG_FSL_CHAIN_TRUST_H
gaurav rana98cb0ef2015-03-10 14:08:50 +05308
Simon Glass1af3c7f2020-05-10 11:40:09 -06009#include <linux/stringify.h>
10
Aneesh Bansalbdc22072016-01-22 16:37:24 +053011#ifdef CONFIG_CHAIN_OF_TRUST
12
gaurav rana98cb0ef2015-03-10 14:08:50 +053013/*
14 * Control should not reach back to uboot after validation of images
15 * for secure boot flow and therefore bootscript should have
16 * the bootm command. If control reaches back to uboot anyhow
17 * after validating images, core should just spin.
18 */
19
Sam Protsenko5abc1a42017-08-14 20:22:17 +030020#ifdef CONFIG_USE_BOOTARGS
Tom Rinif4cd75e2022-06-17 16:24:34 -040021#define SET_BOOTARGS "setenv bootargs \'" CONFIG_BOOTARGS" \';"
Saksham Jain2bfe4892016-03-23 16:24:43 +053022#else
Tom Rinif4cd75e2022-06-17 16:24:34 -040023#define SET_BOOTARGS "setenv bootargs \'root=/dev/ram " \
Saksham Jain2bfe4892016-03-23 16:24:43 +053024 "rw console=ttyS0,115200 ramdisk_size=600000\';"
25#endif
26
Tom Rinif4cd75e2022-06-17 16:24:34 -040027#define SECBOOT \
gaurav rana98cb0ef2015-03-10 14:08:50 +053028 "setenv bs_hdraddr " __stringify(CONFIG_BOOTSCRIPT_HDR_ADDR)";" \
Tom Rinif4cd75e2022-06-17 16:24:34 -040029 SET_BOOTARGS \
gaurav rana98cb0ef2015-03-10 14:08:50 +053030 "esbc_validate $bs_hdraddr;" \
31 "source $img_addr;" \
32 "esbc_halt\0"
gaurav rana98cb0ef2015-03-10 14:08:50 +053033
Aneesh Bansal5050f6f2015-06-16 10:36:43 +053034#ifdef CONFIG_BOOTSCRIPT_COPY_RAM
Tom Rinif4cd75e2022-06-17 16:24:34 -040035#define BS_COPY_ENV \
Aneesh Bansal5050f6f2015-06-16 10:36:43 +053036 "setenv bs_hdr_ram " __stringify(CONFIG_BS_HDR_ADDR_RAM)";" \
Sumit Garg69d4b482016-06-14 13:52:39 -040037 "setenv bs_hdr_device " __stringify(CONFIG_BS_HDR_ADDR_DEVICE)";" \
Aneesh Bansal5050f6f2015-06-16 10:36:43 +053038 "setenv bs_hdr_size " __stringify(CONFIG_BS_HDR_SIZE)";" \
39 "setenv bs_ram " __stringify(CONFIG_BS_ADDR_RAM)";" \
Sumit Garg69d4b482016-06-14 13:52:39 -040040 "setenv bs_device " __stringify(CONFIG_BS_ADDR_DEVICE)";" \
Aneesh Bansal5050f6f2015-06-16 10:36:43 +053041 "setenv bs_size " __stringify(CONFIG_BS_SIZE)";"
42
Saksham Jain3f701cc2016-03-23 16:24:37 +053043/* For secure boot flow, default environment used will be used */
Ruchika Gupta762f92a2017-04-17 18:07:18 +053044#if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_NAND_BOOT) || \
45 defined(CONFIG_SD_BOOT)
Tom Rinif4cd75e2022-06-17 16:24:34 -040046#if defined(CONFIG_NAND_BOOT)
47#define BS_COPY_CMD \
Sumit Garg69d4b482016-06-14 13:52:39 -040048 "nand read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \
49 "nand read $bs_ram $bs_device $bs_size ;"
Sumit Garg69d4b482016-06-14 13:52:39 -040050#elif defined(CONFIG_SD_BOOT)
Tom Rinif4cd75e2022-06-17 16:24:34 -040051#define BS_COPY_CMD \
Sumit Garg69d4b482016-06-14 13:52:39 -040052 "mmc read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \
53 "mmc read $bs_ram $bs_device $bs_size ;"
Ruchika Gupta762f92a2017-04-17 18:07:18 +053054#endif
55#else
Tom Rinif4cd75e2022-06-17 16:24:34 -040056#define BS_COPY_CMD \
Sumit Garg69d4b482016-06-14 13:52:39 -040057 "cp.b $bs_hdr_device $bs_hdr_ram $bs_hdr_size ;" \
58 "cp.b $bs_device $bs_ram $bs_size ;"
gaurav rana98cb0ef2015-03-10 14:08:50 +053059#endif
Tom Rinif4cd75e2022-06-17 16:24:34 -040060#else /* !CONFIG_BOOTSCRIPT_COPY_RAM */
61#define BS_COPY_ENV
62#define BS_COPY_CMD
Saksham Jain3f701cc2016-03-23 16:24:37 +053063#endif /* CONFIG_BOOTSCRIPT_COPY_RAM */
gaurav rana98cb0ef2015-03-10 14:08:50 +053064
Tom Rinif4cd75e2022-06-17 16:24:34 -040065#define CHAIN_BOOT_CMD BS_COPY_ENV \
66 BS_COPY_CMD \
67 SECBOOT
gaurav rana98cb0ef2015-03-10 14:08:50 +053068
69#endif
70#endif