2 * linux/arch/alpha/kernel/sys_rawhide.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 RAWHIDE.
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_mcpcia.h>
26 #include <asm/tlbflush.h>
31 #include "machvec_impl.h"
35 * HACK ALERT! only the boot cpu is used for interrupts.
39 /* Note mask bit is true for ENABLED irqs. */
41 static unsigned int hose_irq_masks
[4] = {
42 0xff0000, 0xfe0000, 0xff0000, 0xff0000
44 static unsigned int cached_irq_masks
[4];
45 DEFINE_SPINLOCK(rawhide_irq_lock
);
48 rawhide_update_irq_hw(int hose
, int mask
)
50 *(vuip
)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(hose
)) = mask
;
52 *(vuip
)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(hose
));
55 #define hose_exists(h) \
56 (((h) < MCPCIA_MAX_HOSES) && (cached_irq_masks[(h)] != 0))
59 rawhide_enable_irq(struct irq_data
*d
)
61 unsigned int mask
, hose
;
62 unsigned int irq
= d
->irq
;
66 if (!hose_exists(hose
)) /* if hose non-existent, exit */
72 spin_lock(&rawhide_irq_lock
);
73 mask
|= cached_irq_masks
[hose
];
74 cached_irq_masks
[hose
] = mask
;
75 rawhide_update_irq_hw(hose
, mask
);
76 spin_unlock(&rawhide_irq_lock
);
80 rawhide_disable_irq(struct irq_data
*d
)
82 unsigned int mask
, hose
;
83 unsigned int irq
= d
->irq
;
87 if (!hose_exists(hose
)) /* if hose non-existent, exit */
91 mask
= ~(1 << irq
) | hose_irq_masks
[hose
];
93 spin_lock(&rawhide_irq_lock
);
94 mask
&= cached_irq_masks
[hose
];
95 cached_irq_masks
[hose
] = mask
;
96 rawhide_update_irq_hw(hose
, mask
);
97 spin_unlock(&rawhide_irq_lock
);
101 rawhide_mask_and_ack_irq(struct irq_data
*d
)
103 unsigned int mask
, mask1
, hose
;
104 unsigned int irq
= d
->irq
;
108 if (!hose_exists(hose
)) /* if hose non-existent, exit */
113 mask
= ~mask1
| hose_irq_masks
[hose
];
115 spin_lock(&rawhide_irq_lock
);
117 mask
&= cached_irq_masks
[hose
];
118 cached_irq_masks
[hose
] = mask
;
119 rawhide_update_irq_hw(hose
, mask
);
121 /* Clear the interrupt. */
122 *(vuip
)MCPCIA_INT_REQ(MCPCIA_HOSE2MID(hose
)) = mask1
;
124 spin_unlock(&rawhide_irq_lock
);
127 static struct irq_chip rawhide_irq_type
= {
129 .irq_unmask
= rawhide_enable_irq
,
130 .irq_mask
= rawhide_disable_irq
,
131 .irq_mask_ack
= rawhide_mask_and_ack_irq
,
135 rawhide_srm_device_interrupt(unsigned long vector
)
139 irq
= (vector
- 0x800) >> 4;
142 * The RAWHIDE SRM console reports PCI interrupts with a vector
143 * 0x80 *higher* than one might expect, as PCI IRQ 0 (ie bit 0)
144 * shows up as IRQ 24, etc, etc. We adjust it down by 8 to have
145 * it line up with the actual bit numbers from the REQ registers,
146 * which is how we manage the interrupts/mask. Sigh...
148 * Also, PCI #1 interrupts are offset some more... :-(
152 /* SCSI on PCI1 is special. */
156 /* Adjust by which hose it is from. */
157 irq
-= ((irq
+ 16) >> 2) & 0x38;
163 rawhide_init_irq(void)
165 struct pci_controller
*hose
;
170 /* Clear them all; only hoses that exist will be non-zero. */
171 for (i
= 0; i
< MCPCIA_MAX_HOSES
; i
++) cached_irq_masks
[i
] = 0;
173 for (hose
= hose_head
; hose
; hose
= hose
->next
) {
174 unsigned int h
= hose
->index
;
175 unsigned int mask
= hose_irq_masks
[h
];
177 cached_irq_masks
[h
] = mask
;
178 *(vuip
)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(h
)) = mask
;
179 *(vuip
)MCPCIA_INT_MASK1(MCPCIA_HOSE2MID(h
)) = 0;
182 for (i
= 16; i
< 128; ++i
) {
183 irq_set_chip_and_handler(i
, &rawhide_irq_type
,
185 irq_set_status_flags(i
, IRQ_LEVEL
);
189 common_init_isa_dma();
193 * PCI Fixup configuration.
195 * Summary @ MCPCIA_PCI0_INT_REQ:
197 * 0 Interrupt Line A from slot 2 PCI0
198 * 1 Interrupt Line B from slot 2 PCI0
199 * 2 Interrupt Line C from slot 2 PCI0
200 * 3 Interrupt Line D from slot 2 PCI0
201 * 4 Interrupt Line A from slot 3 PCI0
202 * 5 Interrupt Line B from slot 3 PCI0
203 * 6 Interrupt Line C from slot 3 PCI0
204 * 7 Interrupt Line D from slot 3 PCI0
205 * 8 Interrupt Line A from slot 4 PCI0
206 * 9 Interrupt Line B from slot 4 PCI0
207 * 10 Interrupt Line C from slot 4 PCI0
208 * 11 Interrupt Line D from slot 4 PCI0
209 * 12 Interrupt Line A from slot 5 PCI0
210 * 13 Interrupt Line B from slot 5 PCI0
211 * 14 Interrupt Line C from slot 5 PCI0
212 * 15 Interrupt Line D from slot 5 PCI0
213 * 16 EISA interrupt (PCI 0) or SCSI interrupt (PCI 1)
217 * 1 EISA bridge (PCI bus 0 only)
218 * 2 PCI option slot 2
219 * 3 PCI option slot 3
220 * 4 PCI option slot 4
221 * 5 PCI option slot 5
226 rawhide_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
228 static char irq_tab
[5][5] __initdata
= {
229 /*INT INTA INTB INTC INTD */
230 { 16+16, 16+16, 16+16, 16+16, 16+16}, /* IdSel 1 SCSI PCI 1 */
231 { 16+ 0, 16+ 0, 16+ 1, 16+ 2, 16+ 3}, /* IdSel 2 slot 2 */
232 { 16+ 4, 16+ 4, 16+ 5, 16+ 6, 16+ 7}, /* IdSel 3 slot 3 */
233 { 16+ 8, 16+ 8, 16+ 9, 16+10, 16+11}, /* IdSel 4 slot 4 */
234 { 16+12, 16+12, 16+13, 16+14, 16+15} /* IdSel 5 slot 5 */
236 const long min_idsel
= 1, max_idsel
= 5, irqs_per_slot
= 5;
238 struct pci_controller
*hose
= dev
->sysdata
;
239 int irq
= COMMON_TABLE_LOOKUP
;
241 irq
+= 24 * hose
->index
;
250 struct alpha_machine_vector rawhide_mv __initmv
= {
251 .vector_name
= "Rawhide",
255 .machine_check
= mcpcia_machine_check
,
256 .max_isa_dma_address
= ALPHA_MAX_ISA_DMA_ADDRESS
,
257 .min_io_address
= DEFAULT_IO_BASE
,
258 .min_mem_address
= MCPCIA_DEFAULT_MEM_BASE
,
259 .pci_dac_offset
= MCPCIA_DAC_OFFSET
,
262 .device_interrupt
= rawhide_srm_device_interrupt
,
264 .init_arch
= mcpcia_init_arch
,
265 .init_irq
= rawhide_init_irq
,
266 .init_rtc
= common_init_rtc
,
267 .init_pci
= common_init_pci
,
269 .pci_map_irq
= rawhide_map_irq
,
270 .pci_swizzle
= common_swizzle
,