]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/environment/ti/boot.h
common: Drop linux/stringify.h from common header
[thirdparty/u-boot.git] / include / environment / ti / boot.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
4fd79ac9
SP
2/*
3 * Boot related environment variable definitions on TI boards.
4 *
5 * (C) Copyright 2017 Linaro Ltd.
6 * Sam Protsenko <semen.protsenko@linaro.org>
4fd79ac9
SP
7 */
8
9#ifndef __TI_BOOT_H
10#define __TI_BOOT_H
11
1af3c7f4
SG
12#include <linux/stringify.h>
13
4fd79ac9 14#ifndef CONSOLEDEV
adc097e1 15#define CONSOLEDEV "ttyS2"
4fd79ac9
SP
16#endif
17
18#ifndef PARTS_DEFAULT
d94e6dbc
SP
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 */
c90a760f
SP
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};" \
1e4fb783 35 "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \
35e3d2e8 36 "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \
c90a760f 37 "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
d94e6dbc
SP
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};" \
c90a760f
SP
47 "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
48#endif /* PARTS_DEFAULT */
4fd79ac9 49
e883ffe0
IO
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;"
0f5103de 57#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0"
e883ffe0
IO
58#else
59#define AVB_VERIFY_CHECK ""
60#define AVB_VERIFY_CMD ""
61#endif
62
edd31084
RT
63#define CONTROL_PARTITION "misc"
64
65#if defined(CONFIG_CMD_AB_SELECT)
d94e6dbc 66#define AB_SELECT_SLOT \
edd31084
RT
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;" \
d94e6dbc
SP
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};"
edd31084 81#else
d94e6dbc
SP
82#define AB_SELECT_SLOT ""
83#define AB_SELECT_ARGS ""
edd31084
RT
84#endif
85
add1a6bc
SP
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; " \
41ee72f4 108 "fdt addr $fdtaddr 0x80000; " \
add1a6bc
SP
109 "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \
110 "adtimg addr $dtboaddr; " \
41ee72f4 111 "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \
add1a6bc 112 "fdt apply $dtbo0_addr; " \
41ee72f4 113 "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \
add1a6bc
SP
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; " \
41ee72f4 119 "fdt addr $fdtaddr 0x80000; " \
add1a6bc
SP
120 "else " \
121 "echo Error: Android boot is not supported for $board_name; " \
122 "exit; " \
123 "fi; " \
124
3db0989e
SP
125#define FASTBOOT_CMD \
126 "echo Booting into fastboot ...; " \
127 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; "
128
4fd79ac9
SP
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" \
e883ffe0 137 AVB_VERIFY_CMD \
4fd79ac9
SP
138 "partitions=" PARTS_DEFAULT "\0" \
139 "optargs=\0" \
a17c8b18 140 "dofastboot=0\0" \
2717c084 141 "emmc_linux_boot=" \
6ca43a58 142 "echo Trying to boot Linux from eMMC ...; " \
2717c084
SP
143 "setenv mmcdev 1; " \
144 "setenv bootpart 1:2; " \
145 "setenv mmcroot /dev/mmcblk0p2 rw; " \
146 "run mmcboot;\0" \
a17c8b18 147 "emmc_android_boot=" \
d94e6dbc
SP
148 "setenv mmcdev 1; " \
149 "mmc dev $mmcdev; " \
150 "mmc rescan; " \
151 AB_SELECT_SLOT \
3db0989e
SP
152 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
153 CONTROL_PARTITION "; then " \
d94e6dbc 154 "setenv ardaddr -; " \
3db0989e 155 "if bcb test command = bootonce-bootloader; then " \
d94e6dbc 156 "echo Android: Bootloader boot...; " \
3db0989e
SP
157 "bcb clear command; bcb store; " \
158 FASTBOOT_CMD \
d94e6dbc 159 "exit; " \
3db0989e 160 "elif bcb test command = boot-recovery; then " \
d94e6dbc
SP
161 "echo Android: Recovery boot...; " \
162 "setenv ardaddr $loadaddr;" \
163 "setenv apart recovery; " \
3db0989e 164 "else " \
d94e6dbc
SP
165 "echo Android: Normal boot...; " \
166 "setenv ardaddr $loadaddr; " \
167 "setenv apart boot${slot_suffix}; " \
3db0989e
SP
168 "fi; " \
169 "else " \
170 "echo Warning: BCB is corrupted or does not exist; " \
d94e6dbc
SP
171 "echo Android: Normal boot...; " \
172 "fi; " \
a17c8b18
SP
173 "setenv eval_bootargs setenv bootargs $bootargs; " \
174 "run eval_bootargs; " \
a17c8b18 175 "setenv machid fe6; " \
e883ffe0 176 AVB_VERIFY_CHECK \
d94e6dbc
SP
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; " \
add1a6bc 181 PREPARE_FDT \
d94e6dbc 182 "bootm $loadaddr $ardaddr $fdtaddr; " \
edd31084 183 "else " \
d94e6dbc
SP
184 "echo $apart partition not found; " \
185 "exit; " \
edd31084 186 "fi;\0"
4fd79ac9
SP
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;" \
3741c044 202 "if test $board_name = dra76x_acd; then " \
911d76c4 203 "setenv fdtfile dra76-evm.dtb; fi;" \
4fd79ac9
SP
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;" \
08318317
LV
208 "if test $board_name = beagle_x15_revc; then " \
209 "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \
019d1237
CR
210 "if test $board_name = am5729_beagleboneai; then " \
211 "setenv fdtfile am5729-beagleboneai.dtb; fi;" \
4fd79ac9
SP
212 "if test $board_name = am572x_idk; then " \
213 "setenv fdtfile am572x-idk.dtb; fi;" \
3741c044
LV
214 "if test $board_name = am574x_idk; then " \
215 "setenv fdtfile am574x-idk.dtb; fi;" \
4fd79ac9
SP
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;" \
3db0989e 229 FASTBOOT_CMD \
4fd79ac9
SP
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;" \
2717c084 237 "run emmc_linux_boot; " \
a17c8b18 238 "run emmc_android_boot; " \
4fd79ac9
SP
239 ""
240
241#endif /* CONFIG_OMAP54XX */
242
243#endif /* __TI_BOOT_H */