2 * linux/arch/alpha/kernel/sys_miata.c
4 * Copyright (C) 1995 David A Rusling
5 * Copyright (C) 1996 Jay A Estabrook
6 * Copyright (C) 1998, 1999 Richard Henderson
8 * Code supporting the MIATA (EV56+PYXIS).
11 #include <linux/kernel.h>
12 #include <linux/types.h>
14 #include <linux/sched.h>
15 #include <linux/pci.h>
16 #include <linux/init.h>
18 #include <asm/ptrace.h>
19 #include <asm/system.h>
22 #include <asm/mmu_context.h>
24 #include <asm/pgtable.h>
25 #include <asm/core_pyxis.h>
30 #include "machvec_impl.h"
34 miata_update_irq_hw(unsigned long irq
, unsigned long mask
, int unmask_p
)
37 /* Make CERTAIN none of the bogus ints get enabled... */
38 *(vulp
)PYXIS_INT_MASK
=
39 ~((long)mask
>> 16) & ~0x400000000000063bUL
;
41 /* ... and read it back to make sure it got written. */
42 *(vulp
)PYXIS_INT_MASK
;
45 outb(mask
>> 8, 0xA1); /* ISA PIC2 */
47 outb(mask
, 0x21); /* ISA PIC1 */
51 miata_device_interrupt(unsigned long vector
, struct pt_regs
*regs
)
53 unsigned long pld
, tmp
;
56 /* Read the interrupt summary register of PYXIS */
57 pld
= *(vulp
)PYXIS_INT_REQ
;
60 * For now, AND off any bits we are not interested in:
61 * HALT (2), timer (6), ISA Bridge (7), 21142/3 (8)
62 * then all the PCI slots/INTXs (12-31).
64 /* Maybe HALT should only be used for SRM console boots? */
65 pld
&= 0x00000000fffff9c4UL
;
68 * Now for every possible bit set, work through them and call
69 * the appropriate interrupt handler.
73 pld
&= pld
- 1; /* clear least bit set */
75 isa_device_interrupt(vector
, regs
);
79 /* if not timer int */
80 handle_irq(16 + i
, 16 + i
, regs
);
82 *(vulp
)PYXIS_INT_REQ
= 1UL << i
; mb();
83 tmp
= *(vulp
)PYXIS_INT_REQ
;
88 miata_srm_device_interrupt(unsigned long vector
, struct pt_regs
* regs
)
92 ack
= irq
= (vector
- 0x800) >> 4;
95 * I really hate to do this, but the MIATA SRM console ignores the
96 * low 8 bits in the interrupt summary register, and reports the
97 * vector 0x80 *lower* than I expected from the bit numbering in
99 * This was done because the low 8 summary bits really aren't used
100 * for reporting any interrupts (the PCI-ISA bridge, bit 7, isn't
101 * used for this purpose, as PIC interrupts are delivered as the
102 * vectors 0x800-0x8f0).
103 * But I really don't want to change the fixup code for allocation
104 * of IRQs, nor the alpha_irq_mask maintenance stuff, both of which
105 * look nice and clean now.
106 * So, here's this grotty hack... :-(
111 handle_irq(irq
, ack
, regs
);
117 STANDARD_INIT_IRQ_PROLOG
;
120 alpha_mv
.device_interrupt
= miata_srm_device_interrupt
;
122 /* Note invert on MASK bits. */
123 *(vulp
)PYXIS_INT_MASK
=
124 ~((long)alpha_irq_mask
>> 16) & ~0x400000000000063bUL
; mb();
126 /* These break on MiataGL so we'll try not to do it at all. */
127 *(vulp
)PYXIS_INT_HILO
= 0x000000B2UL
; mb(); /* ISA/NMI HI */
128 *(vulp
)PYXIS_RT_COUNT
= 0UL; mb(); /* clear count */
130 /* Clear upper timer. */
131 *(vulp
)PYXIS_INT_REQ
= 0x4000000000000180UL
; mb();
133 enable_irq(16 + 2); /* enable HALT switch - SRM only? */
134 enable_irq(16 + 6); /* enable timer */
135 enable_irq(16 + 7); /* enable ISA PIC cascade */
136 enable_irq(2); /* enable cascade */
141 * PCI Fixup configuration.
143 * Summary @ PYXIS_INT_REQ:
147 * 2 Halt/Reset switch
154 * 9 EIDE (deprecated, ISA 14/15 used)
157 *12 Interrupt Line A from slot 4
158 *13 Interrupt Line B from slot 4
159 *14 Interrupt Line C from slot 4
160 *15 Interrupt Line D from slot 4
161 *16 Interrupt Line A from slot 5
162 *17 Interrupt line B from slot 5
163 *18 Interrupt Line C from slot 5
164 *19 Interrupt Line D from slot 5
165 *20 Interrupt Line A from slot 1
166 *21 Interrupt Line B from slot 1
167 *22 Interrupt Line C from slot 1
168 *23 Interrupt Line D from slot 1
169 *24 Interrupt Line A from slot 2
170 *25 Interrupt Line B from slot 2
171 *26 Interrupt Line C from slot 2
172 *27 Interrupt Line D from slot 2
173 *27 Interrupt Line A from slot 3
174 *29 Interrupt Line B from slot 3
175 *30 Interrupt Line C from slot 3
176 *31 Interrupt Line D from slot 3
178 * The device to slot mapping looks like:
186 * 8 PCI-PCI Bridge (SBU Riser)
189 * 11 PCI on board slot 4 (SBU Riser)
190 * 12 PCI on board slot 5 (SBU Riser)
192 * These are behind the bridge, so I'm not sure what to do...
194 * 13 PCI on board slot 1 (SBU Riser)
195 * 14 PCI on board slot 2 (SBU Riser)
196 * 15 PCI on board slot 3 (SBU Riser)
199 * This two layered interrupt approach means that we allocate IRQ 16 and
200 * above for PCI interrupts. The IRQ relates to which bit the interrupt
201 * comes in on. This makes interrupt processing much easier.
205 miata_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
207 static char irq_tab
[18][5] __initlocaldata
= {
208 /*INT INTA INTB INTC INTD */
209 {16+ 8, 16+ 8, 16+ 8, 16+ 8, 16+ 8}, /* IdSel 14, DC21142 */
210 { -1, -1, -1, -1, -1}, /* IdSel 15, EIDE */
211 { -1, -1, -1, -1, -1}, /* IdSel 16, none */
212 { -1, -1, -1, -1, -1}, /* IdSel 17, none */
213 { -1, -1, -1, -1, -1}, /* IdSel 18, PCI-ISA */
214 { -1, -1, -1, -1, -1}, /* IdSel 19, PCI-PCI */
215 { -1, -1, -1, -1, -1}, /* IdSel 20, none */
216 { -1, -1, -1, -1, -1}, /* IdSel 21, none */
217 {16+12, 16+12, 16+13, 16+14, 16+15}, /* IdSel 22, slot 4 */
218 {16+16, 16+16, 16+17, 16+18, 16+19}, /* IdSel 23, slot 5 */
219 /* the next 7 are actually on PCI bus 1, across the bridge */
220 {16+11, 16+11, 16+11, 16+11, 16+11}, /* IdSel 24, QLISP/GL*/
221 { -1, -1, -1, -1, -1}, /* IdSel 25, none */
222 { -1, -1, -1, -1, -1}, /* IdSel 26, none */
223 { -1, -1, -1, -1, -1}, /* IdSel 27, none */
224 {16+20, 16+20, 16+21, 16+22, 16+23}, /* IdSel 28, slot 1 */
225 {16+24, 16+24, 16+25, 16+26, 16+27}, /* IdSel 29, slot 2 */
226 {16+28, 16+28, 16+29, 16+30, 16+31}, /* IdSel 30, slot 3 */
227 /* This bridge is on the main bus of the later orig MIATA */
228 { -1, -1, -1, -1, -1}, /* IdSel 31, PCI-PCI */
230 const long min_idsel
= 3, max_idsel
= 20, irqs_per_slot
= 5;
231 return COMMON_TABLE_LOOKUP
;
235 miata_swizzle(struct pci_dev
*dev
, u8
*pinp
)
237 int slot
, pin
= *pinp
;
239 if (dev
->bus
->number
== 0) {
240 slot
= PCI_SLOT(dev
->devfn
);
242 /* Check for the built-in bridge. */
243 else if ((PCI_SLOT(dev
->bus
->self
->devfn
) == 8) ||
244 (PCI_SLOT(dev
->bus
->self
->devfn
) == 20)) {
245 slot
= PCI_SLOT(dev
->devfn
) + 9;
249 /* Must be a card-based bridge. */
251 if ((PCI_SLOT(dev
->bus
->self
->devfn
) == 8) ||
252 (PCI_SLOT(dev
->bus
->self
->devfn
) == 20)) {
253 slot
= PCI_SLOT(dev
->devfn
) + 9;
256 pin
= bridge_swizzle(pin
, PCI_SLOT(dev
->devfn
));
258 /* Move up the chain of bridges. */
259 dev
= dev
->bus
->self
;
260 /* Slot of the next bridge. */
261 slot
= PCI_SLOT(dev
->devfn
);
262 } while (dev
->bus
->self
);
272 SMC669_Init(0); /* it might be a GL (fails harmlessly if not) */
277 miata_kill_arch (int mode
, char *reboot_cmd
)
279 /* Who said DEC engineers have no sense of humor? ;-) */
280 if (alpha_using_srm
) {
281 *(vuip
) PYXIS_RESET
= 0x0000dead;
284 common_kill_arch(mode
, reboot_cmd
);
292 struct alpha_machine_vector miata_mv __initmv
= {
293 vector_name
: "Miata",
298 machine_check
: pyxis_machine_check
,
299 max_dma_address
: ALPHA_MAX_DMA_ADDRESS
,
300 min_io_address
: DEFAULT_IO_BASE
,
301 min_mem_address
: DEFAULT_MEM_BASE
,
304 irq_probe_mask
: _PROBE_MASK(48),
305 update_irq_hw
: miata_update_irq_hw
,
306 ack_irq
: common_ack_irq
,
307 device_interrupt
: miata_device_interrupt
,
309 init_arch
: pyxis_init_arch
,
310 init_irq
: miata_init_irq
,
311 init_pit
: common_init_pit
,
312 init_pci
: miata_init_pci
,
313 kill_arch
: miata_kill_arch
,
314 pci_map_irq
: miata_map_irq
,
315 pci_swizzle
: miata_swizzle
,