2 * linux/arch/$(ARCH)/platform/$(PLATFORM)/ints.c
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
8 * Copyright (c) 2000 Michael Leslie <mleslie@lineo.com>
9 * Copyright (c) 1996 Roman Zippel
10 * Copyright (c) 1999 D. Jeff Dionne <jeff@uclinux.org>
13 #include <linux/config.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/kernel_stat.h>
18 #include <linux/errno.h>
20 #include <asm/system.h>
22 #include <asm/traps.h>
24 #include <asm/machdep.h>
25 #include <asm/setup.h>
26 #include <asm/m68360.h>
28 /* from quicc/commproc.c: */
30 extern void cpm_interrupt_init(void);
32 #define INTERNAL_IRQS (96)
34 /* assembler routines */
35 asmlinkage
void system_call(void);
36 asmlinkage
void buserr(void);
37 asmlinkage
void trap(void);
38 asmlinkage
void bad_interrupt(void);
39 asmlinkage
void inthandler(void);
41 extern void *_ramvec
[];
43 /* The number of spurious interrupts */
44 volatile unsigned int num_spurious
;
45 unsigned int local_irq_count
[NR_CPUS
];
47 /* irq node variables for the 32 (potential) on chip sources */
48 static irq_node_t int_irq_list
[INTERNAL_IRQS
];
50 static short int_irq_ablecount
[INTERNAL_IRQS
];
53 * This function should be called during kernel startup to initialize
54 * IRQ handling routines.
60 int vba
= (CPM_VECTOR_BASE
<<4);
62 /* set up the vectors */
78 _ramvec
[32] = system_call
;
84 /* set up CICR for vector base address and irq level */
85 /* irl = 4, hp = 1f - see MC68360UM p 7-377 */
86 pquicc
->intr_cicr
= 0x00e49f00 | vba
;
88 /* CPM interrupt vectors: (p 7-376) */
89 _ramvec
[vba
+CPMVEC_ERROR
] = bad_interrupt
; /* Error */
90 _ramvec
[vba
+CPMVEC_PIO_PC11
] = inthandler
; /* pio - pc11 */
91 _ramvec
[vba
+CPMVEC_PIO_PC10
] = inthandler
; /* pio - pc10 */
92 _ramvec
[vba
+CPMVEC_SMC2
] = inthandler
; /* smc2/pip */
93 _ramvec
[vba
+CPMVEC_SMC1
] = inthandler
; /* smc1 */
94 _ramvec
[vba
+CPMVEC_SPI
] = inthandler
; /* spi */
95 _ramvec
[vba
+CPMVEC_PIO_PC9
] = inthandler
; /* pio - pc9 */
96 _ramvec
[vba
+CPMVEC_TIMER4
] = inthandler
; /* timer 4 */
97 _ramvec
[vba
+CPMVEC_RESERVED1
] = inthandler
; /* reserved */
98 _ramvec
[vba
+CPMVEC_PIO_PC8
] = inthandler
; /* pio - pc8 */
99 _ramvec
[vba
+CPMVEC_PIO_PC7
] = inthandler
; /* pio - pc7 */
100 _ramvec
[vba
+CPMVEC_PIO_PC6
] = inthandler
; /* pio - pc6 */
101 _ramvec
[vba
+CPMVEC_TIMER3
] = inthandler
; /* timer 3 */
102 _ramvec
[vba
+CPMVEC_RISCTIMER
] = inthandler
; /* reserved */
103 _ramvec
[vba
+CPMVEC_PIO_PC5
] = inthandler
; /* pio - pc5 */
104 _ramvec
[vba
+CPMVEC_PIO_PC4
] = inthandler
; /* pio - pc4 */
105 _ramvec
[vba
+CPMVEC_RESERVED2
] = inthandler
; /* reserved */
106 _ramvec
[vba
+CPMVEC_RISCTIMER
] = inthandler
; /* timer table */
107 _ramvec
[vba
+CPMVEC_TIMER2
] = inthandler
; /* timer 2 */
108 _ramvec
[vba
+CPMVEC_RESERVED3
] = inthandler
; /* reserved */
109 _ramvec
[vba
+CPMVEC_IDMA2
] = inthandler
; /* idma 2 */
110 _ramvec
[vba
+CPMVEC_IDMA1
] = inthandler
; /* idma 1 */
111 _ramvec
[vba
+CPMVEC_SDMA_CB_ERR
] = inthandler
; /* sdma channel bus error */
112 _ramvec
[vba
+CPMVEC_PIO_PC3
] = inthandler
; /* pio - pc3 */
113 _ramvec
[vba
+CPMVEC_PIO_PC2
] = inthandler
; /* pio - pc2 */
114 /* _ramvec[vba+CPMVEC_TIMER1] = cpm_isr_timer1; */ /* timer 1 */
115 _ramvec
[vba
+CPMVEC_TIMER1
] = inthandler
; /* timer 1 */
116 _ramvec
[vba
+CPMVEC_PIO_PC1
] = inthandler
; /* pio - pc1 */
117 _ramvec
[vba
+CPMVEC_SCC4
] = inthandler
; /* scc 4 */
118 _ramvec
[vba
+CPMVEC_SCC3
] = inthandler
; /* scc 3 */
119 _ramvec
[vba
+CPMVEC_SCC2
] = inthandler
; /* scc 2 */
120 _ramvec
[vba
+CPMVEC_SCC1
] = inthandler
; /* scc 1 */
121 _ramvec
[vba
+CPMVEC_PIO_PC0
] = inthandler
; /* pio - pc0 */
124 /* turn off all CPM interrupts */
125 pquicc
->intr_cimr
= 0x00000000;
127 /* initialize handlers */
128 for (i
= 0; i
< INTERNAL_IRQS
; i
++) {
129 int_irq_list
[i
].handler
= NULL
;
130 int_irq_list
[i
].flags
= IRQ_FLG_STD
;
131 int_irq_list
[i
].dev_id
= NULL
;
132 int_irq_list
[i
].devname
= NULL
;
137 void M68360_insert_irq(irq_node_t
**list
, irq_node_t
*node
)
143 printk("%s: Warning: dev_id of %s is zero\n",
144 __FUNCTION__
, node
->devname
);
146 local_irq_save(flags
);
158 local_irq_restore(flags
);
161 void M68360_delete_irq(irq_node_t
**list
, void *dev_id
)
166 local_irq_save(flags
);
168 for (node
= *list
; node
; list
= &node
->next
, node
= *list
) {
169 if (node
->dev_id
== dev_id
) {
171 /* Mark it as free. */
172 node
->handler
= NULL
;
173 local_irq_restore(flags
);
177 local_irq_restore(flags
);
178 printk ("%s: tried to remove invalid irq\n", __FUNCTION__
);
182 int request_irq(unsigned int irq
, void (*handler
)(int, void *, struct pt_regs
*),
183 unsigned long flags
, const char *devname
, void *dev_id
)
187 irq
+= (CPM_VECTOR_BASE
<<4);
189 if (irq
>= INTERNAL_IRQS
) {
190 printk ("%s: Unknown IRQ %d from %s\n", __FUNCTION__
, irq
, devname
);
194 if (!(int_irq_list
[irq
].flags
& IRQ_FLG_STD
)) {
195 if (int_irq_list
[irq
].flags
& IRQ_FLG_LOCK
) {
196 printk("%s: IRQ %d from %s is not replaceable\n",
197 __FUNCTION__
, irq
, int_irq_list
[irq
].devname
);
200 if (flags
& IRQ_FLG_REPLACE
) {
201 printk("%s: %s can't replace IRQ %d from %s\n",
202 __FUNCTION__
, devname
, irq
, int_irq_list
[irq
].devname
);
206 int_irq_list
[irq
].handler
= handler
;
207 int_irq_list
[irq
].flags
= flags
;
208 int_irq_list
[irq
].dev_id
= dev_id
;
209 int_irq_list
[irq
].devname
= devname
;
211 /* enable in the CIMR */
212 if (!int_irq_ablecount
[irq
])
213 pquicc
->intr_cimr
|= mask
;
214 /* *(volatile unsigned long *)0xfffff304 &= ~(1<<irq); */
219 void free_irq(unsigned int irq
, void *dev_id
)
221 if (irq
>= INTERNAL_IRQS
) {
222 printk ("%s: Unknown IRQ %d\n", __FUNCTION__
, irq
);
226 if (int_irq_list
[irq
].dev_id
!= dev_id
)
227 printk("%s: removing probably wrong IRQ %d from %s\n",
228 __FUNCTION__
, irq
, int_irq_list
[irq
].devname
);
229 int_irq_list
[irq
].handler
= NULL
;
230 int_irq_list
[irq
].flags
= IRQ_FLG_STD
;
231 int_irq_list
[irq
].dev_id
= NULL
;
232 int_irq_list
[irq
].devname
= NULL
;
234 *(volatile unsigned long *)0xfffff304 |= 1<<irq
;
239 * Enable/disable a particular machine specific interrupt source.
240 * Note that this may affect other interrupts in case of a shared interrupt.
241 * This function should only be called for a _very_ short time to change some
242 * internal data, that may not be changed by the interrupt at the same time.
243 * int_(enable|disable)_irq calls may also be nested.
245 void M68360_enable_irq(unsigned int irq
)
247 if (irq
>= INTERNAL_IRQS
) {
248 printk("%s: Unknown IRQ %d\n", __FUNCTION__
, irq
);
252 if (--int_irq_ablecount
[irq
])
255 /* enable the interrupt */
256 *(volatile unsigned long *)0xfffff304 &= ~(1<<irq
);
259 void M68360_disable_irq(unsigned int irq
)
261 if (irq
>= INTERNAL_IRQS
) {
262 printk("%s: Unknown IRQ %d\n", __FUNCTION__
, irq
);
266 if (int_irq_ablecount
[irq
]++)
269 /* disable the interrupt */
270 *(volatile unsigned long *)0xfffff304 |= 1<<irq
;
274 int show_interrupts(struct seq_file
*p
, void *v
)
278 for (i
= 0; i
< NR_IRQS
; i
++) {
279 if (int_irq_list
[i
].flags
& IRQ_FLG_STD
)
282 seq_printf(p
, "%3d: %10u ", i
, kstat_cpu(0).irqs
[i
]);
283 if (int_irq_list
[i
].flags
& IRQ_FLG_LOCK
)
287 seq_printf(p
, "%s\n", int_irq_list
[i
].devname
);
289 seq_printf(p
, " : %10u spurious\n", num_spurious
);
294 /* The 68k family did not have a good way to determine the source
295 * of interrupts until later in the family. The EC000 core does
296 * not provide the vector number on the stack, we vector everything
297 * into one vector and look in the blasted mask register...
298 * This code is designed to be fast, almost constant time, not clean!
300 void process_int(int vec
, struct pt_regs
*fp
)
305 /* unsigned long pend = *(volatile unsigned long *)0xfffff30c; */
307 /* irq = vec + (CPM_VECTOR_BASE<<4); */
310 /* unsigned long pend = *(volatile unsigned long *)pquicc->intr_cipr; */
312 /* Bugger all that weirdness. For the moment, I seem to know where I came from;
313 * vec is passed from a specific ISR, so I'll use it. */
315 if (int_irq_list
[irq
].handler
) {
316 int_irq_list
[irq
].handler(irq
, int_irq_list
[irq
].dev_id
, fp
);
317 kstat_cpu(0).irqs
[irq
]++;
318 pquicc
->intr_cisr
= (1 << vec
); /* indicate that irq has been serviced */
320 printk("unregistered interrupt %d!\nTurning it off in the CIMR...\n", irq
);
321 /* *(volatile unsigned long *)0xfffff304 |= mask; */
322 pquicc
->intr_cimr
&= ~(1 << vec
);