1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Boot related environment variable definitions on TI boards. 4 * 5 * (C) Copyright 2017 Linaro Ltd. 6 * Sam Protsenko <semen.protsenko@linaro.org> 7 */ 8 9 #ifndef __TI_BOOT_H 10 #define __TI_BOOT_H 11 12 #include <linux/stringify.h> 13 14 #ifndef CONSOLEDEV 15 #define CONSOLEDEV "ttyS2" 16 #endif 17 18 #ifndef PARTS_DEFAULT 19 /* 20 * Default GPT tables for eMMC (Linux and Android). Notes: 21 * 1. Keep partitions aligned to erase group size (512 KiB) when possible 22 * 2. Keep partitions in sync with DFU_ALT_INFO_EMMC (see dfu.h) 23 * 3. Keep 'bootloader' partition (U-Boot proper) start address in sync with 24 * CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (see common/spl/Kconfig) 25 */ 26 #define PARTS_DEFAULT \ 27 /* Linux partitions */ \ 28 "uuid_disk=${uuid_gpt_disk};" \ 29 "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \ 30 "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \ 31 /* Android partitions */ \ 32 "partitions_android=" \ 33 "uuid_disk=${uuid_gpt_disk};" \ 34 "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \ 35 "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ 36 "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ 37 "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ 38 "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ 39 "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ 40 "name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};" \ 41 "name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};" \ 42 "name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};" \ 43 "name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};" \ 44 "name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \ 45 "name=super,size=2560M,uuid=${uuid_gpt_super};" \ 46 "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ 47 "name=userdata,size=-,uuid=${uuid_gpt_userdata}" 48 #endif /* PARTS_DEFAULT */ 49 50 #if defined(CONFIG_CMD_AVB) 51 #define AVB_VERIFY_CHECK "if run avb_verify; then " \ 52 "echo AVB verification OK.;" \ 53 "set bootargs $bootargs $avb_bootargs;" \ 54 "else " \ 55 "echo AVB verification failed.;" \ 56 "exit; fi;" 57 #define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0" 58 #else 59 #define AVB_VERIFY_CHECK "" 60 #define AVB_VERIFY_CMD "" 61 #endif 62 63 #define CONTROL_PARTITION "misc" 64 65 #if defined(CONFIG_CMD_AB_SELECT) 66 #define AB_SELECT_SLOT \ 67 "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ 68 "then " \ 69 "echo " CONTROL_PARTITION \ 70 " partition number:${control_part_number};" \ 71 "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \ 72 "else " \ 73 "echo " CONTROL_PARTITION " partition not found;" \ 74 "exit;" \ 75 "fi;" \ 76 "setenv slot_suffix _${slot_name};" 77 #define AB_SELECT_ARGS \ 78 "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \ 79 "echo A/B cmdline addition: ${bootargs_ab};" \ 80 "setenv bootargs ${bootargs} ${bootargs_ab};" 81 #else 82 #define AB_SELECT_SLOT "" 83 #define AB_SELECT_ARGS "" 84 #endif 85 86 /* 87 * Prepares complete device tree blob for current board (for Android boot). 88 * 89 * Boot image or recovery image should be loaded into $loadaddr prior to running 90 * these commands. The logic of these commnads is next: 91 * 92 * 1. Read correct DTB for current SoC/board from boot image in $loadaddr 93 * to $fdtaddr 94 * 2. Merge all needed DTBO for current board from 'dtbo' partition into read 95 * DTB 96 * 3. User should provide $fdtaddr as 3rd argument to 'bootm' 97 */ 98 #define PREPARE_FDT \ 99 "echo Preparing FDT...; " \ 100 "if test $board_name = am57xx_evm_reva3; then " \ 101 "echo \" Reading DTBO partition...\"; " \ 102 "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \ 103 "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \ 104 "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \ 105 "echo \" Reading DTB for AM57x EVM RevA3...\"; " \ 106 "abootimg get dtb --index=0 dtb_start dtb_size; " \ 107 "cp.b $dtb_start $fdtaddr $dtb_size; " \ 108 "fdt addr $fdtaddr 0x80000; " \ 109 "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \ 110 "adtimg addr $dtboaddr; " \ 111 "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \ 112 "fdt apply $dtbo0_addr; " \ 113 "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \ 114 "fdt apply $dtbo1_addr; " \ 115 "elif test $board_name = beagle_x15_revc; then " \ 116 "echo \" Reading DTB for Beagle X15 RevC...\"; " \ 117 "abootimg get dtb --index=0 dtb_start dtb_size; " \ 118 "cp.b $dtb_start $fdtaddr $dtb_size; " \ 119 "fdt addr $fdtaddr 0x80000; " \ 120 "else " \ 121 "echo Error: Android boot is not supported for $board_name; " \ 122 "exit; " \ 123 "fi; " \ 124 125 #define FASTBOOT_CMD \ 126 "echo Booting into fastboot ...; " \ 127 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " 128 129 #define DEFAULT_COMMON_BOOT_TI_ARGS \ 130 "console=" CONSOLEDEV ",115200n8\0" \ 131 "fdtfile=undefined\0" \ 132 "bootpart=0:2\0" \ 133 "bootdir=/boot\0" \ 134 "bootfile=zImage\0" \ 135 "usbtty=cdc_acm\0" \ 136 "vram=16M\0" \ 137 AVB_VERIFY_CMD \ 138 "partitions=" PARTS_DEFAULT "\0" \ 139 "optargs=\0" \ 140 "dofastboot=0\0" \ 141 "emmc_linux_boot=" \ 142 "echo Trying to boot Linux from eMMC ...; " \ 143 "setenv mmcdev 1; " \ 144 "setenv bootpart 1:2; " \ 145 "setenv mmcroot /dev/mmcblk0p2 rw; " \ 146 "run mmcboot;\0" \ 147 "emmc_android_boot=" \ 148 "setenv mmcdev 1; " \ 149 "mmc dev $mmcdev; " \ 150 "mmc rescan; " \ 151 AB_SELECT_SLOT \ 152 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ 153 CONTROL_PARTITION "; then " \ 154 "setenv ardaddr -; " \ 155 "if bcb test command = bootonce-bootloader; then " \ 156 "echo Android: Bootloader boot...; " \ 157 "bcb clear command; bcb store; " \ 158 FASTBOOT_CMD \ 159 "exit; " \ 160 "elif bcb test command = boot-recovery; then " \ 161 "echo Android: Recovery boot...; " \ 162 "setenv ardaddr $loadaddr;" \ 163 "setenv apart recovery; " \ 164 "else " \ 165 "echo Android: Normal boot...; " \ 166 "setenv ardaddr $loadaddr; " \ 167 "setenv apart boot${slot_suffix}; " \ 168 "fi; " \ 169 "else " \ 170 "echo Warning: BCB is corrupted or does not exist; " \ 171 "echo Android: Normal boot...; " \ 172 "fi; " \ 173 "setenv eval_bootargs setenv bootargs $bootargs; " \ 174 "run eval_bootargs; " \ 175 "setenv machid fe6; " \ 176 AVB_VERIFY_CHECK \ 177 AB_SELECT_ARGS \ 178 "if part start mmc $mmcdev $apart boot_start; then " \ 179 "part size mmc $mmcdev $apart boot_size; " \ 180 "mmc read $loadaddr $boot_start $boot_size; " \ 181 PREPARE_FDT \ 182 "bootm $loadaddr $ardaddr $fdtaddr; " \ 183 "else " \ 184 "echo $apart partition not found; " \ 185 "exit; " \ 186 "fi;\0" 187 188 #ifdef CONFIG_OMAP54XX 189 190 #define DEFAULT_FDT_TI_ARGS \ 191 "findfdt="\ 192 "if test $board_name = omap5_uevm; then " \ 193 "setenv fdtfile omap5-uevm.dtb; fi; " \ 194 "if test $board_name = dra7xx; then " \ 195 "setenv fdtfile dra7-evm.dtb; fi;" \ 196 "if test $board_name = dra72x-revc; then " \ 197 "setenv fdtfile dra72-evm-revc.dtb; fi;" \ 198 "if test $board_name = dra72x; then " \ 199 "setenv fdtfile dra72-evm.dtb; fi;" \ 200 "if test $board_name = dra71x; then " \ 201 "setenv fdtfile dra71-evm.dtb; fi;" \ 202 "if test $board_name = dra76x_acd; then " \ 203 "setenv fdtfile dra76-evm.dtb; fi;" \ 204 "if test $board_name = beagle_x15; then " \ 205 "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ 206 "if test $board_name = beagle_x15_revb1; then " \ 207 "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \ 208 "if test $board_name = beagle_x15_revc; then " \ 209 "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \ 210 "if test $board_name = am5729_beagleboneai; then " \ 211 "setenv fdtfile am5729-beagleboneai.dtb; fi;" \ 212 "if test $board_name = am572x_idk; then " \ 213 "setenv fdtfile am572x-idk.dtb; fi;" \ 214 "if test $board_name = am574x_idk; then " \ 215 "setenv fdtfile am574x-idk.dtb; fi;" \ 216 "if test $board_name = am57xx_evm; then " \ 217 "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ 218 "if test $board_name = am57xx_evm_reva3; then " \ 219 "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ 220 "if test $board_name = am571x_idk; then " \ 221 "setenv fdtfile am571x-idk.dtb; fi;" \ 222 "if test $fdtfile = undefined; then " \ 223 "echo WARNING: Could not determine device tree to use; fi; \0" 224 225 #define CONFIG_BOOTCOMMAND \ 226 "if test ${dofastboot} -eq 1; then " \ 227 "echo Boot fastboot requested, resetting dofastboot ...;" \ 228 "setenv dofastboot 0; saveenv;" \ 229 FASTBOOT_CMD \ 230 "fi;" \ 231 "if test ${boot_fit} -eq 1; then " \ 232 "run update_to_fit;" \ 233 "fi;" \ 234 "run findfdt; " \ 235 "run envboot; " \ 236 "run mmcboot;" \ 237 "run emmc_linux_boot; " \ 238 "run emmc_android_boot; " \ 239 "" 240 241 #endif /* CONFIG_OMAP54XX */ 242 243 #endif /* __TI_BOOT_H */ 244