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