blob: d548dd833c155d0722d651d52f1f11d6563a3f69 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
rev13@wp.plb3b57e82015-03-01 12:44:39 +01002/*
3 * (C) Copyright 2010,2011
4 * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
5 *
6 * (C) Copyright 2015
Kamil Lulkodecd33b2015-11-29 11:50:53 +01007 * Kamil Lulko, <kamil.lulko@gmail.com>
rev13@wp.plb3b57e82015-03-01 12:44:39 +01008 */
9
10#include <common.h>
Simon Glass1d91ba72019-11-14 12:57:37 -070011#include <cpu_func.h>
rev13@wp.plb3b57e82015-03-01 12:44:39 +010012#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 */
19int cleanup_before_linux(void)
20{
Vikas Manochacd9b3bd2017-05-03 15:48:26 -070021 /*
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
Patrice Chotardbedc1582018-03-30 09:22:40 +020040 icache_disable();
41 invalidate_icache_all();
42
rev13@wp.plb3b57e82015-03-01 12:44:39 +010043 return 0;
44}
45
46/*
47 * Perform the low-level reset.
48 */
49void reset_cpu(ulong addr)
50{
51 /*
52 * Perform reset but keep priority group unchanged.
53 */
54 writel((V7M_AIRCR_VECTKEY << V7M_AIRCR_VECTKEY_SHIFT)
55 | (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK)
56 | V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
57}