1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2010,2011
4  * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
5  *
6  * (C) Copyright 2015
7  * Kamil Lulko, <kamil.lulko@gmail.com>
8  */
9 
10 #include <common.h>
11 #include <cpu_func.h>
12 #include <irq_func.h>
13 #include <asm/io.h>
14 #include <asm/armv7m.h>
15 #include <spl.h>
16 
17 /*
18  * This is called right before passing control to
19  * the Linux kernel point.
20  */
cleanup_before_linux(void)21 int cleanup_before_linux(void)
22 {
23 	/*
24 	 * this function is called just before we call linux
25 	 * it prepares the processor for linux
26 	 *
27 	 * disable interrupt and turn off caches etc ...
28 	 */
29 	disable_interrupts();
30 	/*
31 	 * turn off D-cache
32 	 * dcache_disable() in turn flushes the d-cache
33 	 * MPU is still enabled & can't be disabled as the u-boot
34 	 * code might be running in sdram which by default is not
35 	 * executable area.
36 	 */
37 	dcache_disable();
38 	/* invalidate to make sure no cache line gets dirty between
39 	 * dcache flushing and disabling dcache */
40 	invalidate_dcache_all();
41 
42 	icache_disable();
43 	invalidate_icache_all();
44 
45 	return 0;
46 }
47 
48 /*
49  * Perform the low-level reset.
50  */
reset_cpu(void)51 void reset_cpu(void)
52 {
53 	/*
54 	 * Perform reset but keep priority group unchanged.
55 	 */
56 	writel((V7M_AIRCR_VECTKEY << V7M_AIRCR_VECTKEY_SHIFT)
57 		| (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK)
58 		| V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
59 }
60 
spl_perform_fixups(struct spl_image_info * spl_image)61 void spl_perform_fixups(struct spl_image_info *spl_image)
62 {
63 	spl_image->entry_point |= 0x1;
64 }
65