Home | History | Annotate | Line # | Download | only in pci
pci_alphabook1.c revision 1.6
      1 /* $NetBSD: pci_alphabook1.c,v 1.6 2000/12/28 22:59:07 sommerfeld 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.6 2000/12/28 22:59:07 sommerfeld 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 	set_iointr(&sio_iointr);
    135 #else
    136 	panic("pci_alphabook1_pickintr: no I/O interrupt handler (no sio)");
    137 #endif
    138 }
    139 
    140 int
    141 dec_alphabook1_intr_map(pa, ihp)
    142 	struct pci_attach_args *pa;
    143 	pci_intr_handle_t *ihp;
    144 {
    145 	pcitag_t bustag = pa->pa_intrtag;
    146 	int buspin = pa->pa_intrpin;
    147 	pci_chipset_tag_t pc = pa->pa_pc;
    148 	int device, irq;
    149 
    150 	if (buspin == 0) {
    151 		/* No IRQ used. */
    152 		return 1;
    153 	}
    154 	if (buspin > 4) {
    155 		printf("dec_alphabook1_intr_map: bad interrupt pin %d\n",
    156 		    buspin);
    157 		return 1;
    158 	}
    159 
    160 	alpha_pci_decompose_tag(pc, bustag, NULL, &device, NULL);
    161 
    162 	/*
    163 	 * There is only one interrupting PCI device on the AlphaBook: an
    164 	 * NCR SCSI at device 6.  Devices 7 and 8 are the SIO and a
    165 	 * Cirrus PD6729 PCMCIA controller.  There are no option slots
    166 	 * available.
    167 	 *
    168 	 * NOTE!  Apparently, there was a later AlphaBook which uses
    169 	 * a different interrupt scheme, and has a built-in Tulip Ethernet
    170 	 * interface!  We do not handle that here!
    171 	 */
    172 
    173 	switch (device) {
    174 	case 6:					/* NCR SCSI */
    175 		irq = 14;
    176 		break;
    177 
    178 	default:
    179                 printf("dec_alphabook1_intr_map: weird device number %d\n",
    180 		    device);
    181                 return 1;
    182 	}
    183 
    184 	*ihp = irq;
    185 	return (0);
    186 }
    187 
    188 const char *
    189 dec_alphabook1_intr_string(lcv, ih)
    190 	void *lcv;
    191 	pci_intr_handle_t ih;
    192 {
    193 #if 0
    194 	struct lca_config *lcp = lcv;
    195 #endif
    196 
    197 	return sio_intr_string(NULL /*XXX*/, ih);
    198 }
    199 
    200 const struct evcnt *
    201 dec_alphabook1_intr_evcnt(lcv, ih)
    202 	void *lcv;
    203 	pci_intr_handle_t ih;
    204 {
    205 #if 0
    206 	struct lca_config *lcp = lcv;
    207 #endif
    208 
    209 	return sio_intr_evcnt(NULL /*XXX*/, ih);
    210 }
    211 
    212 void *
    213 dec_alphabook1_intr_establish(lcv, ih, level, func, arg)
    214 	void *lcv, *arg;
    215 	pci_intr_handle_t ih;
    216 	int level;
    217 	int (*func) __P((void *));
    218 {
    219 #if 0
    220 	struct lca_config *lcp = lcv;
    221 #endif
    222 
    223 	return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func,
    224 	    arg);
    225 }
    226 
    227 void
    228 dec_alphabook1_intr_disestablish(lcv, cookie)
    229 	void *lcv, *cookie;
    230 {
    231 #if 0
    232 	struct lca_config *lcp = lcv;
    233 #endif
    234 
    235 	sio_intr_disestablish(NULL /*XXX*/, cookie);
    236 }
    237