Guillaume La Roque | 95b488a | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 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 | |
Guillaume La Roque | 95b488a | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 12 | |
| 13 | #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \ |
| 14 | "bootcmd_fastboot=" \ |
| 15 | "sm reboot_reason reason;" \ |
| 16 | "setenv run_fastboot 0;" \ |
| 17 | "if test \"${boot_source}\" = \"usb\"; then " \ |
| 18 | "echo Fastboot forced by usb rom boot;" \ |
| 19 | "setenv run_fastboot 1;" \ |
| 20 | "fi;" \ |
| 21 | "if gpt verify mmc ${mmcdev} ${partitions}; then; " \ |
| 22 | "else " \ |
| 23 | "echo Broken MMC partition scheme;" \ |
| 24 | "setenv run_fastboot 1;" \ |
| 25 | "fi;" \ |
| 26 | "if test \"${reason}\" = \"bootloader\" -o " \ |
| 27 | "\"${reason}\" = \"fastboot\"; then " \ |
| 28 | "echo Fastboot asked by reboot reason;" \ |
| 29 | "setenv run_fastboot 1;" \ |
| 30 | "fi;" \ |
| 31 | "if test \"${skip_fastboot}\" -eq 1; then " \ |
| 32 | "echo Fastboot skipped by environment;" \ |
| 33 | "setenv run_fastboot 0;" \ |
| 34 | "fi;" \ |
| 35 | "if test \"${force_fastboot}\" -eq 1; then " \ |
| 36 | "echo Fastboot forced by environment;" \ |
| 37 | "setenv run_fastboot 1;" \ |
| 38 | "fi;" \ |
| 39 | "if test \"${run_fastboot}\" -eq 1; then " \ |
| 40 | "echo Running Fastboot...;" \ |
Mattijs Korpershoek | b0a88af | 2021-07-29 09:21:10 +0200 | [diff] [blame^] | 41 | "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \ |
Guillaume La Roque | 95b488a | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 42 | "fi\0" |
| 43 | |
| 44 | #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \ |
| 45 | "fastboot " |
| 46 | |
| 47 | /* TOFIX: Run actual recovery instead of fastboot */ |
| 48 | #define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \ |
| 49 | "bootcmd_recovery=" \ |
| 50 | "pinmux dev pinctrl@14;" \ |
| 51 | "pinmux dev pinctrl@40;" \ |
| 52 | "sm reboot_reason reason;" \ |
| 53 | "setenv run_recovery 0;" \ |
| 54 | "if run check_button; then " \ |
| 55 | "echo Recovery button is pressed;" \ |
| 56 | "setenv run_recovery 1;" \ |
| 57 | "elif test \"${reason}\" = \"recovery\" -o " \ |
| 58 | "\"${reason}\" = \"update\"; then " \ |
| 59 | "echo Recovery asked by reboot reason;" \ |
| 60 | "setenv run_recovery 1;" \ |
| 61 | "fi;" \ |
| 62 | "if test \"${skip_recovery}\" -eq 1; then " \ |
| 63 | "echo Recovery skipped by environment;" \ |
| 64 | "setenv run_recovery 0;" \ |
| 65 | "fi;" \ |
| 66 | "if test \"${force_recovery}\" -eq 1; then " \ |
| 67 | "echo Recovery forced by environment;" \ |
| 68 | "setenv run_recovery 1;" \ |
| 69 | "fi;" \ |
| 70 | "if test \"${run_recovery}\" -eq 1; then " \ |
| 71 | "echo Running Recovery...;" \ |
Mattijs Korpershoek | b0a88af | 2021-07-29 09:21:10 +0200 | [diff] [blame^] | 72 | "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \ |
Guillaume La Roque | 95b488a | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 73 | "fi\0" |
| 74 | |
| 75 | #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \ |
| 76 | "recovery " |
| 77 | |
| 78 | #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \ |
| 79 | "bootcmd_system=" \ |
| 80 | "echo Loading Android boot partition...;" \ |
| 81 | "mmc dev ${mmcdev};" \ |
| 82 | "setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \ |
| 83 | "part start mmc ${mmcdev} ${bootpart} boot_start;" \ |
| 84 | "part size mmc ${mmcdev} ${bootpart} boot_size;" \ |
| 85 | "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \ |
| 86 | "echo Running Android...;" \ |
| 87 | "bootm ${loadaddr};" \ |
| 88 | "fi;" \ |
| 89 | "echo Failed to boot Android...;" \ |
| 90 | "reset\0" |
| 91 | |
| 92 | #define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \ |
| 93 | "system " |
| 94 | |
| 95 | #define BOOT_TARGET_DEVICES(func) \ |
| 96 | func(FASTBOOT, fastboot, na) \ |
| 97 | func(RECOVERY, recovery, na) \ |
| 98 | func(SYSTEM, system, na) \ |
| 99 | |
| 100 | #define PREBOOT_LOAD_LOGO \ |
Guillaume La Roque | b7162fa | 2020-10-30 16:03:44 +0100 | [diff] [blame] | 101 | "if test \"${boot_source}\" != \"usb\" && " \ |
| 102 | "gpt verify mmc ${mmcdev} ${partitions}; then; " \ |
| 103 | "mmc dev ${mmcdev};" \ |
| 104 | "part start mmc ${mmcdev} ${logopart} boot_start;" \ |
| 105 | "part size mmc ${mmcdev} ${logopart} boot_size;" \ |
| 106 | "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \ |
Guillaume La Roque | 95b488a | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 107 | "bmp display ${loadaddr} m m;" \ |
Guillaume La Roque | b7162fa | 2020-10-30 16:03:44 +0100 | [diff] [blame] | 108 | "fi;" \ |
Guillaume La Roque | 95b488a | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 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" \ |
Mattijs Korpershoek | 4d73d35 | 2021-07-29 09:21:09 +0200 | [diff] [blame] | 130 | "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \ |
| 131 | BOOTENV |
Guillaume La Roque | 95b488a | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 132 | |
| 133 | #include <configs/meson64.h> |
| 134 | |
| 135 | #endif /* __MESON64_ANDROID_CONFIG_H */ |