meson64_android.h 4.6 KB

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