|
| 1 | +/* |
| 2 | + * Carsten Langgaard, carstenl@mips.com |
| 3 | + * Copyright (C) 1999, 2000 MIPS Technologies, Inc. All rights reserved. |
| 4 | + * |
| 5 | + * This program is free software; you can distribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License (Version 2) as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This program is distributed in the hope it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License along |
| 15 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. |
| 17 | + * |
| 18 | + * Interrupt exception dispatch code. |
| 19 | + */ |
| 20 | +#include <linux/config.h> |
| 21 | + |
| 22 | +#include <asm/asm.h> |
| 23 | +#include <asm/mipsregs.h> |
| 24 | +#include <asm/regdef.h> |
| 25 | +#include <asm/stackframe.h> |
| 26 | + |
| 27 | +/* A lot of complication here is taken away because: |
| 28 | + * |
| 29 | + * 1) We handle one interrupt and return, sitting in a loop and moving across |
| 30 | + * all the pending IRQ bits in the cause register is _NOT_ the answer, the |
| 31 | + * common case is one pending IRQ so optimize in that direction. |
| 32 | + * |
| 33 | + * 2) We need not check against bits in the status register IRQ mask, that |
| 34 | + * would make this routine slow as hell. |
| 35 | + * |
| 36 | + * 3) Linux only thinks in terms of all IRQs on or all IRQs off, nothing in |
| 37 | + * between like BSD spl() brain-damage. |
| 38 | + * |
| 39 | + * Furthermore, the IRQs on the MIPS board look basically (barring software |
| 40 | + * IRQs which we don't use at all and all external interrupt sources are |
| 41 | + * combined together on hardware interrupt 0 (MIPS IRQ 2)) like: |
| 42 | + * |
| 43 | + * MIPS IRQ Source |
| 44 | + * -------- ------ |
| 45 | + * 0 Software (ignored) |
| 46 | + * 1 Software (ignored) |
| 47 | + * 2 Combined hardware interrupt (hw0) |
| 48 | + * 3 Hardware (ignored) |
| 49 | + * 4 Hardware (ignored) |
| 50 | + * 5 Hardware (ignored) |
| 51 | + * 6 Hardware (ignored) |
| 52 | + * 7 R4k timer (what we use) |
| 53 | + * |
| 54 | + * Note: On the SEAD board thing are a little bit different. |
| 55 | + * Here IRQ 2 (hw0) is wired to the UART0 and IRQ 3 (hw1) is wired |
| 56 | + * wired to UART1. |
| 57 | + * |
| 58 | + * We handle the IRQ according to _our_ priority which is: |
| 59 | + * |
| 60 | + * Highest ---- R4k Timer |
| 61 | + * Lowest ---- Combined hardware interrupt |
| 62 | + * |
| 63 | + * then we just return, if multiple IRQs are pending then we will just take |
| 64 | + * another exception, big deal. |
| 65 | + */ |
| 66 | + |
| 67 | + .text |
| 68 | + .set noreorder |
| 69 | + .set noat |
| 70 | + .align 5 |
| 71 | + NESTED(mipsIRQ, PT_SIZE, sp) |
| 72 | + SAVE_ALL |
| 73 | + CLI |
| 74 | + .set at |
| 75 | + |
| 76 | + mfc0 s0, CP0_CAUSE # get irq bits |
| 77 | + mfc0 s1, CP0_STATUS # get irq mask |
| 78 | + and s0, s1 |
| 79 | + |
| 80 | + /* First we check for r4k counter/timer IRQ. */ |
| 81 | + andi a0, s0, CAUSEF_IP7 |
| 82 | + beq a0, zero, 1f |
| 83 | + andi a0, s0, CAUSEF_IP2 # delay slot, check hw0 interrupt |
| 84 | + |
| 85 | + /* Wheee, a timer interrupt. */ |
| 86 | + move a0, sp |
| 87 | + jal mips_timer_interrupt |
| 88 | + nop |
| 89 | + |
| 90 | + j ret_from_irq |
| 91 | + nop |
| 92 | + |
| 93 | +1: |
| 94 | +#if defined(CONFIG_MIPS_SEAD) |
| 95 | + beq a0, zero, 1f |
| 96 | + andi a0, s0, CAUSEF_IP3 # delay slot, check hw1 interrupt |
| 97 | +#else |
| 98 | + beq a0, zero, 1f # delay slot, check hw3 interrupt |
| 99 | + andi a0, s0, CAUSEF_IP5 |
| 100 | +#endif |
| 101 | + |
| 102 | + /* Wheee, combined hardware level zero interrupt. */ |
| 103 | +#if defined(CONFIG_MIPS_ATLAS) |
| 104 | + jal atlas_hw0_irqdispatch |
| 105 | +#elif defined(CONFIG_MIPS_MALTA) |
| 106 | + jal malta_hw0_irqdispatch |
| 107 | +#elif defined(CONFIG_MIPS_SEAD) |
| 108 | + jal sead_hw0_irqdispatch |
| 109 | +#else |
| 110 | +#error "MIPS board not supported\n" |
| 111 | +#endif |
| 112 | + move a0, sp # delay slot |
| 113 | + |
| 114 | + j ret_from_irq |
| 115 | + nop # delay slot |
| 116 | + |
| 117 | +1: |
| 118 | +#if defined(CONFIG_MIPS_SEAD) |
| 119 | + beq a0, zero, 1f |
| 120 | + andi a0, s0, CAUSEF_IP5 # delay slot, check hw3 interrupt |
| 121 | + jal sead_hw1_irqdispatch |
| 122 | + move a0, sp # delay slot |
| 123 | + j ret_from_irq |
| 124 | + nop # delay slot |
| 125 | +1: |
| 126 | +#endif |
| 127 | +#if defined(CONFIG_MIPS_MALTA) |
| 128 | + beq a0, zero, 1f # check hw3 (coreHI) interrupt |
| 129 | + nop |
| 130 | + jal corehi_irqdispatch |
| 131 | + move a0, sp |
| 132 | + j ret_from_irq |
| 133 | + nop |
| 134 | +1: |
| 135 | +#endif |
| 136 | + /* |
| 137 | + * Here by mistake? This is possible, what can happen is that by the |
| 138 | + * time we take the exception the IRQ pin goes low, so just leave if |
| 139 | + * this is the case. |
| 140 | + */ |
| 141 | + move a1,s0 |
| 142 | + PRINT("Got interrupt: c0_cause = %08x\n") |
| 143 | + mfc0 a1, CP0_EPC |
| 144 | + PRINT("c0_epc = %08x\n") |
| 145 | + |
| 146 | + j ret_from_irq |
| 147 | + nop |
| 148 | + END(mipsIRQ) |
0 commit comments