Blame view
arch/m68k/q40/q40ints.c
7.91 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/* * arch/m68k/q40/q40ints.c * * Copyright (C) 1999,2001 Richard Zidlicky * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. * * .. used to be loosely based on bvme6000ints.c * */ #include <linux/types.h> #include <linux/kernel.h> #include <linux/errno.h> |
1da177e4c Linux-2.6.12-rc2 |
17 |
#include <linux/interrupt.h> |
a03010ed9 m68k/q40: Convert... |
18 |
#include <linux/irq.h> |
1da177e4c Linux-2.6.12-rc2 |
19 |
|
1da177e4c Linux-2.6.12-rc2 |
20 21 |
#include <asm/ptrace.h> #include <asm/system.h> |
1da177e4c Linux-2.6.12-rc2 |
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#include <asm/traps.h> #include <asm/q40_master.h> #include <asm/q40ints.h> /* * Q40 IRQs are defined as follows: * 3,4,5,6,7,10,11,14,15 : ISA dev IRQs * 16-31: reserved * 32 : keyboard int * 33 : frame int (50/200 Hz periodic timer) * 34 : sample int (10/20 KHz periodic timer) * */ |
77dda339e [PATCH] m68k: con... |
36 |
static void q40_irq_handler(unsigned int, struct pt_regs *fp); |
e8abf5e73 m68k/irq: Switch ... |
37 38 |
static void q40_irq_enable(struct irq_data *data); static void q40_irq_disable(struct irq_data *data); |
1da177e4c Linux-2.6.12-rc2 |
39 |
|
77dda339e [PATCH] m68k: con... |
40 41 |
unsigned short q40_ablecount[35]; unsigned short q40_state[35]; |
1da177e4c Linux-2.6.12-rc2 |
42 |
|
e8abf5e73 m68k/irq: Switch ... |
43 |
static unsigned int q40_irq_startup(struct irq_data *data) |
77dda339e [PATCH] m68k: con... |
44 |
{ |
e8abf5e73 m68k/irq: Switch ... |
45 |
unsigned int irq = data->irq; |
77dda339e [PATCH] m68k: con... |
46 47 48 49 |
/* test for ISA ints not implemented by HW */ switch (irq) { case 1: case 2: case 8: case 9: case 11: case 12: case 13: |
f85e7cdc3 m68k: replace rem... |
50 51 |
printk("%s: ISA IRQ %d not implemented by HW ", __func__, irq); |
c288bf253 m68k/irq: Rename ... |
52 |
/* FIXME return -ENXIO; */ |
77dda339e [PATCH] m68k: con... |
53 54 55 |
} return 0; } |
1da177e4c Linux-2.6.12-rc2 |
56 |
|
e8abf5e73 m68k/irq: Switch ... |
57 |
static void q40_irq_shutdown(struct irq_data *data) |
77dda339e [PATCH] m68k: con... |
58 59 |
{ } |
1da177e4c Linux-2.6.12-rc2 |
60 |
|
c288bf253 m68k/irq: Rename ... |
61 |
static struct irq_chip q40_irq_chip = { |
77dda339e [PATCH] m68k: con... |
62 |
.name = "q40", |
c288bf253 m68k/irq: Rename ... |
63 64 |
.irq_startup = q40_irq_startup, .irq_shutdown = q40_irq_shutdown, |
e8abf5e73 m68k/irq: Switch ... |
65 66 |
.irq_enable = q40_irq_enable, .irq_disable = q40_irq_disable, |
77dda339e [PATCH] m68k: con... |
67 |
}; |
1da177e4c Linux-2.6.12-rc2 |
68 69 70 71 72 73 74 75 76 77 78 |
/* * void q40_init_IRQ (void) * * Parameters: None * * Returns: Nothing * * This function is called during kernel startup to initialize * the q40 IRQ handling routines. */ |
77dda339e [PATCH] m68k: con... |
79 |
static int disabled; |
1da177e4c Linux-2.6.12-rc2 |
80 |
|
66a3f820c m68k: missing __init |
81 |
void __init q40_init_IRQ(void) |
1da177e4c Linux-2.6.12-rc2 |
82 |
{ |
edb347256 m68k/irq: Add m68... |
83 84 |
m68k_setup_irq_controller(&q40_irq_chip, handle_simple_irq, 1, Q40_IRQ_MAX); |
1da177e4c Linux-2.6.12-rc2 |
85 86 |
/* setup handler for ISA ints */ |
77dda339e [PATCH] m68k: con... |
87 |
m68k_setup_auto_interrupt(q40_irq_handler); |
e8abf5e73 m68k/irq: Switch ... |
88 89 |
m68k_irq_startup_irq(IRQ_AUTO_2); m68k_irq_startup_irq(IRQ_AUTO_4); |
1da177e4c Linux-2.6.12-rc2 |
90 91 |
/* now enable some ints.. */ |
77dda339e [PATCH] m68k: con... |
92 |
master_outb(1, EXT_ENABLE_REG); /* ISA IRQ 5-15 */ |
1da177e4c Linux-2.6.12-rc2 |
93 94 |
/* make sure keyboard IRQ is disabled */ |
77dda339e [PATCH] m68k: con... |
95 |
master_outb(0, KEY_IRQ_ENABLE_REG); |
1da177e4c Linux-2.6.12-rc2 |
96 |
} |
1da177e4c Linux-2.6.12-rc2 |
97 98 99 |
/* * this stuff doesn't really belong here.. |
77dda339e [PATCH] m68k: con... |
100 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
101 102 103 104 105 106 107 108 |
int ql_ticks; /* 200Hz ticks since last jiffie */ static int sound_ticks; #define SVOL 45 void q40_mksound(unsigned int hz, unsigned int ticks) { |
77dda339e [PATCH] m68k: con... |
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
/* for now ignore hz, except that hz==0 switches off sound */ /* simply alternate the ampl (128-SVOL)-(128+SVOL)-..-.. at 200Hz */ if (hz == 0) { if (sound_ticks) sound_ticks = 1; *DAC_LEFT = 128; *DAC_RIGHT = 128; return; } /* sound itself is done in q40_timer_int */ if (sound_ticks == 0) sound_ticks = 1000; /* pretty long beep */ sound_ticks = ticks << 1; |
1da177e4c Linux-2.6.12-rc2 |
124 |
} |
40220c1a1 IRQ: Use the new ... |
125 |
static irq_handler_t q40_timer_routine; |
1da177e4c Linux-2.6.12-rc2 |
126 |
|
2850bc273 [PATCH] m68k pt_r... |
127 |
static irqreturn_t q40_timer_int (int irq, void * dev) |
1da177e4c Linux-2.6.12-rc2 |
128 |
{ |
77dda339e [PATCH] m68k: con... |
129 130 131 132 133 134 135 136 137 |
ql_ticks = ql_ticks ? 0 : 1; if (sound_ticks) { unsigned char sval=(sound_ticks & 1) ? 128-SVOL : 128+SVOL; sound_ticks--; *DAC_LEFT=sval; *DAC_RIGHT=sval; } if (!ql_ticks) |
2850bc273 [PATCH] m68k pt_r... |
138 |
q40_timer_routine(irq, dev); |
77dda339e [PATCH] m68k: con... |
139 |
return IRQ_HANDLED; |
1da177e4c Linux-2.6.12-rc2 |
140 |
} |
40220c1a1 IRQ: Use the new ... |
141 |
void q40_sched_init (irq_handler_t timer_routine) |
1da177e4c Linux-2.6.12-rc2 |
142 |
{ |
77dda339e [PATCH] m68k: con... |
143 |
int timer_irq; |
1da177e4c Linux-2.6.12-rc2 |
144 |
|
77dda339e [PATCH] m68k: con... |
145 146 |
q40_timer_routine = timer_routine; timer_irq = Q40_IRQ_FRAME; |
1da177e4c Linux-2.6.12-rc2 |
147 |
|
77dda339e [PATCH] m68k: con... |
148 |
if (request_irq(timer_irq, q40_timer_int, 0, |
1da177e4c Linux-2.6.12-rc2 |
149 |
"timer", q40_timer_int)) |
77dda339e [PATCH] m68k: con... |
150 |
panic("Couldn't register timer int"); |
1da177e4c Linux-2.6.12-rc2 |
151 |
|
77dda339e [PATCH] m68k: con... |
152 153 |
master_outb(-1, FRAME_CLEAR_REG); master_outb( 1, FRAME_RATE_REG); |
1da177e4c Linux-2.6.12-rc2 |
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
} /* * tables to translate bits into IRQ numbers * it is a good idea to order the entries by priority * */ struct IRQ_TABLE{ unsigned mask; int irq ;}; #if 0 static struct IRQ_TABLE iirqs[]={ {Q40_IRQ_FRAME_MASK,Q40_IRQ_FRAME}, {Q40_IRQ_KEYB_MASK,Q40_IRQ_KEYBOARD}, {0,0}}; #endif static struct IRQ_TABLE eirqs[] = { { .mask = Q40_IRQ3_MASK, .irq = 3 }, /* ser 1 */ { .mask = Q40_IRQ4_MASK, .irq = 4 }, /* ser 2 */ { .mask = Q40_IRQ14_MASK, .irq = 14 }, /* IDE 1 */ { .mask = Q40_IRQ15_MASK, .irq = 15 }, /* IDE 2 */ { .mask = Q40_IRQ6_MASK, .irq = 6 }, /* floppy, handled elsewhere */ { .mask = Q40_IRQ7_MASK, .irq = 7 }, /* par */ { .mask = Q40_IRQ5_MASK, .irq = 5 }, { .mask = Q40_IRQ10_MASK, .irq = 10 }, {0,0} }; /* complain only this many times about spurious ints : */ |
0c79cf6af spelling fixes: a... |
183 |
static int ccleirq=60; /* ISA dev IRQs*/ |
1da177e4c Linux-2.6.12-rc2 |
184 185 186 187 188 189 190 191 192 193 194 195 196 |
/*static int cclirq=60;*/ /* internal */ /* FIXME: add shared ints,mask,unmask,probing.... */ #define IRQ_INPROGRESS 1 /*static unsigned short saved_mask;*/ //static int do_tint=0; #define DEBUG_Q40INT /*#define IP_USE_DISABLE *//* would be nice, but crashes ???? */ static int mext_disabled=0; /* ext irq disabled by master chip? */ static int aliased_irq=0; /* how many times inside handler ?*/ |
77dda339e [PATCH] m68k: con... |
197 198 |
/* got interrupt, dispatch to ISA or keyboard/timer IRQs */ static void q40_irq_handler(unsigned int irq, struct pt_regs *fp) |
1da177e4c Linux-2.6.12-rc2 |
199 |
{ |
77dda339e [PATCH] m68k: con... |
200 201 |
unsigned mir, mer; int i; |
1da177e4c Linux-2.6.12-rc2 |
202 203 |
//repeat: |
77dda339e [PATCH] m68k: con... |
204 205 206 207 208 209 210 211 212 213 214 |
mir = master_inb(IIRQ_REG); #ifdef CONFIG_BLK_DEV_FD if ((mir & Q40_IRQ_EXT_MASK) && (master_inb(EIRQ_REG) & Q40_IRQ6_MASK)) { floppy_hardint(); return; } #endif switch (irq) { case 4: case 6: |
1425df87c m68k/irq: Rename ... |
215 |
do_IRQ(Q40_IRQ_SAMPLE, fp); |
77dda339e [PATCH] m68k: con... |
216 217 218 |
return; } if (mir & Q40_IRQ_FRAME_MASK) { |
1425df87c m68k/irq: Rename ... |
219 |
do_IRQ(Q40_IRQ_FRAME, fp); |
77dda339e [PATCH] m68k: con... |
220 221 222 223 224 225 226 |
master_outb(-1, FRAME_CLEAR_REG); } if ((mir & Q40_IRQ_SER_MASK) || (mir & Q40_IRQ_EXT_MASK)) { mer = master_inb(EIRQ_REG); for (i = 0; eirqs[i].mask; i++) { if (mer & eirqs[i].mask) { irq = eirqs[i].irq; |
1da177e4c Linux-2.6.12-rc2 |
227 228 229 230 |
/* * There is a little mess wrt which IRQ really caused this irq request. The * main problem is that IIRQ_REG and EIRQ_REG reflect the state when they * are read - which is long after the request came in. In theory IRQs should |
0c79cf6af spelling fixes: a... |
231 |
* not just go away but they occasionally do |
1da177e4c Linux-2.6.12-rc2 |
232 |
*/ |
77dda339e [PATCH] m68k: con... |
233 234 235 236 237 238 239 |
if (irq > 4 && irq <= 15 && mext_disabled) { /*aliased_irq++;*/ goto iirq; } if (q40_state[irq] & IRQ_INPROGRESS) { /* some handlers do local_irq_enable() for irq latency reasons, */ /* however reentering an active irq handler is not permitted */ |
1da177e4c Linux-2.6.12-rc2 |
240 |
#ifdef IP_USE_DISABLE |
77dda339e [PATCH] m68k: con... |
241 242 243 244 |
/* in theory this is the better way to do it because it still */ /* lets through eg the serial irqs, unfortunately it crashes */ disable_irq(irq); disabled = 1; |
1da177e4c Linux-2.6.12-rc2 |
245 |
#else |
77dda339e [PATCH] m68k: con... |
246 247 248 249 250 |
/*printk("IRQ_INPROGRESS detected for irq %d, disabling - %s disabled ", irq, disabled ? "already" : "not yet"); */ fp->sr = (((fp->sr) & (~0x700))+0x200); disabled = 1; |
1da177e4c Linux-2.6.12-rc2 |
251 |
#endif |
77dda339e [PATCH] m68k: con... |
252 253 254 |
goto iirq; } q40_state[irq] |= IRQ_INPROGRESS; |
1425df87c m68k/irq: Rename ... |
255 |
do_IRQ(irq, fp); |
77dda339e [PATCH] m68k: con... |
256 257 258 259 260 261 262 |
q40_state[irq] &= ~IRQ_INPROGRESS; /* naively enable everything, if that fails than */ /* this function will be reentered immediately thus */ /* getting another chance to disable the IRQ */ if (disabled) { |
1da177e4c Linux-2.6.12-rc2 |
263 |
#ifdef IP_USE_DISABLE |
77dda339e [PATCH] m68k: con... |
264 265 266 267 |
if (irq > 4) { disabled = 0; enable_irq(irq); } |
1da177e4c Linux-2.6.12-rc2 |
268 |
#else |
77dda339e [PATCH] m68k: con... |
269 270 271 |
disabled = 0; /*printk("reenabling irq %d ", irq); */ |
1da177e4c Linux-2.6.12-rc2 |
272 |
#endif |
77dda339e [PATCH] m68k: con... |
273 |
} |
1da177e4c Linux-2.6.12-rc2 |
274 |
// used to do 'goto repeat;' here, this delayed bh processing too long |
77dda339e [PATCH] m68k: con... |
275 276 277 278 279 280 281 282 |
return; } } if (mer && ccleirq > 0 && !aliased_irq) { printk("ISA interrupt from unknown source? EIRQ_REG = %x ",mer); ccleirq--; } |
1da177e4c Linux-2.6.12-rc2 |
283 |
} |
77dda339e [PATCH] m68k: con... |
284 285 286 287 |
iirq: mir = master_inb(IIRQ_REG); /* should test whether keyboard irq is really enabled, doing it in defhand */ if (mir & Q40_IRQ_KEYB_MASK) |
1425df87c m68k/irq: Rename ... |
288 |
do_IRQ(Q40_IRQ_KEYBOARD, fp); |
1da177e4c Linux-2.6.12-rc2 |
289 |
|
77dda339e [PATCH] m68k: con... |
290 |
return; |
1da177e4c Linux-2.6.12-rc2 |
291 |
} |
1da177e4c Linux-2.6.12-rc2 |
292 |
|
e8abf5e73 m68k/irq: Switch ... |
293 |
void q40_irq_enable(struct irq_data *data) |
1da177e4c Linux-2.6.12-rc2 |
294 |
{ |
e8abf5e73 m68k/irq: Switch ... |
295 |
unsigned int irq = data->irq; |
77dda339e [PATCH] m68k: con... |
296 297 298 |
if (irq >= 5 && irq <= 15) { mext_disabled--; if (mext_disabled > 0) |
e8abf5e73 m68k/irq: Switch ... |
299 300 |
printk("q40_irq_enable : nested disable/enable "); |
77dda339e [PATCH] m68k: con... |
301 302 303 |
if (mext_disabled == 0) master_outb(1, EXT_ENABLE_REG); } |
1da177e4c Linux-2.6.12-rc2 |
304 |
} |
e8abf5e73 m68k/irq: Switch ... |
305 |
void q40_irq_disable(struct irq_data *data) |
1da177e4c Linux-2.6.12-rc2 |
306 |
{ |
e8abf5e73 m68k/irq: Switch ... |
307 |
unsigned int irq = data->irq; |
77dda339e [PATCH] m68k: con... |
308 309 310 311 312 313 314 315 316 317 318 319 |
/* disable ISA iqs : only do something if the driver has been * verified to be Q40 "compatible" - right now IDE, NE2K * Any driver should not attempt to sleep across disable_irq !! */ if (irq >= 5 && irq <= 15) { master_outb(0, EXT_ENABLE_REG); mext_disabled++; if (mext_disabled > 1) printk("disable_irq nesting count %d ",mext_disabled); } |
1da177e4c Linux-2.6.12-rc2 |
320 |
} |