1 /* $NetBSD: pci_alphabook1.c,v 1.8 2002/05/15 16:57:42 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 * NASA Ames Research Center. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 /* 41 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 42 * All rights reserved. 43 * 44 * Authors: Jeffrey Hsu and Chris G. Demetriou 45 * 46 * Permission to use, copy, modify and distribute this software and 47 * its documentation is hereby granted, provided that both the copyright 48 * notice and this permission notice appear in all copies of the 49 * software, derivative works or modified versions, and any portions 50 * thereof, and that both notices appear in supporting documentation. 51 * 52 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 53 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 54 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 55 * 56 * Carnegie Mellon requests users of this software to return to 57 * 58 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 59 * School of Computer Science 60 * Carnegie Mellon University 61 * Pittsburgh PA 15213-3890 62 * 63 * any improvements or extensions that they make and grant Carnegie the 64 * rights to redistribute these changes. 65 */ 66 67 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 68 69 __KERNEL_RCSID(0, "$NetBSD: pci_alphabook1.c,v 1.8 2002/05/15 16:57:42 thorpej Exp $"); 70 71 #include <sys/types.h> 72 #include <sys/param.h> 73 #include <sys/time.h> 74 #include <sys/systm.h> 75 #include <sys/errno.h> 76 #include <sys/device.h> 77 78 #include <uvm/uvm_extern.h> 79 80 #include <machine/autoconf.h> 81 #include <machine/bus.h> 82 #include <machine/intr.h> 83 84 #include <dev/isa/isavar.h> 85 #include <dev/pci/pcireg.h> 86 #include <dev/pci/pcivar.h> 87 88 #include <alpha/pci/lcavar.h> 89 90 #include <alpha/pci/pci_alphabook1.h> 91 #include <alpha/pci/siovar.h> 92 #include <alpha/pci/sioreg.h> 93 94 #include "sio.h" 95 96 int dec_alphabook1_intr_map __P((struct pci_attach_args *, pci_intr_handle_t *)); 97 const char *dec_alphabook1_intr_string __P((void *, pci_intr_handle_t)); 98 const struct evcnt *dec_alphabook1_intr_evcnt __P((void *, pci_intr_handle_t)); 99 void *dec_alphabook1_intr_establish __P((void *, pci_intr_handle_t, 100 int, int (*func)(void *), void *)); 101 void dec_alphabook1_intr_disestablish __P((void *, void *)); 102 103 #define LCA_SIO_DEVICE 7 /* XXX */ 104 105 void 106 pci_alphabook1_pickintr(lcp) 107 struct lca_config *lcp; 108 { 109 bus_space_tag_t iot = &lcp->lc_iot; 110 pci_chipset_tag_t pc = &lcp->lc_pc; 111 pcireg_t sioclass; 112 int sioII; 113 114 /* XXX MAGIC NUMBER */ 115 sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0), 116 PCI_CLASS_REG); 117 sioII = (sioclass & 0xff) >= 3; 118 119 if (!sioII) 120 printf("WARNING: SIO NOT SIO II... NO BETS...\n"); 121 122 pc->pc_intr_v = lcp; 123 pc->pc_intr_map = dec_alphabook1_intr_map; 124 pc->pc_intr_string = dec_alphabook1_intr_string; 125 pc->pc_intr_evcnt = dec_alphabook1_intr_evcnt; 126 pc->pc_intr_establish = dec_alphabook1_intr_establish; 127 pc->pc_intr_disestablish = dec_alphabook1_intr_disestablish; 128 129 /* Not supported on AlphaBook. */ 130 pc->pc_pciide_compat_intr_establish = NULL; 131 132 #if NSIO 133 sio_intr_setup(pc, iot); 134 #else 135 panic("pci_alphabook1_pickintr: no I/O interrupt handler (no sio)"); 136 #endif 137 } 138 139 int 140 dec_alphabook1_intr_map(pa, ihp) 141 struct pci_attach_args *pa; 142 pci_intr_handle_t *ihp; 143 { 144 pcitag_t bustag = pa->pa_intrtag; 145 int buspin = pa->pa_intrpin; 146 pci_chipset_tag_t pc = pa->pa_pc; 147 int device, irq; 148 149 if (buspin == 0) { 150 /* No IRQ used. */ 151 return 1; 152 } 153 if (buspin > 4) { 154 printf("dec_alphabook1_intr_map: bad interrupt pin %d\n", 155 buspin); 156 return 1; 157 } 158 159 pci_decompose_tag(pc, bustag, NULL, &device, NULL); 160 161 /* 162 * There is only one interrupting PCI device on the AlphaBook: an 163 * NCR SCSI at device 6. Devices 7 and 8 are the SIO and a 164 * Cirrus PD6729 PCMCIA controller. There are no option slots 165 * available. 166 * 167 * NOTE! Apparently, there was a later AlphaBook which uses 168 * a different interrupt scheme, and has a built-in Tulip Ethernet 169 * interface! We do not handle that here! 170 */ 171 172 switch (device) { 173 case 6: /* NCR SCSI */ 174 irq = 14; 175 break; 176 177 default: 178 printf("dec_alphabook1_intr_map: weird device number %d\n", 179 device); 180 return 1; 181 } 182 183 *ihp = irq; 184 return (0); 185 } 186 187 const char * 188 dec_alphabook1_intr_string(lcv, ih) 189 void *lcv; 190 pci_intr_handle_t ih; 191 { 192 #if 0 193 struct lca_config *lcp = lcv; 194 #endif 195 196 return sio_intr_string(NULL /*XXX*/, ih); 197 } 198 199 const struct evcnt * 200 dec_alphabook1_intr_evcnt(lcv, ih) 201 void *lcv; 202 pci_intr_handle_t ih; 203 { 204 #if 0 205 struct lca_config *lcp = lcv; 206 #endif 207 208 return sio_intr_evcnt(NULL /*XXX*/, ih); 209 } 210 211 void * 212 dec_alphabook1_intr_establish(lcv, ih, level, func, arg) 213 void *lcv, *arg; 214 pci_intr_handle_t ih; 215 int level; 216 int (*func) __P((void *)); 217 { 218 #if 0 219 struct lca_config *lcp = lcv; 220 #endif 221 222 return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func, 223 arg); 224 } 225 226 void 227 dec_alphabook1_intr_disestablish(lcv, cookie) 228 void *lcv, *cookie; 229 { 230 #if 0 231 struct lca_config *lcp = lcv; 232 #endif 233 234 sio_intr_disestablish(NULL /*XXX*/, cookie); 235 } 236