Merge https://source.denx.de/u-boot/custodians/u-boot-usb
[platform/kernel/u-boot.git] / include / configs / stm32mp13_common.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2022, STMicroelectronics - All Rights Reserved
4  *
5  * Configuration settings for the STM32MP13x CPU
6  */
7
8 #ifndef __CONFIG_STM32MP13_COMMMON_H
9 #define __CONFIG_STM32MP13_COMMMON_H
10 #include <linux/sizes.h>
11 #include <asm/arch/stm32.h>
12
13 /*
14  * Configuration of the external SRAM memory used by U-Boot
15  */
16 #define CONFIG_SYS_SDRAM_BASE           STM32_DDR_BASE
17
18 /*
19  * For booting Linux, use the first 256 MB of memory, since this is
20  * the maximum mapped by the Linux kernel during initialization.
21  */
22 #define CONFIG_SYS_BOOTMAPSZ            SZ_256M
23
24 /*MMC SD*/
25 #define CONFIG_SYS_MMC_MAX_DEVICE       2
26
27 /* NAND support */
28 #define CONFIG_SYS_MAX_NAND_DEVICE      1
29
30 /*****************************************************************************/
31 #ifdef CONFIG_DISTRO_DEFAULTS
32 /*****************************************************************************/
33
34 #ifdef CONFIG_CMD_MMC
35 #define BOOT_TARGET_MMC0(func)  func(MMC, mmc, 0)
36 #define BOOT_TARGET_MMC1(func)  func(MMC, mmc, 1)
37 #else
38 #define BOOT_TARGET_MMC0(func)
39 #define BOOT_TARGET_MMC1(func)
40 #endif
41
42 #define BOOT_TARGET_DEVICES(func)       \
43         BOOT_TARGET_MMC1(func)          \
44         BOOT_TARGET_MMC0(func)
45
46 /*
47  * default bootcmd for stm32mp13:
48  * for mmc boot (eMMC, SD card), distro boot on the same mmc device
49  */
50 #define STM32MP_BOOTCMD "bootcmd_stm32mp=" \
51         "echo \"Boot over ${boot_device}${boot_instance}!\";" \
52                 "run env_check;" \
53                 "if test ${boot_device} = mmc;" \
54                 "then env set boot_targets \"mmc${boot_instance}\"; fi;" \
55                 "run distro_bootcmd;" \
56         "fi;\0"
57
58 #define STM32MP_EXTRA \
59         "env_check=if env info -p -d -q; then env save; fi\0" \
60         "boot_net_usb_start=true\0"
61
62 #ifndef STM32MP_BOARD_EXTRA_ENV
63 #define STM32MP_BOARD_EXTRA_ENV
64 #endif
65
66 #include <config_distro_bootcmd.h>
67
68 /*
69  * memory layout for 32M uncompressed/compressed kernel,
70  * 1M fdt, 1M script, 1M pxe and 1M for overlay
71  * and the ramdisk at the end.
72  */
73 #define __KERNEL_ADDR_R     __stringify(0xc2000000)
74 #define __FDT_ADDR_R        __stringify(0xc4000000)
75 #define __SCRIPT_ADDR_R     __stringify(0xc4100000)
76 #define __PXEFILE_ADDR_R    __stringify(0xc4200000)
77 #define __FDTOVERLAY_ADDR_R __stringify(0xc4300000)
78 #define __RAMDISK_ADDR_R    __stringify(0xc4400000)
79
80 #define STM32MP_MEM_LAYOUT \
81         "kernel_addr_r=" __KERNEL_ADDR_R "\0" \
82         "fdt_addr_r=" __FDT_ADDR_R "\0" \
83         "scriptaddr=" __SCRIPT_ADDR_R "\0" \
84         "pxefile_addr_r=" __PXEFILE_ADDR_R "\0" \
85         "fdtoverlay_addr_r=" __FDTOVERLAY_ADDR_R "\0" \
86         "ramdisk_addr_r=" __RAMDISK_ADDR_R "\0"
87
88 #define CONFIG_EXTRA_ENV_SETTINGS \
89         STM32MP_MEM_LAYOUT \
90         STM32MP_BOOTCMD \
91         BOOTENV \
92         STM32MP_EXTRA \
93         STM32MP_BOARD_EXTRA_ENV
94
95 #endif /* ifdef CONFIG_DISTRO_DEFAULTS*/
96
97 #endif /* __CONFIG_STM32MP13_COMMMON_H */