2 * U-boot - traps.c Routines related to interrupts and exceptions
4 * Copyright (c) 2005 blackfin.uclinux.org
6 * This file is based on
7 * No original Copyright holder listed,
8 * Probabily original (C) Roman Zippel (assigned DJD, 1999)
10 * Copyright 2003 Metrowerks - for Blackfin
11 * Copyright 2000-2001 Lineo, Inc. D. Jeff Dionne <jeff@lineo.ca>
12 * Copyright 1999-2000 D. Jeff Dionne, <jeff@uclinux.org>
14 * (C) Copyright 2000-2004
15 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
17 * See file CREDITS for list of people who contributed to this
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License as
22 * published by the Free Software Foundation; either version 2 of
23 * the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 #include <linux/types.h>
38 #include <asm/errno.h>
40 #include <asm/system.h>
41 #include <asm/traps.h>
43 #include <asm/machdep.h>
45 #include <asm/arch/anomaly.h>
49 #define pr_debug(fmt,arg...) printf(fmt,##arg)
52 __attribute__ ((format(printf, 1, 2))) pr_debug(const char *fmt, ...)
64 void process_int(unsigned long vec, struct pt_regs *fp)
66 printf("interrupt\n");
70 extern unsigned int icplb_table[page_descriptor_table_size][2];
71 extern unsigned int dcplb_table[page_descriptor_table_size][2];
73 unsigned long last_cplb_fault_retx;
75 static unsigned int cplb_sizes[4] =
76 { 1024, 4 * 1024, 1024 * 1024, 4 * 1024 * 1024 };
78 void trap_c(struct pt_regs *regs)
81 unsigned long trapnr = (regs->seqstat) & SEQSTAT_EXCAUSE;
82 unsigned int i, j, size, *I0, *I1;
83 unsigned short data = 0;
86 /* 0x26 - Data CPLB Miss */
89 #ifdef ANOMALY_05000261
91 * Work around an anomaly: if we see a new DCPLB fault,
92 * return without doing anything. Then,
93 * if we get the same fault again, handle it.
95 addr = last_cplb_fault_retx;
96 last_cplb_fault_retx = regs->retx;
97 printf("this time, curr = 0x%08x last = 0x%08x\n",
98 addr, last_cplb_fault_retx);
99 if (addr != last_cplb_fault_retx)
107 addr = *pDCPLB_FAULT_ADDR;
109 addr = *pICPLB_FAULT_ADDR;
111 for (i = 0; i < page_descriptor_table_size; i++) {
113 size = cplb_sizes[dcplb_table[i][1] >> 16];
114 j = dcplb_table[i][0];
116 size = cplb_sizes[icplb_table[i][1] >> 16];
117 j = icplb_table[i][0];
119 if ((j <= addr) && ((j + size) > addr)) {
120 pr_debug("found %i 0x%08x\n", i, j);
124 if (i == page_descriptor_table_size) {
125 printf("something is really wrong\n");
126 do_reset(NULL, 0, 0, NULL);
129 /* Turn the cache off */
131 __builtin_bfin_ssync();
133 *(unsigned int *)DMEM_CONTROL &=
134 ~(ACACHE_BCACHE | ENDCPLB | PORT_PREF0);
135 __builtin_bfin_ssync();
137 __builtin_bfin_ssync();
139 *(unsigned int *)IMEM_CONTROL &= ~(IMC | ENICPLB);
140 __builtin_bfin_ssync();
144 I0 = (unsigned int *)DCPLB_ADDR0;
145 I1 = (unsigned int *)DCPLB_DATA0;
147 I0 = (unsigned int *)ICPLB_ADDR0;
148 I1 = (unsigned int *)ICPLB_DATA0;
152 while (*I1 & CPLB_LOCK) {
153 pr_debug("skipping %i %08p - %08x\n", j, I1, *I1);
159 pr_debug("remove %i 0x%08x 0x%08x\n", j, *I0, *I1);
161 for (; j < 15; j++) {
162 pr_debug("replace %i 0x%08x 0x%08x\n", j, I0, I0 + 1);
168 *I0 = dcplb_table[i][0];
169 *I1 = dcplb_table[i][1];
170 I0 = (unsigned int *)DCPLB_ADDR0;
171 I1 = (unsigned int *)DCPLB_DATA0;
173 *I0 = icplb_table[i][0];
174 *I1 = icplb_table[i][1];
175 I0 = (unsigned int *)ICPLB_ADDR0;
176 I1 = (unsigned int *)ICPLB_DATA0;
179 for (j = 0; j < 16; j++) {
180 pr_debug("%i 0x%08x 0x%08x\n", j, *I0++, *I1++);
183 /* Turn the cache back on */
185 j = *(unsigned int *)DMEM_CONTROL;
186 __builtin_bfin_ssync();
188 *(unsigned int *)DMEM_CONTROL =
189 ACACHE_BCACHE | ENDCPLB | PORT_PREF0 | j;
190 __builtin_bfin_ssync();
192 __builtin_bfin_ssync();
194 *(unsigned int *)IMEM_CONTROL = IMC | ENICPLB;
195 __builtin_bfin_ssync();
200 /* All traps come here */
201 printf("code=[0x%x], ", (unsigned int)(regs->seqstat & 0x3f));
202 printf("stack frame=0x%x, ", (unsigned int)regs);
203 printf("bad PC=0x%04x\n", (unsigned int)regs->pc);
207 printf("Unhandled IRQ or exceptions!\n");
208 printf("Please reset the board \n");
209 do_reset(NULL, 0, 0, NULL);
217 void dump(struct pt_regs *fp)
219 pr_debug("RETE: %08lx RETN: %08lx RETX: %08lx RETS: %08lx\n",
220 fp->rete, fp->retn, fp->retx, fp->rets);
221 pr_debug("IPEND: %04lx SYSCFG: %04lx\n", fp->ipend, fp->syscfg);
222 pr_debug("SEQSTAT: %08lx SP: %08lx\n", (long)fp->seqstat, (long)fp);
223 pr_debug("R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n",
224 fp->r0, fp->r1, fp->r2, fp->r3);
225 pr_debug("R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n",
226 fp->r4, fp->r5, fp->r6, fp->r7);
227 pr_debug("P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n",
228 fp->p0, fp->p1, fp->p2, fp->p3);
229 pr_debug("P4: %08lx P5: %08lx FP: %08lx\n",
230 fp->p4, fp->p5, fp->fp);
231 pr_debug("A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
232 fp->a0w, fp->a0x, fp->a1w, fp->a1x);
234 pr_debug("LB0: %08lx LT0: %08lx LC0: %08lx\n",
235 fp->lb0, fp->lt0, fp->lc0);
236 pr_debug("LB1: %08lx LT1: %08lx LC1: %08lx\n",
237 fp->lb1, fp->lt1, fp->lc1);
238 pr_debug("B0: %08lx L0: %08lx M0: %08lx I0: %08lx\n",
239 fp->b0, fp->l0, fp->m0, fp->i0);
240 pr_debug("B1: %08lx L1: %08lx M1: %08lx I1: %08lx\n",
241 fp->b1, fp->l1, fp->m1, fp->i1);
242 pr_debug("B2: %08lx L2: %08lx M2: %08lx I2: %08lx\n",
243 fp->b2, fp->l2, fp->m2, fp->i2);
244 pr_debug("B3: %08lx L3: %08lx M3: %08lx I3: %08lx\n",
245 fp->b3, fp->l3, fp->m3, fp->i3);
247 pr_debug("DCPLB_FAULT_ADDR=%p\n", *pDCPLB_FAULT_ADDR);
248 pr_debug("ICPLB_FAULT_ADDR=%p\n", *pICPLB_FAULT_ADDR);