irqhandler.h revision 1.3 1 1.3 matt /* $NetBSD: irqhandler.h,v 1.3 2007/03/08 20:48:39 matt Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) 1994-1996 Mark Brinicombe.
5 1.1 thorpej * Copyright (c) 1994 Brini.
6 1.1 thorpej * All rights reserved.
7 1.1 thorpej *
8 1.1 thorpej * This code is derived from software written for Brini by Mark Brinicombe
9 1.1 thorpej *
10 1.1 thorpej * Redistribution and use in source and binary forms, with or without
11 1.1 thorpej * modification, are permitted provided that the following conditions
12 1.1 thorpej * are met:
13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.1 thorpej * notice, this list of conditions and the following disclaimer.
15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.1 thorpej * documentation and/or other materials provided with the distribution.
18 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.1 thorpej * must display the following acknowledgement:
20 1.1 thorpej * This product includes software developed by Mark Brinicombe
21 1.1 thorpej * for the NetBSD Project.
22 1.1 thorpej * 4. The name of the company nor the name of the author may be used to
23 1.1 thorpej * endorse or promote products derived from this software without specific
24 1.1 thorpej * prior written permission.
25 1.1 thorpej *
26 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
27 1.1 thorpej * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28 1.1 thorpej * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 1.1 thorpej * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30 1.1 thorpej * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31 1.1 thorpej * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 1.1 thorpej * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 thorpej * SUCH DAMAGE.
37 1.1 thorpej *
38 1.1 thorpej * IRQ related stuff (defines + structures)
39 1.1 thorpej *
40 1.1 thorpej * Created : 30/09/94
41 1.1 thorpej */
42 1.1 thorpej
43 1.1 thorpej #ifndef _ARM32_IRQHANDLER_H_
44 1.1 thorpej #define _ARM32_IRQHANDLER_H_
45 1.1 thorpej
46 1.1 thorpej #ifndef _LOCORE
47 1.1 thorpej #include <sys/types.h>
48 1.2 matt #include <sys/evcnt.h>
49 1.1 thorpej #endif /* _LOCORE */
50 1.1 thorpej
51 1.1 thorpej /* Define the IRQ bits */
52 1.1 thorpej
53 1.1 thorpej /*
54 1.1 thorpej * XXX this is really getting rather horrible.
55 1.1 thorpej * Shortly to be replaced with system specific interrupt tables and handling
56 1.1 thorpej */
57 1.1 thorpej
58 1.1 thorpej #ifdef OFWGENCFG
59 1.1 thorpej /* These are just made up for now! -JJK */
60 1.1 thorpej #define IRQ_TIMER0 0
61 1.1 thorpej #endif
62 1.1 thorpej
63 1.1 thorpej #ifdef SHARK
64 1.1 thorpej /*
65 1.1 thorpej * shark hardware requirements for IRQ's:
66 1.1 thorpej * IDE: 14 (hardwired)
67 1.1 thorpej * PCI: 5, 9, 10, 11, 15(mapped to UMIPCI inta, intb, intc, intd)
68 1.1 thorpej * UMIISA: 10, 11, 12
69 1.1 thorpej * SuperIO: 1, 3..12, 14, 15(all may be remapped. defaults as follows.)
70 1.1 thorpej * KBC: 1
71 1.1 thorpej * USI: 3 (UART with Slow Infrared support)
72 1.1 thorpej * UART: 4
73 1.1 thorpej * FLOPPY: 6 (not currently used on shark)
74 1.1 thorpej * PARALLEL: 7
75 1.1 thorpej * RTC: 8 (not used on shark: RTC in sequoia used)
76 1.1 thorpej * MOUSE: 12
77 1.1 thorpej * Sequoia: 8 (internal RTC hardwired to irq 8)
78 1.1 thorpej * Codec: 5, 7, 9, 10, 15 (irqe, connected to 15, has special status.)
79 1.1 thorpej * CS8900: 5, 10, 11, 12 (P.14 of datasheet sez only 1 used/time)
80 1.1 thorpej * FERR#: 13 (unconnected floating point error)
81 1.1 thorpej *
82 1.1 thorpej * total of 15 irqs:
83 1.1 thorpej * timer, ide, 2 umi = isa/pci, ethernet, 2 codec, kb, usi, uart, floppy,
84 1.1 thorpej * parallel, rtc, mouse, ferr (irq 13)
85 1.1 thorpej *
86 1.1 thorpej * eventually, need to read the OFW dev info tree, and allocate IRQs.
87 1.1 thorpej * hardcoded for now.
88 1.1 thorpej */
89 1.1 thorpej #define IRQ_TIMER0 0x00 /* hardwired to 8254 counter 0 in sequoia */
90 1.1 thorpej #define IRQ_KEYBOARD 0x01
91 1.1 thorpej #define IRQ_CASCADE 0x02 /* hardwired IRQ for second 8259 = IRQ_SLAVE */
92 1.1 thorpej #define IRQ_USI 0x03
93 1.1 thorpej #define IRQ_UART 0x04
94 1.1 thorpej #define IRQ_ETHERNET 0x05
95 1.1 thorpej #define IRQ_FLOPPY 0x06
96 1.1 thorpej #define IRQ_PARALLEL 0x07
97 1.3 matt #endif
98 1.1 thorpej
99 1.3 matt #if defined(SHARK) || defined(OFWGENCFG)
100 1.1 thorpej #define IRQ_RTC 0x08 /* hardwired to the sequoia RTC */
101 1.3 matt #endif
102 1.3 matt #ifdef SHARK
103 1.1 thorpej #define IRQ_CODEC1 0x09
104 1.1 thorpej #define IRQ_UMI1 0x0A /* isa or pci */
105 1.1 thorpej #define IRQ_UMI2 0x0B /* isa or pci */
106 1.1 thorpej
107 1.1 thorpej #define IRQ_MOUSE 0x0C
108 1.1 thorpej #define IRQ_FERR 0x0D /* FERR# pin on sequoia needs to be connected */
109 1.1 thorpej #define IRQ_IDE 0x0E /* hardwired to the IDE connector */
110 1.1 thorpej #define IRQ_CODEC2 0x0F /* special interrupt on codec */
111 1.1 thorpej #endif /* SHARK */
112 1.1 thorpej
113 1.1 thorpej #define IRQ_VSYNC IRQ_FLYBACK /* Aliased */
114 1.1 thorpej #define IRQ_NETSLOT IRQ_EXTENDED
115 1.1 thorpej
116 1.1 thorpej #define IRQ_INSTRUCT -1
117 1.1 thorpej #define NIRQS 0x20
118 1.1 thorpej
119 1.1 thorpej #include <machine/intr.h>
120 1.1 thorpej
121 1.1 thorpej #ifndef _LOCORE
122 1.1 thorpej typedef struct irqhandler {
123 1.3 matt int (*ih_func)(void *arg); /* handler function */
124 1.1 thorpej void *ih_arg; /* Argument to handler */
125 1.1 thorpej int ih_level; /* Interrupt level */
126 1.1 thorpej int ih_num; /* Interrupt number (for accounting) */
127 1.1 thorpej u_int ih_flags; /* Interrupt flags */
128 1.1 thorpej u_int ih_maskaddr; /* mask address for expansion cards */
129 1.1 thorpej u_int ih_maskbits; /* interrupt bit for expansion cards */
130 1.1 thorpej struct irqhandler *ih_next; /* next handler */
131 1.2 matt struct evcnt ih_ev; /* evcnt structure */
132 1.1 thorpej } irqhandler_t;
133 1.1 thorpej
134 1.1 thorpej #ifdef _KERNEL
135 1.1 thorpej extern u_int irqmasks[IPL_LEVELS];
136 1.1 thorpej extern irqhandler_t *irqhandlers[NIRQS];
137 1.1 thorpej
138 1.3 matt void irq_init(void);
139 1.3 matt int irq_claim(int, irqhandler_t *, const char *group, const char *name);
140 1.3 matt int irq_release(int, irqhandler_t *);
141 1.3 matt void *intr_claim(int irq, int level, int (*func)(void *), void *arg,
142 1.3 matt const char *group, const char *name);
143 1.3 matt int intr_release(void *ih);
144 1.3 matt void irq_setmasks(void);
145 1.3 matt void disable_irq(int);
146 1.3 matt void enable_irq(int);
147 1.1 thorpej #endif /* _KERNEL */
148 1.1 thorpej #endif /* _LOCORE */
149 1.1 thorpej
150 1.1 thorpej #define IRQ_FLAG_ACTIVE 0x00000001 /* This is the active handler in list */
151 1.1 thorpej
152 1.1 thorpej #endif /* _ARM32_IRQHANDLER_H_ */
153 1.1 thorpej
154 1.1 thorpej /* End of irqhandler.h */
155