blob: e22f05c889918887f22cff4fd824525321053422 [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
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...;" \
Mattijs Korpershoekb0a88af2021-07-29 09:21:10 +020044 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020045 "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...;" \
Mattijs Korpershoekb0a88af2021-07-29 09:21:10 +020075 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020076 "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=" \
Mattijs Korpershoek5a4a7102021-07-29 09:21:11 +020083 "echo Loading Android " BOOT_PARTITION " partition...;" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020084 "mmc dev ${mmcdev};" \
85 "setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
Mattijs Korpershoek5a4a7102021-07-29 09:21:11 +020086 "part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
87 "part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +020088 "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 \
Guillaume La Roqueb7162fa2020-10-30 16:03:44 +0100104 "if test \"${boot_source}\" != \"usb\" && " \
105 "gpt verify mmc ${mmcdev} ${partitions}; then; " \
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 " \
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200110 "bmp display ${loadaddr} m m;" \
Guillaume La Roqueb7162fa2020-10-30 16:03:44 +0100111 "fi;" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200112 "fi;"
113
114#define CONFIG_EXTRA_ENV_SETTINGS \
115 "partitions=" PARTS_DEFAULT "\0" \
116 "mmcdev=2\0" \
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200117 "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" \
Mattijs Korpershoek4d73d352021-07-29 09:21:09 +0200132 "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
133 BOOTENV
Guillaume La Roque95b488a2019-10-11 17:33:57 +0200134
135#include <configs/meson64.h>
136
137#endif /* __MESON64_ANDROID_CONFIG_H */