diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2006-06-25 08:47:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:00:57 -0400 |
commit | 74be8d0835f91f0f77a2f1554dfa7242f1f7b652 (patch) | |
tree | 8a761fdba6a921bad34a9f87ed4af4e336c05e55 /arch/m68k/amiga/cia.c | |
parent | 68387c448b7f2b3e2bfa0f606391cd3b602b1997 (diff) |
[PATCH] m68k: convert amiga irq code
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/m68k/amiga/cia.c')
-rw-r--r-- | arch/m68k/amiga/cia.c | 155 |
1 files changed, 78 insertions, 77 deletions
diff --git a/arch/m68k/amiga/cia.c b/arch/m68k/amiga/cia.c index 4a003d87f98d..0956e45399e5 100644 --- a/arch/m68k/amiga/cia.c +++ b/arch/m68k/amiga/cia.c | |||
@@ -29,21 +29,18 @@ struct ciabase { | |||
29 | unsigned short int_mask; | 29 | unsigned short int_mask; |
30 | int handler_irq, cia_irq, server_irq; | 30 | int handler_irq, cia_irq, server_irq; |
31 | char *name; | 31 | char *name; |
32 | irq_handler_t irq_list[CIA_IRQS]; | ||
33 | } ciaa_base = { | 32 | } ciaa_base = { |
34 | .cia = &ciaa, | 33 | .cia = &ciaa, |
35 | .int_mask = IF_PORTS, | 34 | .int_mask = IF_PORTS, |
36 | .handler_irq = IRQ_AUTO_2, | 35 | .handler_irq = IRQ_AMIGA_PORTS, |
37 | .cia_irq = IRQ_AMIGA_CIAA, | 36 | .cia_irq = IRQ_AMIGA_CIAA, |
38 | .server_irq = IRQ_AMIGA_PORTS, | 37 | .name = "CIAA" |
39 | .name = "CIAA handler" | ||
40 | }, ciab_base = { | 38 | }, ciab_base = { |
41 | .cia = &ciab, | 39 | .cia = &ciab, |
42 | .int_mask = IF_EXTER, | 40 | .int_mask = IF_EXTER, |
43 | .handler_irq = IRQ_AUTO_6, | 41 | .handler_irq = IRQ_AMIGA_EXTER, |
44 | .cia_irq = IRQ_AMIGA_CIAB, | 42 | .cia_irq = IRQ_AMIGA_CIAB, |
45 | .server_irq = IRQ_AMIGA_EXTER, | 43 | .name = "CIAB" |
46 | .name = "CIAB handler" | ||
47 | }; | 44 | }; |
48 | 45 | ||
49 | /* | 46 | /* |
@@ -66,13 +63,11 @@ unsigned char cia_set_irq(struct ciabase *base, unsigned char mask) | |||
66 | 63 | ||
67 | /* | 64 | /* |
68 | * Enable or disable CIA interrupts, return old interrupt mask, | 65 | * Enable or disable CIA interrupts, return old interrupt mask, |
69 | * interrupts will only be enabled if a handler exists | ||
70 | */ | 66 | */ |
71 | 67 | ||
72 | unsigned char cia_able_irq(struct ciabase *base, unsigned char mask) | 68 | unsigned char cia_able_irq(struct ciabase *base, unsigned char mask) |
73 | { | 69 | { |
74 | unsigned char old, tmp; | 70 | unsigned char old; |
75 | int i; | ||
76 | 71 | ||
77 | old = base->icr_mask; | 72 | old = base->icr_mask; |
78 | base->icr_data |= base->cia->icr; | 73 | base->icr_data |= base->cia->icr; |
@@ -82,98 +77,104 @@ unsigned char cia_able_irq(struct ciabase *base, unsigned char mask) | |||
82 | else | 77 | else |
83 | base->icr_mask &= ~mask; | 78 | base->icr_mask &= ~mask; |
84 | base->icr_mask &= CIA_ICR_ALL; | 79 | base->icr_mask &= CIA_ICR_ALL; |
85 | for (i = 0, tmp = 1; i < CIA_IRQS; i++, tmp <<= 1) { | ||
86 | if ((tmp & base->icr_mask) && !base->irq_list[i].handler) { | ||
87 | base->icr_mask &= ~tmp; | ||
88 | base->cia->icr = tmp; | ||
89 | } | ||
90 | } | ||
91 | if (base->icr_data & base->icr_mask) | 80 | if (base->icr_data & base->icr_mask) |
92 | amiga_custom.intreq = IF_SETCLR | base->int_mask; | 81 | amiga_custom.intreq = IF_SETCLR | base->int_mask; |
93 | return old; | 82 | return old; |
94 | } | 83 | } |
95 | 84 | ||
96 | int cia_request_irq(struct ciabase *base, unsigned int irq, | ||
97 | irqreturn_t (*handler)(int, void *, struct pt_regs *), | ||
98 | unsigned long flags, const char *devname, void *dev_id) | ||
99 | { | ||
100 | unsigned char mask; | ||
101 | |||
102 | base->irq_list[irq].handler = handler; | ||
103 | base->irq_list[irq].flags = flags; | ||
104 | base->irq_list[irq].dev_id = dev_id; | ||
105 | base->irq_list[irq].devname = devname; | ||
106 | |||
107 | /* enable the interrupt */ | ||
108 | mask = 1 << irq; | ||
109 | cia_set_irq(base, mask); | ||
110 | cia_able_irq(base, CIA_ICR_SETCLR | mask); | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | void cia_free_irq(struct ciabase *base, unsigned int irq, void *dev_id) | ||
115 | { | ||
116 | if (base->irq_list[irq].dev_id != dev_id) | ||
117 | printk("%s: removing probably wrong IRQ %i from %s\n", | ||
118 | __FUNCTION__, base->cia_irq + irq, | ||
119 | base->irq_list[irq].devname); | ||
120 | |||
121 | base->irq_list[irq].handler = NULL; | ||
122 | base->irq_list[irq].flags = 0; | ||
123 | |||
124 | cia_able_irq(base, 1 << irq); | ||
125 | } | ||
126 | |||
127 | static irqreturn_t cia_handler(int irq, void *dev_id, struct pt_regs *fp) | 85 | static irqreturn_t cia_handler(int irq, void *dev_id, struct pt_regs *fp) |
128 | { | 86 | { |
129 | struct ciabase *base = (struct ciabase *)dev_id; | 87 | struct ciabase *base = (struct ciabase *)dev_id; |
130 | int mach_irq, i; | 88 | int mach_irq; |
131 | unsigned char ints; | 89 | unsigned char ints; |
132 | 90 | ||
133 | mach_irq = base->cia_irq; | 91 | mach_irq = base->cia_irq; |
134 | ints = cia_set_irq(base, CIA_ICR_ALL); | 92 | ints = cia_set_irq(base, CIA_ICR_ALL); |
135 | amiga_custom.intreq = base->int_mask; | 93 | amiga_custom.intreq = base->int_mask; |
136 | for (i = 0; i < CIA_IRQS; i++, mach_irq++) { | 94 | for (; ints; mach_irq++, ints >>= 1) { |
137 | if (ints & 1) { | 95 | if (ints & 1) |
138 | kstat_cpu(0).irqs[mach_irq]++; | 96 | m68k_handle_int(mach_irq, fp); |
139 | base->irq_list[i].handler(mach_irq, base->irq_list[i].dev_id, fp); | ||
140 | } | ||
141 | ints >>= 1; | ||
142 | } | 97 | } |
143 | amiga_do_irq_list(base->server_irq, fp); | ||
144 | return IRQ_HANDLED; | 98 | return IRQ_HANDLED; |
145 | } | 99 | } |
146 | 100 | ||
147 | void __init cia_init_IRQ(struct ciabase *base) | 101 | static void cia_enable_irq(unsigned int irq) |
148 | { | 102 | { |
149 | int i; | 103 | unsigned char mask; |
150 | 104 | ||
151 | /* init isr handlers */ | 105 | if (irq >= IRQ_AMIGA_CIAB) { |
152 | for (i = 0; i < CIA_IRQS; i++) { | 106 | mask = 1 << (irq - IRQ_AMIGA_CIAB); |
153 | base->irq_list[i].handler = NULL; | 107 | cia_set_irq(&ciab_base, mask); |
154 | base->irq_list[i].flags = 0; | 108 | cia_able_irq(&ciab_base, CIA_ICR_SETCLR | mask); |
109 | } else { | ||
110 | mask = 1 << (irq - IRQ_AMIGA_CIAA); | ||
111 | cia_set_irq(&ciaa_base, mask); | ||
112 | cia_able_irq(&ciaa_base, CIA_ICR_SETCLR | mask); | ||
155 | } | 113 | } |
114 | } | ||
156 | 115 | ||
157 | /* clear any pending interrupt and turn off all interrupts */ | 116 | static void cia_disable_irq(unsigned int irq) |
158 | cia_set_irq(base, CIA_ICR_ALL); | 117 | { |
159 | cia_able_irq(base, CIA_ICR_ALL); | 118 | if (irq >= IRQ_AMIGA_CIAB) |
119 | cia_able_irq(&ciab_base, 1 << (irq - IRQ_AMIGA_CIAB)); | ||
120 | else | ||
121 | cia_able_irq(&ciaa_base, 1 << (irq - IRQ_AMIGA_CIAA)); | ||
122 | } | ||
160 | 123 | ||
161 | /* install CIA handler */ | 124 | static struct irq_controller cia_irq_controller = { |
162 | request_irq(base->handler_irq, cia_handler, 0, base->name, base); | 125 | .name = "cia", |
126 | .lock = SPIN_LOCK_UNLOCKED, | ||
127 | .enable = cia_enable_irq, | ||
128 | .disable = cia_disable_irq, | ||
129 | }; | ||
130 | |||
131 | /* | ||
132 | * Override auto irq 2 & 6 and use them as general chain | ||
133 | * for external interrupts, we link the CIA interrupt sources | ||
134 | * into this chain. | ||
135 | */ | ||
163 | 136 | ||
164 | amiga_custom.intena = IF_SETCLR | base->int_mask; | 137 | static void auto_enable_irq(unsigned int irq) |
138 | { | ||
139 | switch (irq) { | ||
140 | case IRQ_AUTO_2: | ||
141 | amiga_custom.intena = IF_SETCLR | IF_PORTS; | ||
142 | break; | ||
143 | case IRQ_AUTO_6: | ||
144 | amiga_custom.intena = IF_SETCLR | IF_EXTER; | ||
145 | break; | ||
146 | } | ||
165 | } | 147 | } |
166 | 148 | ||
167 | int cia_get_irq_list(struct ciabase *base, struct seq_file *p) | 149 | static void auto_disable_irq(unsigned int irq) |
168 | { | 150 | { |
169 | int i, j; | 151 | switch (irq) { |
170 | 152 | case IRQ_AUTO_2: | |
171 | j = base->cia_irq; | 153 | amiga_custom.intena = IF_PORTS; |
172 | for (i = 0; i < CIA_IRQS; i++) { | 154 | break; |
173 | seq_printf(p, "cia %2d: %10d ", j + i, | 155 | case IRQ_AUTO_6: |
174 | kstat_cpu(0).irqs[j + i]); | 156 | amiga_custom.intena = IF_EXTER; |
175 | seq_puts(p, " "); | 157 | break; |
176 | seq_printf(p, "%s\n", base->irq_list[i].devname); | ||
177 | } | 158 | } |
178 | return 0; | 159 | } |
160 | |||
161 | static struct irq_controller auto_irq_controller = { | ||
162 | .name = "auto", | ||
163 | .lock = SPIN_LOCK_UNLOCKED, | ||
164 | .enable = auto_enable_irq, | ||
165 | .disable = auto_disable_irq, | ||
166 | }; | ||
167 | |||
168 | void __init cia_init_IRQ(struct ciabase *base) | ||
169 | { | ||
170 | m68k_setup_irq_controller(&cia_irq_controller, base->cia_irq, CIA_IRQS); | ||
171 | |||
172 | /* clear any pending interrupt and turn off all interrupts */ | ||
173 | cia_set_irq(base, CIA_ICR_ALL); | ||
174 | cia_able_irq(base, CIA_ICR_ALL); | ||
175 | |||
176 | /* override auto int and install CIA handler */ | ||
177 | m68k_setup_irq_controller(&auto_irq_controller, base->handler_irq, 1); | ||
178 | m68k_irq_startup(base->handler_irq); | ||
179 | request_irq(base->handler_irq, cia_handler, SA_SHIRQ, base->name, base); | ||
179 | } | 180 | } |