Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / mach-imx / imx8 / cpu.c
index e03193cb4cad3fb77824fca53718c41749e6cb23..38b2c0926f58a3258341129a46884a484fd25433 100644 (file)
@@ -9,6 +9,8 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <init.h>
+#include <log.h>
+#include <asm/cache.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/uclass.h>
@@ -22,6 +24,7 @@
 #include <asm/armv8/mmu.h>
 #include <asm/setup.h>
 #include <asm/mach-imx/boot_mode.h>
+#include <spl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -573,3 +576,44 @@ u32 get_cpu_rev(void)
 
        return (id << 12) | rev;
 }
+
+void board_boot_order(u32 *spl_boot_list)
+{
+       spl_boot_list[0] = spl_boot_device();
+
+       if (spl_boot_list[0] == BOOT_DEVICE_SPI) {
+               /* Check whether we own the flexspi0, if not, use NOR boot */
+               if (!sc_rm_is_resource_owned(-1, SC_R_FSPI_0))
+                       spl_boot_list[0] = BOOT_DEVICE_NOR;
+       }
+}
+
+bool m4_parts_booted(void)
+{
+       sc_rm_pt_t m4_parts[2];
+       int err;
+
+       err = sc_rm_get_resource_owner(-1, SC_R_M4_0_PID0, &m4_parts[0]);
+       if (err) {
+               printf("%s get resource [%d] owner error: %d\n", __func__,
+                      SC_R_M4_0_PID0, err);
+               return false;
+       }
+
+       if (sc_pm_is_partition_started(-1, m4_parts[0]))
+               return true;
+
+       if (is_imx8qm()) {
+               err = sc_rm_get_resource_owner(-1, SC_R_M4_1_PID0, &m4_parts[1]);
+               if (err) {
+                       printf("%s get resource [%d] owner error: %d\n",
+                              __func__, SC_R_M4_1_PID0, err);
+                       return false;
+               }
+
+               if (sc_pm_is_partition_started(-1, m4_parts[1]))
+                       return true;
+       }
+
+       return false;
+}