1 1.18 thorpej /* $NetBSD: pci_2100_a500.c,v 1.18 2021/07/04 22:42:36 thorpej Exp $ */ 2 1.1 thorpej 3 1.1 thorpej /*- 4 1.1 thorpej * Copyright (c) 1999 The NetBSD Foundation, Inc. 5 1.1 thorpej * All rights reserved. 6 1.1 thorpej * 7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation 8 1.1 thorpej * by Jason R. Thorpe. 9 1.1 thorpej * 10 1.1 thorpej * Redistribution and use in source and binary forms, with or without 11 1.1 thorpej * modification, are permitted provided that the following conditions 12 1.1 thorpej * are met: 13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright 14 1.1 thorpej * notice, this list of conditions and the following disclaimer. 15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the 17 1.1 thorpej * documentation and/or other materials provided with the distribution. 18 1.1 thorpej * 19 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE. 30 1.1 thorpej */ 31 1.1 thorpej 32 1.1 thorpej #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 33 1.1 thorpej 34 1.18 thorpej __KERNEL_RCSID(0, "$NetBSD: pci_2100_a500.c,v 1.18 2021/07/04 22:42:36 thorpej Exp $"); 35 1.1 thorpej 36 1.1 thorpej #include <sys/types.h> 37 1.1 thorpej #include <sys/param.h> 38 1.1 thorpej #include <sys/time.h> 39 1.1 thorpej #include <sys/systm.h> 40 1.1 thorpej #include <sys/errno.h> 41 1.17 thorpej #include <sys/kmem.h> 42 1.1 thorpej #include <sys/device.h> 43 1.14 thorpej #include <sys/cpu.h> 44 1.1 thorpej #include <sys/syslog.h> 45 1.1 thorpej 46 1.1 thorpej #include <machine/autoconf.h> 47 1.15 thorpej #include <machine/rpb.h> 48 1.1 thorpej 49 1.1 thorpej #include <dev/eisa/eisavar.h> 50 1.1 thorpej 51 1.1 thorpej #include <dev/pci/pcireg.h> 52 1.1 thorpej #include <dev/pci/pcivar.h> 53 1.1 thorpej 54 1.1 thorpej #include <alpha/pci/ttwogareg.h> 55 1.1 thorpej #include <alpha/pci/ttwogavar.h> 56 1.1 thorpej #include <alpha/pci/pci_2100_a500.h> 57 1.1 thorpej 58 1.1 thorpej static bus_space_tag_t pic_iot; 59 1.1 thorpej static bus_space_handle_t pic_master_ioh; 60 1.1 thorpej static bus_space_handle_t pic_slave_ioh[4]; 61 1.1 thorpej static bus_space_handle_t pic_elcr_ioh; 62 1.1 thorpej 63 1.1 thorpej static const int pic_slave_to_master[4] = { 1, 3, 4, 5 }; 64 1.1 thorpej 65 1.13 thorpej static int dec_2100_a500_pic_intr_map(const struct pci_attach_args *, 66 1.13 thorpej pci_intr_handle_t *); 67 1.1 thorpej 68 1.13 thorpej static int dec_2100_a500_icic_intr_map(const struct pci_attach_args *, 69 1.13 thorpej pci_intr_handle_t *); 70 1.1 thorpej 71 1.13 thorpej static void *dec_2100_a500_intr_establish(pci_chipset_tag_t, 72 1.13 thorpej pci_intr_handle_t, int, int (*)(void *), void *); 73 1.13 thorpej static void dec_2100_a500_intr_disestablish(pci_chipset_tag_t, void *); 74 1.13 thorpej 75 1.13 thorpej static int dec_2100_a500_eisa_intr_map(void *, u_int, 76 1.13 thorpej eisa_intr_handle_t *); 77 1.13 thorpej static const char *dec_2100_a500_eisa_intr_string(void *, int, char *, size_t); 78 1.13 thorpej static const struct evcnt *dec_2100_a500_eisa_intr_evcnt(void *, int); 79 1.13 thorpej static void *dec_2100_a500_eisa_intr_establish(void *, int, int, int, 80 1.13 thorpej int (*)(void *), void *); 81 1.13 thorpej static void dec_2100_a500_eisa_intr_disestablish(void *, void *); 82 1.13 thorpej static int dec_2100_a500_eisa_intr_alloc(void *, int, int, int *); 83 1.1 thorpej 84 1.1 thorpej #define PCI_STRAY_MAX 5 85 1.1 thorpej 86 1.1 thorpej /* 87 1.1 thorpej * On systems with cascaded 8259s, it's actually 32. Systems which 88 1.1 thorpej * use the ICIC interrupt logic have 64, however. 89 1.1 thorpej */ 90 1.1 thorpej #define SABLE_MAX_IRQ 64 91 1.1 thorpej #define SABLE_8259_MAX_IRQ 32 92 1.1 thorpej 93 1.13 thorpej static void dec_2100_a500_iointr(void *, u_long); 94 1.1 thorpej 95 1.13 thorpej static void dec_2100_a500_pic_enable_intr(struct ttwoga_config *, 96 1.13 thorpej int, int); 97 1.13 thorpej static void dec_2100_a500_pic_init_intr(struct ttwoga_config *); 98 1.13 thorpej static void dec_2100_a500_pic_setlevel(struct ttwoga_config *, int, int); 99 1.13 thorpej static void dec_2100_a500_pic_eoi(struct ttwoga_config *, int); 100 1.13 thorpej 101 1.13 thorpej static void dec_2100_a500_icic_enable_intr(struct ttwoga_config *, 102 1.13 thorpej int, int); 103 1.13 thorpej static void dec_2100_a500_icic_init_intr(struct ttwoga_config *); 104 1.13 thorpej static void dec_2100_a500_icic_setlevel(struct ttwoga_config *, int, int); 105 1.13 thorpej static void dec_2100_a500_icic_eoi(struct ttwoga_config *, int); 106 1.1 thorpej 107 1.1 thorpej #define T2_IRQ_EISA_START 7 108 1.1 thorpej #define T2_IRQ_EISA_COUNT 16 109 1.1 thorpej 110 1.1 thorpej #define T2_IRQ_IS_EISA(irq) \ 111 1.1 thorpej ((irq) >= T2_IRQ_EISA_START && \ 112 1.1 thorpej (irq) < (T2_IRQ_EISA_START + T2_IRQ_EISA_COUNT)) 113 1.1 thorpej 114 1.13 thorpej static const int dec_2100_a500_intr_deftype[SABLE_MAX_IRQ] = { 115 1.1 thorpej IST_LEVEL, /* PCI slot 0 A */ 116 1.1 thorpej IST_LEVEL, /* on-board SCSI */ 117 1.1 thorpej IST_LEVEL, /* on-board Ethernet */ 118 1.1 thorpej IST_EDGE, /* mouse */ 119 1.1 thorpej IST_LEVEL, /* PCI slot 1 A */ 120 1.1 thorpej IST_LEVEL, /* PCI slot 2 A */ 121 1.1 thorpej IST_EDGE, /* keyboard */ 122 1.1 thorpej IST_EDGE, /* floppy (EISA IRQ 0) */ 123 1.1 thorpej IST_EDGE, /* serial port 1 (EISA IRQ 1) */ 124 1.1 thorpej IST_EDGE, /* parallel port (EISA IRQ 2) */ 125 1.1 thorpej IST_NONE, /* EISA IRQ 3 (edge/level) */ 126 1.1 thorpej IST_NONE, /* EISA IRQ 4 (edge/level) */ 127 1.1 thorpej IST_NONE, /* EISA IRQ 5 (edge/level) */ 128 1.1 thorpej IST_NONE, /* EISA IRQ 6 (edge/level) */ 129 1.1 thorpej IST_NONE, /* EISA IRQ 7 (edge/level) */ 130 1.1 thorpej IST_EDGE, /* serial port 0 (EISA IRQ 8) */ 131 1.1 thorpej IST_NONE, /* EISA IRQ 9 (edge/level) */ 132 1.1 thorpej IST_NONE, /* EISA IRQ 10 (edge/level) */ 133 1.1 thorpej IST_NONE, /* EISA IRQ 11 (edge/level) */ 134 1.1 thorpej IST_NONE, /* EISA IRQ 12 (edge/level) */ 135 1.1 thorpej IST_LEVEL, /* PCI slot 2 B (EISA IRQ 13 n/c) */ 136 1.1 thorpej IST_NONE, /* EISA IRQ 14 (edge/level) */ 137 1.1 thorpej IST_NONE, /* EISA IRQ 15 (edge/level) */ 138 1.1 thorpej IST_LEVEL, /* I2C (XXX double-check this) */ 139 1.1 thorpej IST_LEVEL, /* PCI slot 0 B */ 140 1.1 thorpej IST_LEVEL, /* PCI slot 1 B */ 141 1.1 thorpej IST_LEVEL, /* PCI slot 0 C */ 142 1.1 thorpej IST_LEVEL, /* PCI slot 1 C */ 143 1.1 thorpej IST_LEVEL, /* PCI slot 2 C */ 144 1.1 thorpej IST_LEVEL, /* PCI slot 0 D */ 145 1.1 thorpej IST_LEVEL, /* PCI slot 1 D */ 146 1.1 thorpej IST_LEVEL, /* PCI slot 2 D */ 147 1.1 thorpej 148 1.1 thorpej /* 149 1.1 thorpej * These are the PCI interrupts on the T3/T4 systems. See 150 1.1 thorpej * dec_2100_a500_icic_intr_map() for the mapping. 151 1.1 thorpej */ 152 1.1 thorpej IST_LEVEL, 153 1.1 thorpej IST_LEVEL, 154 1.1 thorpej IST_LEVEL, 155 1.1 thorpej IST_LEVEL, 156 1.1 thorpej IST_LEVEL, 157 1.1 thorpej IST_LEVEL, 158 1.1 thorpej IST_LEVEL, 159 1.1 thorpej IST_LEVEL, 160 1.1 thorpej IST_LEVEL, 161 1.1 thorpej IST_LEVEL, 162 1.1 thorpej IST_LEVEL, 163 1.1 thorpej IST_LEVEL, 164 1.1 thorpej IST_LEVEL, 165 1.1 thorpej IST_LEVEL, 166 1.1 thorpej IST_LEVEL, 167 1.1 thorpej IST_LEVEL, 168 1.1 thorpej IST_LEVEL, 169 1.1 thorpej IST_LEVEL, 170 1.1 thorpej IST_LEVEL, 171 1.1 thorpej IST_LEVEL, 172 1.1 thorpej IST_LEVEL, 173 1.1 thorpej IST_LEVEL, 174 1.1 thorpej IST_LEVEL, 175 1.1 thorpej IST_LEVEL, 176 1.1 thorpej IST_LEVEL, 177 1.1 thorpej IST_LEVEL, 178 1.1 thorpej IST_LEVEL, 179 1.1 thorpej IST_LEVEL, 180 1.1 thorpej IST_LEVEL, 181 1.1 thorpej IST_LEVEL, 182 1.1 thorpej IST_LEVEL, 183 1.1 thorpej IST_LEVEL, 184 1.1 thorpej }; 185 1.1 thorpej 186 1.15 thorpej static void 187 1.15 thorpej pci_2100_a500_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, 188 1.15 thorpej pci_chipset_tag_t pc) 189 1.1 thorpej { 190 1.15 thorpej struct ttwoga_config *tcp = core; 191 1.17 thorpej struct evcnt *ev; 192 1.1 thorpej char *cp; 193 1.1 thorpej int i; 194 1.1 thorpej 195 1.15 thorpej pic_iot = iot; 196 1.1 thorpej 197 1.15 thorpej pc->pc_intr_v = core; 198 1.13 thorpej pc->pc_intr_string = alpha_pci_generic_intr_string; 199 1.13 thorpej pc->pc_intr_evcnt = alpha_pci_generic_intr_evcnt; 200 1.1 thorpej pc->pc_intr_establish = dec_2100_a500_intr_establish; 201 1.1 thorpej pc->pc_intr_disestablish = dec_2100_a500_intr_disestablish; 202 1.1 thorpej 203 1.1 thorpej /* Not supported on T2. */ 204 1.1 thorpej pc->pc_pciide_compat_intr_establish = NULL; 205 1.1 thorpej 206 1.16 thorpej pc->pc_intr_desc = "T2"; 207 1.13 thorpej /* 64 16-byte vectors per hose. */ 208 1.13 thorpej pc->pc_vecbase = 0x800 + ((64 * 16) * tcp->tc_hose); 209 1.13 thorpej pc->pc_nirq = SABLE_MAX_IRQ; 210 1.13 thorpej 211 1.17 thorpej pc->pc_shared_intrs = alpha_shared_intr_alloc(pc->pc_nirq); 212 1.17 thorpej 213 1.17 thorpej for (i = 0; i < pc->pc_nirq; i++) { 214 1.17 thorpej alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, 215 1.17 thorpej PCI_STRAY_MAX); 216 1.17 thorpej alpha_shared_intr_set_private(pc->pc_shared_intrs, i, 217 1.17 thorpej pc->pc_intr_v); 218 1.17 thorpej alpha_shared_intr_set_dfltsharetype(pc->pc_shared_intrs, i, 219 1.17 thorpej tcp->tc_hose == 0 ? dec_2100_a500_intr_deftype[i] 220 1.17 thorpej : IST_LEVEL); 221 1.17 thorpej 222 1.17 thorpej ev = alpha_shared_intr_evcnt(pc->pc_shared_intrs, i); 223 1.17 thorpej cp = kmem_asprintf("irq %d", 224 1.17 thorpej T2_IRQ_IS_EISA(i) ? i - T2_IRQ_EISA_START : i); 225 1.17 thorpej 226 1.17 thorpej alpha_shared_intr_set_string(pc->pc_shared_intrs, i, cp); 227 1.17 thorpej 228 1.17 thorpej evcnt_attach_dynamic(ev, EVCNT_TYPE_INTR, NULL, 229 1.17 thorpej T2_IRQ_IS_EISA(i) ? "eisa" : pc->pc_intr_desc, cp); 230 1.1 thorpej } 231 1.1 thorpej 232 1.1 thorpej /* 233 1.1 thorpej * T2 uses a custom layout of cascaded 8259 PICs for interrupt 234 1.1 thorpej * control. T3 and T4 use a built-in interrupt controller. 235 1.1 thorpej * 236 1.1 thorpej * Note that the external PCI bus (Hose 1) always uses 237 1.1 thorpej * the new interrupt controller. 238 1.1 thorpej */ 239 1.1 thorpej if (tcp->tc_rev < TRN_T3 && tcp->tc_hose == 0) { 240 1.1 thorpej pc->pc_intr_map = dec_2100_a500_pic_intr_map; 241 1.1 thorpej tcp->tc_enable_intr = dec_2100_a500_pic_enable_intr; 242 1.1 thorpej tcp->tc_setlevel = dec_2100_a500_pic_setlevel; 243 1.1 thorpej tcp->tc_eoi = dec_2100_a500_pic_eoi; 244 1.1 thorpej dec_2100_a500_pic_init_intr(tcp); 245 1.1 thorpej } else { 246 1.1 thorpej pc->pc_intr_map = dec_2100_a500_icic_intr_map; 247 1.1 thorpej tcp->tc_enable_intr = dec_2100_a500_icic_enable_intr; 248 1.1 thorpej tcp->tc_setlevel = dec_2100_a500_icic_setlevel; 249 1.1 thorpej tcp->tc_eoi = dec_2100_a500_icic_eoi; 250 1.1 thorpej dec_2100_a500_icic_init_intr(tcp); 251 1.1 thorpej } 252 1.1 thorpej } 253 1.15 thorpej ALPHA_PCI_INTR_INIT(ST_DEC_2100_A500, pci_2100_a500_pickintr) 254 1.15 thorpej ALPHA_PCI_INTR_INIT(ST_DEC_2100A_A500, pci_2100_a500_pickintr) 255 1.1 thorpej 256 1.1 thorpej void 257 1.1 thorpej pci_2100_a500_eisa_pickintr(pci_chipset_tag_t pc, eisa_chipset_tag_t ec) 258 1.1 thorpej { 259 1.1 thorpej 260 1.1 thorpej ec->ec_v = pc->pc_intr_v; 261 1.1 thorpej ec->ec_intr_map = dec_2100_a500_eisa_intr_map; 262 1.1 thorpej ec->ec_intr_string = dec_2100_a500_eisa_intr_string; 263 1.1 thorpej ec->ec_intr_evcnt = dec_2100_a500_eisa_intr_evcnt; 264 1.1 thorpej ec->ec_intr_establish = dec_2100_a500_eisa_intr_establish; 265 1.1 thorpej ec->ec_intr_disestablish = dec_2100_a500_eisa_intr_disestablish; 266 1.1 thorpej } 267 1.1 thorpej 268 1.1 thorpej void 269 1.1 thorpej pci_2100_a500_isa_pickintr(pci_chipset_tag_t pc, isa_chipset_tag_t ic) 270 1.1 thorpej { 271 1.1 thorpej 272 1.1 thorpej ic->ic_v = pc->pc_intr_v; 273 1.1 thorpej ic->ic_intr_evcnt = dec_2100_a500_eisa_intr_evcnt; 274 1.1 thorpej ic->ic_intr_establish = dec_2100_a500_eisa_intr_establish; 275 1.1 thorpej ic->ic_intr_disestablish = dec_2100_a500_eisa_intr_disestablish; 276 1.1 thorpej ic->ic_intr_alloc = dec_2100_a500_eisa_intr_alloc; 277 1.1 thorpej } 278 1.1 thorpej 279 1.1 thorpej /***************************************************************************** 280 1.1 thorpej * PCI interrupt support. 281 1.1 thorpej *****************************************************************************/ 282 1.1 thorpej 283 1.13 thorpej static int 284 1.10 dyoung dec_2100_a500_pic_intr_map(const struct pci_attach_args *pa, 285 1.2 sommerfe pci_intr_handle_t *ihp) 286 1.1 thorpej { 287 1.1 thorpej /* 288 1.1 thorpej * Interrupts in the Sable are even more of a pain than other 289 1.1 thorpej * Alpha systems. The interrupt logic is made up of 5 8259 290 1.1 thorpej * PICs, arranged as follows: 291 1.1 thorpej * 292 1.1 thorpej * Slave 0 --------------------------------+ 293 1.1 thorpej * 0 PCI slot 0 A | 294 1.1 thorpej * 1 on-board SCSI | 295 1.1 thorpej * 2 on-board Ethernet | 296 1.1 thorpej * 3 mouse | 297 1.1 thorpej * 4 PCI slot 1 A | 298 1.1 thorpej * 5 PCI slot 2 A | 299 1.1 thorpej * 6 keyboard | 300 1.1 thorpej * 7 floppy (EISA IRQ 0) | 301 1.1 thorpej * | 302 1.1 thorpej * Slave 1 ------------------------+ | Master 303 1.1 thorpej * 0 serial port 1 (EISA IRQ 1) | | 0 ESC interrupt 304 1.1 thorpej * 1 parallel port (EISA IRQ 2) | +-- 1 Slave 0 305 1.1 thorpej * 2 EISA IRQ 3 | 2 reserved 306 1.1 thorpej * 3 EISA IRQ 4 +---------- 3 Slave 1 307 1.1 thorpej * 4 EISA IRQ 5 +---------- 4 Slave 2 308 1.1 thorpej * 5 EISA IRQ 6 | +-- 5 Slave 3 309 1.1 thorpej * 6 EISA IRQ 7 | | 6 reserved 310 1.1 thorpej * 7 serial port 0 (EISA IRQ 8) | | 7 n/c 311 1.1 thorpej * | | 312 1.1 thorpej * Slave 2 ------------------------+ | 313 1.1 thorpej * 0 EISA IRQ 9 | 314 1.1 thorpej * 1 EISA IRQ 10 | 315 1.1 thorpej * 2 EISA IRQ 11 | 316 1.1 thorpej * 3 EISA IRQ 12 | 317 1.1 thorpej * 4 PCI slot 2 B (EISA IRQ 13 n/c) | 318 1.1 thorpej * 5 EISA IRQ 14 | 319 1.1 thorpej * 6 EISA IRQ 15 | 320 1.1 thorpej * 7 I2C | 321 1.1 thorpej * | 322 1.1 thorpej * Slave 3 --------------------------------+ 323 1.1 thorpej * 0 PCI slot 0 B 324 1.1 thorpej * 1 PCI slot 1 B 325 1.1 thorpej * 2 PCI slot 0 C 326 1.1 thorpej * 3 PCI slot 1 C 327 1.1 thorpej * 4 PCI slot 2 C 328 1.1 thorpej * 5 PCI slot 0 D 329 1.1 thorpej * 6 PCI slot 1 D 330 1.1 thorpej * 7 PCI slot 2 D 331 1.1 thorpej * 332 1.1 thorpej * Careful readers will note that the PCEB does not handle ISA 333 1.1 thorpej * interrupts at all; when ISA interrupts are established, they 334 1.1 thorpej * must be mapped to Sable interrupts. Thankfully, this is easy 335 1.1 thorpej * to do. 336 1.1 thorpej * 337 1.1 thorpej * The T3 and T4, generally found on Lynx, use a totally different 338 1.1 thorpej * scheme because they have more PCI interrupts to handle; see below. 339 1.1 thorpej */ 340 1.1 thorpej static const int irqmap[9/*device*/][4/*pin*/] = { 341 1.1 thorpej { 0x02, -1, -1, -1 }, /* 0: on-board Ethernet */ 342 1.1 thorpej { 0x01, -1, -1, -1 }, /* 1: on-board SCSI */ 343 1.1 thorpej { -1, -1, -1, -1 }, /* 2: invalid */ 344 1.1 thorpej { -1, -1, -1, -1 }, /* 3: invalid */ 345 1.1 thorpej { -1, -1, -1, -1 }, /* 4: invalid */ 346 1.1 thorpej { -1, -1, -1, -1 }, /* 5: invalid */ 347 1.1 thorpej { 0x00, 0x18, 0x1a, 0x1d }, /* 6: PCI slot 0 */ 348 1.1 thorpej { 0x04, 0x19, 0x1b, 0x1e }, /* 7: PCI slot 1 */ 349 1.1 thorpej { 0x05, 0x14, 0x1c, 0x1f }, /* 8: PCI slot 2 */ 350 1.1 thorpej }; 351 1.2 sommerfe pcitag_t bustag = pa->pa_intrtag; 352 1.2 sommerfe int buspin = pa->pa_intrpin; 353 1.2 sommerfe pci_chipset_tag_t pc = pa->pa_pc; 354 1.1 thorpej int device, irq; 355 1.1 thorpej 356 1.1 thorpej if (buspin == 0) { 357 1.1 thorpej /* No IRQ used. */ 358 1.1 thorpej return (1); 359 1.1 thorpej } 360 1.1 thorpej 361 1.13 thorpej if (buspin < 0 || buspin > 4) { 362 1.1 thorpej printf("dec_2100_a500_pic_intr_map: bad interrupt pin %d\n", 363 1.1 thorpej buspin); 364 1.1 thorpej return (1); 365 1.1 thorpej } 366 1.1 thorpej 367 1.4 thorpej pci_decompose_tag(pc, bustag, NULL, &device, NULL); 368 1.1 thorpej if (device > 8) { 369 1.1 thorpej printf("dec_2100_a500_pic_intr_map: bad device %d\n", 370 1.1 thorpej device); 371 1.1 thorpej return (1); 372 1.1 thorpej } 373 1.1 thorpej 374 1.1 thorpej irq = irqmap[device][buspin - 1]; 375 1.1 thorpej if (irq == -1) { 376 1.1 thorpej printf("dec_2100_a500_pic_intr_map: no mapping for " 377 1.1 thorpej "device %d pin %d\n", device, buspin); 378 1.1 thorpej return (1); 379 1.1 thorpej } 380 1.13 thorpej alpha_pci_intr_handle_init(ihp, irq, 0); 381 1.1 thorpej return (0); 382 1.1 thorpej } 383 1.1 thorpej 384 1.13 thorpej static int 385 1.10 dyoung dec_2100_a500_icic_intr_map(const struct pci_attach_args *pa, 386 1.10 dyoung pci_intr_handle_t *ihp) 387 1.1 thorpej { 388 1.2 sommerfe pcitag_t bustag = pa->pa_intrtag; 389 1.2 sommerfe int buspin = pa->pa_intrpin; 390 1.2 sommerfe pci_chipset_tag_t pc = pa->pa_pc; 391 1.1 thorpej int device, irq; 392 1.1 thorpej 393 1.1 thorpej if (buspin == 0) { 394 1.1 thorpej /* No IRQ used. */ 395 1.1 thorpej return (1); 396 1.1 thorpej } 397 1.1 thorpej 398 1.1 thorpej if (buspin > 4) { 399 1.1 thorpej printf("dec_2100_a500_icic_intr_map: bad interrupt in %d\n", 400 1.1 thorpej buspin); 401 1.1 thorpej return (1); 402 1.1 thorpej } 403 1.1 thorpej 404 1.4 thorpej pci_decompose_tag(pc, bustag, NULL, &device, NULL); 405 1.1 thorpej switch (device) { 406 1.1 thorpej case 0: /* on-board Ethernet */ 407 1.1 thorpej irq = 24; 408 1.1 thorpej break; 409 1.1 thorpej 410 1.1 thorpej case 1: /* on-board SCSI */ 411 1.1 thorpej irq = 28; 412 1.1 thorpej break; 413 1.1 thorpej 414 1.1 thorpej case 6: /* PCI slots */ 415 1.1 thorpej case 7: 416 1.1 thorpej case 8: 417 1.1 thorpej irq = (32 + (4 * (device - 6))) + (buspin - 1); 418 1.1 thorpej break; 419 1.1 thorpej 420 1.1 thorpej default: 421 1.1 thorpej printf("dec_2100_a500_icic_intr_map: bad device %d\n", 422 1.1 thorpej device); 423 1.1 thorpej return (1); 424 1.1 thorpej } 425 1.1 thorpej 426 1.13 thorpej alpha_pci_intr_handle_init(ihp, irq, 0); 427 1.1 thorpej return (0); 428 1.1 thorpej } 429 1.1 thorpej 430 1.13 thorpej static void * 431 1.13 thorpej dec_2100_a500_intr_establish(pci_chipset_tag_t const pc, 432 1.13 thorpej pci_intr_handle_t const ih, int const level, 433 1.1 thorpej int (*func)(void *), void *arg) 434 1.1 thorpej { 435 1.13 thorpej struct ttwoga_config *tcp = pc->pc_intr_v; 436 1.1 thorpej void *cookie; 437 1.13 thorpej const u_int irq = alpha_pci_intr_handle_get_irq(&ih); 438 1.13 thorpej const u_int flags = alpha_pci_intr_handle_get_flags(&ih); 439 1.1 thorpej 440 1.13 thorpej KASSERT(irq < SABLE_MAX_IRQ); 441 1.1 thorpej 442 1.14 thorpej cookie = alpha_shared_intr_alloc_intrhand(pc->pc_shared_intrs, irq, 443 1.16 thorpej dec_2100_a500_intr_deftype[irq], level, flags, func, arg, "T2"); 444 1.1 thorpej 445 1.14 thorpej if (cookie == NULL) 446 1.14 thorpej return NULL; 447 1.14 thorpej 448 1.14 thorpej mutex_enter(&cpu_lock); 449 1.14 thorpej 450 1.16 thorpej if (! alpha_shared_intr_link(pc->pc_shared_intrs, cookie, "T2")) { 451 1.14 thorpej mutex_exit(&cpu_lock); 452 1.14 thorpej alpha_shared_intr_free_intrhand(cookie); 453 1.14 thorpej return NULL; 454 1.14 thorpej } 455 1.14 thorpej 456 1.14 thorpej if (alpha_shared_intr_firstactive(pc->pc_shared_intrs, irq)) { 457 1.13 thorpej scb_set(pc->pc_vecbase + SCB_IDXTOVEC(irq), 458 1.13 thorpej dec_2100_a500_iointr, tcp); 459 1.13 thorpej (*tcp->tc_enable_intr)(tcp, irq, 1); 460 1.3 thorpej } 461 1.1 thorpej 462 1.14 thorpej mutex_exit(&cpu_lock); 463 1.14 thorpej 464 1.14 thorpej return cookie; 465 1.1 thorpej } 466 1.1 thorpej 467 1.13 thorpej static void 468 1.13 thorpej dec_2100_a500_intr_disestablish(pci_chipset_tag_t const pc, void * const cookie) 469 1.1 thorpej { 470 1.13 thorpej struct ttwoga_config *tcp = pc->pc_intr_v; 471 1.1 thorpej struct alpha_shared_intrhand *ih = cookie; 472 1.1 thorpej unsigned int irq = ih->ih_num; 473 1.1 thorpej 474 1.14 thorpej mutex_enter(&cpu_lock); 475 1.1 thorpej 476 1.14 thorpej if (alpha_shared_intr_firstactive(pc->pc_shared_intrs, irq)) { 477 1.1 thorpej (*tcp->tc_enable_intr)(tcp, irq, 0); 478 1.13 thorpej alpha_shared_intr_set_dfltsharetype(pc->pc_shared_intrs, 479 1.1 thorpej irq, dec_2100_a500_intr_deftype[irq]); 480 1.13 thorpej scb_free(pc->pc_vecbase + SCB_IDXTOVEC(irq)); 481 1.1 thorpej } 482 1.1 thorpej 483 1.16 thorpej alpha_shared_intr_unlink(pc->pc_shared_intrs, cookie, "T2"); 484 1.14 thorpej 485 1.14 thorpej mutex_exit(&cpu_lock); 486 1.14 thorpej 487 1.14 thorpej alpha_shared_intr_free_intrhand(cookie); 488 1.1 thorpej } 489 1.1 thorpej 490 1.1 thorpej /***************************************************************************** 491 1.1 thorpej * EISA interrupt support. 492 1.1 thorpej *****************************************************************************/ 493 1.1 thorpej 494 1.13 thorpej static int 495 1.1 thorpej dec_2100_a500_eisa_intr_map(void *v, u_int eirq, eisa_intr_handle_t *ihp) 496 1.1 thorpej { 497 1.1 thorpej 498 1.1 thorpej if (eirq > 15) { 499 1.1 thorpej printf("dec_2100_a500_eisa_intr_map: bad EISA IRQ %d\n", 500 1.1 thorpej eirq); 501 1.1 thorpej *ihp = -1; 502 1.1 thorpej return (1); 503 1.1 thorpej } 504 1.1 thorpej 505 1.1 thorpej /* 506 1.1 thorpej * EISA IRQ 13 is not connected. 507 1.1 thorpej */ 508 1.1 thorpej if (eirq == 13) { 509 1.1 thorpej printf("dec_2100_a500_eisa_intr_map: EISA IRQ 13 not " 510 1.1 thorpej "connected\n"); 511 1.1 thorpej *ihp = -1; 512 1.1 thorpej return (1); 513 1.1 thorpej } 514 1.1 thorpej 515 1.1 thorpej /* 516 1.1 thorpej * Don't map to a T2 IRQ here; we must do this when we hook the 517 1.1 thorpej * interrupt up, since ISA interrupts aren't explicitly translated. 518 1.1 thorpej */ 519 1.1 thorpej 520 1.1 thorpej *ihp = eirq; 521 1.1 thorpej return (0); 522 1.1 thorpej } 523 1.1 thorpej 524 1.13 thorpej static const char * 525 1.12 christos dec_2100_a500_eisa_intr_string(void *v, int eirq, char *buf, size_t len) 526 1.1 thorpej { 527 1.1 thorpej if (eirq > 15 || eirq == 13) 528 1.12 christos panic("%s: bogus EISA IRQ 0x%x", __func__, eirq); 529 1.1 thorpej 530 1.12 christos snprintf(buf, len, "eisa irq %d (T2 irq %d)", eirq, 531 1.1 thorpej eirq + T2_IRQ_EISA_START); 532 1.12 christos return buf; 533 1.1 thorpej } 534 1.1 thorpej 535 1.13 thorpej static const struct evcnt * 536 1.1 thorpej dec_2100_a500_eisa_intr_evcnt(void *v, int eirq) 537 1.1 thorpej { 538 1.1 thorpej struct ttwoga_config *tcp = v; 539 1.13 thorpej pci_chipset_tag_t const pc = &tcp->tc_pc; 540 1.1 thorpej 541 1.1 thorpej if (eirq > 15 || eirq == 13) 542 1.12 christos panic("%s: bogus EISA IRQ 0x%x", __func__, eirq); 543 1.1 thorpej 544 1.13 thorpej return (alpha_shared_intr_evcnt(pc->pc_shared_intrs, 545 1.1 thorpej eirq + T2_IRQ_EISA_START)); 546 1.1 thorpej } 547 1.1 thorpej 548 1.13 thorpej static void * 549 1.1 thorpej dec_2100_a500_eisa_intr_establish(void *v, int eirq, int type, int level, 550 1.1 thorpej int (*fn)(void *), void *arg) 551 1.1 thorpej { 552 1.1 thorpej struct ttwoga_config *tcp = v; 553 1.13 thorpej pci_chipset_tag_t const pc = &tcp->tc_pc; 554 1.1 thorpej void *cookie; 555 1.1 thorpej int irq; 556 1.1 thorpej 557 1.1 thorpej if (eirq > 15 || type == IST_NONE) 558 1.1 thorpej panic("dec_2100_a500_eisa_intr_establish: bogus irq or type"); 559 1.1 thorpej 560 1.1 thorpej if (eirq == 13) { 561 1.1 thorpej printf("dec_2100_a500_eisa_intr_establish: EISA IRQ 13 not " 562 1.1 thorpej "connected\n"); 563 1.1 thorpej return (NULL); 564 1.1 thorpej } 565 1.1 thorpej 566 1.1 thorpej irq = eirq + T2_IRQ_EISA_START; 567 1.1 thorpej 568 1.1 thorpej /* 569 1.1 thorpej * We can't change the trigger type of some interrupts. Don't allow 570 1.1 thorpej * level triggers to be hooked up to non-changeable edge triggers. 571 1.1 thorpej */ 572 1.1 thorpej if (dec_2100_a500_intr_deftype[irq] == IST_EDGE && type == IST_LEVEL) { 573 1.1 thorpej printf("dec_2100_a500_eisa_intr_establish: non-EDGE on EDGE\n"); 574 1.1 thorpej return (NULL); 575 1.1 thorpej } 576 1.1 thorpej 577 1.14 thorpej cookie = alpha_shared_intr_alloc_intrhand(pc->pc_shared_intrs, irq, 578 1.16 thorpej type, level, 0, fn, arg, "T2"); 579 1.1 thorpej 580 1.14 thorpej if (cookie == NULL) 581 1.14 thorpej return NULL; 582 1.14 thorpej 583 1.14 thorpej mutex_enter(&cpu_lock); 584 1.14 thorpej 585 1.16 thorpej if (! alpha_shared_intr_link(pc->pc_shared_intrs, cookie, "T2")) { 586 1.14 thorpej mutex_exit(&cpu_lock); 587 1.14 thorpej alpha_shared_intr_free_intrhand(cookie); 588 1.14 thorpej return NULL; 589 1.14 thorpej } 590 1.14 thorpej 591 1.14 thorpej if (alpha_shared_intr_firstactive(pc->pc_shared_intrs, irq)) { 592 1.13 thorpej scb_set(pc->pc_vecbase + SCB_IDXTOVEC(irq), 593 1.13 thorpej dec_2100_a500_iointr, tcp); 594 1.1 thorpej (*tcp->tc_setlevel)(tcp, eirq, 595 1.13 thorpej alpha_shared_intr_get_sharetype(pc->pc_shared_intrs, 596 1.1 thorpej irq) == IST_LEVEL); 597 1.1 thorpej (*tcp->tc_enable_intr)(tcp, irq, 1); 598 1.1 thorpej } 599 1.1 thorpej 600 1.14 thorpej mutex_exit(&cpu_lock); 601 1.14 thorpej 602 1.14 thorpej return cookie; 603 1.1 thorpej } 604 1.1 thorpej 605 1.13 thorpej static void 606 1.1 thorpej dec_2100_a500_eisa_intr_disestablish(void *v, void *cookie) 607 1.1 thorpej { 608 1.1 thorpej struct ttwoga_config *tcp = v; 609 1.13 thorpej pci_chipset_tag_t const pc = &tcp->tc_pc; 610 1.1 thorpej struct alpha_shared_intrhand *ih = cookie; 611 1.14 thorpej int irq = ih->ih_num; 612 1.1 thorpej 613 1.14 thorpej mutex_enter(&cpu_lock); 614 1.1 thorpej 615 1.14 thorpej if (alpha_shared_intr_firstactive(pc->pc_shared_intrs, irq)) { 616 1.1 thorpej (*tcp->tc_enable_intr)(tcp, irq, 0); 617 1.13 thorpej alpha_shared_intr_set_dfltsharetype(pc->pc_shared_intrs, 618 1.1 thorpej irq, dec_2100_a500_intr_deftype[irq]); 619 1.13 thorpej scb_free(pc->pc_vecbase + SCB_IDXTOVEC(irq)); 620 1.1 thorpej } 621 1.1 thorpej 622 1.14 thorpej /* Remove it from the link. */ 623 1.16 thorpej alpha_shared_intr_unlink(pc->pc_shared_intrs, cookie, "T2"); 624 1.14 thorpej 625 1.14 thorpej mutex_exit(&cpu_lock); 626 1.14 thorpej 627 1.14 thorpej alpha_shared_intr_free_intrhand(cookie); 628 1.1 thorpej } 629 1.1 thorpej 630 1.13 thorpej static int 631 1.1 thorpej dec_2100_a500_eisa_intr_alloc(void *v, int mask, int type, int *eirqp) 632 1.1 thorpej { 633 1.1 thorpej 634 1.1 thorpej /* XXX Not supported right now. */ 635 1.1 thorpej return (1); 636 1.1 thorpej } 637 1.1 thorpej 638 1.1 thorpej /***************************************************************************** 639 1.1 thorpej * Interrupt support routines. 640 1.1 thorpej *****************************************************************************/ 641 1.1 thorpej 642 1.1 thorpej #define ICIC_ADDR(tcp, addr) \ 643 1.1 thorpej do { \ 644 1.1 thorpej alpha_mb(); \ 645 1.1 thorpej T2GA((tcp), T2_AIR) = (addr); \ 646 1.1 thorpej alpha_mb(); \ 647 1.1 thorpej alpha_mb(); \ 648 1.1 thorpej (void) T2GA((tcp), T2_AIR); \ 649 1.1 thorpej alpha_mb(); \ 650 1.1 thorpej alpha_mb(); \ 651 1.1 thorpej } while (0) 652 1.1 thorpej 653 1.1 thorpej #define ICIC_READ(tcp) T2GA((tcp), T2_DIR) 654 1.1 thorpej #define ICIC_WRITE(tcp, val) \ 655 1.1 thorpej do { \ 656 1.1 thorpej alpha_mb(); \ 657 1.1 thorpej T2GA((tcp), T2_DIR) = (val); \ 658 1.1 thorpej alpha_mb(); \ 659 1.1 thorpej alpha_mb(); \ 660 1.1 thorpej } while (0) 661 1.1 thorpej 662 1.13 thorpej static void 663 1.3 thorpej dec_2100_a500_iointr(void *arg, u_long vec) 664 1.1 thorpej { 665 1.3 thorpej struct ttwoga_config *tcp = arg; 666 1.13 thorpej pci_chipset_tag_t const pc = &tcp->tc_pc; 667 1.3 thorpej int irq, rv; 668 1.3 thorpej 669 1.13 thorpej irq = SCB_VECTOIDX(vec - pc->pc_vecbase); 670 1.1 thorpej 671 1.13 thorpej rv = alpha_shared_intr_dispatch(pc->pc_shared_intrs, irq); 672 1.1 thorpej (*tcp->tc_eoi)(tcp, irq); 673 1.1 thorpej if (rv == 0) { 674 1.16 thorpej alpha_shared_intr_stray(pc->pc_shared_intrs, irq, "T2"); 675 1.13 thorpej if (ALPHA_SHARED_INTR_DISABLE(pc->pc_shared_intrs, irq)) 676 1.1 thorpej (*tcp->tc_enable_intr)(tcp, irq, 0); 677 1.6 thorpej } else 678 1.13 thorpej alpha_shared_intr_reset_strays(pc->pc_shared_intrs, irq); 679 1.1 thorpej } 680 1.1 thorpej 681 1.13 thorpej static void 682 1.1 thorpej dec_2100_a500_pic_enable_intr(struct ttwoga_config *tcp, int irq, int onoff) 683 1.1 thorpej { 684 1.1 thorpej int pic; 685 1.11 matt uint8_t bit, mask; 686 1.1 thorpej 687 1.1 thorpej pic = irq >> 3; 688 1.1 thorpej bit = 1 << (irq & 0x7); 689 1.1 thorpej 690 1.1 thorpej mask = bus_space_read_1(pic_iot, pic_slave_ioh[pic], 1); 691 1.1 thorpej if (onoff) 692 1.1 thorpej mask &= ~bit; 693 1.1 thorpej else 694 1.1 thorpej mask |= bit; 695 1.1 thorpej bus_space_write_1(pic_iot, pic_slave_ioh[pic], 1, mask); 696 1.1 thorpej } 697 1.1 thorpej 698 1.13 thorpej static void 699 1.1 thorpej dec_2100_a500_icic_enable_intr(struct ttwoga_config *tcp, int irq, int onoff) 700 1.1 thorpej { 701 1.11 matt uint64_t bit, mask; 702 1.1 thorpej 703 1.1 thorpej bit = 1UL << irq; 704 1.1 thorpej 705 1.1 thorpej ICIC_ADDR(tcp, 0x40); 706 1.1 thorpej 707 1.1 thorpej mask = ICIC_READ(tcp); 708 1.1 thorpej if (onoff) 709 1.1 thorpej mask &= ~bit; 710 1.1 thorpej else 711 1.1 thorpej mask |= bit; 712 1.1 thorpej ICIC_WRITE(tcp, mask); 713 1.1 thorpej } 714 1.1 thorpej 715 1.13 thorpej static void 716 1.1 thorpej dec_2100_a500_pic_init_intr(struct ttwoga_config *tcp) 717 1.1 thorpej { 718 1.1 thorpej static const int picaddr[4] = { 719 1.1 thorpej 0x536, 0x53a, 0x53c, 0x53e 720 1.1 thorpej }; 721 1.1 thorpej int pic; 722 1.1 thorpej 723 1.1 thorpej /* 724 1.1 thorpej * Map the master PIC. 725 1.1 thorpej */ 726 1.1 thorpej if (bus_space_map(pic_iot, 0x534, 2, 0, &pic_master_ioh)) 727 1.1 thorpej panic("dec_2100_a500_pic_init_intr: unable to map master PIC"); 728 1.1 thorpej 729 1.1 thorpej /* 730 1.1 thorpej * Map all slave PICs and mask off the interrupts on them. 731 1.1 thorpej */ 732 1.1 thorpej for (pic = 0; pic < 4; pic++) { 733 1.1 thorpej if (bus_space_map(pic_iot, picaddr[pic], 2, 0, 734 1.1 thorpej &pic_slave_ioh[pic])) 735 1.1 thorpej panic("dec_2100_a500_pic_init_intr: unable to map " 736 1.1 thorpej "slave PIC %d", pic); 737 1.1 thorpej bus_space_write_1(pic_iot, pic_slave_ioh[pic], 1, 0xff); 738 1.1 thorpej } 739 1.1 thorpej 740 1.1 thorpej /* 741 1.1 thorpej * Map the ELCR registers. 742 1.1 thorpej */ 743 1.1 thorpej if (bus_space_map(pic_iot, 0x26, 2, 0, &pic_elcr_ioh)) 744 1.1 thorpej panic("dec_2100_a500_pic_init_intr: unable to map ELCR " 745 1.1 thorpej "registers"); 746 1.1 thorpej } 747 1.1 thorpej 748 1.13 thorpej static void 749 1.1 thorpej dec_2100_a500_icic_init_intr(struct ttwoga_config *tcp) 750 1.1 thorpej { 751 1.1 thorpej 752 1.1 thorpej ICIC_ADDR(tcp, 0x40); 753 1.1 thorpej ICIC_WRITE(tcp, 0xffffffffffffffffUL); 754 1.1 thorpej } 755 1.1 thorpej 756 1.13 thorpej static void 757 1.1 thorpej dec_2100_a500_pic_setlevel(struct ttwoga_config *tcp, int eirq, int level) 758 1.1 thorpej { 759 1.1 thorpej int elcr; 760 1.11 matt uint8_t bit, mask; 761 1.1 thorpej 762 1.1 thorpej switch (eirq) { /* EISA IRQ */ 763 1.1 thorpej case 3: 764 1.1 thorpej case 4: 765 1.1 thorpej case 5: 766 1.1 thorpej case 6: 767 1.1 thorpej case 7: 768 1.1 thorpej elcr = 0; 769 1.1 thorpej bit = 1 << (eirq - 3); 770 1.1 thorpej break; 771 1.1 thorpej 772 1.1 thorpej case 9: 773 1.1 thorpej case 10: 774 1.1 thorpej case 11: 775 1.1 thorpej elcr = 0; 776 1.1 thorpej bit = 1 << (eirq - 4); 777 1.1 thorpej break; 778 1.1 thorpej 779 1.1 thorpej case 12: 780 1.1 thorpej elcr = 1; 781 1.1 thorpej bit = 1 << (eirq - 12); 782 1.1 thorpej break; 783 1.1 thorpej 784 1.1 thorpej case 14: 785 1.1 thorpej case 15: 786 1.1 thorpej elcr = 1; 787 1.1 thorpej bit = 1 << (eirq - 13); 788 1.1 thorpej break; 789 1.1 thorpej 790 1.1 thorpej default: 791 1.1 thorpej panic("dec_2100_a500_pic_setlevel: bogus EISA IRQ %d", eirq); 792 1.1 thorpej } 793 1.1 thorpej 794 1.1 thorpej mask = bus_space_read_1(pic_iot, pic_elcr_ioh, elcr); 795 1.1 thorpej if (level) 796 1.1 thorpej mask |= bit; 797 1.1 thorpej else 798 1.1 thorpej mask &= ~bit; 799 1.1 thorpej bus_space_write_1(pic_iot, pic_elcr_ioh, elcr, mask); 800 1.1 thorpej } 801 1.1 thorpej 802 1.13 thorpej static void 803 1.1 thorpej dec_2100_a500_icic_setlevel(struct ttwoga_config *tcp, int eirq, int level) 804 1.1 thorpej { 805 1.11 matt uint64_t bit, mask; 806 1.1 thorpej 807 1.1 thorpej switch (eirq) { 808 1.1 thorpej case 3: 809 1.1 thorpej case 4: 810 1.1 thorpej case 5: 811 1.1 thorpej case 6: 812 1.1 thorpej case 7: 813 1.1 thorpej case 9: 814 1.1 thorpej case 10: 815 1.1 thorpej case 11: 816 1.1 thorpej case 12: 817 1.1 thorpej case 14: 818 1.1 thorpej case 15: 819 1.1 thorpej bit = 1UL << (eirq + T2_IRQ_EISA_START); 820 1.1 thorpej 821 1.1 thorpej ICIC_ADDR(tcp, 0x50); 822 1.1 thorpej mask = ICIC_READ(tcp); 823 1.1 thorpej if (level) 824 1.1 thorpej mask |= bit; 825 1.1 thorpej else 826 1.1 thorpej mask &= ~bit; 827 1.1 thorpej ICIC_WRITE(tcp, mask); 828 1.1 thorpej break; 829 1.1 thorpej 830 1.1 thorpej default: 831 1.1 thorpej panic("dec_2100_a500_icic_setlevel: bogus EISA IRQ %d", eirq); 832 1.1 thorpej } 833 1.1 thorpej } 834 1.1 thorpej 835 1.13 thorpej static void 836 1.1 thorpej dec_2100_a500_pic_eoi(struct ttwoga_config *tcp, int irq) 837 1.1 thorpej { 838 1.1 thorpej int pic; 839 1.1 thorpej 840 1.1 thorpej if (irq >= 0 && irq <= 7) 841 1.1 thorpej pic = 0; 842 1.1 thorpej else if (irq >= 8 && irq <= 15) 843 1.1 thorpej pic = 1; 844 1.1 thorpej else if (irq >= 16 && irq <= 23) 845 1.1 thorpej pic = 2; 846 1.1 thorpej else 847 1.1 thorpej pic = 3; 848 1.1 thorpej 849 1.1 thorpej bus_space_write_1(pic_iot, pic_slave_ioh[pic], 0, 850 1.1 thorpej 0xe0 | (irq - (8 * pic))); 851 1.1 thorpej bus_space_write_1(pic_iot, pic_master_ioh, 0, 852 1.1 thorpej 0xe0 | pic_slave_to_master[pic]); 853 1.1 thorpej } 854 1.1 thorpej 855 1.13 thorpej static void 856 1.1 thorpej dec_2100_a500_icic_eoi(struct ttwoga_config *tcp, int irq) 857 1.1 thorpej { 858 1.1 thorpej 859 1.1 thorpej T2GA(tcp, T2_VAR) = irq; 860 1.1 thorpej alpha_mb(); 861 1.1 thorpej alpha_mb(); /* MAGIC */ 862 1.1 thorpej } 863