blob: f9f2b2641685acf4fd4d7a2a9cc887d911c990ce [file] [log] [blame]
Guillaume La Roque880c0aa2019-10-11 17:33:57 +02001/* 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
Mattijs Korpershoekf2cd6482021-07-29 09:21:11 +020012#ifndef BOOT_PARTITION
13#define BOOT_PARTITION "boot"
14#endif
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020015
Mattijs Korpershoek211f1d92021-07-29 09:21:12 +020016#ifndef LOGO_PARTITION
17#define LOGO_PARTITION "logo"
18#endif
19
Mattijs Korpershoek9d0ac612021-07-30 14:28:08 +020020#ifndef CONTROL_PARTITION
21#define CONTROL_PARTITION "misc"
22#endif
23
Mattijs Korpershoek72d7c032021-07-30 14:28:09 +020024#ifndef RECOVERY_PARTITION
25#define RECOVERY_PARTITION "recovery"
26#endif
27
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020028#define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
29 "bootcmd_fastboot=" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020030 "setenv run_fastboot 0;" \
31 "if test \"${boot_source}\" = \"usb\"; then " \
32 "echo Fastboot forced by usb rom boot;" \
33 "setenv run_fastboot 1;" \
34 "fi;" \
35 "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
36 "else " \
37 "echo Broken MMC partition scheme;" \
38 "setenv run_fastboot 1;" \
39 "fi;" \
Mattijs Korpershoek9d0ac612021-07-30 14:28:08 +020040 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
41 CONTROL_PARTITION "; then " \
42 "if bcb test command = bootonce-bootloader; then " \
43 "echo BCB: Bootloader boot...; " \
44 "bcb clear command; bcb store; " \
45 "setenv run_fastboot 1;" \
46 "fi; " \
Mattijs Korpershoekacc53c62021-07-30 14:28:10 +020047 "if bcb test command = boot-fastboot; then " \
48 "echo BCB: fastboot userspace boot...; " \
49 "setenv force_recovery 1;" \
50 "fi; " \
Mattijs Korpershoek9d0ac612021-07-30 14:28:08 +020051 "else " \
52 "echo Warning: BCB is corrupted or does not exist; " \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020053 "fi;" \
54 "if test \"${run_fastboot}\" -eq 1; then " \
55 "echo Running Fastboot...;" \
Mattijs Korpershoek75be1eb2021-07-29 09:21:10 +020056 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020057 "fi\0"
58
59#define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
60 "fastboot "
61
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020062#define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
63 "bootcmd_recovery=" \
64 "pinmux dev pinctrl@14;" \
65 "pinmux dev pinctrl@40;" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020066 "setenv run_recovery 0;" \
67 "if run check_button; then " \
68 "echo Recovery button is pressed;" \
69 "setenv run_recovery 1;" \
Mattijs Korpershoek72d7c032021-07-30 14:28:09 +020070 "fi; " \
71 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
72 CONTROL_PARTITION "; then " \
73 "if bcb test command = boot-recovery; then " \
74 "echo BCB: Recovery boot...; " \
75 "setenv run_recovery 1;" \
76 "fi;" \
77 "else " \
78 "echo Warning: BCB is corrupted or does not exist; " \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +020079 "fi;" \
80 "if test \"${skip_recovery}\" -eq 1; then " \
81 "echo Recovery skipped by environment;" \
82 "setenv run_recovery 0;" \
83 "fi;" \
84 "if test \"${force_recovery}\" -eq 1; then " \
85 "echo Recovery forced by environment;" \
86 "setenv run_recovery 1;" \
87 "fi;" \
88 "if test \"${run_recovery}\" -eq 1; then " \
89 "echo Running Recovery...;" \
Mattijs Korpershoek72d7c032021-07-30 14:28:09 +020090 "mmc dev ${mmcdev};" \
91 "setenv bootargs \"${bootargs} androidboot.serialno=${serial#}\";" \
92 "part start mmc ${mmcdev} " RECOVERY_PARTITION " boot_start;" \
93 "part size mmc ${mmcdev} " RECOVERY_PARTITION " boot_size;" \
94 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
95 "echo Running Android Recovery...;" \
96 "bootm ${loadaddr};" \
97 "fi;" \
98 "echo Failed to boot Android...;" \
99 "reset;" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200100 "fi\0"
101
102#define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \
103 "recovery "
104
105#define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
106 "bootcmd_system=" \
Mattijs Korpershoekf2cd6482021-07-29 09:21:11 +0200107 "echo Loading Android " BOOT_PARTITION " partition...;" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200108 "mmc dev ${mmcdev};" \
Mattijs Korpershoek143e1532021-07-29 09:21:13 +0200109 "setenv bootargs ${bootargs} androidboot.serialno=${serial#};" \
Mattijs Korpershoekf2cd6482021-07-29 09:21:11 +0200110 "part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
111 "part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200112 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
113 "echo Running Android...;" \
114 "bootm ${loadaddr};" \
115 "fi;" \
116 "echo Failed to boot Android...;" \
117 "reset\0"
118
119#define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \
120 "system "
121
122#define BOOT_TARGET_DEVICES(func) \
123 func(FASTBOOT, fastboot, na) \
124 func(RECOVERY, recovery, na) \
125 func(SYSTEM, system, na) \
126
127#define PREBOOT_LOAD_LOGO \
Guillaume La Roque82f65082020-10-30 16:03:44 +0100128 "if test \"${boot_source}\" != \"usb\" && " \
129 "gpt verify mmc ${mmcdev} ${partitions}; then; " \
130 "mmc dev ${mmcdev};" \
Mattijs Korpershoek211f1d92021-07-29 09:21:12 +0200131 "part start mmc ${mmcdev} " LOGO_PARTITION " boot_start;" \
132 "part size mmc ${mmcdev} " LOGO_PARTITION " boot_size;" \
Guillaume La Roque82f65082020-10-30 16:03:44 +0100133 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200134 "bmp display ${loadaddr} m m;" \
Guillaume La Roque82f65082020-10-30 16:03:44 +0100135 "fi;" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200136 "fi;"
137
138#define CONFIG_EXTRA_ENV_SETTINGS \
139 "partitions=" PARTS_DEFAULT "\0" \
140 "mmcdev=2\0" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200141 "gpio_recovery=88\0" \
142 "check_button=gpio input ${gpio_recovery};test $? -eq 0;\0" \
143 "load_logo=" PREBOOT_LOAD_LOGO "\0" \
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200144 "stdin=" STDIN_CFG "\0" \
145 "stdout=" STDOUT_CFG "\0" \
146 "stderr=" STDOUT_CFG "\0" \
147 "loadaddr=0x01000000\0" \
148 "fdt_addr_r=0x01000000\0" \
149 "scriptaddr=0x08000000\0" \
150 "kernel_addr_r=0x01080000\0" \
151 "pxefile_addr_r=0x01080000\0" \
152 "ramdisk_addr_r=0x13000000\0" \
Mattijs Korpershoekd1af9aa2021-07-29 09:21:09 +0200153 "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
154 BOOTENV
Guillaume La Roque880c0aa2019-10-11 17:33:57 +0200155
156#include <configs/meson64.h>
157
158#endif /* __MESON64_ANDROID_CONFIG_H */