1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef _LINUX_ATARIINTS_H_
19#define _LINUX_ATARIINTS_H_
20
21#include <asm/irq.h>
22#include <asm/atarihw.h>
23
24
25
26
27
28
29#define STMFP_SOURCE_BASE 8
30#define TTMFP_SOURCE_BASE 24
31#define SCC_SOURCE_BASE 40
32#define VME_SOURCE_BASE 56
33#define VME_MAX_SOURCES 16
34
35#define NUM_ATARI_SOURCES 141
36
37
38#define IRQ_VECTOR_TO_SOURCE(v) ((v) - ((v) < 0x20 ? 0x18 : (0x40-8)))
39
40
41#define IRQ_SOURCE_TO_VECTOR(i) ((i) + ((i) < 8 ? 0x18 : (0x40-8)))
42
43
44#define IRQ_MFP_BUSY (8)
45#define IRQ_MFP_DCD (9)
46#define IRQ_MFP_CTS (10)
47#define IRQ_MFP_GPU (11)
48#define IRQ_MFP_TIMD (12)
49#define IRQ_MFP_TIMC (13)
50#define IRQ_MFP_ACIA (14)
51#define IRQ_MFP_FDC (15)
52#define IRQ_MFP_ACSI IRQ_MFP_FDC
53#define IRQ_MFP_FSCSI IRQ_MFP_FDC
54#define IRQ_MFP_IDE IRQ_MFP_FDC
55#define IRQ_MFP_TIMB (16)
56#define IRQ_MFP_SERERR (17)
57#define IRQ_MFP_SEREMPT (18)
58#define IRQ_MFP_RECERR (19)
59#define IRQ_MFP_RECFULL (20)
60#define IRQ_MFP_TIMA (21)
61#define IRQ_MFP_RI (22)
62#define IRQ_MFP_MMD (23)
63
64
65#define IRQ_TT_MFP_IO0 (24)
66#define IRQ_TT_MFP_IO1 (25)
67#define IRQ_TT_MFP_SCC (26)
68#define IRQ_TT_MFP_RI (27)
69#define IRQ_TT_MFP_TIMD (28)
70#define IRQ_TT_MFP_TIMC (29)
71#define IRQ_TT_MFP_DRVRDY (30)
72#define IRQ_TT_MFP_SCSIDMA (31)
73#define IRQ_TT_MFP_TIMB (32)
74#define IRQ_TT_MFP_SERERR (33)
75#define IRQ_TT_MFP_SEREMPT (34)
76#define IRQ_TT_MFP_RECERR (35)
77#define IRQ_TT_MFP_RECFULL (36)
78#define IRQ_TT_MFP_TIMA (37)
79#define IRQ_TT_MFP_RTC (38)
80#define IRQ_TT_MFP_SCSI (39)
81
82
83#define IRQ_SCCB_TX (40)
84#define IRQ_SCCB_STAT (42)
85#define IRQ_SCCB_RX (44)
86#define IRQ_SCCB_SPCOND (46)
87#define IRQ_SCCA_TX (48)
88#define IRQ_SCCA_STAT (50)
89#define IRQ_SCCA_RX (52)
90#define IRQ_SCCA_SPCOND (54)
91
92
93#define IRQ_MFP_TIMER1 (64)
94#define IRQ_MFP_TIMER2 (65)
95#define IRQ_MFP_TIMER3 (66)
96#define IRQ_MFP_TIMER4 (67)
97#define IRQ_MFP_TIMER5 (68)
98#define IRQ_MFP_TIMER6 (69)
99#define IRQ_MFP_TIMER7 (70)
100#define IRQ_MFP_TIMER8 (71)
101
102#define INT_CLK 24576
103#define INT_TICKS 246
104
105
106#define MFP_ENABLE 0
107#define MFP_PENDING 1
108#define MFP_SERVICE 2
109#define MFP_MASK 3
110
111
112
113
114
115static inline int get_mfp_bit( unsigned irq, int type )
116
117{ unsigned char mask, *reg;
118
119 mask = 1 << (irq & 7);
120 reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
121 ((irq & 8) >> 2) + (((irq-8) & 16) << 3);
122 return( *reg & mask );
123}
124
125static inline void set_mfp_bit( unsigned irq, int type )
126
127{ unsigned char mask, *reg;
128
129 mask = 1 << (irq & 7);
130 reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
131 ((irq & 8) >> 2) + (((irq-8) & 16) << 3);
132 __asm__ __volatile__ ( "orb %0,%1"
133 : : "di" (mask), "m" (*reg) : "memory" );
134}
135
136static inline void clear_mfp_bit( unsigned irq, int type )
137
138{ unsigned char mask, *reg;
139
140 mask = ~(1 << (irq & 7));
141 reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
142 ((irq & 8) >> 2) + (((irq-8) & 16) << 3);
143 if (type == MFP_PENDING || type == MFP_SERVICE)
144 __asm__ __volatile__ ( "moveb %0,%1"
145 : : "di" (mask), "m" (*reg) : "memory" );
146 else
147 __asm__ __volatile__ ( "andb %0,%1"
148 : : "di" (mask), "m" (*reg) : "memory" );
149}
150
151
152
153
154
155
156
157static inline void atari_enable_irq( unsigned irq )
158
159{
160 if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
161 set_mfp_bit( irq, MFP_MASK );
162}
163
164static inline void atari_disable_irq( unsigned irq )
165
166{
167 if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
168 clear_mfp_bit( irq, MFP_MASK );
169}
170
171
172
173
174
175
176static inline void atari_turnon_irq( unsigned irq )
177
178{
179 if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
180 set_mfp_bit( irq, MFP_ENABLE );
181}
182
183static inline void atari_turnoff_irq( unsigned irq )
184
185{
186 if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
187 clear_mfp_bit( irq, MFP_ENABLE );
188 clear_mfp_bit( irq, MFP_PENDING );
189}
190
191static inline void atari_clear_pending_irq( unsigned irq )
192
193{
194 if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
195 clear_mfp_bit( irq, MFP_PENDING );
196}
197
198static inline int atari_irq_pending( unsigned irq )
199
200{
201 if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return( 0 );
202 return( get_mfp_bit( irq, MFP_PENDING ) );
203}
204
205unsigned int atari_register_vme_int(void);
206void atari_unregister_vme_int(unsigned int);
207
208#endif
209