blob: 0abe307bb22c747da3da1cebaa3b50f3aa7b8830 [file] [log] [blame]
wdenk8ed96042005-01-09 23:16:25 +00001/*
2 * (C) Copyright 2004 Texas Insturments
3 *
4 * (C) Copyright 2002
5 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Marius Groeger <mgroeger@sysgo.de>
7 *
8 * (C) Copyright 2002
9 * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
10 *
11 * See file CREDITS for list of people who contributed to this
12 * project.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
28 */
29
30/*
31 * CPU specific code
32 */
33
34#include <common.h>
35#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020036#include <asm/system.h>
wdenk8ed96042005-01-09 23:16:25 +000037
Wolfgang Denkd87080b2006-03-31 18:32:53 +020038#ifdef CONFIG_USE_IRQ
39DECLARE_GLOBAL_DATA_PTR;
40#endif
41
wdenk8ed96042005-01-09 23:16:25 +000042static void cp_delay (void)
43{
44 volatile int i;
45
46 /* Many OMAP regs need at least 2 nops */
47 for (i = 0; i < 100; i++);
48}
49
wdenk8ed96042005-01-09 23:16:25 +000050int cpu_init (void)
51{
52 /*
53 * setup up stacks if necessary
54 */
55#ifdef CONFIG_USE_IRQ
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056 IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4;
wdenk8ed96042005-01-09 23:16:25 +000057 FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
58#endif
59 return 0;
60}
61
62int cleanup_before_linux (void)
63{
64 /*
65 * this function is called just before we call linux
66 * it prepares the processor for linux
67 *
68 * we turn off caches etc ...
69 */
70
71 unsigned long i;
72
73 disable_interrupts ();
74
75#ifdef CONFIG_LCD
76 {
77 extern void lcd_disable(void);
78 extern void lcd_panel_disable(void);
79
80 lcd_disable(); /* proper disable of lcd & panel */
81 lcd_panel_disable();
82 }
83#endif
84
85 /* turn off I/D-cache */
86 asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020087 i &= ~(CR_C | CR_I);
wdenk8ed96042005-01-09 23:16:25 +000088 asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
89
90 /* flush I/D-cache */
91 i = 0;
wdenk082acfd2005-01-10 00:01:04 +000092 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i)); /* invalidate both caches and flush btb */
93 asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (i)); /* mem barrier to sync things */
wdenk8ed96042005-01-09 23:16:25 +000094 return(0);
95}
96
97int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
98{
wdenk8ed96042005-01-09 23:16:25 +000099 disable_interrupts ();
100 reset_cpu (0);
101 /*NOTREACHED*/
102 return(0);
103}
104
105void icache_enable (void)
106{
107 ulong reg;
108
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +0200109 reg = get_cr (); /* get control reg. */
wdenk8ed96042005-01-09 23:16:25 +0000110 cp_delay ();
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +0200111 set_cr (reg | CR_I);
wdenk8ed96042005-01-09 23:16:25 +0000112}
113
114void icache_disable (void)
115{
116 ulong reg;
117
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +0200118 reg = get_cr ();
wdenk8ed96042005-01-09 23:16:25 +0000119 cp_delay ();
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +0200120 set_cr (reg & ~CR_I);
wdenk8ed96042005-01-09 23:16:25 +0000121}
122
123int icache_status (void)
124{
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +0200125 return(get_cr () & CR_I) != 0;
wdenk8ed96042005-01-09 23:16:25 +0000126}