3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
36 #include <asm/hardware.h>
41 * setup up stacks if necessary
44 DECLARE_GLOBAL_DATA_PTR;
46 IRQ_STACK_START = _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4;
47 FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
52 int cleanup_before_linux (void)
55 * this function is called just before we call linux
56 * it prepares the processor for linux
58 * we turn off caches etc ...
59 * and we set the CPU-speed to 73 MHz - see start.S for details
62 #if defined(CONFIG_IMPA7) || defined(CONFIG_EP7312)
65 disable_interrupts ();
67 /* turn off I-cache */
68 asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
70 asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
73 asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
74 #ifdef CONFIG_ARM7_REVD
75 /* go to high speed */
76 IO_SYSCON3 = (IO_SYSCON3 & ~CLKCTL) | CLKCTL_73;
78 #elif defined(CONFIG_NETARM) || defined(CONFIG_S3C4510B)
79 disable_interrupts ();
80 /* Nothing more needed */
82 #error No cleanup_before_linux() defined for this CPU type
87 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
89 extern void reset_cpu (ulong addr);
91 disable_interrupts ();
98 * Instruction and Data cache enable and disable functions
102 #if defined(CONFIG_IMPA7) || defined(CONFIG_EP7312) || defined(CONFIG_NETARM)
103 /* read co-processor 15, register #1 (control register) */
104 static unsigned long read_p15_c1(void)
108 __asm__ __volatile__(
109 "mrc p15, 0, %0, c1, c0, 0 @ read control reg\n"
113 /* printf("p15/c1 is = %08lx\n", value); */
117 /* write to co-processor 15, register #1 (control register) */
118 static void write_p15_c1(unsigned long value)
120 /* printf("write %08lx to p15/c1\n", value); */
121 __asm__ __volatile__(
122 "mcr p15, 0, %0, c1, c0, 0 @ write it back\n"
130 static void cp_delay (void)
134 /* copro seems to need some delay between reading and writing */
135 for (i = 0; i < 100; i++);
138 /* See also ARM Ref. Man. */
139 #define C1_MMU (1<<0) /* mmu off/on */
140 #define C1_ALIGN (1<<1) /* alignment faults off/on */
141 #define C1_IDC (1<<2) /* icache and/or dcache off/on */
142 #define C1_WRITE_BUFFER (1<<3) /* write buffer off/on */
143 #define C1_BIG_ENDIAN (1<<7) /* big endian off/on */
144 #define C1_SYS_PROT (1<<8) /* system protection */
145 #define C1_ROM_PROT (1<<9) /* ROM protection */
146 #define C1_HIGH_VECTORS (1<<13) /* location of vectors: low/high addresses */
148 void icache_enable (void)
152 reg = read_p15_c1 ();
154 write_p15_c1 (reg | C1_IDC);
157 void icache_disable (void)
161 reg = read_p15_c1 ();
163 write_p15_c1 (reg & ~C1_IDC);
166 int icache_status (void)
168 return (read_p15_c1 () & C1_IDC) != 0;
171 void dcache_enable (void)
175 reg = read_p15_c1 ();
177 write_p15_c1 (reg | C1_IDC);
180 void dcache_disable (void)
184 reg = read_p15_c1 ();
186 write_p15_c1 (reg & ~C1_IDC);
189 int dcache_status (void)
191 return (read_p15_c1 () & C1_IDC) != 0;
194 #elif defined(CONFIG_S3C4510B)
196 void icache_enable (void)
200 /* disable all cache bits */
201 CLR_REG( REG_SYSCFG, 0x3F);
203 /* 8KB cache, write enable */
204 SET_REG( REG_SYSCFG, CACHE_WRITE_BUFF | CACHE_MODE_01);
206 /* clear TAG RAM bits */
207 for ( i = 0; i < 256; i++)
208 PUT_REG( CACHE_TAG_RAM + 4*i, 0x00000000);
211 for(i=0; i < 1024; i++)
212 PUT_REG( CACHE_SET0_RAM + 4*i, 0x00000000);
215 for(i=0; i < 1024; i++)
216 PUT_REG( CACHE_SET1_RAM + 4*i, 0x00000000);
219 SET_REG( REG_SYSCFG, CACHE_ENABLE);
223 void icache_disable (void)
225 /* disable all cache bits */
226 CLR_REG( REG_SYSCFG, 0x3F);
229 int icache_status (void)
231 return GET_REG( REG_SYSCFG) & CACHE_ENABLE;
234 void dcache_enable (void)
236 /* we don't have seperate instruction/data caches */
240 void dcache_disable (void)
242 /* we don't have seperate instruction/data caches */
246 int dcache_status (void)
248 /* we don't have seperate instruction/data caches */
249 return icache_status();
253 #error No icache/dcache enable/disable functions defined for this CPU type