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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [sh/] [kernel/] [irq_microdev.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * linux/arch/sh/kernel/irq_microdev.c
3
 *
4
 * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
5
 *
6
 * SuperH SH4-202 MicroDev board support.
7
 *
8
 * May be copied or modified under the terms of the GNU General Public
9
 * License.  See linux/COPYING for more information.
10
 */
11
 
12
#include <linux/config.h>
13
#include <linux/init.h>
14
#include <linux/irq.h>
15
 
16
#include <asm/system.h>
17
#include <asm/io.h>
18
#include <asm/irq_microdev.h>
19
 
20
#define NUM_EXTERNAL_IRQS 16    /* IRL0 .. IRL15 */
21
 
22
 
23
static const struct
24
{
25
        unsigned char fpgaIrq;
26
        unsigned char mapped;
27
        const char *name;
28
}       fpgaIrqTable[NUM_EXTERNAL_IRQS] =
29
{
30
        { 0,     0,       "unused" },             /* IRQ #0       IRL=15  0x200  */
31
        { 0,     0,       "unused" },             /* IRQ #1       IRL=14  0x220  */
32
        { 0,     0,       "unused" },             /* IRQ #2       IRL=13  0x240  */
33
        { 18,   1,      "Ethernet" },           /* IRQ #3       IRL=12  0x260  */
34
        { 0,     0,       "unused" },             /* IRQ #4       IRL=11  0x280  */
35
        { 0,     0,       "unused" },             /* IRQ #5       IRL=10  0x2a0  */
36
        { 0,     0,       "unused" },             /* IRQ #6       IRL=9   0x2c0  */
37
        { 0,     0,       "unused" },             /* IRQ #7       IRL=8   0x2e0  */
38
        { 8,    1,      "PCI INTA" },           /* IRQ #8       IRL=7   0x300  */
39
        { 9,    1,      "PCI INTB" },           /* IRQ #9       IRL=6   0x320  */
40
        { 10,   1,      "PCI INTC" },           /* IRQ #10      IRL=5   0x340  */
41
        { 11,   1,      "PCI INTD" },           /* IRQ #11      IRL=4   0x360  */
42
        { 0,     0,       "unused" },             /* IRQ #12      IRL=3   0x380  */
43
        { 0,     0,       "unused" },             /* IRQ #13      IRL=2   0x3a0  */
44
        { 0,     0,       "unused" },             /* IRQ #14      IRL=1   0x3c0  */
45
        { 0,     0,       "unused" },             /* IRQ #15      IRL=0   0x3e0  */
46
};
47
 
48
static void enable_microdev_irq(unsigned int irq);
49
static void disable_microdev_irq(unsigned int irq);
50
 
51
        /* shutdown is same as "disable" */
52
#define shutdown_microdev_irq disable_microdev_irq
53
 
54
static void mask_and_ack_microdev(unsigned int);
55
static void end_microdev_irq(unsigned int irq);
56
 
57
static unsigned int startup_microdev_irq(unsigned int irq)
58
{
59
        enable_microdev_irq(irq);
60
        return 0;                /* never anything pending */
61
}
62
 
63
static struct hw_interrupt_type microdev_irq_type = {
64
        "MicroDev-IRQ",
65
        startup_microdev_irq,
66
        shutdown_microdev_irq,
67
        enable_microdev_irq,
68
        disable_microdev_irq,
69
        mask_and_ack_microdev,
70
        end_microdev_irq
71
};
72
 
73
static void disable_microdev_irq(unsigned int irq)
74
{
75
        unsigned int flags;
76
        unsigned int fpgaIrq;
77
 
78
        if (irq >= NUM_EXTERNAL_IRQS) return;
79
        if (!fpgaIrqTable[irq].mapped) return;
80
 
81
        fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
82
 
83
                /* disable interrupts */
84
        save_and_cli(flags);
85
 
86
                /* disable interupts on the FPGA INTC register */
87
        ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG);
88
 
89
                /* restore interrupts */
90
        restore_flags(flags);
91
}
92
 
93
static void enable_microdev_irq(unsigned int irq)
94
{
95
        unsigned long priorityReg, priorities, pri;
96
        unsigned int flags;
97
        unsigned int fpgaIrq;
98
 
99
 
100
        if (irq >= NUM_EXTERNAL_IRQS) return;
101
        if (!fpgaIrqTable[irq].mapped) return;
102
 
103
        pri = 15 - irq;
104
 
105
        fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
106
        priorityReg = MICRODEV_FPGA_INTPRI_REG(fpgaIrq);
107
 
108
                /* disable interrupts */
109
        save_and_cli(flags);
110
 
111
                /* set priority for the interrupt */
112
        priorities = ctrl_inl(priorityReg);
113
        priorities &= ~MICRODEV_FPGA_INTPRI_MASK(fpgaIrq);
114
        priorities |= MICRODEV_FPGA_INTPRI_LEVEL(fpgaIrq, pri);
115
        ctrl_outl(priorities, priorityReg);
116
 
117
                /* enable interupts on the FPGA INTC register */
118
        ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG);
119
 
120
                /* restore interrupts */
121
        restore_flags(flags);
122
}
123
 
124
        /* This functions sets the desired irq handler to be a MicroDev type */
125
static void __init make_microdev_irq(unsigned int irq)
126
{
127
        disable_irq_nosync(irq);
128
        irq_desc[irq].handler = &microdev_irq_type;
129
        disable_microdev_irq(irq);
130
}
131
 
132
static void mask_and_ack_microdev(unsigned int irq)
133
{
134
        disable_microdev_irq(irq);
135
}
136
 
137
static void end_microdev_irq(unsigned int irq)
138
{
139
        if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
140
        {
141
                enable_microdev_irq(irq);
142
        }
143
}
144
 
145
extern void __init init_microdev_irq(void)
146
{
147
        int i;
148
 
149
                /* disable interupts on the FPGA INTC register */
150
        ctrl_outl(~0ul, MICRODEV_FPGA_INTDSB_REG);
151
 
152
        for (i = 0; i < NUM_EXTERNAL_IRQS; i++)
153
        {
154
                make_microdev_irq(i);
155
        }
156
}
157
 
158
 

powered by: WebSVN 2.1.0

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