]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/cpu.c
am33xx: Update DT files, add am335x_gp_evm_config target
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / cpu.c
1 /*
2  * (C) Copyright 2008 Texas Insturments
3  *
4  * (C) Copyright 2002
5  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6  * Marius Groeger <mgroeger@sysgo.de>
7  *
8  * (C) Copyright 2002
9  * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
10  *
11  * SPDX-License-Identifier:     GPL-2.0+
12  */
13
14 /*
15  * CPU specific code
16  */
17
18 #include <common.h>
19 #include <command.h>
20 #include <lcd.h>
21 #include <asm/system.h>
22 #include <asm/cache.h>
23 #include <asm/armv7.h>
24 #include <linux/compiler.h>
25
26 void __weak cpu_cache_initialization(void){}
27
28 int cleanup_before_linux_select(int flags)
29 {
30         /*
31          * this function is called just before we call linux
32          * it prepares the processor for linux
33          *
34          * we turn off caches etc ...
35          */
36 #ifndef CONFIG_SPL_BUILD
37         disable_interrupts();
38 #endif
39
40         /*
41          * Turn off I-cache and invalidate it
42          */
43         icache_disable();
44         invalidate_icache_all();
45
46         if (flags & CBL_DISABLE_CACHES) {
47                 /*
48                 * turn off D-cache
49                 * dcache_disable() in turn flushes the d-cache and disables MMU
50                 */
51                 dcache_disable();
52                 v7_outer_cache_disable();
53
54                 /*
55                 * After D-cache is flushed and before it is disabled there may
56                 * be some new valid entries brought into the cache. We are
57                 * sure that these lines are not dirty and will not affect our
58                 * execution. (because unwinding the call-stack and setting a
59                 * bit in CP15 SCTRL is all we did during this. We have not
60                 * pushed anything on to the stack. Neither have we affected
61                 * any static data) So just invalidate the entire d-cache again
62                 * to avoid coherency problems for kernel
63                 */
64                 invalidate_dcache_all();
65         } else {
66                 flush_dcache_all();
67                 invalidate_icache_all();
68                 icache_enable();
69         }
70
71         /*
72          * Some CPU need more cache attention before starting the kernel.
73          */
74         cpu_cache_initialization();
75
76         return 0;
77 }
78
79 int cleanup_before_linux(void)
80 {
81         return cleanup_before_linux_select(CBL_ALL);
82 }