2 * linux/arch/alpha/kernel/sys_noritake.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 NORITAKE (AlphaServer 1000A),
9 * CORELLE (AlphaServer 800), and ALCOR Primo (AlphaStation 600A).
12 #include <linux/kernel.h>
13 #include <linux/types.h>
15 #include <linux/sched.h>
16 #include <linux/pci.h>
17 #include <linux/init.h>
18 #include <linux/bitops.h>
20 #include <asm/ptrace.h>
21 #include <asm/system.h>
24 #include <asm/mmu_context.h>
26 #include <asm/pgtable.h>
27 #include <asm/core_apecs.h>
28 #include <asm/core_cia.h>
29 #include <asm/tlbflush.h>
34 #include "machvec_impl.h"
36 /* Note mask bit is true for ENABLED irqs. */
37 static int cached_irq_mask;
40 noritake_update_irq_hw(int irq, int mask)
51 noritake_enable_irq(unsigned int irq)
53 noritake_update_irq_hw(irq, cached_irq_mask |= 1 << (irq - 16));
57 noritake_disable_irq(unsigned int irq)
59 noritake_update_irq_hw(irq, cached_irq_mask &= ~(1 << (irq - 16)));
63 noritake_startup_irq(unsigned int irq)
65 noritake_enable_irq(irq);
69 static struct hw_interrupt_type noritake_irq_type = {
70 .typename = "NORITAKE",
71 .startup = noritake_startup_irq,
72 .shutdown = noritake_disable_irq,
73 .enable = noritake_enable_irq,
74 .disable = noritake_disable_irq,
75 .ack = noritake_disable_irq,
76 .end = noritake_enable_irq,
80 noritake_device_interrupt(unsigned long vector)
85 /* Read the interrupt summary registers of NORITAKE */
86 pld = (((unsigned long) inw(0x54c) << 32)
87 | ((unsigned long) inw(0x54a) << 16)
88 | ((unsigned long) inb(0xa0) << 8)
92 * Now for every possible bit set, work through them and call
93 * the appropriate interrupt handler.
97 pld &= pld - 1; /* clear least bit set */
99 isa_device_interrupt(vector);
107 noritake_srm_device_interrupt(unsigned long vector)
111 irq = (vector - 0x800) >> 4;
114 * I really hate to do this, too, but the NORITAKE SRM console also
115 * reports PCI vectors *lower* than I expected from the bit numbers
116 * in the documentation.
117 * But I really don't want to change the fixup code for allocation
118 * of IRQs, nor the alpha_irq_mask maintenance stuff, both of which
119 * look nice and clean now.
120 * So, here's this additional grotty hack... :-(
129 noritake_init_irq(void)
134 alpha_mv.device_interrupt = noritake_srm_device_interrupt;
139 for (i = 16; i < 48; ++i) {
140 irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
141 irq_desc[i].chip = &noritake_irq_type;
145 common_init_isa_dma();
150 * PCI Fixup configuration.
152 * Summary @ 0x542, summary register #1:
154 * 0 All valid ints from summary regs 2 & 3
155 * 1 QLOGIC ISP1020A SCSI
156 * 2 Interrupt Line A from slot 0
157 * 3 Interrupt Line B from slot 0
158 * 4 Interrupt Line A from slot 1
159 * 5 Interrupt line B from slot 1
160 * 6 Interrupt Line A from slot 2
161 * 7 Interrupt Line B from slot 2
162 * 8 Interrupt Line A from slot 3
163 * 9 Interrupt Line B from slot 3
164 *10 Interrupt Line A from slot 4
165 *11 Interrupt Line B from slot 4
166 *12 Interrupt Line A from slot 5
167 *13 Interrupt Line B from slot 5
168 *14 Interrupt Line A from slot 6
169 *15 Interrupt Line B from slot 6
171 * Summary @ 0x544, summary register #2:
173 * 0 OR of all unmasked ints in SR #2
174 * 1 OR of secondary bus ints
175 * 2 Interrupt Line C from slot 0
176 * 3 Interrupt Line D from slot 0
177 * 4 Interrupt Line C from slot 1
178 * 5 Interrupt line D from slot 1
179 * 6 Interrupt Line C from slot 2
180 * 7 Interrupt Line D from slot 2
181 * 8 Interrupt Line C from slot 3
182 * 9 Interrupt Line D from slot 3
183 *10 Interrupt Line C from slot 4
184 *11 Interrupt Line D from slot 4
185 *12 Interrupt Line C from slot 5
186 *13 Interrupt Line D from slot 5
187 *14 Interrupt Line C from slot 6
188 *15 Interrupt Line D from slot 6
190 * The device to slot mapping looks like:
193 * 7 Intel PCI-EISA bridge chip
194 * 8 DEC PCI-PCI bridge chip
195 * 11 PCI on board slot 0
196 * 12 PCI on board slot 1
197 * 13 PCI on board slot 2
200 * This two layered interrupt approach means that we allocate IRQ 16 and
201 * above for PCI interrupts. The IRQ relates to which bit the interrupt
202 * comes in on. This makes interrupt processing much easier.
206 noritake_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
208 static char irq_tab[15][5] __initdata = {
209 /*INT INTA INTB INTC INTD */
210 /* note: IDSELs 16, 17, and 25 are CORELLE only */
211 { 16+1, 16+1, 16+1, 16+1, 16+1}, /* IdSel 16, QLOGIC */
212 { -1, -1, -1, -1, -1}, /* IdSel 17, S3 Trio64 */
213 { -1, -1, -1, -1, -1}, /* IdSel 18, PCEB */
214 { -1, -1, -1, -1, -1}, /* IdSel 19, PPB */
215 { -1, -1, -1, -1, -1}, /* IdSel 20, ???? */
216 { -1, -1, -1, -1, -1}, /* IdSel 21, ???? */
217 { 16+2, 16+2, 16+3, 32+2, 32+3}, /* IdSel 22, slot 0 */
218 { 16+4, 16+4, 16+5, 32+4, 32+5}, /* IdSel 23, slot 1 */
219 { 16+6, 16+6, 16+7, 32+6, 32+7}, /* IdSel 24, slot 2 */
220 { 16+8, 16+8, 16+9, 32+8, 32+9}, /* IdSel 25, slot 3 */
221 /* The following 5 are actually on PCI bus 1, which is
222 across the built-in bridge of the NORITAKE only. */
223 { 16+1, 16+1, 16+1, 16+1, 16+1}, /* IdSel 16, QLOGIC */
224 { 16+8, 16+8, 16+9, 32+8, 32+9}, /* IdSel 17, slot 3 */
225 {16+10, 16+10, 16+11, 32+10, 32+11}, /* IdSel 18, slot 4 */
226 {16+12, 16+12, 16+13, 32+12, 32+13}, /* IdSel 19, slot 5 */
227 {16+14, 16+14, 16+15, 32+14, 32+15}, /* IdSel 20, slot 6 */
229 const long min_idsel = 5, max_idsel = 19, irqs_per_slot = 5;
230 return COMMON_TABLE_LOOKUP;
234 noritake_swizzle(struct pci_dev *dev, u8 *pinp)
236 int slot, pin = *pinp;
238 if (dev->bus->number == 0) {
239 slot = PCI_SLOT(dev->devfn);
241 /* Check for the built-in bridge */
242 else if (PCI_SLOT(dev->bus->self->devfn) == 8) {
243 slot = PCI_SLOT(dev->devfn) + 15; /* WAG! */
247 /* Must be a card-based bridge. */
249 if (PCI_SLOT(dev->bus->self->devfn) == 8) {
250 slot = PCI_SLOT(dev->devfn) + 15;
253 pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn)) ;
255 /* Move up the chain of bridges. */
256 dev = dev->bus->self;
257 /* Slot of the next bridge. */
258 slot = PCI_SLOT(dev->devfn);
259 } while (dev->bus->self);
265 #if defined(CONFIG_ALPHA_GENERIC) || !defined(CONFIG_ALPHA_PRIMO)
267 noritake_apecs_machine_check(unsigned long vector, unsigned long la_ptr)
269 #define MCHK_NO_DEVSEL 0x205U
270 #define MCHK_NO_TABT 0x204U
272 struct el_common *mchk_header;
275 mchk_header = (struct el_common *)la_ptr;
277 /* Clear the error before any reporting. */
285 code = mchk_header->code;
286 process_mcheck_info(vector, la_ptr, "NORITAKE APECS",
288 && (code == MCHK_NO_DEVSEL
289 || code == MCHK_NO_TABT)));
298 #if defined(CONFIG_ALPHA_GENERIC) || !defined(CONFIG_ALPHA_PRIMO)
299 struct alpha_machine_vector noritake_mv __initmv = {
300 .vector_name = "Noritake",
304 .machine_check = noritake_apecs_machine_check,
305 .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
306 .min_io_address = EISA_DEFAULT_IO_BASE,
307 .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
310 .device_interrupt = noritake_device_interrupt,
312 .init_arch = apecs_init_arch,
313 .init_irq = noritake_init_irq,
314 .init_rtc = common_init_rtc,
315 .init_pci = common_init_pci,
316 .pci_map_irq = noritake_map_irq,
317 .pci_swizzle = noritake_swizzle,
322 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PRIMO)
323 struct alpha_machine_vector noritake_primo_mv __initmv = {
324 .vector_name = "Noritake-Primo",
328 .machine_check = cia_machine_check,
329 .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
330 .min_io_address = EISA_DEFAULT_IO_BASE,
331 .min_mem_address = CIA_DEFAULT_MEM_BASE,
334 .device_interrupt = noritake_device_interrupt,
336 .init_arch = cia_init_arch,
337 .init_irq = noritake_init_irq,
338 .init_rtc = common_init_rtc,
339 .init_pci = cia_init_pci,
340 .kill_arch = cia_kill_arch,
341 .pci_map_irq = noritake_map_irq,
342 .pci_swizzle = noritake_swizzle,
344 ALIAS_MV(noritake_primo)