]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - cpu/arm1136/cpu.c
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / cpu / arm1136 / cpu.c
1 /*
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, <garyj@denx.de>
10  *
11  * (C) Copyright 2008-2010 Freescale Semiconductor, Inc.
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 /*
33  * CPU specific code
34  */
35
36 #include <common.h>
37 #include <command.h>
38 #include <asm/system.h>
39 #include <asm/cache-cp15.h>
40 #include <asm/mmu.h>
41
42 #define dcache_invalidate_all_l1()      \
43 {       \
44         int i = 0;      \
45         /* Clean and Invalidate Entire Data Cache */       \
46         asm volatile ("mcr p15, 0, %0, c7, c14, 0;"     \
47                         :       \
48                         : "r"(i)        \
49                         : "memory");    \
50         asm volatile ("mcr p15, 0, %0, c8, c7, 0;"      \
51                         :       \
52                         : "r"(i)        \
53                         : "memory"); /* Invalidate i+d-TLBs */  \
54 }
55
56 #define dcache_disable_l1()     \
57 {       \
58         int i = 0;      \
59         asm volatile ("mcr p15, 0, %0, c7, c6, 0;"      \
60                         :       \
61                         : "r"(i)); /* clear data cache */       \
62         asm volatile ("mrc p15, 0, %0, c1, c0, 0;"      \
63                         : "=r"(i));     \
64         i &= (~0x0004); /* disable DCache */    \
65                         /* but not MMU and alignment faults */     \
66         asm volatile ("mcr p15, 0, %0, c1, c0, 0;"      \
67                         :       \
68                         : "r"(i));      \
69 }
70
71 #define icache_invalidate_all_l1()        \
72 {       \
73         /* this macro can discard dirty cache lines (N/A for ICache) */ \
74         int i = 0;      \
75         asm volatile ("mcr p15, 0, %0, c7, c5, 0;"      \
76                         :       \
77                         : "r"(i)); /* flush ICache */   \
78         asm volatile ("mcr p15, 0, %0, c8, c5, 0;"      \
79                         :       \
80                         : "r"(i)); /* flush ITLB only */        \
81         asm volatile ("mcr p15, 0, %0, c7, c5, 4;"      \
82                         :       \
83                         : "r"(i)); /* flush prefetch buffer */  \
84         asm (   \
85         "nop;" /* next few instructions may be via cache */     \
86         "nop;"  \
87         "nop;"  \
88         "nop;"  \
89         "nop;"  \
90         "nop;");        \
91 }
92
93 #define cache_flush()   \
94 {       \
95         dcache_invalidate_all_l1();     \
96         icache_invalidate_all_l1();     \
97 }
98
99 int cleanup_before_linux (void)
100 {
101         /*
102          * this function is called just before we call linux
103          * it prepares the processor for linux
104          *
105          * we turn off caches etc ...
106          */
107
108         disable_interrupts ();
109
110 #ifdef CONFIG_LCD
111         {
112                 extern void lcd_disable(void);
113                 extern void lcd_panel_disable(void);
114
115                 lcd_disable(); /* proper disable of lcd & panel */
116                 lcd_panel_disable();
117         }
118 #endif
119         /* flush I/D-cache */
120         cache_flush();
121
122         /* turn off I/D-cache */
123         icache_disable();
124         dcache_disable();
125
126         /* MMU Off */
127         MMU_OFF();
128
129 /*Workaround to enable L2CC during kernel decompressing*/
130 #ifdef fixup_before_linux
131         fixup_before_linux;
132 #endif
133         return 0;
134 }
135