blob: f81ebc9ba299530c19413506eb9248688b623356 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk4a9cbbe2002-08-27 09:48:53 +00002/*
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 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
9 * Alex Zuepke <azu@sysgo.de>
wdenk4a9cbbe2002-08-27 09:48:53 +000010 */
11
12/*
13 * CPU specific code
14 */
15
16#include <common.h>
17#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020018#include <asm/system.h>
Albert ARIBAUDcd6cc342014-04-15 16:13:48 +020019#include <asm/io.h>
wdenk4a9cbbe2002-08-27 09:48:53 +000020
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020021static void cache_flush(void);
22
wdenk4a9cbbe2002-08-27 09:48:53 +000023int cleanup_before_linux (void)
24{
25 /*
26 * this function is called just before we call linux
27 * it prepares the processor for linux
28 *
29 * just disable everything that can disturb booting linux
30 */
31
wdenk4a9cbbe2002-08-27 09:48:53 +000032 disable_interrupts ();
33
34 /* turn off I-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020035 icache_disable();
36 dcache_disable();
wdenk4a9cbbe2002-08-27 09:48:53 +000037
38 /* flush I-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020039 cache_flush();
wdenk4a9cbbe2002-08-27 09:48:53 +000040
41 return (0);
42}
43
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020044/* flush I/D-cache */
45static void cache_flush (void)
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020046{
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020047 unsigned long i = 0;
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020048
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020049 asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
wdenk4a9cbbe2002-08-27 09:48:53 +000050}
Albert ARIBAUDcd6cc342014-04-15 16:13:48 +020051
52#define RST_BASE 0x90030000
53#define RSRR 0x00
54#define RCSR 0x04
55
56__attribute__((noreturn)) void reset_cpu(ulong addr __attribute__((unused)))
57{
58 /* repeat endlessly */
59 while (1) {
60 writel(0, RST_BASE + RCSR);
61 writel(1, RST_BASE + RSRR);
62 }
63}