1 1.41 thorpej /* $NetBSD: pci_axppci_33.c,v 1.41 2021/06/25 13:41:33 thorpej Exp $ */ 2 1.1 cgd 3 1.1 cgd /* 4 1.4 cgd * Copyright (c) 1995, 1996 Carnegie-Mellon University. 5 1.1 cgd * All rights reserved. 6 1.1 cgd * 7 1.3 cgd * Authors: Jeffrey Hsu and Chris G. Demetriou 8 1.37 matt * 9 1.1 cgd * Permission to use, copy, modify and distribute this software and 10 1.1 cgd * its documentation is hereby granted, provided that both the copyright 11 1.1 cgd * notice and this permission notice appear in all copies of the 12 1.1 cgd * software, derivative works or modified versions, and any portions 13 1.1 cgd * thereof, and that both notices appear in supporting documentation. 14 1.37 matt * 15 1.37 matt * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 1.37 matt * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 1.1 cgd * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 1.37 matt * 19 1.1 cgd * Carnegie Mellon requests users of this software to return to 20 1.1 cgd * 21 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU 22 1.1 cgd * School of Computer Science 23 1.1 cgd * Carnegie Mellon University 24 1.1 cgd * Pittsburgh PA 15213-3890 25 1.1 cgd * 26 1.1 cgd * any improvements or extensions that they make and grant Carnegie the 27 1.1 cgd * rights to redistribute these changes. 28 1.1 cgd */ 29 1.11 cgd 30 1.12 cgd #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 31 1.12 cgd 32 1.41 thorpej __KERNEL_RCSID(0, "$NetBSD: pci_axppci_33.c,v 1.41 2021/06/25 13:41:33 thorpej Exp $"); 33 1.1 cgd 34 1.1 cgd #include <sys/types.h> 35 1.1 cgd #include <sys/param.h> 36 1.1 cgd #include <sys/time.h> 37 1.1 cgd #include <sys/systm.h> 38 1.1 cgd #include <sys/errno.h> 39 1.1 cgd #include <sys/device.h> 40 1.25 mrg 41 1.6 cgd #include <machine/autoconf.h> 42 1.40 thorpej #include <machine/rpb.h> 43 1.36 dyoung #include <sys/bus.h> 44 1.3 cgd #include <machine/intr.h> 45 1.3 cgd 46 1.1 cgd #include <dev/isa/isavar.h> 47 1.1 cgd #include <dev/pci/pcireg.h> 48 1.1 cgd #include <dev/pci/pcivar.h> 49 1.1 cgd 50 1.1 cgd #include <alpha/pci/lcavar.h> 51 1.1 cgd 52 1.1 cgd #include <alpha/pci/siovar.h> 53 1.5 cgd #include <alpha/pci/sioreg.h> 54 1.1 cgd 55 1.1 cgd #include "sio.h" 56 1.1 cgd 57 1.39 thorpej static int dec_axppci_33_intr_map(const struct pci_attach_args *, 58 1.39 thorpej pci_intr_handle_t *); 59 1.3 cgd 60 1.40 thorpej static void 61 1.40 thorpej pci_axppci_33_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, 62 1.40 thorpej pci_chipset_tag_t pc) 63 1.3 cgd { 64 1.3 cgd 65 1.40 thorpej pc->pc_intr_v = core; 66 1.3 cgd pc->pc_intr_map = dec_axppci_33_intr_map; 67 1.39 thorpej pc->pc_intr_string = sio_pci_intr_string; 68 1.39 thorpej pc->pc_intr_evcnt = sio_pci_intr_evcnt; 69 1.39 thorpej pc->pc_intr_establish = sio_pci_intr_establish; 70 1.39 thorpej pc->pc_intr_disestablish = sio_pci_intr_disestablish; 71 1.19 thorpej 72 1.20 mjacob /* Not supported on AXPpci33. */ 73 1.19 thorpej pc->pc_pciide_compat_intr_establish = NULL; 74 1.3 cgd 75 1.3 cgd #if NSIO 76 1.17 thorpej sio_intr_setup(pc, iot); 77 1.3 cgd #else 78 1.3 cgd panic("pci_axppci_33_pickintr: no I/O interrupt handler (no sio)"); 79 1.3 cgd #endif 80 1.3 cgd } 81 1.40 thorpej ALPHA_PCI_INTR_INIT(ST_DEC_AXPPCI_33, pci_axppci_33_pickintr) 82 1.3 cgd 83 1.3 cgd int 84 1.35 dyoung dec_axppci_33_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp) 85 1.1 cgd { 86 1.26 sommerfe pcitag_t bustag = pa->pa_intrtag; 87 1.26 sommerfe int buspin = pa->pa_intrpin; 88 1.26 sommerfe pci_chipset_tag_t pc = pa->pa_pc; 89 1.3 cgd int device, pirq; 90 1.13 cgd 91 1.13 cgd #ifndef DIAGNOSTIC 92 1.13 cgd pirq = 0; /* XXX gcc -Wuninitialized */ 93 1.13 cgd #endif 94 1.1 cgd 95 1.21 thorpej if (buspin == 0) { 96 1.21 thorpej /* No IRQ used. */ 97 1.21 thorpej return 1; 98 1.21 thorpej } 99 1.39 thorpej if (buspin < 0 || buspin > 4) { 100 1.21 thorpej printf("dec_axppci_33_intr_map: bad interrupt pin %d\n", 101 1.21 thorpej buspin); 102 1.21 thorpej return 1; 103 1.21 thorpej } 104 1.1 cgd 105 1.28 thorpej pci_decompose_tag(pc, bustag, NULL, &device, NULL); 106 1.1 cgd 107 1.1 cgd switch (device) { 108 1.1 cgd case 6: /* NCR SCSI */ 109 1.1 cgd pirq = 3; 110 1.1 cgd break; 111 1.1 cgd 112 1.1 cgd case 11: /* slot 1 */ 113 1.3 cgd switch (buspin) { 114 1.1 cgd case PCI_INTERRUPT_PIN_A: 115 1.1 cgd case PCI_INTERRUPT_PIN_D: 116 1.1 cgd pirq = 0; 117 1.1 cgd break; 118 1.1 cgd case PCI_INTERRUPT_PIN_B: 119 1.1 cgd pirq = 2; 120 1.1 cgd break; 121 1.1 cgd case PCI_INTERRUPT_PIN_C: 122 1.1 cgd pirq = 1; 123 1.1 cgd break; 124 1.10 cgd #ifdef DIAGNOSTIC 125 1.10 cgd default: /* XXX gcc -Wuninitialized */ 126 1.29 provos panic("dec_axppci_33_intr_map: bogus PCI pin %d", 127 1.10 cgd buspin); 128 1.10 cgd #endif 129 1.1 cgd }; 130 1.1 cgd break; 131 1.1 cgd 132 1.1 cgd case 12: /* slot 2 */ 133 1.3 cgd switch (buspin) { 134 1.1 cgd case PCI_INTERRUPT_PIN_A: 135 1.1 cgd case PCI_INTERRUPT_PIN_D: 136 1.1 cgd pirq = 1; 137 1.1 cgd break; 138 1.1 cgd case PCI_INTERRUPT_PIN_B: 139 1.1 cgd pirq = 0; 140 1.1 cgd break; 141 1.1 cgd case PCI_INTERRUPT_PIN_C: 142 1.1 cgd pirq = 2; 143 1.1 cgd break; 144 1.10 cgd #ifdef DIAGNOSTIC 145 1.10 cgd default: /* XXX gcc -Wuninitialized */ 146 1.29 provos panic("dec_axppci_33_intr_map: bogus PCI pin %d", 147 1.10 cgd buspin); 148 1.10 cgd #endif 149 1.1 cgd }; 150 1.1 cgd break; 151 1.1 cgd 152 1.1 cgd case 8: /* slot 3 */ 153 1.3 cgd switch (buspin) { 154 1.1 cgd case PCI_INTERRUPT_PIN_A: 155 1.1 cgd case PCI_INTERRUPT_PIN_D: 156 1.1 cgd pirq = 2; 157 1.1 cgd break; 158 1.1 cgd case PCI_INTERRUPT_PIN_B: 159 1.1 cgd pirq = 1; 160 1.1 cgd break; 161 1.1 cgd case PCI_INTERRUPT_PIN_C: 162 1.1 cgd pirq = 0; 163 1.1 cgd break; 164 1.10 cgd #ifdef DIAGNOSTIC 165 1.10 cgd default: /* XXX gcc -Wuninitialized */ 166 1.29 provos panic("dec_axppci_33_intr_map bogus: PCI pin %d", 167 1.10 cgd buspin); 168 1.10 cgd #endif 169 1.1 cgd }; 170 1.1 cgd break; 171 1.10 cgd 172 1.1 cgd default: 173 1.37 matt printf("dec_axppci_33_intr_map: weird device number %d\n", 174 1.10 cgd device); 175 1.37 matt return 1; 176 1.1 cgd } 177 1.1 cgd 178 1.1 cgd #if 0 179 1.41 thorpej printf("dec_axppci_33_intr_map: device %d pin %c: pirq %d\n", 180 1.41 thorpej device, '@' + buspin, pirq); 181 1.1 cgd #endif 182 1.1 cgd 183 1.41 thorpej return sio_pirq_intr_map(pc, pirq, ihp); 184 1.1 cgd } 185