litedram: only run sdram init at first boot
authorMatt Johnston <matt@codeconstruct.com.au>
Thu, 27 Oct 2022 03:20:27 +0000 (11:20 +0800)
committerMatt Johnston <matt@codeconstruct.com.au>
Mon, 31 Oct 2022 06:41:15 +0000 (14:41 +0800)
Subsequent boots can skip the dram configuration, it will already
be in a usable state.

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
litedram/gen-src/sdram_init/main.c

index b42502d95e117c6de1e9e6162dbca6d29694b312..2d99410d993de8abc33c3536ca6f0eec183a90d7 100644 (file)
@@ -285,10 +285,14 @@ uint64_t main(void)
                try_flash = true;
        }
        printf("\n");
-       if (ftr & SYS_REG_INFO_HAS_DRAM) {
+       if (ftr & SYS_REG_INFO_HAS_DRAM && !ddrctrl_init_done_read()) {
                printf("LiteDRAM built from LiteX %s\n", LITEX_GIT_SHA1);
                sdram_init();
        }
+
+       val = readq(SYSCON_BASE + SYS_REG_CTRL);
+       writeq(val & ~SYS_REG_CTRL_ALT_RESET, SYSCON_BASE + SYS_REG_CTRL);
+
        if (ftr & SYS_REG_INFO_HAS_BRAM) {
                printf("Booting from BRAM...\n");
                return 0;