]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - cpu/arm_cortexa8/omap3/cache.c
mpc83xx: mpc8313 - handle erratum IPIC1 (TSEC IRQ number swappage)
[karo-tx-uboot.git] / cpu / arm_cortexa8 / omap3 / cache.c
1 /*
2  * (C) Copyright 2008 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  * omap3 L2 cache code
32  */
33
34 #include <common.h>
35 #include <asm/arch/sys_proto.h>
36 #include <asm/cache.h>
37
38 void l2_cache_enable(void)
39 {
40         unsigned long i;
41         volatile unsigned int j;
42
43         /* ES2 onwards we can disable/enable L2 ourselves */
44         if (get_cpu_rev() >= CPU_3XX_ES20) {
45                 __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
46                 __asm__ __volatile__("orr %0, %0, #0x2":"=r"(i));
47                 __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
48         } else {
49                 /* Save r0, r12 and restore them after usage */
50                 __asm__ __volatile__("mov %0, r12":"=r"(j));
51                 __asm__ __volatile__("mov %0, r0":"=r"(i));
52
53                 /*
54                  * GP Device ROM code API usage here
55                  * r12 = AUXCR Write function and r0 value
56                  */
57                 __asm__ __volatile__("mov r12, #0x3");
58                 __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1");
59                 __asm__ __volatile__("orr r0, r0, #0x2");
60                 /* SMI instruction to call ROM Code API */
61                 __asm__ __volatile__(".word 0xE1600070");
62                 __asm__ __volatile__("mov r0, %0":"=r"(i));
63                 __asm__ __volatile__("mov r12, %0":"=r"(j));
64         }
65
66 }
67
68 void l2_cache_disable(void)
69 {
70         unsigned long i;
71         volatile unsigned int j;
72
73         /* ES2 onwards we can disable/enable L2 ourselves */
74         if (get_cpu_rev() >= CPU_3XX_ES20) {
75                 __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
76                 __asm__ __volatile__("bic %0, %0, #0x2":"=r"(i));
77                 __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
78         } else {
79                 /* Save r0, r12 and restore them after usage */
80                 __asm__ __volatile__("mov %0, r12":"=r"(j));
81                 __asm__ __volatile__("mov %0, r0":"=r"(i));
82
83                 /*
84                  * GP Device ROM code API usage here
85                  * r12 = AUXCR Write function and r0 value
86                  */
87                 __asm__ __volatile__("mov r12, #0x3");
88                 __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1");
89                 __asm__ __volatile__("bic r0, r0, #0x2");
90                 /* SMI instruction to call ROM Code API */
91                 __asm__ __volatile__(".word 0xE1600070");
92                 __asm__ __volatile__("mov r0, %0":"=r"(i));
93                 __asm__ __volatile__("mov r12, %0":"=r"(j));
94         }
95 }