xref: /openbmc/u-boot/arch/nds32/cpu/n1213/ag101/cpu.c (revision 47fde91f)
1 /*
2  * (C) Copyright 2002
3  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4  * Marius Groeger <mgroeger@sysgo.de>
5  *
6  * (C) Copyright 2002
7  * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
8  *
9  * Copyright (C) 2011 Andes Technology Corporation
10  * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
11  * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
12  *
13  * See file CREDITS for list of people who contributed to this
14  * project.
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License as
18  * published by the Free Software Foundation; either version 2 of
19  * the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29  * MA 02111-1307 USA
30  */
31 
32 /* CPU specific code */
33 #include <common.h>
34 #include <command.h>
35 #include <watchdog.h>
36 #include <asm/cache.h>
37 
38 #include <faraday/ftwdt010_wdt.h>
39 
40 /*
41  * cleanup_before_linux() is called just before we call linux
42  * it prepares the processor for linux
43  *
44  * we disable interrupt and caches.
45  */
46 int cleanup_before_linux(void)
47 {
48 	disable_interrupts();
49 
50 #ifdef CONFIG_MMU
51 	/* turn off I/D-cache */
52 	icache_disable();
53 	dcache_disable();
54 
55 	/* flush I/D-cache */
56 	invalidate_icac();
57 	invalidate_dcac();
58 #endif
59 
60 	return 0;
61 }
62 
63 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
64 {
65 	disable_interrupts();
66 
67 	/*
68 	 * reset to the base addr of andesboot.
69 	 * currently no ROM loader at addr 0.
70 	 * do not use reset_cpu(0);
71 	 */
72 #ifdef CONFIG_FTWDT010_WATCHDOG
73 	/*
74 	 * workaround: if we use CONFIG_HW_WATCHDOG with ftwdt010, will lead
75 	 * automatic hardware reset when booting Linux.
76 	 * Please do not use CONFIG_HW_WATCHDOG and WATCHDOG_RESET() here.
77 	 */
78 	ftwdt010_wdt_reset();
79 	while (1)
80 		;
81 #endif /* CONFIG_FTWDT010_WATCHDOG */
82 
83 	/*NOTREACHED*/
84 }
85