OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [m68k/] [sun3/] [sun3ints.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
 /*
2
 * linux/arch/m68k/sun3/sun3ints.c -- Sun-3(x) Linux interrupt handling code
3
 *
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
6
 * for more details.
7
 */
8
 
9
#include <linux/types.h>
10
#include <linux/kernel.h>
11
#include <linux/sched.h>
12
#include <linux/kernel_stat.h>
13
#include <linux/interrupt.h>
14
#include <asm/segment.h>
15
#include <asm/intersil.h>
16
#include <asm/oplib.h>
17
#include <asm/sun3ints.h>
18
 
19
extern void sun3_leds (unsigned char);
20
static void sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp);
21
 
22
void sun3_disable_interrupts(void)
23
{
24
        sun3_disable_irq(0);
25
}
26
 
27
void sun3_enable_interrupts(void)
28
{
29
        sun3_enable_irq(0);
30
}
31
 
32
int led_pattern[8] = {
33
       ~(0x80), ~(0x01),
34
       ~(0x40), ~(0x02),
35
       ~(0x20), ~(0x04),
36
       ~(0x10), ~(0x08)
37
};
38
 
39
volatile unsigned char* sun3_intreg;
40
 
41
void sun3_insert_irq(irq_node_t **list, irq_node_t *node)
42
{
43
}
44
 
45
void sun3_delete_irq(irq_node_t **list, void *dev_id)
46
{
47
}
48
 
49
void sun3_enable_irq(unsigned int irq)
50
{
51
        *sun3_intreg |=  (1<<irq);
52
}
53
 
54
void sun3_disable_irq(unsigned int irq)
55
{
56
        *sun3_intreg &= ~(1<<irq);
57
}
58
 
59
inline void sun3_do_irq(int irq, struct pt_regs *fp)
60
{
61
        kstat.irqs[0][SYS_IRQS + irq]++;
62
        *sun3_intreg &= ~(1<<irq);
63
        *sun3_intreg |=  (1<<irq);
64
}
65
 
66
static void sun3_int7(int irq, void *dev_id, struct pt_regs *fp)
67
{
68
        sun3_do_irq(irq,fp);
69
        if(!(kstat.irqs[0][SYS_IRQS + irq] % 2000))
70
                sun3_leds(led_pattern[(kstat.irqs[0][SYS_IRQS+irq]%16000)/2000]);
71
}
72
 
73
static void sun3_int5(int irq, void *dev_id, struct pt_regs *fp)
74
{
75
        kstat.irqs[0][SYS_IRQS + irq]++;
76
#ifdef CONFIG_SUN3
77
        intersil_clear();
78
#endif
79
        *sun3_intreg &= ~(1<<irq);
80
        *sun3_intreg |=  (1<<irq);
81
#ifdef CONFIG_SUN3
82
        intersil_clear();
83
#endif
84
        do_timer(fp);
85
        if(!(kstat.irqs[0][SYS_IRQS + irq] % 20))
86
                sun3_leds(led_pattern[(kstat.irqs[0][SYS_IRQS+irq]%160)
87
                /20]);
88
}
89
 
90
/* handle requested ints, excepting 5 and 7, which always do the same
91
   thing */
92
void (*sun3_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = {
93
        sun3_inthandle, sun3_inthandle, sun3_inthandle, sun3_inthandle,
94
        sun3_inthandle, sun3_int5, sun3_inthandle, sun3_int7
95
};
96
 
97
static const char *dev_names[SYS_IRQS] = { NULL, NULL, NULL, NULL,
98
                                     NULL, "timer", NULL, "int7 handler" };
99
static void *dev_ids[SYS_IRQS];
100
static void (*sun3_inthandler[SYS_IRQS])(int, void *, struct pt_regs *) = {
101
        NULL, NULL, NULL, NULL, NULL, sun3_int5, NULL, sun3_int7
102
};
103
 
104
static void (*sun3_vechandler[SUN3_INT_VECS])(int, void *, struct pt_regs *);
105
static void *vec_ids[SUN3_INT_VECS];
106
static const char *vec_names[SUN3_INT_VECS];
107
static int vec_ints[SUN3_INT_VECS];
108
 
109
 
110
int sun3_get_irq_list(char *buf)
111
{
112
        int i, len = 0;
113
 
114
        for(i = 0; i < (SUN3_INT_VECS-1); i++) {
115
                if(sun3_vechandler[i] != NULL) {
116
                        len += sprintf(buf+len, "vec %3d: %10u %s\n", i+64,
117
                                       vec_ints[i],
118
                                       (vec_names[i]) ? vec_names[i] :
119
                                       "sun3_vechandler");
120
                }
121
        }
122
 
123
        return 0;
124
}
125
 
126
static void sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp)
127
{
128
        if(sun3_inthandler[irq] == NULL)
129
                panic ("bad interrupt %d received (id %p)\n",irq, dev_id);
130
 
131
        kstat.irqs[0][SYS_IRQS + irq]++;
132
        *sun3_intreg &= ~(1<<irq);
133
 
134
        sun3_inthandler[irq](irq, dev_ids[irq], fp);
135
}
136
 
