arm: mach-k3: j721e_init: Add support for backup boot modes
[oweals/u-boot.git] / arch / arm / mach-at91 / spl_atmel.c
index ef745c94775dc81f80d0fa19650b8244642625a0..6ee0e1c24cfbc6fa4715ae2ffcf9753a9a9800f6 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <hang.h>
 #include <asm/io.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pit.h>
@@ -44,7 +45,15 @@ static void switch_to_main_crystal_osc(void)
 #endif
 
        tmp = readl(&pmc->mor);
+/*
+ * some boards have an external oscillator with driving.
+ * in this case we need to disable the internal SoC driving (bypass mode)
+ */
+#if defined(CONFIG_SPL_AT91_MCK_BYPASS)
+       tmp |= AT91_PMC_MOR_OSCBYPASS;
+#else
        tmp &= ~AT91_PMC_MOR_OSCBYPASS;
+#endif
        tmp &= ~AT91_PMC_MOR_KEY(0xff);
        tmp |= AT91_PMC_MOR_KEY(0x37);
        writel(tmp, &pmc->mor);