1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Configuration for Android Amlogic Meson 64bits SoCs
5 * Copyright (C) 2019 Baylibre, SAS
6 * Author: Jerome Brunet <jbrunet@baylibre.com>
9 #ifndef __MESON64_ANDROID_CONFIG_H
10 #define __MESON64_ANDROID_CONFIG_H
12 #include <linux/sizes.h>
14 #define CONFIG_SYS_MALLOC_LEN SZ_128M
16 #ifndef BOOT_PARTITION
17 #define BOOT_PARTITION "boot"
20 #ifndef LOGO_PARTITION
21 #define LOGO_PARTITION "logo"
24 #ifndef CONTROL_PARTITION
25 #define CONTROL_PARTITION "misc"
28 #ifndef RECOVERY_PARTITION
29 #define RECOVERY_PARTITION "recovery"
31 #if defined(CONFIG_CMD_AVB)
32 #define AVB_VERIFY_CHECK \
33 "if test \"${force_avb}\" -eq 1; then " \
34 "if run avb_verify; then " \
35 "echo AVB verification OK.;" \
36 "setenv bootargs \"$bootargs $avb_bootargs\";" \
38 "echo AVB verification failed.;" \
41 "setenv bootargs \"$bootargs androidboot.verifiedbootstate=orange\";" \
42 "echo Running without AVB...; "\
45 #define AVB_VERIFY_CMD "avb_verify=avb init ${mmcdev}; avb verify;\0"
47 #define AVB_VERIFY_CHECK ""
48 #define AVB_VERIFY_CMD ""
51 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
53 "setenv run_fastboot 0;" \
54 "if test \"${boot_source}\" = \"usb\"; then " \
55 "echo Fastboot forced by usb rom boot;" \
56 "setenv run_fastboot 1;" \
58 "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
60 "echo Broken MMC partition scheme;" \
61 "setenv run_fastboot 1;" \
63 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
64 CONTROL_PARTITION "; then " \
65 "if bcb test command = bootonce-bootloader; then " \
66 "echo BCB: Bootloader boot...; " \
67 "bcb clear command; bcb store; " \
68 "setenv run_fastboot 1;" \
70 "if bcb test command = boot-fastboot; then " \
71 "echo BCB: fastboot userspace boot...; " \
72 "setenv force_recovery 1;" \
75 "echo Warning: BCB is corrupted or does not exist; " \
77 "if test \"${run_fastboot}\" -eq 1; then " \
78 "echo Running Fastboot...;" \
79 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
82 #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
85 #define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
87 "pinmux dev pinctrl@14;" \
88 "pinmux dev pinctrl@40;" \
89 "setenv run_recovery 0;" \
90 "if run check_button; then " \
91 "echo Recovery button is pressed;" \
92 "setenv run_recovery 1;" \
94 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
95 CONTROL_PARTITION "; then " \
96 "if bcb test command = boot-recovery; then " \
97 "echo BCB: Recovery boot...; " \
98 "setenv run_recovery 1;" \
101 "echo Warning: BCB is corrupted or does not exist; " \
103 "if test \"${skip_recovery}\" -eq 1; then " \
104 "echo Recovery skipped by environment;" \
105 "setenv run_recovery 0;" \
107 "if test \"${force_recovery}\" -eq 1; then " \
108 "echo Recovery forced by environment;" \
109 "setenv run_recovery 1;" \
111 "if test \"${run_recovery}\" -eq 1; then " \
112 "echo Running Recovery...;" \
113 "mmc dev ${mmcdev};" \
114 "setenv bootargs \"${bootargs} androidboot.serialno=${serial#}\";" \
116 "part start mmc ${mmcdev} " RECOVERY_PARTITION " boot_start;" \
117 "part size mmc ${mmcdev} " RECOVERY_PARTITION " boot_size;" \
118 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
119 "echo Running Android Recovery...;" \
120 "bootm ${loadaddr};" \
122 "echo Failed to boot Android...;" \
126 #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \
129 #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
131 "echo Loading Android " BOOT_PARTITION " partition...;" \
132 "mmc dev ${mmcdev};" \
133 "setenv bootargs ${bootargs} androidboot.serialno=${serial#};" \
135 "part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
136 "part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
137 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
138 "echo Running Android...;" \
139 "bootm ${loadaddr};" \
141 "echo Failed to boot Android...;" \
144 #define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \
147 #define BOOT_TARGET_DEVICES(func) \
148 func(FASTBOOT, fastboot, na) \
149 func(RECOVERY, recovery, na) \
150 func(SYSTEM, system, na) \
152 #define PREBOOT_LOAD_LOGO \
153 "if test \"${boot_source}\" != \"usb\" && " \
154 "gpt verify mmc ${mmcdev} ${partitions}; then; " \
155 "mmc dev ${mmcdev};" \
156 "part start mmc ${mmcdev} " LOGO_PARTITION " boot_start;" \
157 "part size mmc ${mmcdev} " LOGO_PARTITION " boot_size;" \
158 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
159 "bmp display ${loadaddr} m m;" \
163 #define CONFIG_EXTRA_ENV_SETTINGS \
164 "partitions=" PARTS_DEFAULT "\0" \
168 "gpio_recovery=88\0" \
169 "check_button=gpio input ${gpio_recovery};test $? -eq 0;\0" \
170 "load_logo=" PREBOOT_LOAD_LOGO "\0" \
171 "stdin=" STDIN_CFG "\0" \
172 "stdout=" STDOUT_CFG "\0" \
173 "stderr=" STDOUT_CFG "\0" \
174 "loadaddr=0x01000000\0" \
175 "fdt_addr_r=0x01000000\0" \
176 "scriptaddr=0x08000000\0" \
177 "kernel_addr_r=0x01080000\0" \
178 "pxefile_addr_r=0x01080000\0" \
179 "ramdisk_addr_r=0x13000000\0" \
180 "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
183 #include <configs/meson64.h>
185 #endif /* __MESON64_ANDROID_CONFIG_H */