meson64_android.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. #ifndef __MESON64_ANDROID_CONFIG_H
  9. #define __MESON64_ANDROID_CONFIG_H
  10. #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
  11. "bootcmd_fastboot=" \
  12. "sm reboot_reason reason;" \
  13. "setenv run_fastboot 0;" \
  14. "if test \"${boot_source}\" = \"usb\"; then " \
  15. "echo Fastboot forced by usb rom boot;" \
  16. "setenv run_fastboot 1;" \
  17. "fi;" \
  18. "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
  19. "else " \
  20. "echo Broken MMC partition scheme;" \
  21. "setenv run_fastboot 1;" \
  22. "fi;" \
  23. "if test \"${reason}\" = \"bootloader\" -o " \
  24. "\"${reason}\" = \"fastboot\"; then " \
  25. "echo Fastboot asked by reboot reason;" \
  26. "setenv run_fastboot 1;" \
  27. "fi;" \
  28. "if test \"${skip_fastboot}\" -eq 1; then " \
  29. "echo Fastboot skipped by environment;" \
  30. "setenv run_fastboot 0;" \
  31. "fi;" \
  32. "if test \"${force_fastboot}\" -eq 1; then " \
  33. "echo Fastboot forced by environment;" \
  34. "setenv run_fastboot 1;" \
  35. "fi;" \
  36. "if test \"${run_fastboot}\" -eq 1; then " \
  37. "echo Running Fastboot...;" \
  38. "fastboot 0;" \
  39. "fi\0"
  40. #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
  41. "fastboot "
  42. /* TOFIX: Run actual recovery instead of fastboot */
  43. #define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
  44. "bootcmd_recovery=" \
  45. "pinmux dev pinctrl@14;" \
  46. "pinmux dev pinctrl@40;" \
  47. "sm reboot_reason reason;" \
  48. "setenv run_recovery 0;" \
  49. "if run check_button; then " \
  50. "echo Recovery button is pressed;" \
  51. "setenv run_recovery 1;" \
  52. "elif test \"${reason}\" = \"recovery\" -o " \
  53. "\"${reason}\" = \"update\"; then " \
  54. "echo Recovery asked by reboot reason;" \
  55. "setenv run_recovery 1;" \
  56. "fi;" \
  57. "if test \"${skip_recovery}\" -eq 1; then " \
  58. "echo Recovery skipped by environment;" \
  59. "setenv run_recovery 0;" \
  60. "fi;" \
  61. "if test \"${force_recovery}\" -eq 1; then " \
  62. "echo Recovery forced by environment;" \
  63. "setenv run_recovery 1;" \
  64. "fi;" \
  65. "if test \"${run_recovery}\" -eq 1; then " \
  66. "echo Running Recovery...;" \
  67. "fastboot 0;" \
  68. "fi\0"
  69. #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \
  70. "recovery "
  71. #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
  72. "bootcmd_system=" \
  73. "echo Loading Android boot partition...;" \
  74. "mmc dev ${mmcdev};" \
  75. "setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
  76. "part start mmc ${mmcdev} ${bootpart} boot_start;" \
  77. "part size mmc ${mmcdev} ${bootpart} boot_size;" \
  78. "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
  79. "echo Running Android...;" \
  80. "bootm ${loadaddr};" \
  81. "fi;" \
  82. "echo Failed to boot Android...;" \
  83. "reset\0"
  84. #define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \
  85. "system "
  86. #define BOOT_TARGET_DEVICES(func) \
  87. func(FASTBOOT, fastboot, na) \
  88. func(RECOVERY, recovery, na) \
  89. func(SYSTEM, system, na) \
  90. #define PREBOOT_LOAD_LOGO \
  91. "mmc dev ${mmcdev};" \
  92. "part start mmc ${mmcdev} ${logopart} boot_start;" \
  93. "part size mmc ${mmcdev} ${logopart} boot_size;" \
  94. "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
  95. "bmp display ${loadaddr} m m;" \
  96. "fi;"
  97. #define CONFIG_EXTRA_ENV_SETTINGS \
  98. "partitions=" PARTS_DEFAULT "\0" \
  99. "mmcdev=2\0" \
  100. "bootpart=1\0" \
  101. "logopart=2\0" \
  102. "gpio_recovery=88\0" \
  103. "check_button=gpio input ${gpio_recovery};test $? -eq 0;\0" \
  104. "load_logo=" PREBOOT_LOAD_LOGO "\0" \
  105. "console=/dev/ttyAML0\0" \
  106. "bootargs=no_console_suspend\0" \
  107. "stdin=" STDIN_CFG "\0" \
  108. "stdout=" STDOUT_CFG "\0" \
  109. "stderr=" STDOUT_CFG "\0" \
  110. "loadaddr=0x01000000\0" \
  111. "fdt_addr_r=0x01000000\0" \
  112. "scriptaddr=0x08000000\0" \
  113. "kernel_addr_r=0x01080000\0" \
  114. "pxefile_addr_r=0x01080000\0" \
  115. "ramdisk_addr_r=0x13000000\0" \
  116. "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" BOOTENV
  117. #include <configs/meson64.h>
  118. #endif /* __MESON64_ANDROID_CONFIG_H */