xref: /openbmc/u-boot/arch/mips/mach-pic32/reset.c (revision d2427caf)
1 /*
2  * (c) 2015 Purna Chandra Mandal <purna.mandal@microchip.com>
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  *
6  */
7 
8 #include <common.h>
9 #include <asm/io.h>
10 #include <mach/pic32.h>
11 
12 /* SYSKEY */
13 #define UNLOCK_KEY1	0xaa996655
14 #define UNLOCK_KEY2	0x556699aa
15 #define LOCK_KEY	0
16 
17 #define RSWRST          0x1250
18 
19 void _machine_restart(void)
20 {
21 	void __iomem *base;
22 
23 	base = pic32_get_syscfg_base();
24 
25 	/* unlock sequence */
26 	writel(LOCK_KEY, base + SYSKEY);
27 	writel(UNLOCK_KEY1, base + SYSKEY);
28 	writel(UNLOCK_KEY2, base + SYSKEY);
29 
30 	/* soft reset */
31 	writel(0x1, base + RSWRST);
32 	(void) readl(base + RSWRST);
33 
34 	while (1)
35 		;
36 }
37