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