]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | * | |
42a3b4f2 | 18 | * Routines for generic manipulation of the interrupts found on the |
1da177e4 LT |
19 | * Lasat boards. |
20 | */ | |
21 | #include <linux/init.h> | |
22 | #include <linux/sched.h> | |
23 | #include <linux/slab.h> | |
24 | #include <linux/interrupt.h> | |
25 | #include <linux/kernel_stat.h> | |
26 | ||
27 | #include <asm/bootinfo.h> | |
28 | #include <asm/irq.h> | |
29 | #include <asm/lasat/lasatint.h> | |
e4ac58af | 30 | #include <asm/time.h> |
1da177e4 LT |
31 | #include <asm/gdb-stub.h> |
32 | ||
33 | static volatile int *lasat_int_status = NULL; | |
34 | static volatile int *lasat_int_mask = NULL; | |
35 | static volatile int lasat_int_mask_shift; | |
36 | ||
1da177e4 LT |
37 | void disable_lasat_irq(unsigned int irq_nr) |
38 | { | |
1da177e4 | 39 | *lasat_int_mask &= ~(1 << irq_nr) << lasat_int_mask_shift; |
1da177e4 LT |
40 | } |
41 | ||
42 | void enable_lasat_irq(unsigned int irq_nr) | |
43 | { | |
1da177e4 | 44 | *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift; |
1da177e4 LT |
45 | } |
46 | ||
94dee171 | 47 | static struct irq_chip lasat_irq_type = { |
70d21cde | 48 | .name = "Lasat", |
1603b5ac AN |
49 | .ack = disable_lasat_irq, |
50 | .mask = disable_lasat_irq, | |
51 | .mask_ack = disable_lasat_irq, | |
52 | .unmask = enable_lasat_irq, | |
1da177e4 LT |
53 | }; |
54 | ||
55 | static inline int ls1bit32(unsigned int x) | |
56 | { | |
57 | int b = 31, s; | |
58 | ||
59 | s = 16; if (x << 16 == 0) s = 0; b -= s; x <<= s; | |
60 | s = 8; if (x << 8 == 0) s = 0; b -= s; x <<= s; | |
61 | s = 4; if (x << 4 == 0) s = 0; b -= s; x <<= s; | |
62 | s = 2; if (x << 2 == 0) s = 0; b -= s; x <<= s; | |
63 | s = 1; if (x << 1 == 0) s = 0; b -= s; | |
64 | ||
65 | return b; | |
66 | } | |
67 | ||
68 | static unsigned long (* get_int_status)(void); | |
69 | ||
70 | static unsigned long get_int_status_100(void) | |
71 | { | |
72 | return *lasat_int_status & *lasat_int_mask; | |
73 | } | |
74 | ||
42a3b4f2 | 75 | static unsigned long get_int_status_200(void) |
1da177e4 LT |
76 | { |
77 | unsigned long int_status; | |
78 | ||
79 | int_status = *lasat_int_status; | |
80 | int_status &= (int_status >> LASATINT_MASK_SHIFT_200) & 0xffff; | |
81 | return int_status; | |
82 | } | |
83 | ||
937a8015 | 84 | asmlinkage void plat_irq_dispatch(void) |
1da177e4 LT |
85 | { |
86 | unsigned long int_status; | |
e4ac58af | 87 | unsigned int cause = read_c0_cause(); |
1da177e4 LT |
88 | int irq; |
89 | ||
e4ac58af | 90 | if (cause & CAUSEF_IP7) { /* R4000 count / compare IRQ */ |
937a8015 | 91 | ll_timer_interrupt(7); |
e4ac58af RB |
92 | return; |
93 | } | |
94 | ||
1da177e4 LT |
95 | int_status = get_int_status(); |
96 | ||
97 | /* if int_status == 0, then the interrupt has already been cleared */ | |
98 | if (int_status) { | |
99 | irq = ls1bit32(int_status); | |
100 | ||
937a8015 | 101 | do_IRQ(irq); |
1da177e4 LT |
102 | } |
103 | } | |
104 | ||
105 | void __init arch_init_irq(void) | |
106 | { | |
107 | int i; | |
108 | ||
109 | switch (mips_machtype) { | |
110 | case MACH_LASAT_100: | |
111 | lasat_int_status = (void *)LASAT_INT_STATUS_REG_100; | |
112 | lasat_int_mask = (void *)LASAT_INT_MASK_REG_100; | |
113 | lasat_int_mask_shift = LASATINT_MASK_SHIFT_100; | |
114 | get_int_status = get_int_status_100; | |
115 | *lasat_int_mask = 0; | |
116 | break; | |
117 | case MACH_LASAT_200: | |
118 | lasat_int_status = (void *)LASAT_INT_STATUS_REG_200; | |
119 | lasat_int_mask = (void *)LASAT_INT_MASK_REG_200; | |
120 | lasat_int_mask_shift = LASATINT_MASK_SHIFT_200; | |
121 | get_int_status = get_int_status_200; | |
122 | *lasat_int_mask &= 0xffff; | |
123 | break; | |
124 | default: | |
125 | panic("arch_init_irq: mips_machtype incorrect"); | |
126 | } | |
127 | ||
1603b5ac | 128 | for (i = 0; i <= LASATINT_END; i++) |
1417836e | 129 | set_irq_chip_and_handler(i, &lasat_irq_type, handle_level_irq); |
1da177e4 | 130 | } |