blob: 56545a72f86181ed0a9dd7eb752605bc337637dd [file] [log] [blame]
Guillaume La Roque95b488a2019-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 Korpershoek5a4a7102021-07-29 09:21:11 +020012#ifndef BOOT_PARTITION
13#define BOOT_PARTITION "boot"
14#endif
Guillaume La Roque95b488a2019-10-11 17:33:57 +020015
Mattijs Korpershoek4a3ede92021-07-29 09:21:12 +020016#ifndef LOGO_PARTITION
17#define LOGO_PARTITION "logo"
18#endif
19
Guillaume La Roque95b488a2019-10-11 17:33:57 +020020#define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
21 "bootcmd_fastboot=" \
22 "sm reboot_reason reason;" \
23 "setenv run_fastboot 0;" \
24 "if test \"${boot_source}\" = \"usb\"; then " \
25 "echo Fastboot forced by usb rom boot;" \
26 "setenv run_fastboot 1;" \
27 "fi;" \
28 "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
29 "else " \
30 "echo Broken MMC partition scheme;" \
31 "setenv run_fastboot 1;" \
32 "fi;" \
33 "if test \"${reason}\" = \"bootloader\" -o " \
34 "\"${reason}\" = \"fastboot\"; then " \
35 "echo Fastboot asked by reboot reason;" \
36 "setenv run_fastboot 1;" \
37 "fi;" \
38 "if test \"${skip_fastboot}\" -eq 1; then " \
39 "echo Fastboot skipped by environment;" \
40 "setenv run_fastboot 0;" \
41 "fi;" \
42 "if test \"${force_fastboot}\" -eq 1; then " \
43 "echo Fastboot forced by environment;" \
44 "setenv run_fastboot 1;" \
45 "fi;" \
46 "if test \"${run_fastboot}\" -eq 1; then " \
47 "echo Running Fastboot...;" \
Mattijs Korpershoekb0a88af2021-07-29 09:21:10 +020048 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020049 "fi\0"
50
51#define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
52 "fastboot "
53
54/* TOFIX: Run actual recovery instead of fastboot */
55#define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
56 "bootcmd_recovery=" \
57 "pinmux dev pinctrl@14;" \
58 "pinmux dev pinctrl@40;" \
59 "sm reboot_reason reason;" \
60 "setenv run_recovery 0;" \
61 "if run check_button; then " \
62 "echo Recovery button is pressed;" \
63 "setenv run_recovery 1;" \
64 "elif test \"${reason}\" = \"recovery\" -o " \
65 "\"${reason}\" = \"update\"; then " \
66 "echo Recovery asked by reboot reason;" \
67 "setenv run_recovery 1;" \
68 "fi;" \
69 "if test \"${skip_recovery}\" -eq 1; then " \
70 "echo Recovery skipped by environment;" \
71 "setenv run_recovery 0;" \
72 "fi;" \
73 "if test \"${force_recovery}\" -eq 1; then " \
74 "echo Recovery forced by environment;" \
75 "setenv run_recovery 1;" \
76 "fi;" \
77 "if test \"${run_recovery}\" -eq 1; then " \
78 "echo Running Recovery...;" \
Mattijs Korpershoekb0a88af2021-07-29 09:21:10 +020079 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020080 "fi\0"
81
82#define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \
83 "recovery "
84
85#define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
86 "bootcmd_system=" \
Mattijs Korpershoek5a4a7102021-07-29 09:21:11 +020087 "echo Loading Android " BOOT_PARTITION " partition...;" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020088 "mmc dev ${mmcdev};" \
89 "setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
Mattijs Korpershoek5a4a7102021-07-29 09:21:11 +020090 "part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
91 "part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020092 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
93 "echo Running Android...;" \
94 "bootm ${loadaddr};" \
95 "fi;" \
96 "echo Failed to boot Android...;" \
97 "reset\0"
98
99#define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \
100 "system "
101
102#define BOOT_TARGET_DEVICES(func) \
103 func(FASTBOOT, fastboot, na) \
104 func(RECOVERY, recovery, na) \
105 func(SYSTEM, system, na) \
106
107#define PREBOOT_LOAD_LOGO \
Guillaume La Roqueb7162fa2020-10-30 16:03:44 +0100108 "if test \"${boot_source}\" != \"usb\" && " \
109 "gpt verify mmc ${mmcdev} ${partitions}; then; " \
110 "mmc dev ${mmcdev};" \
Mattijs Korpershoek4a3ede92021-07-29 09:21:12 +0200111 "part start mmc ${mmcdev} " LOGO_PARTITION " boot_start;" \
112 "part size mmc ${mmcdev} " LOGO_PARTITION " boot_size;" \
Guillaume La Roqueb7162fa2020-10-30 16:03:44 +0100113 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200114 "bmp display ${loadaddr} m m;" \
Guillaume La Roqueb7162fa2020-10-30 16:03:44 +0100115 "fi;" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200116 "fi;"
117
118#define CONFIG_EXTRA_ENV_SETTINGS \
119 "partitions=" PARTS_DEFAULT "\0" \
120 "mmcdev=2\0" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200121 "gpio_recovery=88\0" \
122 "check_button=gpio input ${gpio_recovery};test $? -eq 0;\0" \
123 "load_logo=" PREBOOT_LOAD_LOGO "\0" \
124 "console=/dev/ttyAML0\0" \
125 "bootargs=no_console_suspend\0" \
126 "stdin=" STDIN_CFG "\0" \
127 "stdout=" STDOUT_CFG "\0" \
128 "stderr=" STDOUT_CFG "\0" \
129 "loadaddr=0x01000000\0" \
130 "fdt_addr_r=0x01000000\0" \
131 "scriptaddr=0x08000000\0" \
132 "kernel_addr_r=0x01080000\0" \
133 "pxefile_addr_r=0x01080000\0" \
134 "ramdisk_addr_r=0x13000000\0" \
Mattijs Korpershoek4d73d352021-07-29 09:21:09 +0200135 "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
136 BOOTENV
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200137
138#include <configs/meson64.h>
139
140#endif /* __MESON64_ANDROID_CONFIG_H */