blob: d9015c6d1a0ba30239e097119e4e063aadea605a [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001#define ASSEMBLY
2#include <asm/linkage.h>
Aubrey.Li3f0606a2007-03-09 13:38:44 +08003#include <config.h>
4#include <asm/blackfin.h>
Mike Frysingerd4d77302008-02-04 19:26:55 -05005#include <asm/mach-common/bits/mpu.h>
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01006
7.text
8.align 2
Aubrey.Li3f0606a2007-03-09 13:38:44 +08009ENTRY(_blackfin_icache_flush_range)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010010 R2 = -32;
11 R2 = R0 & R2;
12 P0 = R2;
13 P1 = R1;
14 CSYNC;
Mike Frysingerd4d77302008-02-04 19:26:55 -050015 1:
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010016 IFLUSH[P0++];
17 CC = P0 < P1(iu);
18 IF CC JUMP 1b(bp);
19 IFLUSH[P0];
20 SSYNC;
21 RTS;
22
Aubrey.Li3f0606a2007-03-09 13:38:44 +080023ENTRY(_blackfin_dcache_flush_range)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010024 R2 = -32;
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010025 R2 = R0 & R2;
26 P0 = R2;
27 P1 = R1;
28 CSYNC;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100291:
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010030 FLUSH[P0++];
31 CC = P0 < P1(iu);
32 IF CC JUMP 1b(bp);
33 FLUSH[P0];
34 SSYNC;
35 RTS;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010036
37ENTRY(_icache_invalidate)
Aubrey.Li3f0606a2007-03-09 13:38:44 +080038ENTRY(_invalidate_entire_icache)
39 [--SP] = (R7:5);
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010040
41 P0.L = (IMEM_CONTROL & 0xFFFF);
42 P0.H = (IMEM_CONTROL >> 16);
Aubrey.Li3f0606a2007-03-09 13:38:44 +080043 R7 =[P0];
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010044
Aubrey Li8440bb12007-03-12 00:25:14 +080045 /*
46 * Clear the IMC bit , All valid bits in the instruction
47 * cache are set to the invalid state
48 */
Aubrey.Li3f0606a2007-03-09 13:38:44 +080049 BITCLR(R7, IMC_P);
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010050 CLI R6;
Aubrey.Li3f0606a2007-03-09 13:38:44 +080051 /* SSYNC required before invalidating cache. */
52 SSYNC;
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010053 .align 8;
54 [P0] = R7;
55 SSYNC;
56 STI R6;
57
58 /* Configures the instruction cache agian */
59 R6 = (IMC | ENICPLB);
60 R7 = R7 | R6;
61
62 CLI R6;
Aubrey.Li3f0606a2007-03-09 13:38:44 +080063 SSYNC;
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010064 .align 8;
65 [P0] = R7;
66 SSYNC;
67 STI R6;
68
Aubrey.Li3f0606a2007-03-09 13:38:44 +080069 (R7:5) =[SP++];
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010070 RTS;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010071
Aubrey Li8db13d62007-03-10 23:49:29 +080072/*
Aubrey.Li3f0606a2007-03-09 13:38:44 +080073 * Invalidate the Entire Data cache by
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010074 * clearing DMC[1:0] bits
75 */
Aubrey.Li3f0606a2007-03-09 13:38:44 +080076ENTRY(_invalidate_entire_dcache)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010077ENTRY(_dcache_invalidate)
Aubrey.Li3f0606a2007-03-09 13:38:44 +080078 [--SP] = (R7:6);
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010079
80 P0.L = (DMEM_CONTROL & 0xFFFF);
81 P0.H = (DMEM_CONTROL >> 16);
Aubrey.Li3f0606a2007-03-09 13:38:44 +080082 R7 =[P0];
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010083
Aubrey Li8440bb12007-03-12 00:25:14 +080084 /*
85 * Clear the DMC[1:0] bits, All valid bits in the data
86 * cache are set to the invalid state
87 */
Aubrey.Li3f0606a2007-03-09 13:38:44 +080088 BITCLR(R7, DMC0_P);
89 BITCLR(R7, DMC1_P);
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010090 CLI R6;
Aubrey.Li3f0606a2007-03-09 13:38:44 +080091 SSYNC;
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010092 .align 8;
93 [P0] = R7;
94 SSYNC;
95 STI R6;
Wolfgang Denk8e7b7032006-03-12 02:55:22 +010096 /* Configures the data cache again */
97
98 R6 = (ACACHE_BCACHE | ENDCPLB | PORT_PREF0);
99 R7 = R7 | R6;
100
101 CLI R6;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800102 SSYNC;
Wolfgang Denk8e7b7032006-03-12 02:55:22 +0100103 .align 8;
104 [P0] = R7;
105 SSYNC;
106 STI R6;
107
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800108 (R7:6) =[SP++];
Wolfgang Denk8e7b7032006-03-12 02:55:22 +0100109 RTS;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100110
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800111ENTRY(_blackfin_dcache_invalidate_range)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100112 R2 = -32;
113 R2 = R0 & R2;
114 P0 = R2;
115 P1 = R1;
116 CSYNC;
1171:
118 FLUSHINV[P0++];
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800119 CC = P0 < P1(iu);
120 IF CC JUMP 1b(bp);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100121
Aubrey Li8440bb12007-03-12 00:25:14 +0800122 /*
123 * If the data crosses a cache line, then we'll be pointing to
124 * the last cache line, but won't have flushed/invalidated it yet, so do
125 * one more.
126 */
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100127 FLUSHINV[P0];
128 SSYNC;
129 RTS;