2 * (C) Copyright 2008 Texas Insturments
5 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Marius Groeger <mgroeger@sysgo.de>
9 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
11 * SPDX-License-Identifier: GPL-2.0+
20 #include <asm/system.h>
21 #include <asm/cache.h>
22 #include <asm/armv7.h>
23 #include <linux/compiler.h>
25 void __weak cpu_cache_initialization(void){}
27 int cleanup_before_linux_select(int flags)
30 * this function is called just before we call linux
31 * it prepares the processor for linux
33 * we turn off caches etc ...
35 #ifndef CONFIG_SPL_BUILD
39 if (flags & CBL_DISABLE_CACHES) {
42 * dcache_disable() in turn flushes the d-cache and disables MMU
45 v7_outer_cache_disable();
48 * After D-cache is flushed and before it is disabled there may
49 * be some new valid entries brought into the cache. We are
50 * sure that these lines are not dirty and will not affect our
51 * execution. (because unwinding the call-stack and setting a
52 * bit in CP15 SCTRL is all we did during this. We have not
53 * pushed anything on to the stack. Neither have we affected
54 * any static data) So just invalidate the entire d-cache again
55 * to avoid coherency problems for kernel
57 invalidate_dcache_all();
60 invalidate_icache_all();
63 * Turn off I-cache and invalidate it
66 invalidate_icache_all();
69 invalidate_icache_all();
74 * Some CPU need more cache attention before starting the kernel.
76 cpu_cache_initialization();
81 int cleanup_before_linux(void)
83 return cleanup_before_linux_select(CBL_ALL);