Merge tag 'tpm-030822' of https://source.denx.de/u-boot/custodians/u-boot-tpm
[platform/kernel/u-boot.git] / include / configs / ti_omap5_common.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2013
4  * Texas Instruments Incorporated.
5  * Sricharan R    <r.sricharan@ti.com>
6  *
7  * Derived from OMAP4 done by:
8  *      Aneesh V <aneesh@ti.com>
9  *
10  * TI OMAP5 AND DRA7XX common configuration settings
11  *
12  * For more details, please see the technical documents listed at
13  * http://www.ti.com/product/omap5432
14  */
15
16 #ifndef __CONFIG_TI_OMAP5_COMMON_H
17 #define __CONFIG_TI_OMAP5_COMMON_H
18
19 /* Use General purpose timer 1 */
20 #define CONFIG_SYS_TIMERBASE            GPT2_BASE
21
22 #include <linux/stringify.h>
23
24 #include <asm/arch/cpu.h>
25 #include <asm/arch/omap.h>
26
27 #include <configs/ti_armv7_omap.h>
28
29 /*
30  * Hardware drivers
31  */
32 #define CONFIG_SYS_NS16550_CLK          48000000
33 #if !defined(CONFIG_DM_SERIAL)
34 #define CONFIG_SYS_NS16550_SERIAL
35 #define CONFIG_SYS_NS16550_REG_SIZE     (-4)
36 #endif
37
38 /*
39  * Environment setup
40  */
41
42 #ifndef DFUARGS
43 #define DFUARGS
44 #endif
45
46 #include <environment/ti/mmc.h>
47 #include <environment/ti/nand.h>
48
49 #ifndef CONSOLEDEV
50 #define CONSOLEDEV "ttyS2"
51 #endif
52
53 #ifndef PARTS_DEFAULT
54 /*
55  * Default GPT tables for eMMC (Linux and Android). Notes:
56  *   1. Keep partitions aligned to erase group size (512 KiB) when possible
57  *   2. Keep partitions in sync with DFU_ALT_INFO_EMMC (see dfu.h)
58  *   3. Keep 'bootloader' partition (U-Boot proper) start address in sync with
59  *      CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (see common/spl/Kconfig)
60  */
61 #define PARTS_DEFAULT \
62         /* Linux partitions */ \
63         "uuid_disk=${uuid_gpt_disk};" \
64         "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
65         "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
66         /* Android partitions */ \
67         "partitions_android=" \
68         "uuid_disk=${uuid_gpt_disk};" \
69         "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
70         "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \
71         "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \
72         "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
73         "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \
74         "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \
75         "name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};" \
76         "name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};" \
77         "name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};" \
78         "name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};" \
79         "name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \
80         "name=super,size=2560M,uuid=${uuid_gpt_super};" \
81         "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \
82         "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
83 #endif /* PARTS_DEFAULT */
84
85 #if defined(CONFIG_CMD_AVB)
86 #define AVB_VERIFY_CHECK "if run avb_verify; then " \
87                                 "echo AVB verification OK.;" \
88                                 "set bootargs $bootargs $avb_bootargs;" \
89                         "else " \
90                                 "echo AVB verification failed.;" \
91                         "exit; fi;"
92 #define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0"
93 #else
94 #define AVB_VERIFY_CHECK ""
95 #define AVB_VERIFY_CMD ""
96 #endif
97
98 #define CONTROL_PARTITION "misc"
99
100 #if defined(CONFIG_CMD_AB_SELECT)
101 #define AB_SELECT_SLOT \
102         "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \
103         "then " \
104                 "echo " CONTROL_PARTITION \
105                         " partition number:${control_part_number};" \
106                 "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \
107         "else " \
108                 "echo " CONTROL_PARTITION " partition not found;" \
109                 "exit;" \
110         "fi;" \
111         "setenv slot_suffix _${slot_name};"
112 #define AB_SELECT_ARGS \
113         "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \
114         "echo A/B cmdline addition: ${bootargs_ab};" \
115         "setenv bootargs ${bootargs} ${bootargs_ab};"
116 #else
117 #define AB_SELECT_SLOT ""
118 #define AB_SELECT_ARGS ""
119 #endif
120
121 /*
122  * Prepares complete device tree blob for current board (for Android boot).
123  *
124  * Boot image or recovery image should be loaded into $loadaddr prior to running
125  * these commands. The logic of these commnads is next:
126  *
127  *   1. Read correct DTB for current SoC/board from boot image in $loadaddr
128  *      to $fdtaddr
129  *   2. Merge all needed DTBO for current board from 'dtbo' partition into read
130  *      DTB
131  *   3. User should provide $fdtaddr as 3rd argument to 'bootm'
132  */
133 #define PREPARE_FDT \
134         "echo Preparing FDT...; " \
135         "if test $board_name = am57xx_evm_reva3; then " \
136                 "echo \"  Reading DTBO partition...\"; " \
137                 "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \
138                 "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \
139                 "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \
140                 "echo \"  Reading DTB for AM57x EVM RevA3...\"; " \
141                 "abootimg get dtb --index=0 dtb_start dtb_size; " \
142                 "cp.b $dtb_start $fdtaddr $dtb_size; " \
143                 "fdt addr $fdtaddr 0x80000; " \
144                 "echo \"  Applying DTBOs for AM57x EVM RevA3...\"; " \
145                 "adtimg addr $dtboaddr; " \
146                 "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \
147                 "fdt apply $dtbo0_addr; " \
148                 "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \
149                 "fdt apply $dtbo1_addr; " \
150         "elif test $board_name = beagle_x15_revc; then " \
151                 "echo \"  Reading DTB for Beagle X15 RevC...\"; " \
152                 "abootimg get dtb --index=0 dtb_start dtb_size; " \
153                 "cp.b $dtb_start $fdtaddr $dtb_size; " \
154                 "fdt addr $fdtaddr 0x80000; " \
155         "else " \
156                 "echo Error: Android boot is not supported for $board_name; " \
157                 "exit; " \
158         "fi; " \
159
160 #define DEFAULT_COMMON_BOOT_TI_ARGS \
161         "console=" CONSOLEDEV ",115200n8\0" \
162         "fdtfile=undefined\0" \
163         "finduuid=part uuid mmc 0:2 uuid\0" \
164         "usbtty=cdc_acm\0" \
165         "vram=16M\0" \
166         AVB_VERIFY_CMD \
167         "partitions=" PARTS_DEFAULT "\0" \
168         "optargs=\0" \
169         "dofastboot=0\0" \
170         "emmc_android_boot=" \
171                 "setenv mmcdev 1; " \
172                 "mmc dev $mmcdev; " \
173                 "mmc rescan; " \
174                 AB_SELECT_SLOT \
175                 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
176                 CONTROL_PARTITION "; then " \
177                         "setenv ardaddr -; " \
178                         "if bcb test command = bootonce-bootloader; then " \
179                                 "echo Android: Bootloader boot...; " \
180                                 "bcb clear command; bcb store; " \
181                                 "fastboot 1; " \
182                                 "exit; " \
183                         "elif bcb test command = boot-recovery; then " \
184                                 "echo Android: Recovery boot...; " \
185                                 "setenv ardaddr $loadaddr;" \
186                                 "setenv apart recovery; " \
187                         "else " \
188                                 "echo Android: Normal boot...; " \
189                                 "setenv ardaddr $loadaddr; " \
190                                 "setenv apart boot${slot_suffix}; " \
191                         "fi; " \
192                 "else " \
193                         "echo Warning: BCB is corrupted or does not exist; " \
194                         "echo Android: Normal boot...; " \
195                 "fi; " \
196                 "setenv eval_bootargs setenv bootargs $bootargs; " \
197                 "run eval_bootargs; " \
198                 "setenv machid fe6; " \
199                 AVB_VERIFY_CHECK \
200                 AB_SELECT_ARGS \
201                 "if part start mmc $mmcdev $apart boot_start; then " \
202                         "part size mmc $mmcdev $apart boot_size; " \
203                         "mmc read $loadaddr $boot_start $boot_size; " \
204                         PREPARE_FDT \
205                         "bootm $loadaddr $ardaddr $fdtaddr; " \
206                 "else " \
207                         "echo $apart partition not found; " \
208                         "exit; " \
209                 "fi;\0"
210
211 #define DEFAULT_FDT_TI_ARGS \
212         "findfdt="\
213                 "if test $board_name = omap5_uevm; then " \
214                         "setenv fdtfile omap5-uevm.dtb; fi; " \
215                 "if test $board_name = dra7xx; then " \
216                         "setenv fdtfile dra7-evm.dtb; fi;" \
217                 "if test $board_name = dra72x-revc; then " \
218                         "setenv fdtfile dra72-evm-revc.dtb; fi;" \
219                 "if test $board_name = dra72x; then " \
220                         "setenv fdtfile dra72-evm.dtb; fi;" \
221                 "if test $board_name = dra71x; then " \
222                         "setenv fdtfile dra71-evm.dtb; fi;" \
223                 "if test $board_name = dra76x_acd; then " \
224                         "setenv fdtfile dra76-evm.dtb; fi;" \
225                 "if test $board_name = beagle_x15; then " \
226                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
227                 "if test $board_name = beagle_x15_revb1; then " \
228                         "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \
229                 "if test $board_name = beagle_x15_revc; then " \
230                         "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \
231                 "if test $board_name = am5729_beagleboneai; then " \
232                         "setenv fdtfile am5729-beagleboneai.dtb; fi;" \
233                 "if test $board_name = am572x_idk; then " \
234                         "setenv fdtfile am572x-idk.dtb; fi;" \
235                 "if test $board_name = am574x_idk; then " \
236                         "setenv fdtfile am574x-idk.dtb; fi;" \
237                 "if test $board_name = am57xx_evm; then " \
238                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
239                 "if test $board_name = am57xx_evm_reva3; then " \
240                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
241                 "if test $board_name = am571x_idk; then " \
242                         "setenv fdtfile am571x-idk.dtb; fi;" \
243                 "if test $fdtfile = undefined; then " \
244                         "echo WARNING: Could not determine device tree to use; fi; \0"
245
246 #define BOOT_TARGET_DEVICES(func) \
247         func(MMC, mmc, 0) \
248         func(MMC, mmc, 1) \
249         func(PXE, pxe, na) \
250         func(DHCP, dhcp, na)
251
252 #include <config_distro_bootcmd.h>
253
254 #define CONFIG_EXTRA_ENV_SETTINGS \
255         DEFAULT_LINUX_BOOT_ENV \
256         DEFAULT_MMC_TI_ARGS \
257         DEFAULT_FIT_TI_ARGS \
258         DEFAULT_COMMON_BOOT_TI_ARGS \
259         DEFAULT_FDT_TI_ARGS \
260         DFUARGS \
261         NETARGS \
262         NANDARGS \
263         BOOTENV
264
265 /*
266  * SPL related defines.  The Public RAM memory map the ROM defines the
267  * area between 0x40300000 and 0x4031E000 as a download area for OMAP5.
268  * On DRA7xx/AM57XX the download area is between 0x40300000 and 0x4037E000.
269  * We set CONFIG_SPL_DISPLAY_PRINT to have omap_rev_string() called and
270  * print some information.
271  */
272 #ifdef CONFIG_TI_SECURE_DEVICE
273 /*
274  * For memory booting on HS parts, the first 4KB of the internal RAM is
275  * reserved for secure world use and the flash loader image is
276  * preceded by a secure certificate. The SPL will therefore run in internal
277  * RAM from address 0x40301350 (0x40300000+0x1000(reserved)+0x350(cert)).
278  */
279 #define TI_OMAP5_SECURE_BOOT_RESV_SRAM_SZ       0x1000
280 /* If no specific start address is specified then the secure EMIF
281  * region will be placed at the end of the DDR space. In order to prevent
282  * the main u-boot relocation from clobbering that memory and causing a
283  * firewall violation, we tell u-boot that memory is protected RAM (PRAM)
284  */
285 #if (CONFIG_TI_SECURE_EMIF_REGION_START == 0)
286 #define CONFIG_PRAM (CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE) >> 10
287 #endif
288 #else
289 /*
290  * For all booting on GP parts, the flash loader image is
291  * downloaded into internal RAM at address 0x40300000.
292  */
293 #endif
294
295 #endif /* __CONFIG_TI_OMAP5_COMMON_H */