blob: 55ea0787a7389ba50b547797f5aff0a7d72b3444 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
rev13@wp.pl12d8a722015-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 Lulko5be93562015-11-29 11:50:53 +01007 * Kamil Lulko, <kamil.lulko@gmail.com>
rev13@wp.pl12d8a722015-03-01 12:44:39 +01008 */
9
10#include <common.h>
11#include <asm/io.h>
12#include <asm/armv7m.h>
13
14/*
15 * This is called right before passing control to
16 * the Linux kernel point.
17 */
18int cleanup_before_linux(void)
19{
Vikas Manocha4098d202017-05-03 15:48:26 -070020 /*
21 * this function is called just before we call linux
22 * it prepares the processor for linux
23 *
24 * disable interrupt and turn off caches etc ...
25 */
26 disable_interrupts();
27 /*
28 * turn off D-cache
29 * dcache_disable() in turn flushes the d-cache
30 * MPU is still enabled & can't be disabled as the u-boot
31 * code might be running in sdram which by default is not
32 * executable area.
33 */
34 dcache_disable();
35 /* invalidate to make sure no cache line gets dirty between
36 * dcache flushing and disabling dcache */
37 invalidate_dcache_all();
38
Patrice Chotardd409c962018-03-30 09:22:40 +020039 icache_disable();
40 invalidate_icache_all();
41
rev13@wp.pl12d8a722015-03-01 12:44:39 +010042 return 0;
43}
44
45/*
46 * Perform the low-level reset.
47 */
48void reset_cpu(ulong addr)
49{
50 /*
51 * Perform reset but keep priority group unchanged.
52 */
53 writel((V7M_AIRCR_VECTKEY << V7M_AIRCR_VECTKEY_SHIFT)
54 | (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK)
55 | V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
56}