xref: /rk3399_rockchip-uboot/arch/arm/cpu/armv7m/cpu.c (revision 4098d2061ff57b731e195abe03a0b73ac69c8689)
112d8a729Srev13@wp.pl /*
212d8a729Srev13@wp.pl  * (C) Copyright 2010,2011
312d8a729Srev13@wp.pl  * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
412d8a729Srev13@wp.pl  *
512d8a729Srev13@wp.pl  * (C) Copyright 2015
65be93569SKamil Lulko  * Kamil Lulko, <kamil.lulko@gmail.com>
712d8a729Srev13@wp.pl  *
812d8a729Srev13@wp.pl  * SPDX-License-Identifier:	GPL-2.0+
912d8a729Srev13@wp.pl  */
1012d8a729Srev13@wp.pl 
1112d8a729Srev13@wp.pl #include <common.h>
1212d8a729Srev13@wp.pl #include <asm/io.h>
1312d8a729Srev13@wp.pl #include <asm/armv7m.h>
1412d8a729Srev13@wp.pl 
1512d8a729Srev13@wp.pl /*
1612d8a729Srev13@wp.pl  * This is called right before passing control to
1712d8a729Srev13@wp.pl  * the Linux kernel point.
1812d8a729Srev13@wp.pl  */
cleanup_before_linux(void)1912d8a729Srev13@wp.pl int cleanup_before_linux(void)
2012d8a729Srev13@wp.pl {
21*4098d206SVikas Manocha 	/*
22*4098d206SVikas Manocha 	 * this function is called just before we call linux
23*4098d206SVikas Manocha 	 * it prepares the processor for linux
24*4098d206SVikas Manocha 	 *
25*4098d206SVikas Manocha 	 * disable interrupt and turn off caches etc ...
26*4098d206SVikas Manocha 	 */
27*4098d206SVikas Manocha 	disable_interrupts();
28*4098d206SVikas Manocha 	/*
29*4098d206SVikas Manocha 	 * turn off D-cache
30*4098d206SVikas Manocha 	 * dcache_disable() in turn flushes the d-cache
31*4098d206SVikas Manocha 	 * MPU is still enabled & can't be disabled as the u-boot
32*4098d206SVikas Manocha 	 * code might be running in sdram which by default is not
33*4098d206SVikas Manocha 	 * executable area.
34*4098d206SVikas Manocha 	 */
35*4098d206SVikas Manocha 	dcache_disable();
36*4098d206SVikas Manocha 	/* invalidate to make sure no cache line gets dirty between
37*4098d206SVikas Manocha 	 * dcache flushing and disabling dcache */
38*4098d206SVikas Manocha 	invalidate_dcache_all();
39*4098d206SVikas Manocha 
4012d8a729Srev13@wp.pl 	return 0;
4112d8a729Srev13@wp.pl }
4212d8a729Srev13@wp.pl 
4312d8a729Srev13@wp.pl /*
4412d8a729Srev13@wp.pl  * Perform the low-level reset.
4512d8a729Srev13@wp.pl  */
reset_cpu(ulong addr)4612d8a729Srev13@wp.pl void reset_cpu(ulong addr)
4712d8a729Srev13@wp.pl {
4812d8a729Srev13@wp.pl 	/*
4912d8a729Srev13@wp.pl 	 * Perform reset but keep priority group unchanged.
5012d8a729Srev13@wp.pl 	 */
5112d8a729Srev13@wp.pl 	writel((V7M_AIRCR_VECTKEY << V7M_AIRCR_VECTKEY_SHIFT)
5212d8a729Srev13@wp.pl 		| (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK)
5312d8a729Srev13@wp.pl 		| V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
5412d8a729Srev13@wp.pl }
55