1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Copyright (C) 2019 Jagan Teki <jagan@amarulasolutions.com> 4 */ 5 6#include <config.h> 7 8#ifdef CONFIG_ARM64 9#define FIT_ARCH "arm64" 10#else 11#define FIT_ARCH "arm" 12#endif 13 14#if defined(CONFIG_SPL_GZIP) 15#define FIT_UBOOT_COMP "gzip" 16#elif defined(CONFIG_SPL_LZMA) 17#define FIT_UBOOT_COMP "lzma" 18#else 19#define FIT_UBOOT_COMP "none" 20#endif 21 22/* 23 * SHA256 should be enabled in SPL when signature validation is involved, 24 * CRC32 should only be used for basic checksum validation of FIT images. 25 */ 26#if defined(CONFIG_SPL_FIT_SIGNATURE) 27#if defined(CONFIG_SPL_SHA256) 28#define FIT_HASH_ALGO "sha256" 29#elif defined(CONFIG_SPL_CRC32) 30#define FIT_HASH_ALGO "crc32" 31#endif 32#endif 33 34#if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE)) 35#define HAS_FIT 36#endif 37 38/ { 39 binman: binman { 40 multiple-images; 41 }; 42}; 43 44#ifdef CONFIG_SPL 45&binman { 46#ifdef HAS_FIT 47 fit_template: template-1 { 48 type = "fit"; 49#ifdef CONFIG_ARM64 50 description = "FIT image for U-Boot with bl31 (TF-A)"; 51#else 52 description = "FIT image with OP-TEE"; 53#endif 54 #address-cells = <1>; 55 fit,fdt-list = "of-list"; 56 fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>; 57 fit,align = <512>; 58 images { 59 u-boot { 60 description = "U-Boot"; 61 type = "standalone"; 62 os = "u-boot"; 63 arch = FIT_ARCH; 64 compression = FIT_UBOOT_COMP; 65 load = <CONFIG_TEXT_BASE>; 66 entry = <CONFIG_TEXT_BASE>; 67 u-boot-nodtb { 68 compress = FIT_UBOOT_COMP; 69 }; 70#ifdef FIT_HASH_ALGO 71 hash { 72 algo = FIT_HASH_ALGO; 73 }; 74#endif 75 }; 76 77#ifdef CONFIG_ARM64 78 @atf-SEQ { 79 fit,operation = "split-elf"; 80 description = "ARM Trusted Firmware"; 81 type = "firmware"; 82 arch = FIT_ARCH; 83 os = "arm-trusted-firmware"; 84 compression = "none"; 85 fit,load; 86 fit,entry; 87 fit,data; 88 89 atf-bl31 { 90 }; 91#ifdef FIT_HASH_ALGO 92 hash { 93 algo = FIT_HASH_ALGO; 94 }; 95#endif 96 }; 97 @tee-SEQ { 98 fit,operation = "split-elf"; 99 description = "TEE"; 100 type = "tee"; 101 arch = FIT_ARCH; 102 os = "tee"; 103 compression = "none"; 104 fit,load; 105 fit,entry; 106 fit,data; 107 108 tee-os { 109 optional; 110 }; 111#ifdef FIT_HASH_ALGO 112 hash { 113 algo = FIT_HASH_ALGO; 114 }; 115#endif 116 }; 117#else /* !CONFIG_ARM64 */ 118 op-tee { 119 description = "OP-TEE"; 120 type = "tee"; 121 arch = FIT_ARCH; 122 os = "tee"; 123 compression = "none"; 124 load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>; 125 entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>; 126 127 tee-os { 128 }; 129#ifdef FIT_HASH_ALGO 130 hash { 131 algo = FIT_HASH_ALGO; 132 }; 133#endif 134 }; 135#endif /* CONFIG_ARM64 */ 136 137 @fdt-SEQ { 138 description = "fdt-NAME"; 139 compression = "none"; 140 type = "flat_dt"; 141#ifdef FIT_HASH_ALGO 142 hash { 143 algo = FIT_HASH_ALGO; 144 }; 145#endif 146 }; 147 }; 148 149 configurations { 150 default = "@config-DEFAULT-SEQ"; 151 @config-SEQ { 152 description = "NAME.dtb"; 153 fdt = "fdt-SEQ"; 154#ifdef CONFIG_ARM64 155 fit,firmware = "atf-1", "u-boot"; 156#else 157 fit,firmware = "op-tee", "u-boot"; 158#endif 159 fit,loadables; 160 fit,compatible; 161 }; 162 }; 163 }; 164#endif /* HAS_FIT */ 165 166 simple-bin { 167 filename = "u-boot-rockchip.bin"; 168 pad-byte = <0xff>; 169 170 mkimage { 171 filename = "idbloader.img"; 172 args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; 173 multiple-data-files; 174 175#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL 176 rockchip-tpl { 177 }; 178#elif defined(CONFIG_TPL) 179 u-boot-tpl { 180 }; 181#endif 182 u-boot-spl { 183 }; 184 }; 185 186#ifdef HAS_FIT 187 fit { 188 filename = "u-boot.itb"; 189 insert-template = <&fit_template>; 190#else 191 u-boot-img { 192#endif 193 offset = <CONFIG_SPL_PAD_TO>; 194 }; 195 }; 196 197#ifdef CONFIG_ROCKCHIP_SPI_IMAGE 198 simple-bin-spi { 199 filename = "u-boot-rockchip-spi.bin"; 200 pad-byte = <0xff>; 201 202 mkimage { 203 filename = "idbloader-spi.img"; 204 args = "-n", CONFIG_SYS_SOC, "-T", "rkspi"; 205 multiple-data-files; 206 207#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL 208 rockchip-tpl { 209 }; 210#elif defined(CONFIG_TPL) 211 u-boot-tpl { 212 }; 213#endif 214 u-boot-spl { 215 }; 216 }; 217 218#ifdef HAS_FIT 219 fit { 220 insert-template = <&fit_template>; 221#else 222 u-boot-img { 223#endif 224 /* Sync with u-boot,spl-payload-offset if present */ 225 offset = <CONFIG_SYS_SPI_U_BOOT_OFFS>; 226 }; 227 }; 228#endif /* CONFIG_ROCKCHIP_SPI_IMAGE */ 229}; 230#endif /* CONFIG_SPL */ 231