^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * ints.c - Generic interrupt controller support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * License. See the file COPYING in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright 1996 Roman Zippel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright 1999 D. Jeff Dionne <jeff@rt-control.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/machdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #if defined(CONFIG_M68328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/MC68328.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #elif defined(CONFIG_M68EZ328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <asm/MC68EZ328.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #elif defined(CONFIG_M68VZ328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/MC68VZ328.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* assembler routines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) asmlinkage void system_call(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) asmlinkage void buserr(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) asmlinkage void trap(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) asmlinkage void trap3(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) asmlinkage void trap4(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) asmlinkage void trap5(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) asmlinkage void trap6(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) asmlinkage void trap7(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) asmlinkage void trap8(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) asmlinkage void trap9(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) asmlinkage void trap10(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) asmlinkage void trap11(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) asmlinkage void trap12(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) asmlinkage void trap13(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) asmlinkage void trap14(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) asmlinkage void trap15(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) asmlinkage void trap33(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) asmlinkage void trap34(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) asmlinkage void trap35(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) asmlinkage void trap36(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) asmlinkage void trap37(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) asmlinkage void trap38(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) asmlinkage void trap39(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) asmlinkage void trap40(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) asmlinkage void trap41(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) asmlinkage void trap42(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) asmlinkage void trap43(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) asmlinkage void trap44(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) asmlinkage void trap45(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) asmlinkage void trap46(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) asmlinkage void trap47(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) asmlinkage irqreturn_t bad_interrupt(int, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) asmlinkage irqreturn_t inthandler(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) asmlinkage irqreturn_t inthandler1(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) asmlinkage irqreturn_t inthandler2(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) asmlinkage irqreturn_t inthandler3(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) asmlinkage irqreturn_t inthandler4(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) asmlinkage irqreturn_t inthandler5(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) asmlinkage irqreturn_t inthandler6(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) asmlinkage irqreturn_t inthandler7(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* The 68k family did not have a good way to determine the source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * of interrupts until later in the family. The EC000 core does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * not provide the vector number on the stack, we vector everything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * into one vector and look in the blasted mask register...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * This code is designed to be fast, almost constant time, not clean!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) void process_int(int vec, struct pt_regs *fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) int mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) unsigned long pend = ISR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) while (pend) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (pend & 0x0000ffff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if (pend & 0x000000ff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (pend & 0x0000000f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) mask = 0x00000001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) irq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) mask = 0x00000010;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) irq = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (pend & 0x00000f00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) mask = 0x00000100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) irq = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) mask = 0x00001000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) irq = 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (pend & 0x00ff0000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (pend & 0x000f0000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) mask = 0x00010000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) irq = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) mask = 0x00100000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) irq = 20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (pend & 0x0f000000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) mask = 0x01000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) irq = 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) mask = 0x10000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) irq = 28;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) while (! (mask & pend)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) mask <<=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) irq++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) do_IRQ(irq, fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) pend &= ~mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void intc_irq_unmask(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) IMR &= ~(1 << d->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static void intc_irq_mask(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) IMR |= (1 << d->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static struct irq_chip intc_irq_chip = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) .name = "M68K-INTC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) .irq_mask = intc_irq_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) .irq_unmask = intc_irq_unmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * This function should be called during kernel startup to initialize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * the machine vector table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) void __init trap_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* set up the vectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) for (i = 72; i < 256; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) _ramvec[i] = (e_vector) bad_interrupt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) _ramvec[32] = system_call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) _ramvec[65] = (e_vector) inthandler1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) _ramvec[66] = (e_vector) inthandler2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) _ramvec[67] = (e_vector) inthandler3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) _ramvec[68] = (e_vector) inthandler4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) _ramvec[69] = (e_vector) inthandler5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) _ramvec[70] = (e_vector) inthandler6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) _ramvec[71] = (e_vector) inthandler7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) void __init init_IRQ(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) IVR = 0x40; /* Set DragonBall IVR (interrupt base) to 64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /* turn off all interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) IMR = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) for (i = 0; (i < NR_IRQS); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) irq_set_chip(i, &intc_irq_chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) irq_set_handler(i, handle_level_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)