xref: /OK3568_Linux_fs/u-boot/arch/nds32/cpu/n1213/ag101/cpu.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * (C) Copyright 2002
3*4882a593Smuzhiyun  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4*4882a593Smuzhiyun  * Marius Groeger <mgroeger@sysgo.de>
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * (C) Copyright 2002
7*4882a593Smuzhiyun  * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * Copyright (C) 2011 Andes Technology Corporation
10*4882a593Smuzhiyun  * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
11*4882a593Smuzhiyun  * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
14*4882a593Smuzhiyun  */
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun /* CPU specific code */
17*4882a593Smuzhiyun #include <common.h>
18*4882a593Smuzhiyun #include <command.h>
19*4882a593Smuzhiyun #include <watchdog.h>
20*4882a593Smuzhiyun #include <asm/cache.h>
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #include <faraday/ftwdt010_wdt.h>
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun  * cleanup_before_linux() is called just before we call linux
26*4882a593Smuzhiyun  * it prepares the processor for linux
27*4882a593Smuzhiyun  *
28*4882a593Smuzhiyun  * we disable interrupt and caches.
29*4882a593Smuzhiyun  */
cleanup_before_linux(void)30*4882a593Smuzhiyun int cleanup_before_linux(void)
31*4882a593Smuzhiyun {
32*4882a593Smuzhiyun 	disable_interrupts();
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun 	/* turn off I/D-cache */
35*4882a593Smuzhiyun 	cache_flush();
36*4882a593Smuzhiyun 	icache_disable();
37*4882a593Smuzhiyun 	dcache_disable();
38*4882a593Smuzhiyun 	return 0;
39*4882a593Smuzhiyun }
40*4882a593Smuzhiyun 
do_reset(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])41*4882a593Smuzhiyun int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
42*4882a593Smuzhiyun {
43*4882a593Smuzhiyun 	disable_interrupts();
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 	/*
46*4882a593Smuzhiyun 	 * reset to the base addr of andesboot.
47*4882a593Smuzhiyun 	 * currently no ROM loader at addr 0.
48*4882a593Smuzhiyun 	 * do not use reset_cpu(0);
49*4882a593Smuzhiyun 	 */
50*4882a593Smuzhiyun #ifdef CONFIG_FTWDT010_WATCHDOG
51*4882a593Smuzhiyun 	/*
52*4882a593Smuzhiyun 	 * workaround: if we use CONFIG_HW_WATCHDOG with ftwdt010, will lead
53*4882a593Smuzhiyun 	 * automatic hardware reset when booting Linux.
54*4882a593Smuzhiyun 	 * Please do not use CONFIG_HW_WATCHDOG and WATCHDOG_RESET() here.
55*4882a593Smuzhiyun 	 */
56*4882a593Smuzhiyun 	ftwdt010_wdt_reset();
57*4882a593Smuzhiyun 	while (1)
58*4882a593Smuzhiyun 		;
59*4882a593Smuzhiyun #endif /* CONFIG_FTWDT010_WATCHDOG */
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun 	/*NOTREACHED*/
62*4882a593Smuzhiyun }
63