Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2015 Freescale Semiconductor, Inc. |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
Aneesh Bansal | bdc2207 | 2016-01-22 16:37:24 +0530 | [diff] [blame] | 6 | #ifndef __CONFIG_FSL_CHAIN_TRUST_H |
| 7 | #define __CONFIG_FSL_CHAIN_TRUST_H |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 8 | |
Simon Glass | 1af3c7f | 2020-05-10 11:40:09 -0600 | [diff] [blame] | 9 | #include <linux/stringify.h> |
| 10 | |
Aneesh Bansal | bdc2207 | 2016-01-22 16:37:24 +0530 | [diff] [blame] | 11 | #ifdef CONFIG_CHAIN_OF_TRUST |
| 12 | |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 13 | /* |
| 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 Protsenko | 5abc1a4 | 2017-08-14 20:22:17 +0300 | [diff] [blame] | 20 | #ifdef CONFIG_USE_BOOTARGS |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 21 | #define SET_BOOTARGS "setenv bootargs \'" CONFIG_BOOTARGS" \';" |
Saksham Jain | 2bfe489 | 2016-03-23 16:24:43 +0530 | [diff] [blame] | 22 | #else |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 23 | #define SET_BOOTARGS "setenv bootargs \'root=/dev/ram " \ |
Saksham Jain | 2bfe489 | 2016-03-23 16:24:43 +0530 | [diff] [blame] | 24 | "rw console=ttyS0,115200 ramdisk_size=600000\';" |
| 25 | #endif |
| 26 | |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 27 | #define SECBOOT \ |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 28 | "setenv bs_hdraddr " __stringify(CONFIG_BOOTSCRIPT_HDR_ADDR)";" \ |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 29 | SET_BOOTARGS \ |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 30 | "esbc_validate $bs_hdraddr;" \ |
| 31 | "source $img_addr;" \ |
| 32 | "esbc_halt\0" |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 33 | |
Aneesh Bansal | 5050f6f | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 34 | #ifdef CONFIG_BOOTSCRIPT_COPY_RAM |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 35 | #define BS_COPY_ENV \ |
Aneesh Bansal | 5050f6f | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 36 | "setenv bs_hdr_ram " __stringify(CONFIG_BS_HDR_ADDR_RAM)";" \ |
Sumit Garg | 69d4b48 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 37 | "setenv bs_hdr_device " __stringify(CONFIG_BS_HDR_ADDR_DEVICE)";" \ |
Aneesh Bansal | 5050f6f | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 38 | "setenv bs_hdr_size " __stringify(CONFIG_BS_HDR_SIZE)";" \ |
| 39 | "setenv bs_ram " __stringify(CONFIG_BS_ADDR_RAM)";" \ |
Sumit Garg | 69d4b48 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 40 | "setenv bs_device " __stringify(CONFIG_BS_ADDR_DEVICE)";" \ |
Aneesh Bansal | 5050f6f | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 41 | "setenv bs_size " __stringify(CONFIG_BS_SIZE)";" |
| 42 | |
Saksham Jain | 3f701cc | 2016-03-23 16:24:37 +0530 | [diff] [blame] | 43 | /* For secure boot flow, default environment used will be used */ |
Ruchika Gupta | 762f92a | 2017-04-17 18:07:18 +0530 | [diff] [blame] | 44 | #if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_NAND_BOOT) || \ |
| 45 | defined(CONFIG_SD_BOOT) |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 46 | #if defined(CONFIG_NAND_BOOT) |
| 47 | #define BS_COPY_CMD \ |
Sumit Garg | 69d4b48 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 48 | "nand read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \ |
| 49 | "nand read $bs_ram $bs_device $bs_size ;" |
Sumit Garg | 69d4b48 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 50 | #elif defined(CONFIG_SD_BOOT) |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 51 | #define BS_COPY_CMD \ |
Sumit Garg | 69d4b48 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 52 | "mmc read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \ |
| 53 | "mmc read $bs_ram $bs_device $bs_size ;" |
Ruchika Gupta | 762f92a | 2017-04-17 18:07:18 +0530 | [diff] [blame] | 54 | #endif |
| 55 | #else |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 56 | #define BS_COPY_CMD \ |
Sumit Garg | 69d4b48 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 57 | "cp.b $bs_hdr_device $bs_hdr_ram $bs_hdr_size ;" \ |
| 58 | "cp.b $bs_device $bs_ram $bs_size ;" |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 59 | #endif |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 60 | #else /* !CONFIG_BOOTSCRIPT_COPY_RAM */ |
| 61 | #define BS_COPY_ENV |
| 62 | #define BS_COPY_CMD |
Saksham Jain | 3f701cc | 2016-03-23 16:24:37 +0530 | [diff] [blame] | 63 | #endif /* CONFIG_BOOTSCRIPT_COPY_RAM */ |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 64 | |
Tom Rini | f4cd75e | 2022-06-17 16:24:34 -0400 | [diff] [blame] | 65 | #define CHAIN_BOOT_CMD BS_COPY_ENV \ |
| 66 | BS_COPY_CMD \ |
| 67 | SECBOOT |
gaurav rana | 98cb0ef | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 68 | |
| 69 | #endif |
| 70 | #endif |