summaryrefslogtreecommitdiff
path: root/arch/arm/cpu/armv7m/cpu.c
blob: 292730c1d7cfab65a3dafc1bd56c7f69d4cb08cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: GPL-2.0+
/*
 * (C) Copyright 2010,2011
 * Vladimir Khusainov, Emcraft Systems, [email protected]
 *
 * (C) Copyright 2015
 * Kamil Lulko, <[email protected]>
 */

#include <cpu_func.h>
#include <irq_func.h>
#include <asm/io.h>
#include <asm/armv7m.h>
#include <spl.h>

/*
 * This is called right before passing control to
 * the Linux kernel point.
 */
int cleanup_before_linux(void)
{
	if (!CONFIG_IS_ENABLED(LIB_BOOTM) && !CONFIG_IS_ENABLED(LIB_BOOTZ))
		return 0;

	/*
	 * this function is called just before we call linux
	 * it prepares the processor for linux
	 *
	 * disable interrupt and turn off caches etc ...
	 */
	disable_interrupts();
	/*
	 * turn off D-cache
	 * dcache_disable() in turn flushes the d-cache
	 * MPU is still enabled & can't be disabled as the u-boot
	 * code might be running in sdram which by default is not
	 * executable area.
	 */
	dcache_disable();
	/* invalidate to make sure no cache line gets dirty between
	 * dcache flushing and disabling dcache */
	invalidate_dcache_all();

	icache_disable();
	invalidate_icache_all();

	return 0;
}

/*
 * Perform the low-level reset. ARMv7M only.
 */
#if IS_ENABLED(CONFIG_CPU_V7M)
void reset_cpu(void)
{
	/*
	 * Perform reset but keep priority group unchanged.
	 */
	writel((V7M_AIRCR_VECTKEY << V7M_AIRCR_VECTKEY_SHIFT)
		| (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK)
		| V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
}
#endif

void spl_perform_arch_fixups(struct spl_image_info *spl_image)
{
	if (IS_ENABLED(CONFIG_XPL_BUILD))
		spl_image->entry_point |= 0x1;
}