1 /* 2 * CPU-specific routines from U-Boot. 3 * See: uboot-xburst/files/arch/mips/cpu/xburst/cpu.c 4 * See: u-boot/arch/mips/include/asm/cacheops.h 5 * 6 * Copyright (C) 2000-2009 Wolfgang Denk, DENX Software Engineering, <wd@denx.de> 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as 10 * published by the Free Software Foundation; either version 2 of 11 * the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA 22 */ 23 24 #include "xburst_types.h" 25 #include "sdram.h" 26 27 void flush_icache_all(void) 28 { 29 u32 addr, t = 0; 30 31 asm volatile ("mtc0 $0, $28"); /* Clear Taglo */ 32 asm volatile ("mtc0 $0, $29"); /* Clear TagHi */ 33 34 for (addr = KSEG0; addr < KSEG0 + CONFIG_SYS_ICACHE_SIZE; 35 addr += CONFIG_SYS_CACHELINE_SIZE) { 36 asm volatile ( 37 ".set mips3\n\t" 38 " cache %0, 0(%1)\n\t" 39 ".set mips2\n\t" 40 : 41 : "I" (Index_Store_Tag_I), "r"(addr)); 42 } 43 44 /* invalicate btb */ 45 asm volatile ( 46 ".set mips32\n\t" 47 "mfc0 %0, $16, 7\n\t" 48 "nop\n\t" 49 "ori %0,2\n\t" 50 "mtc0 %0, $16, 7\n\t" 51 ".set mips2\n\t" 52 : 53 : "r" (t)); 54 } 55 56 void flush_dcache_all(void) 57 { 58 u32 addr; 59 60 for (addr = KSEG0; addr < KSEG0 + CONFIG_SYS_DCACHE_SIZE; 61 addr += CONFIG_SYS_CACHELINE_SIZE) { 62 asm volatile ( 63 ".set mips3\n\t" 64 " cache %0, 0(%1)\n\t" 65 ".set mips2\n\t" 66 : 67 : "I" (Index_Writeback_Inv_D), "r"(addr)); 68 } 69 70 asm volatile ("sync"); 71 } 72 73 void flush_cache_all(void) 74 { 75 flush_dcache_all(); 76 flush_icache_all(); 77 } 78 79 void enable_interrupts(void) 80 { 81 asm volatile( 82 "mfc0 $t3, $12\n" /* CP0_STATUS */ 83 "nop\n" 84 "li $t4, 0x00000001\n" /* IE = enable interrupts */ 85 "or $t3, $t3, $t4\n" 86 "mtc0 $t3, $12\n" 87 "nop\n"); 88 }