Merge tag 'efi-2020-01-rc1-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
[oweals/u-boot.git] / include / configs / meson64_android.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Configuration for Android Amlogic Meson 64bits SoCs
4  *
5  * Copyright (C) 2019 Baylibre, SAS
6  * Author: Jerome Brunet <jbrunet@baylibre.com>
7  */
8
9 #ifndef __MESON64_ANDROID_CONFIG_H
10 #define __MESON64_ANDROID_CONFIG_H
11
12 #define CONFIG_SYS_MMC_ENV_DEV  2
13 #define CONFIG_SYS_MMC_ENV_PART 1
14 #define CONFIG_ENV_SIZE         0x10000
15 #define CONFIG_ENV_OFFSET       (-0x10000)
16
17
18 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
19         "bootcmd_fastboot=" \
20                 "sm reboot_reason reason;" \
21                 "setenv run_fastboot 0;" \
22                 "if test \"${boot_source}\" = \"usb\"; then " \
23                         "echo Fastboot forced by usb rom boot;" \
24                         "setenv run_fastboot 1;" \
25                 "fi;" \
26                 "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
27                 "else " \
28                         "echo Broken MMC partition scheme;" \
29                         "setenv run_fastboot 1;" \
30                 "fi;" \
31                 "if test \"${reason}\" = \"bootloader\" -o " \
32                         "\"${reason}\" = \"fastboot\"; then " \
33                         "echo Fastboot asked by reboot reason;" \
34                         "setenv run_fastboot 1;" \
35                 "fi;" \
36                 "if test \"${skip_fastboot}\" -eq 1; then " \
37                         "echo Fastboot skipped by environment;" \
38                         "setenv run_fastboot 0;" \
39                 "fi;" \
40                 "if test \"${force_fastboot}\" -eq 1; then " \
41                         "echo Fastboot forced by environment;" \
42                         "setenv run_fastboot 1;" \
43                 "fi;" \
44                 "if test \"${run_fastboot}\" -eq 1; then " \
45                         "echo Running Fastboot...;" \
46                         "fastboot 0;" \
47                 "fi\0"
48
49 #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
50                 "fastboot "
51
52 /* TOFIX: Run actual recovery instead of fastboot */
53 #define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
54         "bootcmd_recovery=" \
55                 "pinmux dev pinctrl@14;" \
56                 "pinmux dev pinctrl@40;" \
57                 "sm reboot_reason reason;" \
58                 "setenv run_recovery 0;" \
59                 "if run check_button; then " \
60                         "echo Recovery button is pressed;" \
61                         "setenv run_recovery 1;" \
62                 "elif test \"${reason}\" = \"recovery\" -o " \
63                           "\"${reason}\" = \"update\"; then " \
64                         "echo Recovery asked by reboot reason;" \
65                         "setenv run_recovery 1;" \
66                 "fi;" \
67                 "if test \"${skip_recovery}\" -eq 1; then " \
68                         "echo Recovery skipped by environment;" \
69                         "setenv run_recovery 0;" \
70                 "fi;" \
71                 "if test \"${force_recovery}\" -eq 1; then " \
72                         "echo Recovery forced by environment;" \
73                         "setenv run_recovery 1;" \
74                 "fi;" \
75                 "if test \"${run_recovery}\" -eq 1; then " \
76                         "echo Running Recovery...;" \
77                         "fastboot 0;" \
78                 "fi\0"
79
80 #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \
81                 "recovery "
82
83 #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
84         "bootcmd_system=" \
85                 "echo Loading Android boot partition...;" \
86                 "mmc dev ${mmcdev};" \
87                 "setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
88                 "part start mmc ${mmcdev} ${bootpart} boot_start;" \
89                 "part size mmc ${mmcdev} ${bootpart} boot_size;" \
90                 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
91                         "echo Running Android...;" \
92                         "bootm ${loadaddr};" \
93                 "fi;" \
94                 "echo Failed to boot Android...;" \
95                 "reset\0"
96
97 #define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance)   \
98                 "system "
99
100 #define BOOT_TARGET_DEVICES(func) \
101         func(FASTBOOT, fastboot, na) \
102         func(RECOVERY, recovery, na) \
103         func(SYSTEM, system, na) \
104
105 #define PREBOOT_LOAD_LOGO \
106         "mmc dev ${mmcdev};" \
107         "part start mmc ${mmcdev} ${logopart} boot_start;" \
108         "part size mmc ${mmcdev} ${logopart} boot_size;" \
109         "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
110                         "bmp display ${loadaddr} m m;" \
111         "fi;"
112
113 #define CONFIG_EXTRA_ENV_SETTINGS                                     \
114         "partitions=" PARTS_DEFAULT "\0"                              \
115         "mmcdev=2\0"                                                  \
116         "bootpart=1\0"                                                \
117         "logopart=2\0"                                                \
118         "gpio_recovery=88\0"                                          \
119         "check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
120         "load_logo=" PREBOOT_LOAD_LOGO "\0"                           \
121         "console=/dev/ttyAML0\0"                                      \
122         "bootargs=no_console_suspend\0"                               \
123         "stdin=" STDIN_CFG "\0"                                       \
124         "stdout=" STDOUT_CFG "\0"                                     \
125         "stderr=" STDOUT_CFG "\0"                                     \
126         "loadaddr=0x01000000\0"                                       \
127         "fdt_addr_r=0x01000000\0"                                     \
128         "scriptaddr=0x08000000\0"                                     \
129         "kernel_addr_r=0x01080000\0"                                  \
130         "pxefile_addr_r=0x01080000\0"                                 \
131         "ramdisk_addr_r=0x13000000\0"                                 \
132         "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" BOOTENV
133
134 #include <configs/meson64.h>
135
136 #endif /* __MESON64_ANDROID_CONFIG_H */