1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2008 Texas Insturments
6 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7 * Marius Groeger <mgroeger@sysgo.de>
10 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
19 #include <asm/system.h>
20 #include <asm/cache.h>
21 #include <asm/armv7.h>
22 #include <linux/compiler.h>
24 void __weak cpu_cache_initialization(void){}
26 int cleanup_before_linux_select(int flags)
29 * this function is called just before we call linux
30 * it prepares the processor for linux
32 * we turn off caches etc ...
34 #ifndef CONFIG_SPL_BUILD
38 if (flags & CBL_DISABLE_CACHES) {
41 * dcache_disable() in turn flushes the d-cache and disables MMU
44 v7_outer_cache_disable();
47 * After D-cache is flushed and before it is disabled there may
48 * be some new valid entries brought into the cache. We are
49 * sure that these lines are not dirty and will not affect our
50 * execution. (because unwinding the call-stack and setting a
51 * bit in CP15 SCTRL is all we did during this. We have not
52 * pushed anything on to the stack. Neither have we affected
53 * any static data) So just invalidate the entire d-cache again
54 * to avoid coherency problems for kernel
56 invalidate_dcache_all();
59 invalidate_icache_all();
62 * Turn off I-cache and invalidate it
65 invalidate_icache_all();
68 invalidate_icache_all();
73 * Some CPU need more cache attention before starting the kernel.
75 cpu_cache_initialization();
80 int cleanup_before_linux(void)
82 return cleanup_before_linux_select(CBL_ALL);