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