wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * (C) Copyright 2002 (440 port) |
| 6 | * Scott McNutt, Artesyn Communication Producs, smcnutt@artsyncp.com |
| 7 | * |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 8 | * (C) Copyright 2003 (440GX port) |
| 9 | * Travis B. Sawyer, Sandburst Corporation, tsawyer@sandburst.com |
| 10 | * |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 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 | #include <common.h> |
| 31 | #include <watchdog.h> |
| 32 | #include <command.h> |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 33 | #include <asm/processor.h> |
| 34 | #include <ppc4xx.h> |
| 35 | #include <ppc_asm.tmpl> |
| 36 | #include <commproc.h> |
| 37 | #include "vecnum.h" |
| 38 | |
| 39 | /****************************************************************************/ |
| 40 | |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 41 | /* |
| 42 | * CPM interrupt vector functions. |
| 43 | */ |
| 44 | struct irq_action { |
| 45 | interrupt_handler_t *handler; |
| 46 | void *arg; |
| 47 | int count; |
| 48 | }; |
| 49 | |
| 50 | static struct irq_action irq_vecs[32]; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 51 | void uic0_interrupt( void * parms); /* UIC0 handler */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 52 | |
| 53 | #if defined(CONFIG_440) |
| 54 | static struct irq_action irq_vecs1[32]; /* For UIC1 */ |
| 55 | |
| 56 | void uic1_interrupt( void * parms); /* UIC1 handler */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 57 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 58 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 59 | static struct irq_action irq_vecs2[32]; /* For UIC2 */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 60 | void uic2_interrupt( void * parms); /* UIC2 handler */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 61 | #endif /* CONFIG_440GX CONFIG_440SPE */ |
| 62 | |
| 63 | #if defined(CONFIG_440SPE) |
| 64 | static struct irq_action irq_vecs3[32]; /* For UIC3 */ |
| 65 | void uic3_interrupt( void * parms); /* UIC3 handler */ |
| 66 | #endif /* CONFIG_440SPE */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 67 | |
| 68 | #endif /* CONFIG_440 */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 69 | |
| 70 | /****************************************************************************/ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 71 | #if defined(CONFIG_440) |
| 72 | |
| 73 | /* SPRN changed in 440 */ |
| 74 | static __inline__ void set_evpr(unsigned long val) |
| 75 | { |
| 76 | asm volatile("mtspr 0x03f,%0" : : "r" (val)); |
| 77 | } |
| 78 | |
| 79 | #else /* !defined(CONFIG_440) */ |
| 80 | |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 81 | static __inline__ void set_pit(unsigned long val) |
| 82 | { |
| 83 | asm volatile("mtpit %0" : : "r" (val)); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | static __inline__ void set_tcr(unsigned long val) |
| 88 | { |
| 89 | asm volatile("mttcr %0" : : "r" (val)); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | static __inline__ void set_evpr(unsigned long val) |
| 94 | { |
| 95 | asm volatile("mtevpr %0" : : "r" (val)); |
| 96 | } |
| 97 | #endif /* defined(CONFIG_440 */ |
| 98 | |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 99 | /****************************************************************************/ |
| 100 | |
wdenk | c0aa5c5 | 2003-12-06 19:49:23 +0000 | [diff] [blame] | 101 | int interrupt_init_cpu (unsigned *decrementer_count) |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 102 | { |
| 103 | DECLARE_GLOBAL_DATA_PTR; |
| 104 | |
| 105 | int vec; |
| 106 | unsigned long val; |
| 107 | |
wdenk | c0aa5c5 | 2003-12-06 19:49:23 +0000 | [diff] [blame] | 108 | /* decrementer is automatically reloaded */ |
| 109 | *decrementer_count = 0; |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 110 | |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 111 | /* |
| 112 | * Mark all irqs as free |
| 113 | */ |
| 114 | for (vec=0; vec<32; vec++) { |
| 115 | irq_vecs[vec].handler = NULL; |
| 116 | irq_vecs[vec].arg = NULL; |
| 117 | irq_vecs[vec].count = 0; |
| 118 | #if defined(CONFIG_440) |
| 119 | irq_vecs1[vec].handler = NULL; |
| 120 | irq_vecs1[vec].arg = NULL; |
| 121 | irq_vecs1[vec].count = 0; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 122 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 123 | irq_vecs2[vec].handler = NULL; |
| 124 | irq_vecs2[vec].arg = NULL; |
| 125 | irq_vecs2[vec].count = 0; |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 126 | #endif /* CONFIG_440GX */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 127 | #if defined(CONFIG_440SPE) |
| 128 | irq_vecs3[vec].handler = NULL; |
| 129 | irq_vecs3[vec].arg = NULL; |
| 130 | irq_vecs3[vec].count = 0; |
| 131 | #endif /* CONFIG_440SPE */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 132 | #endif |
| 133 | } |
| 134 | |
| 135 | #ifdef CONFIG_4xx |
| 136 | /* |
| 137 | * Init PIT |
| 138 | */ |
| 139 | #if defined(CONFIG_440) |
| 140 | val = mfspr( tcr ); |
| 141 | val &= (~0x04400000); /* clear DIS & ARE */ |
| 142 | mtspr( tcr, val ); |
| 143 | mtspr( dec, 0 ); /* Prevent exception after TSR clear*/ |
| 144 | mtspr( decar, 0 ); /* clear reload */ |
| 145 | mtspr( tsr, 0x08000000 ); /* clear DEC status */ |
stroese | 4b31de8 | 2005-04-07 05:32:44 +0000 | [diff] [blame] | 146 | val = gd->bd->bi_intfreq/1000; /* 1 msec */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 147 | mtspr( decar, val ); /* Set auto-reload value */ |
| 148 | mtspr( dec, val ); /* Set inital val */ |
| 149 | #else |
| 150 | set_pit(gd->bd->bi_intfreq / 1000); |
| 151 | #endif |
| 152 | #endif /* CONFIG_4xx */ |
| 153 | |
| 154 | #ifdef CONFIG_ADCIOP |
| 155 | /* |
| 156 | * Init PIT |
| 157 | */ |
| 158 | set_pit(66000); |
| 159 | #endif |
| 160 | |
| 161 | /* |
| 162 | * Enable PIT |
| 163 | */ |
| 164 | val = mfspr(tcr); |
| 165 | val |= 0x04400000; |
| 166 | mtspr(tcr, val); |
| 167 | |
| 168 | /* |
| 169 | * Set EVPR to 0 |
| 170 | */ |
| 171 | set_evpr(0x00000000); |
| 172 | |
| 173 | #if defined(CONFIG_440) |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 174 | #if !defined(CONFIG_440GX) |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 175 | /* Install the UIC1 handlers */ |
| 176 | irq_install_handler(VECNUM_UIC1NC, uic1_interrupt, 0); |
| 177 | irq_install_handler(VECNUM_UIC1C, uic1_interrupt, 0); |
| 178 | #endif |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 179 | #endif |
| 180 | |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 181 | #if defined(CONFIG_440GX) |
wdenk | e28cf63 | 2004-03-14 15:20:55 +0000 | [diff] [blame] | 182 | /* Take the GX out of compatibility mode |
| 183 | * Travis Sawyer, 9 Mar 2004 |
| 184 | * NOTE: 440gx user manual inconsistency here |
| 185 | * Compatibility mode and Ethernet Clock select are not |
| 186 | * correct in the manual |
| 187 | */ |
| 188 | mfsdr(sdr_mfr, val); |
| 189 | val &= ~0x10000000; |
| 190 | mtsdr(sdr_mfr,val); |
| 191 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 192 | /* Enable UIC interrupts via UIC Base Enable Register */ |
wdenk | e28cf63 | 2004-03-14 15:20:55 +0000 | [diff] [blame] | 193 | mtdcr(uicb0sr, UICB0_ALL); |
| 194 | mtdcr(uicb0er, 0x54000000); |
| 195 | /* None are critical */ |
| 196 | mtdcr(uicb0cr, 0); |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 197 | #endif |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 198 | |
| 199 | return (0); |
| 200 | } |
| 201 | |
| 202 | /****************************************************************************/ |
| 203 | |
| 204 | /* |
| 205 | * Handle external interrupts |
| 206 | */ |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 207 | #if defined(CONFIG_440GX) |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 208 | void external_interrupt(struct pt_regs *regs) |
| 209 | { |
| 210 | ulong uic_msr; |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 211 | |
| 212 | /* |
| 213 | * Read masked interrupt status register to determine interrupt source |
| 214 | */ |
| 215 | /* 440 GX uses base uic register */ |
| 216 | uic_msr = mfdcr(uicb0msr); |
| 217 | |
wdenk | e28cf63 | 2004-03-14 15:20:55 +0000 | [diff] [blame] | 218 | if ( (UICB0_UIC0CI & uic_msr) || (UICB0_UIC0NCI & uic_msr) ) |
| 219 | uic0_interrupt(0); |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 220 | |
wdenk | e28cf63 | 2004-03-14 15:20:55 +0000 | [diff] [blame] | 221 | if ( (UICB0_UIC1CI & uic_msr) || (UICB0_UIC1NCI & uic_msr) ) |
| 222 | uic1_interrupt(0); |
| 223 | |
| 224 | if ( (UICB0_UIC2CI & uic_msr) || (UICB0_UIC2NCI & uic_msr) ) |
| 225 | uic2_interrupt(0); |
| 226 | |
| 227 | mtdcr(uicb0sr, uic_msr); |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 228 | |
| 229 | return; |
| 230 | |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 231 | } /* external_interrupt CONFIG_440GX */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 232 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 233 | #elif defined(CONFIG_440SPE) |
| 234 | void external_interrupt(struct pt_regs *regs) |
| 235 | { |
| 236 | ulong uic_msr; |
| 237 | |
| 238 | /* |
| 239 | * Read masked interrupt status register to determine interrupt source |
| 240 | */ |
| 241 | /* 440 SPe uses base uic register */ |
| 242 | uic_msr = mfdcr(uic0msr); |
| 243 | |
| 244 | if ( (UICB0_UIC1CI & uic_msr) || (UICB0_UIC1NCI & uic_msr) ) |
| 245 | uic1_interrupt(0); |
| 246 | |
| 247 | if ( (UICB0_UIC2CI & uic_msr) || (UICB0_UIC2NCI & uic_msr) ) |
| 248 | uic2_interrupt(0); |
| 249 | |
| 250 | if ( (UICB0_UIC3CI & uic_msr) || (UICB0_UIC3NCI & uic_msr) ) |
| 251 | uic3_interrupt(0); |
| 252 | |
| 253 | if (uic_msr & ~(UICB0_ALL)) |
| 254 | uic0_interrupt(0); |
| 255 | |
| 256 | mtdcr(uic0sr, uic_msr); |
| 257 | |
| 258 | return; |
| 259 | } /* external_interrupt CONFIG_440SPE */ |
| 260 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 261 | #else |
| 262 | |
| 263 | void external_interrupt(struct pt_regs *regs) |
| 264 | { |
| 265 | ulong uic_msr; |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 266 | ulong msr_shift; |
| 267 | int vec; |
| 268 | |
| 269 | /* |
| 270 | * Read masked interrupt status register to determine interrupt source |
| 271 | */ |
| 272 | uic_msr = mfdcr(uicmsr); |
| 273 | msr_shift = uic_msr; |
| 274 | vec = 0; |
| 275 | |
| 276 | while (msr_shift != 0) { |
| 277 | if (msr_shift & 0x80000000) { |
| 278 | /* |
| 279 | * Increment irq counter (for debug purpose only) |
| 280 | */ |
| 281 | irq_vecs[vec].count++; |
| 282 | |
| 283 | if (irq_vecs[vec].handler != NULL) { |
| 284 | /* call isr */ |
| 285 | (*irq_vecs[vec].handler)(irq_vecs[vec].arg); |
| 286 | } else { |
| 287 | mtdcr(uicer, mfdcr(uicer) & ~(0x80000000 >> vec)); |
| 288 | printf ("Masking bogus interrupt vector 0x%x\n", vec); |
| 289 | } |
| 290 | |
| 291 | /* |
| 292 | * After servicing the interrupt, we have to remove the status indicator. |
| 293 | */ |
| 294 | mtdcr(uicsr, (0x80000000 >> vec)); |
| 295 | } |
| 296 | |
| 297 | /* |
| 298 | * Shift msr to next position and increment vector |
| 299 | */ |
| 300 | msr_shift <<= 1; |
| 301 | vec++; |
| 302 | } |
| 303 | } |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 304 | #endif |
| 305 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 306 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 307 | /* Handler for UIC0 interrupt */ |
| 308 | void uic0_interrupt( void * parms) |
| 309 | { |
| 310 | ulong uic_msr; |
| 311 | ulong msr_shift; |
| 312 | int vec; |
| 313 | |
| 314 | /* |
| 315 | * Read masked interrupt status register to determine interrupt source |
| 316 | */ |
| 317 | uic_msr = mfdcr(uicmsr); |
| 318 | msr_shift = uic_msr; |
| 319 | vec = 0; |
| 320 | |
| 321 | while (msr_shift != 0) { |
| 322 | if (msr_shift & 0x80000000) { |
| 323 | /* |
| 324 | * Increment irq counter (for debug purpose only) |
| 325 | */ |
| 326 | irq_vecs[vec].count++; |
| 327 | |
| 328 | if (irq_vecs[vec].handler != NULL) { |
| 329 | /* call isr */ |
| 330 | (*irq_vecs[vec].handler)(irq_vecs[vec].arg); |
| 331 | } else { |
| 332 | mtdcr(uicer, mfdcr(uicer) & ~(0x80000000 >> vec)); |
| 333 | printf ("Masking bogus interrupt vector (uic0) 0x%x\n", vec); |
| 334 | } |
| 335 | |
| 336 | /* |
| 337 | * After servicing the interrupt, we have to remove the status indicator. |
| 338 | */ |
| 339 | mtdcr(uicsr, (0x80000000 >> vec)); |
| 340 | } |
| 341 | |
| 342 | /* |
| 343 | * Shift msr to next position and increment vector |
| 344 | */ |
| 345 | msr_shift <<= 1; |
| 346 | vec++; |
| 347 | } |
| 348 | } |
| 349 | |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 350 | #endif /* CONFIG_440GX */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 351 | |
| 352 | #if defined(CONFIG_440) |
| 353 | /* Handler for UIC1 interrupt */ |
| 354 | void uic1_interrupt( void * parms) |
| 355 | { |
| 356 | ulong uic1_msr; |
| 357 | ulong msr_shift; |
| 358 | int vec; |
| 359 | |
| 360 | /* |
| 361 | * Read masked interrupt status register to determine interrupt source |
| 362 | */ |
| 363 | uic1_msr = mfdcr(uic1msr); |
| 364 | msr_shift = uic1_msr; |
| 365 | vec = 0; |
| 366 | |
| 367 | while (msr_shift != 0) { |
| 368 | if (msr_shift & 0x80000000) { |
| 369 | /* |
| 370 | * Increment irq counter (for debug purpose only) |
| 371 | */ |
| 372 | irq_vecs1[vec].count++; |
| 373 | |
| 374 | if (irq_vecs1[vec].handler != NULL) { |
| 375 | /* call isr */ |
| 376 | (*irq_vecs1[vec].handler)(irq_vecs1[vec].arg); |
| 377 | } else { |
| 378 | mtdcr(uic1er, mfdcr(uic1er) & ~(0x80000000 >> vec)); |
| 379 | printf ("Masking bogus interrupt vector (uic1) 0x%x\n", vec); |
| 380 | } |
| 381 | |
| 382 | /* |
| 383 | * After servicing the interrupt, we have to remove the status indicator. |
| 384 | */ |
| 385 | mtdcr(uic1sr, (0x80000000 >> vec)); |
| 386 | } |
| 387 | |
| 388 | /* |
| 389 | * Shift msr to next position and increment vector |
| 390 | */ |
| 391 | msr_shift <<= 1; |
| 392 | vec++; |
| 393 | } |
| 394 | } |
| 395 | #endif /* defined(CONFIG_440) */ |
| 396 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 397 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
| 398 | /* Handler for UIC2 interrupt */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 399 | void uic2_interrupt( void * parms) |
| 400 | { |
| 401 | ulong uic2_msr; |
| 402 | ulong msr_shift; |
| 403 | int vec; |
| 404 | |
| 405 | /* |
| 406 | * Read masked interrupt status register to determine interrupt source |
| 407 | */ |
| 408 | uic2_msr = mfdcr(uic2msr); |
| 409 | msr_shift = uic2_msr; |
| 410 | vec = 0; |
| 411 | |
| 412 | while (msr_shift != 0) { |
| 413 | if (msr_shift & 0x80000000) { |
| 414 | /* |
| 415 | * Increment irq counter (for debug purpose only) |
| 416 | */ |
| 417 | irq_vecs2[vec].count++; |
| 418 | |
| 419 | if (irq_vecs2[vec].handler != NULL) { |
| 420 | /* call isr */ |
| 421 | (*irq_vecs2[vec].handler)(irq_vecs2[vec].arg); |
| 422 | } else { |
| 423 | mtdcr(uic2er, mfdcr(uic2er) & ~(0x80000000 >> vec)); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 424 | printf ("Masking bogus interrupt vector (uic2) 0x%x\n", vec); |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | /* |
| 428 | * After servicing the interrupt, we have to remove the status indicator. |
| 429 | */ |
| 430 | mtdcr(uic2sr, (0x80000000 >> vec)); |
| 431 | } |
| 432 | |
| 433 | /* |
| 434 | * Shift msr to next position and increment vector |
| 435 | */ |
| 436 | msr_shift <<= 1; |
| 437 | vec++; |
| 438 | } |
| 439 | } |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 440 | #endif /* defined(CONFIG_440GX) */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 441 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 442 | #if defined(CONFIG_440SPE) |
| 443 | /* Handler for UIC3 interrupt */ |
| 444 | void uic3_interrupt( void * parms) |
| 445 | { |
| 446 | ulong uic3_msr; |
| 447 | ulong msr_shift; |
| 448 | int vec; |
| 449 | |
| 450 | /* |
| 451 | * Read masked interrupt status register to determine interrupt source |
| 452 | */ |
| 453 | uic3_msr = mfdcr(uic3msr); |
| 454 | msr_shift = uic3_msr; |
| 455 | vec = 0; |
| 456 | |
| 457 | while (msr_shift != 0) { |
| 458 | if (msr_shift & 0x80000000) { |
| 459 | /* |
| 460 | * Increment irq counter (for debug purpose only) |
| 461 | */ |
| 462 | irq_vecs3[vec].count++; |
| 463 | |
| 464 | if (irq_vecs3[vec].handler != NULL) { |
| 465 | /* call isr */ |
| 466 | (*irq_vecs3[vec].handler)(irq_vecs3[vec].arg); |
| 467 | } else { |
| 468 | mtdcr(uic3er, mfdcr(uic3er) & ~(0x80000000 >> vec)); |
| 469 | printf ("Masking bogus interrupt vector (uic3) 0x%x\n", vec); |
| 470 | } |
| 471 | |
| 472 | /* |
| 473 | * After servicing the interrupt, we have to remove the status indicator. |
| 474 | */ |
| 475 | mtdcr(uic3sr, (0x80000000 >> vec)); |
| 476 | } |
| 477 | |
| 478 | /* |
| 479 | * Shift msr to next position and increment vector |
| 480 | */ |
| 481 | msr_shift <<= 1; |
| 482 | vec++; |
| 483 | } |
| 484 | } |
| 485 | #endif /* defined(CONFIG_440SPE) */ |
| 486 | |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 487 | /****************************************************************************/ |
| 488 | |
| 489 | /* |
| 490 | * Install and free a interrupt handler. |
| 491 | */ |
| 492 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 493 | void irq_install_handler (int vec, interrupt_handler_t * handler, void *arg) |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 494 | { |
| 495 | struct irq_action *irqa = irq_vecs; |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 496 | int i = vec; |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 497 | |
| 498 | #if defined(CONFIG_440) |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 499 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 500 | if ((vec > 31) && (vec < 64)) { |
| 501 | i = vec - 32; |
| 502 | irqa = irq_vecs1; |
| 503 | } else if (vec > 63) { |
| 504 | i = vec - 64; |
| 505 | irqa = irq_vecs2; |
| 506 | } |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 507 | #else /* CONFIG_440GX */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 508 | if (vec > 31) { |
| 509 | i = vec - 32; |
| 510 | irqa = irq_vecs1; |
| 511 | } |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 512 | #endif /* CONFIG_440GX */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 513 | #endif /* CONFIG_440 */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 514 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 515 | /* |
| 516 | * print warning when replacing with a different irq vector |
| 517 | */ |
| 518 | if ((irqa[i].handler != NULL) && (irqa[i].handler != handler)) { |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 519 | printf ("Interrupt vector %d: handler 0x%x replacing 0x%x\n", |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 520 | vec, (uint) handler, (uint) irqa[i].handler); |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 521 | } |
| 522 | irqa[i].handler = handler; |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 523 | irqa[i].arg = arg; |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 524 | |
| 525 | #if defined(CONFIG_440) |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 526 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 527 | if ((vec > 31) && (vec < 64)) |
| 528 | mtdcr (uic1er, mfdcr (uic1er) | (0x80000000 >> i)); |
| 529 | else if (vec > 63) |
| 530 | mtdcr (uic2er, mfdcr (uic2er) | (0x80000000 >> i)); |
| 531 | else |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 532 | #endif /* CONFIG_440GX */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 533 | if (vec > 31) |
| 534 | mtdcr (uic1er, mfdcr (uic1er) | (0x80000000 >> i)); |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 535 | else |
| 536 | #endif |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 537 | mtdcr (uicer, mfdcr (uicer) | (0x80000000 >> i)); |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 538 | #if 0 |
| 539 | printf ("Install interrupt for vector %d ==> %p\n", vec, handler); |
| 540 | #endif |
| 541 | } |
| 542 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 543 | void irq_free_handler (int vec) |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 544 | { |
| 545 | struct irq_action *irqa = irq_vecs; |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 546 | int i = vec; |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 547 | |
| 548 | #if defined(CONFIG_440) |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 549 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 550 | if ((vec > 31) && (vec < 64)) { |
| 551 | irqa = irq_vecs1; |
| 552 | i = vec - 32; |
| 553 | } else if (vec > 63) { |
| 554 | irqa = irq_vecs2; |
| 555 | i = vec - 64; |
| 556 | } |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 557 | #endif /* CONFIG_440GX */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 558 | if (vec > 31) { |
| 559 | irqa = irq_vecs1; |
| 560 | i = vec - 32; |
| 561 | } |
| 562 | #endif |
| 563 | |
| 564 | #if 0 |
| 565 | printf ("Free interrupt for vector %d ==> %p\n", |
| 566 | vec, irq_vecs[vec].handler); |
| 567 | #endif |
| 568 | |
| 569 | #if defined(CONFIG_440) |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 570 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 571 | if ((vec > 31) && (vec < 64)) |
| 572 | mtdcr (uic1er, mfdcr (uic1er) & ~(0x80000000 >> i)); |
| 573 | else if (vec > 63) |
| 574 | mtdcr (uic2er, mfdcr (uic2er) & ~(0x80000000 >> i)); |
| 575 | else |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 576 | #endif /* CONFIG_440GX */ |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 577 | if (vec > 31) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 578 | mtdcr (uic1er, mfdcr (uic1er) & ~(0x80000000 >> i)); |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 579 | else |
| 580 | #endif |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 581 | mtdcr (uicer, mfdcr (uicer) & ~(0x80000000 >> i)); |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 582 | |
| 583 | irqa[i].handler = NULL; |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 584 | irqa[i].arg = NULL; |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | /****************************************************************************/ |
| 588 | |
wdenk | c0aa5c5 | 2003-12-06 19:49:23 +0000 | [diff] [blame] | 589 | void timer_interrupt_cpu (struct pt_regs *regs) |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 590 | { |
wdenk | c0aa5c5 | 2003-12-06 19:49:23 +0000 | [diff] [blame] | 591 | /* nothing to do here */ |
| 592 | return; |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | /****************************************************************************/ |
| 596 | |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 597 | #if (CONFIG_COMMANDS & CFG_CMD_IRQ) |
| 598 | |
| 599 | /******************************************************************************* |
| 600 | * |
| 601 | * irqinfo - print information about PCI devices |
| 602 | * |
| 603 | */ |
| 604 | int |
| 605 | do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 606 | { |
| 607 | int vec; |
| 608 | |
| 609 | printf ("\nInterrupt-Information:\n"); |
| 610 | #if defined(CONFIG_440) |
| 611 | printf ("\nUIC 0\n"); |
| 612 | #endif |
| 613 | printf ("Nr Routine Arg Count\n"); |
| 614 | |
| 615 | for (vec=0; vec<32; vec++) { |
| 616 | if (irq_vecs[vec].handler != NULL) { |
| 617 | printf ("%02d %08lx %08lx %d\n", |
| 618 | vec, |
| 619 | (ulong)irq_vecs[vec].handler, |
| 620 | (ulong)irq_vecs[vec].arg, |
| 621 | irq_vecs[vec].count); |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | #if defined(CONFIG_440) |
| 626 | printf ("\nUIC 1\n"); |
| 627 | printf ("Nr Routine Arg Count\n"); |
| 628 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 629 | for (vec=0; vec<32; vec++) { |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 630 | if (irq_vecs1[vec].handler != NULL) |
| 631 | printf ("%02d %08lx %08lx %d\n", |
| 632 | vec+31, (ulong)irq_vecs1[vec].handler, |
| 633 | (ulong)irq_vecs1[vec].arg, irq_vecs1[vec].count); |
| 634 | } |
| 635 | printf("\n"); |
| 636 | #endif |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 637 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 638 | #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 639 | printf ("\nUIC 2\n"); |
| 640 | printf ("Nr Routine Arg Count\n"); |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 641 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 642 | for (vec=0; vec<32; vec++) { |
| 643 | if (irq_vecs2[vec].handler != NULL) |
| 644 | printf ("%02d %08lx %08lx %d\n", |
| 645 | vec+63, (ulong)irq_vecs2[vec].handler, |
| 646 | (ulong)irq_vecs2[vec].arg, irq_vecs2[vec].count); |
| 647 | } |
| 648 | printf("\n"); |
| 649 | #endif |
| 650 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame^] | 651 | #if defined(CONFIG_440SPE) |
| 652 | printf ("\nUIC 3\n"); |
| 653 | printf ("Nr Routine Arg Count\n"); |
| 654 | |
| 655 | for (vec=0; vec<32; vec++) { |
| 656 | if (irq_vecs3[vec].handler != NULL) |
| 657 | printf ("%02d %08lx %08lx %d\n", |
| 658 | vec+63, (ulong)irq_vecs3[vec].handler, |
| 659 | (ulong)irq_vecs3[vec].arg, irq_vecs3[vec].count); |
| 660 | } |
| 661 | printf("\n"); |
| 662 | #endif |
| 663 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 664 | return 0; |
| 665 | } |
wdenk | f780aa2 | 2002-09-18 19:21:21 +0000 | [diff] [blame] | 666 | #endif /* CONFIG_COMMANDS & CFG_CMD_IRQ */ |