Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/mach-common/cacheinit.S |
| 3 | * Based on: |
| 4 | * Author: LG Soft India |
| 5 | * |
| 6 | * Created: ? |
| 7 | * Description: cache initialization |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright 2004-2006 Analog Devices Inc. |
| 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (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, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
| 30 | /* This function sets up the data and instruction cache. The |
| 31 | * tables like icplb table, dcplb table and Page Descriptor table |
| 32 | * are defined in cplbtab.h. You can configure those tables for |
| 33 | * your suitable requirements |
| 34 | */ |
| 35 | |
| 36 | #include <linux/linkage.h> |
| 37 | #include <asm/blackfin.h> |
| 38 | |
| 39 | .text |
| 40 | |
| 41 | #if defined(CONFIG_BLKFIN_CACHE) |
| 42 | ENTRY(_bfin_icache_init) |
| 43 | |
| 44 | /* Initialize Instruction CPLBS */ |
| 45 | |
| 46 | I0.L = (ICPLB_ADDR0 & 0xFFFF); |
| 47 | I0.H = (ICPLB_ADDR0 >> 16); |
| 48 | |
| 49 | I1.L = (ICPLB_DATA0 & 0xFFFF); |
| 50 | I1.H = (ICPLB_DATA0 >> 16); |
| 51 | |
| 52 | I2.L = _icplb_table; |
| 53 | I2.H = _icplb_table; |
| 54 | |
| 55 | r1 = -1; /* end point comparison */ |
| 56 | r3 = 15; /* max counter */ |
| 57 | |
| 58 | /* read entries from table */ |
| 59 | |
| 60 | .Lread_iaddr: |
| 61 | R0 = [I2++]; |
| 62 | CC = R0 == R1; |
| 63 | IF CC JUMP .Lidone; |
| 64 | [I0++] = R0; |
| 65 | |
| 66 | .Lread_idata: |
| 67 | R2 = [I2++]; |
| 68 | [I1++] = R2; |
| 69 | R3 = R3 + R1; |
| 70 | CC = R3 == R1; |
| 71 | IF !CC JUMP .Lread_iaddr; |
| 72 | |
| 73 | .Lidone: |
| 74 | /* Enable Instruction Cache */ |
| 75 | P0.l = (IMEM_CONTROL & 0xFFFF); |
| 76 | P0.h = (IMEM_CONTROL >> 16); |
| 77 | R1 = [P0]; |
| 78 | R0 = (IMC | ENICPLB); |
| 79 | R0 = R0 | R1; |
| 80 | |
| 81 | /* Anomaly 05000125 */ |
| 82 | CLI R2; |
| 83 | SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */ |
| 84 | .align 8; |
| 85 | [P0] = R0; |
| 86 | SSYNC; |
| 87 | STI R2; |
| 88 | RTS; |
Mike Frysinger | 51be24c | 2007-06-11 15:31:30 +0800 | [diff] [blame^] | 89 | |
| 90 | ENDPROC(_bfin_icache_init) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 91 | #endif |
| 92 | |
| 93 | #if defined(CONFIG_BLKFIN_DCACHE) |
| 94 | ENTRY(_bfin_dcache_init) |
| 95 | |
| 96 | /* Initialize Data CPLBS */ |
| 97 | |
| 98 | I0.L = (DCPLB_ADDR0 & 0xFFFF); |
| 99 | I0.H = (DCPLB_ADDR0 >> 16); |
| 100 | |
| 101 | I1.L = (DCPLB_DATA0 & 0xFFFF); |
| 102 | I1.H = (DCPLB_DATA0 >> 16); |
| 103 | |
| 104 | I2.L = _dcplb_table; |
| 105 | I2.H = _dcplb_table; |
| 106 | |
| 107 | R1 = -1; /* end point comparison */ |
| 108 | R3 = 15; /* max counter */ |
| 109 | |
| 110 | /* read entries from table */ |
| 111 | .Lread_daddr: |
| 112 | R0 = [I2++]; |
| 113 | cc = R0 == R1; |
| 114 | IF CC JUMP .Lddone; |
| 115 | [I0++] = R0; |
| 116 | |
| 117 | .Lread_ddata: |
| 118 | R2 = [I2++]; |
| 119 | [I1++] = R2; |
| 120 | R3 = R3 + R1; |
| 121 | CC = R3 == R1; |
| 122 | IF !CC JUMP .Lread_daddr; |
| 123 | .Lddone: |
| 124 | P0.L = (DMEM_CONTROL & 0xFFFF); |
| 125 | P0.H = (DMEM_CONTROL >> 16); |
| 126 | R1 = [P0]; |
| 127 | |
| 128 | R0 = DMEM_CNTR; |
| 129 | |
| 130 | R0 = R0 | R1; |
| 131 | /* Anomaly 05000125 */ |
| 132 | CLI R2; |
| 133 | SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */ |
| 134 | .align 8; |
| 135 | [P0] = R0; |
| 136 | SSYNC; |
| 137 | STI R2; |
| 138 | RTS; |
Mike Frysinger | 51be24c | 2007-06-11 15:31:30 +0800 | [diff] [blame^] | 139 | |
| 140 | ENDPROC(_bfin_dcache_init) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 141 | #endif |