Home | History | Annotate | Line # | Download | only in pci
pci_alphabook1.c revision 1.1
      1 /* $NetBSD: pci_alphabook1.c,v 1.1 1998/06/26 05:42:35 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 (at) 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.1 1998/06/26 05:42:35 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 #include <vm/vm.h>
     78 
     79 #include <machine/autoconf.h>
     80 #include <machine/bus.h>
     81 #include <machine/intr.h>
     82 
     83 #include <dev/isa/isavar.h>
     84 #include <dev/pci/pcireg.h>
     85 #include <dev/pci/pcivar.h>
     86 
     87 #include <alpha/pci/lcavar.h>
     88 
     89 #include <alpha/pci/pci_alphabook1.h>
     90 #include <alpha/pci/siovar.h>
     91 #include <alpha/pci/sioreg.h>
     92 
     93 #include "sio.h"
     94 
     95 int     dec_alphabook1_intr_map __P((void *, pcitag_t, int, int,
     96 	    pci_intr_handle_t *));
     97 const char *dec_alphabook1_intr_string __P((void *, pci_intr_handle_t));
     98 void    *dec_alphabook1_intr_establish __P((void *, pci_intr_handle_t,
     99 	    int, int (*func)(void *), void *));
    100 void    dec_alphabook1_intr_disestablish __P((void *, void *));
    101 
    102 #define	LCA_SIO_DEVICE	7	/* XXX */
    103 
    104 void
    105 pci_alphabook1_pickintr(lcp)
    106 	struct lca_config *lcp;
    107 {
    108 	bus_space_tag_t iot = &lcp->lc_iot;
    109 	pci_chipset_tag_t pc = &lcp->lc_pc;
    110 	pcireg_t sioclass;
    111 	int sioII;
    112 
    113 	/* XXX MAGIC NUMBER */
    114 	sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0),
    115 	    PCI_CLASS_REG);
    116         sioII = (sioclass & 0xff) >= 3;
    117 
    118 	if (!sioII)
    119 		printf("WARNING: SIO NOT SIO II... NO BETS...\n");
    120 
    121 	pc->pc_intr_v = lcp;
    122 	pc->pc_intr_map = dec_alphabook1_intr_map;
    123 	pc->pc_intr_string = dec_alphabook1_intr_string;
    124 	pc->pc_intr_establish = dec_alphabook1_intr_establish;
    125 	pc->pc_intr_disestablish = dec_alphabook1_intr_disestablish;
    126 
    127 	/* Not supported on AlphaBook. */
    128 	pc->pc_pciide_compat_intr_establish = NULL;
    129 
    130 #if NSIO
    131 	sio_intr_setup(pc, iot);
    132 	set_iointr(&sio_iointr);
    133 #else
    134 	panic("pci_alphabook1_pickintr: no I/O interrupt handler (no sio)");
    135 #endif
    136 }
    137 
    138 int
    139 dec_alphabook1_intr_map(lcv, bustag, buspin, line, ihp)
    140 	void *lcv;
    141 	pcitag_t bustag;
    142 	int buspin, line;
    143 	pci_intr_handle_t *ihp;
    144 {
    145 	struct lca_config *lcp = lcv;
    146 	pci_chipset_tag_t pc = &lcp->lc_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 	alpha_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 void *
    200 dec_alphabook1_intr_establish(lcv, ih, level, func, arg)
    201 	void *lcv, *arg;
    202 	pci_intr_handle_t ih;
    203 	int level;
    204 	int (*func) __P((void *));
    205 {
    206 #if 0
    207 	struct lca_config *lcp = lcv;
    208 #endif
    209 
    210 	return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func,
    211 	    arg);
    212 }
    213 
    214 void
    215 dec_alphabook1_intr_disestablish(lcv, cookie)
    216 	void *lcv, *cookie;
    217 {
    218 #if 0
    219 	struct lca_config *lcp = lcv;
    220 #endif
    221 
    222 	sio_intr_disestablish(NULL /*XXX*/, cookie);
    223 }
    224