1 /*
2 * linux/arch/alpha/kernel/sys_jensen.c
3 *
4 * Copyright (C) 1995 Linus Torvalds
5 * Copyright (C) 1998, 1999 Richard Henderson
6 *
7 * Code supporting the Jensen.
8 */
9
10 #include <linux/kernel.h>
11 #include <linux/types.h>
12 #include <linux/mm.h>
13 #include <linux/sched.h>
14 #include <linux/pci.h>
15 #include <linux/init.h>
16
17 #include <asm/ptrace.h>
18 #include <asm/system.h>
19
20 #define __EXTERN_INLINE inline
21 #include <asm/io.h>
22 #include <asm/jensen.h>
23 #undef __EXTERN_INLINE
24
25 #include <asm/dma.h>
26 #include <asm/irq.h>
27 #include <asm/mmu_context.h>
28 #include <asm/pgtable.h>
29
30 #include "proto.h"
31 #include "irq_impl.h"
32 #include "pci_impl.h"
33 #include "machvec_impl.h"
34
35
36 /*
37 * Jensen is special: the vector is 0x8X0 for EISA interrupt X, and
38 * 0x9X0 for the local motherboard interrupts.
39 *
40 * Note especially that those local interrupts CANNOT be masked,
41 * which causes much of the pain below...
42 *
43 * 0x660 - NMI
44 *
45 * 0x800 - IRQ0 interval timer (not used, as we use the RTC timer)
46 * 0x810 - IRQ1 line printer (duh..)
47 * 0x860 - IRQ6 floppy disk
48 *
49 * 0x900 - COM1
50 * 0x920 - COM2
51 * 0x980 - keyboard
52 * 0x990 - mouse
53 *
54 * PCI-based systems are more sane: they don't have the local
55 * interrupts at all, and have only normal PCI interrupts from
56 * devices. Happily it's easy enough to do a sane mapping from the
57 * Jensen.
58 *
59 * Note that this means that we may have to do a hardware
60 * "local_op" to a different interrupt than we report to the rest of the
61 * world.
62 */
63
64 static unsigned int
jensen_local_startup(unsigned int irq)65 jensen_local_startup(unsigned int irq)
66 {
67 /* the parport is really hw IRQ 1, silly Jensen. */
68 if (irq == 7)
69 i8259a_startup_irq(1);
70 else
71 /*
72 * For all true local interrupts, set the flag that prevents
73 * the IPL from being dropped during handler processing.
74 */
75 if (irq_desc[irq].action)
76 irq_desc[irq].action->flags |= SA_INTERRUPT;
77 return 0;
78 }
79
80 static void
jensen_local_shutdown(unsigned int irq)81 jensen_local_shutdown(unsigned int irq)
82 {
83 /* the parport is really hw IRQ 1, silly Jensen. */
84 if (irq == 7)
85 i8259a_disable_irq(1);
86 }
87
88 static void
jensen_local_enable(unsigned int irq)89 jensen_local_enable(unsigned int irq)
90 {
91 /* the parport is really hw IRQ 1, silly Jensen. */
92 if (irq == 7)
93 i8259a_enable_irq(1);
94 }
95
96 static void
jensen_local_disable(unsigned int irq)97 jensen_local_disable(unsigned int irq)
98 {
99 /* the parport is really hw IRQ 1, silly Jensen. */
100 if (irq == 7)
101 i8259a_disable_irq(1);
102 }
103
104 static void
jensen_local_ack(unsigned int irq)105 jensen_local_ack(unsigned int irq)
106 {
107 /* the parport is really hw IRQ 1, silly Jensen. */
108 if (irq == 7)
109 i8259a_mask_and_ack_irq(1);
110 }
111
112 static void
jensen_local_end(unsigned int irq)113 jensen_local_end(unsigned int irq)
114 {
115 /* the parport is really hw IRQ 1, silly Jensen. */
116 if (irq == 7)
117 i8259a_end_irq(1);
118 }
119
120 static struct hw_interrupt_type jensen_local_irq_type = {
121 typename: "LOCAL",
122 startup: jensen_local_startup,
123 shutdown: jensen_local_shutdown,
124 enable: jensen_local_enable,
125 disable: jensen_local_disable,
126 ack: jensen_local_ack,
127 end: jensen_local_end,
128 };
129
130 static void
jensen_device_interrupt(unsigned long vector,struct pt_regs * regs)131 jensen_device_interrupt(unsigned long vector, struct pt_regs * regs)
132 {
133 int irq;
134
135 switch (vector) {
136 case 0x660:
137 printk("Whee.. NMI received. Probable hardware error\n");
138 printk("61=%02x, 461=%02x\n", inb(0x61), inb(0x461));
139 return;
140
141 /* local device interrupts: */
142 case 0x900: irq = 4; break; /* com1 -> irq 4 */
143 case 0x920: irq = 3; break; /* com2 -> irq 3 */
144 case 0x980: irq = 1; break; /* kbd -> irq 1 */
145 case 0x990: irq = 9; break; /* mouse -> irq 9 */
146
147 default:
148 if (vector > 0x900) {
149 printk("Unknown local interrupt %lx\n", vector);
150 return;
151 }
152
153 irq = (vector - 0x800) >> 4;
154 if (irq == 1)
155 irq = 7;
156 break;
157 }
158
159 /* If there is no handler yet... */
160 if (irq_desc[irq].action == NULL) {
161 /* If it is a local interrupt that cannot be masked... */
162 if (vector >= 0x900)
163 {
164 /* Clear keyboard/mouse state */
165 inb(0x64);
166 inb(0x60);
167 /* Reset serial ports */
168 inb(0x3fa);
169 inb(0x2fa);
170 outb(0x0c, 0x3fc);
171 outb(0x0c, 0x2fc);
172 /* Clear NMI */
173 outb(0,0x61);
174 outb(0,0x461);
175 }
176 }
177
178 #if 0
179 /* A useful bit of code to find out if an interrupt is going wild. */
180 {
181 static unsigned int last_msg = 0, last_cc = 0;
182 static int last_irq = -1, count = 0;
183 unsigned int cc;
184
185 __asm __volatile("rpcc %0" : "=r"(cc));
186 ++count;
187 #define JENSEN_CYCLES_PER_SEC (150000000)
188 if (cc - last_msg > ((JENSEN_CYCLES_PER_SEC) * 3) ||
189 irq != last_irq) {
190 printk(KERN_CRIT " irq %d count %d cc %u @ %lx\n",
191 irq, count, cc-last_cc, regs->pc);
192 count = 0;
193 last_msg = cc;
194 last_irq = irq;
195 }
196 last_cc = cc;
197 }
198 #endif
199
200 handle_irq(irq, regs);
201 }
202
203 static void __init
jensen_init_irq(void)204 jensen_init_irq(void)
205 {
206 init_i8259a_irqs();
207
208 irq_desc[1].handler = &jensen_local_irq_type;
209 irq_desc[4].handler = &jensen_local_irq_type;
210 irq_desc[3].handler = &jensen_local_irq_type;
211 irq_desc[7].handler = &jensen_local_irq_type;
212 irq_desc[9].handler = &jensen_local_irq_type;
213
214 common_init_isa_dma();
215 }
216
217 static void __init
jensen_init_arch(void)218 jensen_init_arch(void)
219 {
220 struct pci_controller *hose;
221
222 /* Create a hose so that we can report i/o base addresses to
223 userland. */
224
225 pci_isa_hose = hose = alloc_pci_controller();
226 hose->io_space = &ioport_resource;
227 hose->mem_space = &iomem_resource;
228 hose->index = 0;
229
230 hose->sparse_mem_base = EISA_MEM - IDENT_ADDR;
231 hose->dense_mem_base = 0;
232 hose->sparse_io_base = EISA_IO - IDENT_ADDR;
233 hose->dense_io_base = 0;
234
235 hose->sg_isa = hose->sg_pci = NULL;
236 __direct_map_base = 0;
237 __direct_map_size = 0xffffffff;
238 }
239
240 static void
jensen_machine_check(u64 vector,u64 la,struct pt_regs * regs)241 jensen_machine_check (u64 vector, u64 la, struct pt_regs *regs)
242 {
243 printk(KERN_CRIT "Machine check\n");
244 }
245
246 #define jensen_pci_tbi ((void*)0)
247
248
249 /*
250 * The System Vector
251 */
252
253 struct alpha_machine_vector jensen_mv __initmv = {
254 vector_name: "Jensen",
255 DO_EV4_MMU,
256 IO_LITE(JENSEN,jensen),
257 BUS(jensen),
258 machine_check: jensen_machine_check,
259 max_dma_address: ALPHA_MAX_DMA_ADDRESS,
260 rtc_port: 0x170,
261
262 nr_irqs: 16,
263 device_interrupt: jensen_device_interrupt,
264
265 init_arch: jensen_init_arch,
266 init_irq: jensen_init_irq,
267 init_rtc: common_init_rtc,
268 init_pci: NULL,
269 kill_arch: NULL,
270 };
271 ALIAS_MV(jensen)
272