1 /* $NetBSD: pci_2100_a500.c,v 1.8 2007/12/03 15:33:06 ad Exp $ */
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 __KERNEL_RCSID(0, "$NetBSD: pci_2100_a500.c,v 1.8 2007/12/03 15:33:06 ad Exp $");
36 #include <sys/types.h>
37 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/errno.h>
41 #include <sys/malloc.h>
42 #include <sys/device.h>
43 #include <sys/syslog.h>
45 #include <machine/autoconf.h>
47 #include <dev/eisa/eisavar.h>
49 #include <dev/pci/pcireg.h>
50 #include <dev/pci/pcivar.h>
52 #include <alpha/pci/ttwogareg.h>
53 #include <alpha/pci/ttwogavar.h>
54 #include <alpha/pci/pci_2100_a500.h>
56 static bus_space_tag_t pic_iot
;
57 static bus_space_handle_t pic_master_ioh
;
58 static bus_space_handle_t pic_slave_ioh
[4];
59 static bus_space_handle_t pic_elcr_ioh
;
61 static const int pic_slave_to_master
[4] = { 1, 3, 4, 5 };
63 int dec_2100_a500_pic_intr_map(struct pci_attach_args
*,
66 int dec_2100_a500_icic_intr_map(struct pci_attach_args
*,
69 const char *dec_2100_a500_intr_string(void *, pci_intr_handle_t
);
70 const struct evcnt
*dec_2100_a500_intr_evcnt(void *, pci_intr_handle_t
);
71 void *dec_2100_a500_intr_establish(void *, pci_intr_handle_t
,
72 int, int (*)(void *), void *);
73 void dec_2100_a500_intr_disestablish(void *, void *);
75 int dec_2100_a500_eisa_intr_map(void *, u_int
, eisa_intr_handle_t
*);
76 const char *dec_2100_a500_eisa_intr_string(void *, int);
77 const struct evcnt
*dec_2100_a500_eisa_intr_evcnt(void *, int);
78 void *dec_2100_a500_eisa_intr_establish(void *, int, int, int,
79 int (*)(void *), void *);
80 void dec_2100_a500_eisa_intr_disestablish(void *, void *);
81 int dec_2100_a500_eisa_intr_alloc(void *, int, int, int *);
83 #define PCI_STRAY_MAX 5
86 * On systems with cascaded 8259s, it's actually 32. Systems which
87 * use the ICIC interrupt logic have 64, however.
89 #define SABLE_MAX_IRQ 64
90 #define SABLE_8259_MAX_IRQ 32
92 void dec_2100_a500_iointr(void *, u_long
);
94 void dec_2100_a500_pic_enable_intr(struct ttwoga_config
*, int, int);
95 void dec_2100_a500_pic_init_intr(struct ttwoga_config
*);
96 void dec_2100_a500_pic_setlevel(struct ttwoga_config
*, int, int);
97 void dec_2100_a500_pic_eoi(struct ttwoga_config
*, int);
99 void dec_2100_a500_icic_enable_intr(struct ttwoga_config
*, int, int);
100 void dec_2100_a500_icic_init_intr(struct ttwoga_config
*);
101 void dec_2100_a500_icic_setlevel(struct ttwoga_config
*, int, int);
102 void dec_2100_a500_icic_eoi(struct ttwoga_config
*, int);
104 #define T2_IRQ_EISA_START 7
105 #define T2_IRQ_EISA_COUNT 16
107 #define T2_IRQ_IS_EISA(irq) \
108 ((irq) >= T2_IRQ_EISA_START && \
109 (irq) < (T2_IRQ_EISA_START + T2_IRQ_EISA_COUNT))
111 const int dec_2100_a500_intr_deftype
[SABLE_MAX_IRQ
] = {
112 IST_LEVEL
, /* PCI slot 0 A */
113 IST_LEVEL
, /* on-board SCSI */
114 IST_LEVEL
, /* on-board Ethernet */
115 IST_EDGE
, /* mouse */
116 IST_LEVEL
, /* PCI slot 1 A */
117 IST_LEVEL
, /* PCI slot 2 A */
118 IST_EDGE
, /* keyboard */
119 IST_EDGE
, /* floppy (EISA IRQ 0) */
120 IST_EDGE
, /* serial port 1 (EISA IRQ 1) */
121 IST_EDGE
, /* parallel port (EISA IRQ 2) */
122 IST_NONE
, /* EISA IRQ 3 (edge/level) */
123 IST_NONE
, /* EISA IRQ 4 (edge/level) */
124 IST_NONE
, /* EISA IRQ 5 (edge/level) */
125 IST_NONE
, /* EISA IRQ 6 (edge/level) */
126 IST_NONE
, /* EISA IRQ 7 (edge/level) */
127 IST_EDGE
, /* serial port 0 (EISA IRQ 8) */
128 IST_NONE
, /* EISA IRQ 9 (edge/level) */
129 IST_NONE
, /* EISA IRQ 10 (edge/level) */
130 IST_NONE
, /* EISA IRQ 11 (edge/level) */
131 IST_NONE
, /* EISA IRQ 12 (edge/level) */
132 IST_LEVEL
, /* PCI slot 2 B (EISA IRQ 13 n/c) */
133 IST_NONE
, /* EISA IRQ 14 (edge/level) */
134 IST_NONE
, /* EISA IRQ 15 (edge/level) */
135 IST_LEVEL
, /* I2C (XXX double-check this) */
136 IST_LEVEL
, /* PCI slot 0 B */
137 IST_LEVEL
, /* PCI slot 1 B */
138 IST_LEVEL
, /* PCI slot 0 C */
139 IST_LEVEL
, /* PCI slot 1 C */
140 IST_LEVEL
, /* PCI slot 2 C */
141 IST_LEVEL
, /* PCI slot 0 D */
142 IST_LEVEL
, /* PCI slot 1 D */
143 IST_LEVEL
, /* PCI slot 2 D */
146 * These are the PCI interrupts on the T3/T4 systems. See
147 * dec_2100_a500_icic_intr_map() for the mapping.
184 pci_2100_a500_pickintr(struct ttwoga_config
*tcp
)
186 pci_chipset_tag_t pc
= &tcp
->tc_pc
;
190 pic_iot
= &tcp
->tc_iot
;
193 pc
->pc_intr_string
= dec_2100_a500_intr_string
;
194 pc
->pc_intr_evcnt
= dec_2100_a500_intr_evcnt
;
195 pc
->pc_intr_establish
= dec_2100_a500_intr_establish
;
196 pc
->pc_intr_disestablish
= dec_2100_a500_intr_disestablish
;
198 /* Not supported on T2. */
199 pc
->pc_pciide_compat_intr_establish
= NULL
;
201 tcp
->tc_intrtab
= alpha_shared_intr_alloc(SABLE_MAX_IRQ
, 8);
202 for (i
= 0; i
< SABLE_MAX_IRQ
; i
++) {
203 alpha_shared_intr_set_dfltsharetype(tcp
->tc_intrtab
,
204 i
, tcp
->tc_hose
== 0 ?
205 dec_2100_a500_intr_deftype
[i
] : IST_LEVEL
);
206 alpha_shared_intr_set_maxstrays(tcp
->tc_intrtab
,
209 cp
= alpha_shared_intr_string(tcp
->tc_intrtab
, i
);
210 sprintf(cp
, "irq %d", T2_IRQ_IS_EISA(i
) ?
211 i
- T2_IRQ_EISA_START
: i
);
212 evcnt_attach_dynamic(alpha_shared_intr_evcnt(
213 tcp
->tc_intrtab
, i
), EVCNT_TYPE_INTR
, NULL
,
214 T2_IRQ_IS_EISA(i
) ? "eisa" : "T2", cp
);
217 /* 64 16-byte vectors per hose. */
218 tcp
->tc_vecbase
= 0x800 + ((64 * 16) * tcp
->tc_hose
);
221 * T2 uses a custom layout of cascaded 8259 PICs for interrupt
222 * control. T3 and T4 use a built-in interrupt controller.
224 * Note that the external PCI bus (Hose 1) always uses
225 * the new interrupt controller.
227 if (tcp
->tc_rev
< TRN_T3
&& tcp
->tc_hose
== 0) {
228 pc
->pc_intr_map
= dec_2100_a500_pic_intr_map
;
229 tcp
->tc_enable_intr
= dec_2100_a500_pic_enable_intr
;
230 tcp
->tc_setlevel
= dec_2100_a500_pic_setlevel
;
231 tcp
->tc_eoi
= dec_2100_a500_pic_eoi
;
232 dec_2100_a500_pic_init_intr(tcp
);
234 pc
->pc_intr_map
= dec_2100_a500_icic_intr_map
;
235 tcp
->tc_enable_intr
= dec_2100_a500_icic_enable_intr
;
236 tcp
->tc_setlevel
= dec_2100_a500_icic_setlevel
;
237 tcp
->tc_eoi
= dec_2100_a500_icic_eoi
;
238 dec_2100_a500_icic_init_intr(tcp
);
243 pci_2100_a500_eisa_pickintr(pci_chipset_tag_t pc
, eisa_chipset_tag_t ec
)
246 ec
->ec_v
= pc
->pc_intr_v
;
247 ec
->ec_intr_map
= dec_2100_a500_eisa_intr_map
;
248 ec
->ec_intr_string
= dec_2100_a500_eisa_intr_string
;
249 ec
->ec_intr_evcnt
= dec_2100_a500_eisa_intr_evcnt
;
250 ec
->ec_intr_establish
= dec_2100_a500_eisa_intr_establish
;
251 ec
->ec_intr_disestablish
= dec_2100_a500_eisa_intr_disestablish
;
255 pci_2100_a500_isa_pickintr(pci_chipset_tag_t pc
, isa_chipset_tag_t ic
)
258 ic
->ic_v
= pc
->pc_intr_v
;
259 ic
->ic_intr_evcnt
= dec_2100_a500_eisa_intr_evcnt
;
260 ic
->ic_intr_establish
= dec_2100_a500_eisa_intr_establish
;
261 ic
->ic_intr_disestablish
= dec_2100_a500_eisa_intr_disestablish
;
262 ic
->ic_intr_alloc
= dec_2100_a500_eisa_intr_alloc
;
265 /*****************************************************************************
266 * PCI interrupt support.
267 *****************************************************************************/
270 dec_2100_a500_pic_intr_map(struct pci_attach_args
*pa
,
271 pci_intr_handle_t
*ihp
)
274 * Interrupts in the Sable are even more of a pain than other
275 * Alpha systems. The interrupt logic is made up of 5 8259
276 * PICs, arranged as follows:
278 * Slave 0 --------------------------------+
281 * 2 on-board Ethernet |
286 * 7 floppy (EISA IRQ 0) |
288 * Slave 1 ------------------------+ | Master
289 * 0 serial port 1 (EISA IRQ 1) | | 0 ESC interrupt
290 * 1 parallel port (EISA IRQ 2) | +-- 1 Slave 0
291 * 2 EISA IRQ 3 | 2 reserved
292 * 3 EISA IRQ 4 +---------- 3 Slave 1
293 * 4 EISA IRQ 5 +---------- 4 Slave 2
294 * 5 EISA IRQ 6 | +-- 5 Slave 3
295 * 6 EISA IRQ 7 | | 6 reserved
296 * 7 serial port 0 (EISA IRQ 8) | | 7 n/c
298 * Slave 2 ------------------------+ |
303 * 4 PCI slot 2 B (EISA IRQ 13 n/c) |
308 * Slave 3 --------------------------------+
318 * Careful readers will note that the PCEB does not handle ISA
319 * interrupts at all; when ISA interrupts are established, they
320 * must be mapped to Sable interrupts. Thankfully, this is easy
323 * The T3 and T4, generally found on Lynx, use a totally different
324 * scheme because they have more PCI interrupts to handle; see below.
326 static const int irqmap
[9/*device*/][4/*pin*/] = {
327 { 0x02, -1, -1, -1 }, /* 0: on-board Ethernet */
328 { 0x01, -1, -1, -1 }, /* 1: on-board SCSI */
329 { -1, -1, -1, -1 }, /* 2: invalid */
330 { -1, -1, -1, -1 }, /* 3: invalid */
331 { -1, -1, -1, -1 }, /* 4: invalid */
332 { -1, -1, -1, -1 }, /* 5: invalid */
333 { 0x00, 0x18, 0x1a, 0x1d }, /* 6: PCI slot 0 */
334 { 0x04, 0x19, 0x1b, 0x1e }, /* 7: PCI slot 1 */
335 { 0x05, 0x14, 0x1c, 0x1f }, /* 8: PCI slot 2 */
337 pcitag_t bustag
= pa
->pa_intrtag
;
338 int buspin
= pa
->pa_intrpin
;
339 pci_chipset_tag_t pc
= pa
->pa_pc
;
348 printf("dec_2100_a500_pic_intr_map: bad interrupt pin %d\n",
353 pci_decompose_tag(pc
, bustag
, NULL
, &device
, NULL
);
355 printf("dec_2100_a500_pic_intr_map: bad device %d\n",
360 irq
= irqmap
[device
][buspin
- 1];
362 printf("dec_2100_a500_pic_intr_map: no mapping for "
363 "device %d pin %d\n", device
, buspin
);
371 dec_2100_a500_icic_intr_map(struct pci_attach_args
*pa
, pci_intr_handle_t
*ihp
)
373 pcitag_t bustag
= pa
->pa_intrtag
;
374 int buspin
= pa
->pa_intrpin
;
375 pci_chipset_tag_t pc
= pa
->pa_pc
;
384 printf("dec_2100_a500_icic_intr_map: bad interrupt in %d\n",
389 pci_decompose_tag(pc
, bustag
, NULL
, &device
, NULL
);
391 case 0: /* on-board Ethernet */
395 case 1: /* on-board SCSI */
399 case 6: /* PCI slots */
402 irq
= (32 + (4 * (device
- 6))) + (buspin
- 1);
406 printf("dec_2100_a500_icic_intr_map: bad device %d\n",
416 dec_2100_a500_intr_string(void *v
, pci_intr_handle_t ih
)
418 static char irqstr
[15]; /* 11 + 2 + NULL + sanity */
420 if (ih
>= SABLE_MAX_IRQ
)
421 panic("dec_2100_a500_intr_string: bogus T2 IRQ 0x%lx", ih
);
423 sprintf(irqstr
, "T2 irq %ld", ih
);
428 dec_2100_a500_intr_evcnt(void *v
, pci_intr_handle_t ih
)
430 struct ttwoga_config
*tcp
= v
;
432 if (ih
>= SABLE_MAX_IRQ
)
433 panic("dec_2100_a500_intr_evcnt: bogus T2 IRQ 0x%lx", ih
);
435 return (alpha_shared_intr_evcnt(tcp
->tc_intrtab
, ih
));
439 dec_2100_a500_intr_establish(void *v
, pci_intr_handle_t ih
, int level
,
440 int (*func
)(void *), void *arg
)
442 struct ttwoga_config
*tcp
= v
;
445 if (ih
>= SABLE_MAX_IRQ
)
446 panic("dec_2100_a500_intr_establish: bogus IRQ 0x%lx",
449 cookie
= alpha_shared_intr_establish(tcp
->tc_intrtab
, ih
,
450 dec_2100_a500_intr_deftype
[ih
], level
, func
, arg
, "T2 irq");
452 if (cookie
!= NULL
&&
453 alpha_shared_intr_firstactive(tcp
->tc_intrtab
, ih
)) {
454 scb_set(tcp
->tc_vecbase
+ SCB_IDXTOVEC(ih
),
455 dec_2100_a500_iointr
, tcp
, level
);
456 (*tcp
->tc_enable_intr
)(tcp
, ih
, 1);
463 dec_2100_a500_intr_disestablish(void *v
, void *cookie
)
465 struct ttwoga_config
*tcp
= v
;
466 struct alpha_shared_intrhand
*ih
= cookie
;
467 unsigned int irq
= ih
->ih_num
;
472 alpha_shared_intr_disestablish(tcp
->tc_intrtab
, cookie
,
474 if (alpha_shared_intr_isactive(tcp
->tc_intrtab
, irq
) == 0) {
475 (*tcp
->tc_enable_intr
)(tcp
, irq
, 0);
476 alpha_shared_intr_set_dfltsharetype(tcp
->tc_intrtab
,
477 irq
, dec_2100_a500_intr_deftype
[irq
]);
478 scb_free(tcp
->tc_vecbase
+ SCB_IDXTOVEC(irq
));
484 /*****************************************************************************
485 * EISA interrupt support.
486 *****************************************************************************/
489 dec_2100_a500_eisa_intr_map(void *v
, u_int eirq
, eisa_intr_handle_t
*ihp
)
493 printf("dec_2100_a500_eisa_intr_map: bad EISA IRQ %d\n",
500 * EISA IRQ 13 is not connected.
503 printf("dec_2100_a500_eisa_intr_map: EISA IRQ 13 not "
510 * Don't map to a T2 IRQ here; we must do this when we hook the
511 * interrupt up, since ISA interrupts aren't explicitly translated.
519 dec_2100_a500_eisa_intr_string(void *v
, int eirq
)
521 static char irqstr
[32];
523 if (eirq
> 15 || eirq
== 13)
524 panic("dec_2100_a500_eisa_intr_string: bogus EISA IRQ 0x%x",
527 sprintf(irqstr
, "eisa irq %d (T2 irq %d)", eirq
,
528 eirq
+ T2_IRQ_EISA_START
);
533 dec_2100_a500_eisa_intr_evcnt(void *v
, int eirq
)
535 struct ttwoga_config
*tcp
= v
;
537 if (eirq
> 15 || eirq
== 13)
538 panic("dec_2100_a500_eisa_intr_evcnt: bogus EISA IRQ 0x%x",
541 return (alpha_shared_intr_evcnt(tcp
->tc_intrtab
,
542 eirq
+ T2_IRQ_EISA_START
));
546 dec_2100_a500_eisa_intr_establish(void *v
, int eirq
, int type
, int level
,
547 int (*fn
)(void *), void *arg
)
549 struct ttwoga_config
*tcp
= v
;
553 if (eirq
> 15 || type
== IST_NONE
)
554 panic("dec_2100_a500_eisa_intr_establish: bogus irq or type");
557 printf("dec_2100_a500_eisa_intr_establish: EISA IRQ 13 not "
562 irq
= eirq
+ T2_IRQ_EISA_START
;
565 * We can't change the trigger type of some interrupts. Don't allow
566 * level triggers to be hooked up to non-changeable edge triggers.
568 if (dec_2100_a500_intr_deftype
[irq
] == IST_EDGE
&& type
== IST_LEVEL
) {
569 printf("dec_2100_a500_eisa_intr_establish: non-EDGE on EDGE\n");
573 cookie
= alpha_shared_intr_establish(tcp
->tc_intrtab
, irq
,
574 type
, level
, fn
, arg
, "T2 irq");
576 if (cookie
!= NULL
&&
577 alpha_shared_intr_firstactive(tcp
->tc_intrtab
, irq
)) {
578 scb_set(tcp
->tc_vecbase
+ SCB_IDXTOVEC(irq
),
579 dec_2100_a500_iointr
, tcp
, level
);
580 (*tcp
->tc_setlevel
)(tcp
, eirq
,
581 alpha_shared_intr_get_sharetype(tcp
->tc_intrtab
,
583 (*tcp
->tc_enable_intr
)(tcp
, irq
, 1);
590 dec_2100_a500_eisa_intr_disestablish(void *v
, void *cookie
)
592 struct ttwoga_config
*tcp
= v
;
593 struct alpha_shared_intrhand
*ih
= cookie
;
594 int s
, irq
= ih
->ih_num
;
598 /* Remove it from the link. */
599 alpha_shared_intr_disestablish(tcp
->tc_intrtab
, cookie
,
602 if (alpha_shared_intr_isactive(tcp
->tc_intrtab
, irq
) == 0) {
603 (*tcp
->tc_enable_intr
)(tcp
, irq
, 0);
604 alpha_shared_intr_set_dfltsharetype(tcp
->tc_intrtab
,
605 irq
, dec_2100_a500_intr_deftype
[irq
]);
606 scb_free(tcp
->tc_vecbase
+ SCB_IDXTOVEC(irq
));
613 dec_2100_a500_eisa_intr_alloc(void *v
, int mask
, int type
, int *eirqp
)
616 /* XXX Not supported right now. */
620 /*****************************************************************************
621 * Interrupt support routines.
622 *****************************************************************************/
624 #define ICIC_ADDR(tcp, addr) \
627 T2GA((tcp), T2_AIR) = (addr); \
630 (void) T2GA((tcp), T2_AIR); \
635 #define ICIC_READ(tcp) T2GA((tcp), T2_DIR)
636 #define ICIC_WRITE(tcp, val) \
639 T2GA((tcp), T2_DIR) = (val); \
645 dec_2100_a500_iointr(void *arg
, u_long vec
)
647 struct ttwoga_config
*tcp
= arg
;
650 irq
= SCB_VECTOIDX(vec
- tcp
->tc_vecbase
);
652 rv
= alpha_shared_intr_dispatch(tcp
->tc_intrtab
, irq
);
653 (*tcp
->tc_eoi
)(tcp
, irq
);
655 alpha_shared_intr_stray(tcp
->tc_intrtab
, irq
, "T2 irq");
656 if (ALPHA_SHARED_INTR_DISABLE(tcp
->tc_intrtab
, irq
))
657 (*tcp
->tc_enable_intr
)(tcp
, irq
, 0);
659 alpha_shared_intr_reset_strays(tcp
->tc_intrtab
, irq
);
663 dec_2100_a500_pic_enable_intr(struct ttwoga_config
*tcp
, int irq
, int onoff
)
669 bit
= 1 << (irq
& 0x7);
671 mask
= bus_space_read_1(pic_iot
, pic_slave_ioh
[pic
], 1);
676 bus_space_write_1(pic_iot
, pic_slave_ioh
[pic
], 1, mask
);
680 dec_2100_a500_icic_enable_intr(struct ttwoga_config
*tcp
, int irq
, int onoff
)
686 ICIC_ADDR(tcp
, 0x40);
688 mask
= ICIC_READ(tcp
);
693 ICIC_WRITE(tcp
, mask
);
697 dec_2100_a500_pic_init_intr(struct ttwoga_config
*tcp
)
699 static const int picaddr
[4] = {
700 0x536, 0x53a, 0x53c, 0x53e
705 * Map the master PIC.
707 if (bus_space_map(pic_iot
, 0x534, 2, 0, &pic_master_ioh
))
708 panic("dec_2100_a500_pic_init_intr: unable to map master PIC");
711 * Map all slave PICs and mask off the interrupts on them.
713 for (pic
= 0; pic
< 4; pic
++) {
714 if (bus_space_map(pic_iot
, picaddr
[pic
], 2, 0,
715 &pic_slave_ioh
[pic
]))
716 panic("dec_2100_a500_pic_init_intr: unable to map "
717 "slave PIC %d", pic
);
718 bus_space_write_1(pic_iot
, pic_slave_ioh
[pic
], 1, 0xff);
722 * Map the ELCR registers.
724 if (bus_space_map(pic_iot
, 0x26, 2, 0, &pic_elcr_ioh
))
725 panic("dec_2100_a500_pic_init_intr: unable to map ELCR "
730 dec_2100_a500_icic_init_intr(struct ttwoga_config
*tcp
)
733 ICIC_ADDR(tcp
, 0x40);
734 ICIC_WRITE(tcp
, 0xffffffffffffffffUL
);
738 dec_2100_a500_pic_setlevel(struct ttwoga_config
*tcp
, int eirq
, int level
)
743 switch (eirq
) { /* EISA IRQ */
750 bit
= 1 << (eirq
- 3);
757 bit
= 1 << (eirq
- 4);
762 bit
= 1 << (eirq
- 12);
768 bit
= 1 << (eirq
- 13);
772 panic("dec_2100_a500_pic_setlevel: bogus EISA IRQ %d", eirq
);
775 mask
= bus_space_read_1(pic_iot
, pic_elcr_ioh
, elcr
);
780 bus_space_write_1(pic_iot
, pic_elcr_ioh
, elcr
, mask
);
784 dec_2100_a500_icic_setlevel(struct ttwoga_config
*tcp
, int eirq
, int level
)
800 bit
= 1UL << (eirq
+ T2_IRQ_EISA_START
);
802 ICIC_ADDR(tcp
, 0x50);
803 mask
= ICIC_READ(tcp
);
808 ICIC_WRITE(tcp
, mask
);
812 panic("dec_2100_a500_icic_setlevel: bogus EISA IRQ %d", eirq
);
817 dec_2100_a500_pic_eoi(struct ttwoga_config
*tcp
, int irq
)
821 if (irq
>= 0 && irq
<= 7)
823 else if (irq
>= 8 && irq
<= 15)
825 else if (irq
>= 16 && irq
<= 23)
830 bus_space_write_1(pic_iot
, pic_slave_ioh
[pic
], 0,
831 0xe0 | (irq
- (8 * pic
)));
832 bus_space_write_1(pic_iot
, pic_master_ioh
, 0,
833 0xe0 | pic_slave_to_master
[pic
]);
837 dec_2100_a500_icic_eoi(struct ttwoga_config
*tcp
, int irq
)
840 T2GA(tcp
, T2_VAR
) = irq
;
842 alpha_mb(); /* MAGIC */