Guillaume La Roque | 880c0aa | 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 | |
Mattijs Korpershoek | f2cd648 | 2021-07-29 09:21:11 +0200 | [diff] [blame] | 12 | #ifndef BOOT_PARTITION |
| 13 | #define BOOT_PARTITION "boot" |
| 14 | #endif |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 15 | |
Mattijs Korpershoek | 211f1d9 | 2021-07-29 09:21:12 +0200 | [diff] [blame] | 16 | #ifndef LOGO_PARTITION |
| 17 | #define LOGO_PARTITION "logo" |
| 18 | #endif |
| 19 | |
Mattijs Korpershoek | 9d0ac61 | 2021-07-30 14:28:08 +0200 | [diff] [blame] | 20 | #ifndef CONTROL_PARTITION |
| 21 | #define CONTROL_PARTITION "misc" |
| 22 | #endif |
| 23 | |
Mattijs Korpershoek | 72d7c03 | 2021-07-30 14:28:09 +0200 | [diff] [blame^] | 24 | #ifndef RECOVERY_PARTITION |
| 25 | #define RECOVERY_PARTITION "recovery" |
| 26 | #endif |
| 27 | |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 28 | #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \ |
| 29 | "bootcmd_fastboot=" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 30 | "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 Korpershoek | 9d0ac61 | 2021-07-30 14:28:08 +0200 | [diff] [blame] | 40 | "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; " \ |
| 47 | "else " \ |
| 48 | "echo Warning: BCB is corrupted or does not exist; " \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 49 | "fi;" \ |
| 50 | "if test \"${run_fastboot}\" -eq 1; then " \ |
| 51 | "echo Running Fastboot...;" \ |
Mattijs Korpershoek | 75be1eb | 2021-07-29 09:21:10 +0200 | [diff] [blame] | 52 | "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 53 | "fi\0" |
| 54 | |
| 55 | #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \ |
| 56 | "fastboot " |
| 57 | |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 58 | #define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \ |
| 59 | "bootcmd_recovery=" \ |
| 60 | "pinmux dev pinctrl@14;" \ |
| 61 | "pinmux dev pinctrl@40;" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 62 | "setenv run_recovery 0;" \ |
| 63 | "if run check_button; then " \ |
| 64 | "echo Recovery button is pressed;" \ |
| 65 | "setenv run_recovery 1;" \ |
Mattijs Korpershoek | 72d7c03 | 2021-07-30 14:28:09 +0200 | [diff] [blame^] | 66 | "fi; " \ |
| 67 | "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ |
| 68 | CONTROL_PARTITION "; then " \ |
| 69 | "if bcb test command = boot-recovery; then " \ |
| 70 | "echo BCB: Recovery boot...; " \ |
| 71 | "setenv run_recovery 1;" \ |
| 72 | "fi;" \ |
| 73 | "else " \ |
| 74 | "echo Warning: BCB is corrupted or does not exist; " \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 75 | "fi;" \ |
| 76 | "if test \"${skip_recovery}\" -eq 1; then " \ |
| 77 | "echo Recovery skipped by environment;" \ |
| 78 | "setenv run_recovery 0;" \ |
| 79 | "fi;" \ |
| 80 | "if test \"${force_recovery}\" -eq 1; then " \ |
| 81 | "echo Recovery forced by environment;" \ |
| 82 | "setenv run_recovery 1;" \ |
| 83 | "fi;" \ |
| 84 | "if test \"${run_recovery}\" -eq 1; then " \ |
| 85 | "echo Running Recovery...;" \ |
Mattijs Korpershoek | 72d7c03 | 2021-07-30 14:28:09 +0200 | [diff] [blame^] | 86 | "mmc dev ${mmcdev};" \ |
| 87 | "setenv bootargs \"${bootargs} androidboot.serialno=${serial#}\";" \ |
| 88 | "part start mmc ${mmcdev} " RECOVERY_PARTITION " boot_start;" \ |
| 89 | "part size mmc ${mmcdev} " RECOVERY_PARTITION " boot_size;" \ |
| 90 | "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \ |
| 91 | "echo Running Android Recovery...;" \ |
| 92 | "bootm ${loadaddr};" \ |
| 93 | "fi;" \ |
| 94 | "echo Failed to boot Android...;" \ |
| 95 | "reset;" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 96 | "fi\0" |
| 97 | |
| 98 | #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \ |
| 99 | "recovery " |
| 100 | |
| 101 | #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \ |
| 102 | "bootcmd_system=" \ |
Mattijs Korpershoek | f2cd648 | 2021-07-29 09:21:11 +0200 | [diff] [blame] | 103 | "echo Loading Android " BOOT_PARTITION " partition...;" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 104 | "mmc dev ${mmcdev};" \ |
Mattijs Korpershoek | 143e153 | 2021-07-29 09:21:13 +0200 | [diff] [blame] | 105 | "setenv bootargs ${bootargs} androidboot.serialno=${serial#};" \ |
Mattijs Korpershoek | f2cd648 | 2021-07-29 09:21:11 +0200 | [diff] [blame] | 106 | "part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \ |
| 107 | "part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 108 | "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \ |
| 109 | "echo Running Android...;" \ |
| 110 | "bootm ${loadaddr};" \ |
| 111 | "fi;" \ |
| 112 | "echo Failed to boot Android...;" \ |
| 113 | "reset\0" |
| 114 | |
| 115 | #define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \ |
| 116 | "system " |
| 117 | |
| 118 | #define BOOT_TARGET_DEVICES(func) \ |
| 119 | func(FASTBOOT, fastboot, na) \ |
| 120 | func(RECOVERY, recovery, na) \ |
| 121 | func(SYSTEM, system, na) \ |
| 122 | |
| 123 | #define PREBOOT_LOAD_LOGO \ |
Guillaume La Roque | 82f6508 | 2020-10-30 16:03:44 +0100 | [diff] [blame] | 124 | "if test \"${boot_source}\" != \"usb\" && " \ |
| 125 | "gpt verify mmc ${mmcdev} ${partitions}; then; " \ |
| 126 | "mmc dev ${mmcdev};" \ |
Mattijs Korpershoek | 211f1d9 | 2021-07-29 09:21:12 +0200 | [diff] [blame] | 127 | "part start mmc ${mmcdev} " LOGO_PARTITION " boot_start;" \ |
| 128 | "part size mmc ${mmcdev} " LOGO_PARTITION " boot_size;" \ |
Guillaume La Roque | 82f6508 | 2020-10-30 16:03:44 +0100 | [diff] [blame] | 129 | "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 130 | "bmp display ${loadaddr} m m;" \ |
Guillaume La Roque | 82f6508 | 2020-10-30 16:03:44 +0100 | [diff] [blame] | 131 | "fi;" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 132 | "fi;" |
| 133 | |
| 134 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
| 135 | "partitions=" PARTS_DEFAULT "\0" \ |
| 136 | "mmcdev=2\0" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 137 | "gpio_recovery=88\0" \ |
| 138 | "check_button=gpio input ${gpio_recovery};test $? -eq 0;\0" \ |
| 139 | "load_logo=" PREBOOT_LOAD_LOGO "\0" \ |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 140 | "stdin=" STDIN_CFG "\0" \ |
| 141 | "stdout=" STDOUT_CFG "\0" \ |
| 142 | "stderr=" STDOUT_CFG "\0" \ |
| 143 | "loadaddr=0x01000000\0" \ |
| 144 | "fdt_addr_r=0x01000000\0" \ |
| 145 | "scriptaddr=0x08000000\0" \ |
| 146 | "kernel_addr_r=0x01080000\0" \ |
| 147 | "pxefile_addr_r=0x01080000\0" \ |
| 148 | "ramdisk_addr_r=0x13000000\0" \ |
Mattijs Korpershoek | d1af9aa | 2021-07-29 09:21:09 +0200 | [diff] [blame] | 149 | "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \ |
| 150 | BOOTENV |
Guillaume La Roque | 880c0aa | 2019-10-11 17:33:57 +0200 | [diff] [blame] | 151 | |
| 152 | #include <configs/meson64.h> |
| 153 | |
| 154 | #endif /* __MESON64_ANDROID_CONFIG_H */ |