blob: 65427b5312bea62a9a08a02d3b633c3fdb55bcee [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>
Simon Glass8f3f7612019-11-14 12:57:42 -070012#include <irq_func.h>
rev13@wp.plb3b57e82015-03-01 12:44:39 +010013#include <asm/io.h>
14#include <asm/armv7m.h>
Ovidiu Panait8bbad142022-01-01 19:13:25 +020015#include <spl.h>
rev13@wp.plb3b57e82015-03-01 12:44:39 +010016
17/*
18 * This is called right before passing control to
19 * the Linux kernel point.
20 */
21int cleanup_before_linux(void)
22{
Vikas Manochacd9b3bd2017-05-03 15:48:26 -070023 /*
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
Patrice Chotardbedc1582018-03-30 09:22:40 +020042 icache_disable();
43 invalidate_icache_all();
44
rev13@wp.plb3b57e82015-03-01 12:44:39 +010045 return 0;
46}
47
48/*
49 * Perform the low-level reset.
50 */
Harald Seiler6f14d5f2020-12-15 16:47:52 +010051void reset_cpu(void)
rev13@wp.plb3b57e82015-03-01 12:44:39 +010052{
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}
Ovidiu Panait8bbad142022-01-01 19:13:25 +020060
61void spl_perform_fixups(struct spl_image_info *spl_image)
62{
63 spl_image->entry_point |= 0x1;
64}