1 /* $NetBSD: pci_alphabook1.c,v 1.16 2012/02/06 02:14:15 matt 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 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /* 34 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 35 * All rights reserved. 36 * 37 * Authors: Jeffrey Hsu and Chris G. Demetriou 38 * 39 * Permission to use, copy, modify and distribute this software and 40 * its documentation is hereby granted, provided that both the copyright 41 * notice and this permission notice appear in all copies of the 42 * software, derivative works or modified versions, and any portions 43 * thereof, and that both notices appear in supporting documentation. 44 * 45 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 46 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 47 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 48 * 49 * Carnegie Mellon requests users of this software to return to 50 * 51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 52 * School of Computer Science 53 * Carnegie Mellon University 54 * Pittsburgh PA 15213-3890 55 * 56 * any improvements or extensions that they make and grant Carnegie the 57 * rights to redistribute these changes. 58 */ 59 60 #include <sys/types.h> 61 #include <sys/param.h> 62 #include <sys/time.h> 63 #include <sys/systm.h> 64 #include <sys/errno.h> 65 #include <sys/device.h> 66 67 #include <machine/intr.h> 68 69 #include <dev/isa/isavar.h> 70 #include <dev/pci/pcireg.h> 71 #include <dev/pci/pcivar.h> 72 73 #include <alpha/pci/lcavar.h> 74 75 #include <alpha/pci/pci_alphabook1.h> 76 #include <alpha/pci/siovar.h> 77 #include <alpha/pci/sioreg.h> 78 79 #include "sio.h" 80 81 int dec_alphabook1_intr_map(struct pci_attach_args *, 82 pci_intr_handle_t *); 83 const char *dec_alphabook1_intr_string(void *, pci_intr_handle_t); 84 int dec_alphabook1_intr_line(void *, pci_intr_handle_t); 85 void *dec_alphabook1_intr_establish(void *, pci_intr_handle_t, 86 int, int (*func)(void *), void *, const char *); 87 void dec_alphabook1_intr_disestablish(void *, void *); 88 89 #define LCA_SIO_DEVICE 7 /* XXX */ 90 91 void 92 pci_alphabook1_pickintr(struct lca_config *lcp) 93 { 94 bus_space_tag_t iot = &lcp->lc_iot; 95 pci_chipset_tag_t pc = &lcp->lc_pc; 96 pcireg_t sioclass; 97 int sioII; 98 99 /* XXX MAGIC NUMBER */ 100 sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0), 101 PCI_CLASS_REG); 102 sioII = (sioclass & 0xff) >= 3; 103 104 if (!sioII) 105 printf("WARNING: SIO NOT SIO II... NO BETS...\n"); 106 107 pc->pc_intr_v = lcp; 108 pc->pc_intr_map = dec_alphabook1_intr_map; 109 pc->pc_intr_string = dec_alphabook1_intr_string; 110 pc->pc_intr_line = dec_alphabook1_intr_line; 111 pc->pc_intr_establish = dec_alphabook1_intr_establish; 112 pc->pc_intr_disestablish = dec_alphabook1_intr_disestablish; 113 114 /* Not supported on AlphaBook. */ 115 pc->pc_pciide_compat_intr_establish = NULL; 116 117 #if NSIO 118 sio_intr_setup(pc, iot); 119 #else 120 panic("pci_alphabook1_pickintr: no I/O interrupt handler (no sio)"); 121 #endif 122 } 123 124 int 125 dec_alphabook1_intr_map(struct pci_attach_args *pa, 126 pci_intr_handle_t *ihp) 127 { 128 pcitag_t bustag = pa->pa_intrtag; 129 int buspin = pa->pa_intrpin; 130 pci_chipset_tag_t pc = pa->pa_pc; 131 int device, irq; 132 133 if (buspin == 0) { 134 /* No IRQ used. */ 135 return 1; 136 } 137 if (buspin > 4) { 138 printf("dec_alphabook1_intr_map: bad interrupt pin %d\n", 139 buspin); 140 return 1; 141 } 142 143 pci_decompose_tag(pc, bustag, NULL, &device, NULL); 144 145 /* 146 * There is only one interrupting PCI device on the AlphaBook: an 147 * NCR SCSI at device 6. Devices 7 and 8 are the SIO and a 148 * Cirrus PD6729 PCMCIA controller. There are no option slots 149 * available. 150 * 151 * NOTE! Apparently, there was a later AlphaBook which uses 152 * a different interrupt scheme, and has a built-in Tulip Ethernet 153 * interface! We do not handle that here! 154 */ 155 156 switch (device) { 157 case 6: /* NCR SCSI */ 158 irq = 14; 159 break; 160 161 default: 162 printf("dec_alphabook1_intr_map: weird device number %d\n", 163 device); 164 return 1; 165 } 166 167 *ihp = irq; 168 return (0); 169 } 170 171 const char * 172 dec_alphabook1_intr_string(void *lcv, pci_intr_handle_t ih) 173 { 174 return sio_intr_string(NULL /*XXX*/, ih); 175 } 176 177 int 178 dec_alphabook1_intr_line(void *lcv, pci_intr_handle_t ih) 179 { 180 return sio_intr_line(NULL /*XXX*/, ih); 181 } 182 183 void * 184 dec_alphabook1_intr_establish(void *lcv, pci_intr_handle_t ih, 185 int level, int (*func)(void *), void *arg, const char *name) 186 { 187 return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func, 188 arg, name); 189 } 190 191 void 192 dec_alphabook1_intr_disestablish(void *lcv, void *cookie) 193 { 194 sio_intr_disestablish(NULL /*XXX*/, cookie); 195 } 196