137
static void sun3_vec255(int irq, void *dev_id, struct pt_regs *fp)
138
{
139
//      intersil_clear();
140
}
141
 
142
void sun3_init_IRQ(void)
143
{
144
        int i;
145
 
146
        *sun3_intreg = 1;
147
 
148
        for(i = 0; i < SYS_IRQS; i++)
149
        {
150
                if(dev_names[i])
151
                        sys_request_irq(i, sun3_default_handler[i],
152
                                        0, dev_names[i], NULL);
153
        }
154
 
155
        for(i = 0; i < 192; i++)
156
                sun3_vechandler[i] = NULL;
157
 
158
        sun3_vechandler[191] = sun3_vec255;
159
}
160
 
161
int sun3_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
162
                      unsigned long flags, const char *devname, void *dev_id)
163
{
164
 
165
        if(irq < SYS_IRQS) {
166
                if(sun3_inthandler[irq] != NULL) {
167
                        printk("sun3_request_irq: request for irq %d -- already taken!\n", irq);
168
                        return 1;
169
                }
170
 
171
                sun3_inthandler[irq] = handler;
172
                dev_ids[irq] = dev_id;
173
                dev_names[irq] = devname;
174
 
175
                /* setting devname would be nice */
176
                sys_request_irq(irq, sun3_default_handler[irq], 0, devname, NULL);
177
 
178
                return 0;
179
        } else {
180
                if((irq >= 64) && (irq <= 255)) {
181
                        int vec;
182
 
183
                        vec = irq - 64;
184
                        if(sun3_vechandler[vec] != NULL) {
185
                                printk("sun3_request_irq: request for vec %d -- already taken!\n", irq);
186
                                return 1;
187
                        }
188
 
189
                        sun3_vechandler[vec] = handler;
190
                        vec_ids[vec] = dev_id;
191
                        vec_names[vec] = devname;
192
                        vec_ints[vec] = 0;
193
 
194
                        return 0;
195
                }
196
        }
197
 
198
        printk("sun3_request_irq: invalid irq %d\n", irq);
199
        return 1;
200
 
201
}
202
 
203
void sun3_free_irq(unsigned int irq, void *dev_id)
204
{
205
 
206
        if(irq < SYS_IRQS) {
207
                if(sun3_inthandler[irq] == NULL)
208
                        panic("sun3_free_int: attempt to free unused irq %d\n", irq);
209
                if(dev_ids[irq] != dev_id)
210
                        panic("sun3_free_int: incorrect dev_id for irq %d\n", irq);
211
 
212
                sun3_inthandler[irq] = NULL;
213
                return;
214
        } else if((irq >= 64) && (irq <= 255)) {
215
                int vec;
216
 
217
                vec = irq - 64;
218
                if(sun3_vechandler[vec] == NULL)
219
                        panic("sun3_free_int: attempt to free unused vector %d\n", irq);
220
                if(vec_ids[irq] != dev_id)
221
                        panic("sun3_free_int: incorrect dev_id for vec %d\n", irq);
222
 
223
                sun3_vechandler[vec] = NULL;
224
                return;
225
        } else {
226
                panic("sun3_free_irq: invalid irq %d\n", irq);
227
        }
228
}
229
 
230
void sun3_process_int(int irq, struct pt_regs *regs)
231
{
232
 
233
        if((irq >= 64) && (irq <= 255)) {
234
                int vec;
235
 
236
                vec = irq - 64;
237
                if(sun3_vechandler[vec] == NULL)
238
                        panic ("bad interrupt vector %d received\n",irq);
239
 
240
                vec_ints[vec]++;
241
                sun3_vechandler[vec](irq, vec_ids[vec], regs);
242
                return;
243
        } else {
244
                panic("sun3_process_int: unable to handle interrupt vector %d\n",
245
                      irq);
246
        }
247
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.