arm: stm32mp: activate data cache on DDR in SPL
authorPatrick Delaunay <patrick.delaunay@st.com>
Thu, 30 Apr 2020 14:30:21 +0000 (16:30 +0200)
committerPatrick Delaunay <patrick.delaunay@st.com>
Thu, 14 May 2020 07:02:12 +0000 (09:02 +0200)
Activate cache on DDR to improve the accesses to DDR used by SPL:
- CONFIG_SPL_BSS_START_ADDR
- CONFIG_SYS_SPL_MALLOC_START

Cache is configured only when DDR is fully initialized,
to avoid speculative access and issue in get_ram_size().
Data cache is deactivated at the end of SPL, to flush the data cache
and the TLB.

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
arch/arm/mach-stm32mp/spl.c

index 6368db4f6d3adeae5c5f094e342120008d87efec..b7e7e92ef678d758018e4441ef9c15d033081ec9 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <dm.h>
 #include <hang.h>
 #include <spl.h>
@@ -128,4 +129,22 @@ void board_init_f(ulong dummy)
                printf("DRAM init failed: %d\n", ret);
                hang();
        }
+
+       /*
+        * activate cache on DDR only when DDR is fully initialized
+        * to avoid speculative access and issue in get_ram_size()
+        */
+       if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+               mmu_set_region_dcache_behaviour(STM32_DDR_BASE, STM32_DDR_SIZE,
+                                               DCACHE_DEFAULT_OPTION);
+}
+
+void spl_board_prepare_for_boot(void)
+{
+       dcache_disable();
+}
+
+void spl_board_prepare_for_boot_linux(void)
+{
+       dcache_disable();
 }