Home | History | Annotate | Line # | Download | only in pci
pci_alphabook1.c revision 1.5
      1 /* $NetBSD: pci_alphabook1.c,v 1.5 2000/06/29 08:58:48 mrg 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.5 2000/06/29 08:58:48 mrg 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((void *, pcitag_t, int, int,
     97 	    pci_intr_handle_t *));
     98 const char *dec_alphabook1_intr_string __P((void *, pci_intr_handle_t));
     99 const struct evcnt *dec_alphabook1_intr_evcnt __P((void *, pci_intr_handle_t));
    100 void    *dec_alphabook1_intr_establish __P((void *, pci_intr_handle_t,
    101 	    int, int (*func)(void *), void *));
    102 void    dec_alphabook1_intr_disestablish __P((void *, void *));
    103 
    104 #define	LCA_SIO_DEVICE	7	/* XXX */
    105 
    106 void
    107 pci_alphabook1_pickintr(lcp)
    108 	struct lca_config *lcp;
    109 {
    110 	bus_space_tag_t iot = &lcp->lc_iot;
    111 	pci_chipset_tag_t pc = &lcp->lc_pc;
    112 	pcireg_t sioclass;
    113 	int sioII;
    114 
    115 	/* XXX MAGIC NUMBER */
    116 	sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0),
    117 	    PCI_CLASS_REG);
    118         sioII = (sioclass & 0xff) >= 3;
    119 
    120 	if (!sioII)
    121 		printf("WARNING: SIO NOT SIO II... NO BETS...\n");
    122 
    123 	pc->pc_intr_v = lcp;
    124 	pc->pc_intr_map = dec_alphabook1_intr_map;
    125 	pc->pc_intr_string = dec_alphabook1_intr_string;
    126 	pc->pc_intr_evcnt = dec_alphabook1_intr_evcnt;
    127 	pc->pc_intr_establish = dec_alphabook1_intr_establish;
    128 	pc->pc_intr_disestablish = dec_alphabook1_intr_disestablish;
    129 
    130 	/* Not supported on AlphaBook. */
    131 	pc->pc_pciide_compat_intr_establish = NULL;
    132 
    133 #if NSIO
    134 	sio_intr_setup(pc, iot);
    135 	set_iointr(&sio_iointr);
    136 #else
    137 	panic("pci_alphabook1_pickintr: no I/O interrupt handler (no sio)");
    138 #endif
    139 }
    140 
    141 int
    142 dec_alphabook1_intr_map(lcv, bustag, buspin, line, ihp)
    143 	void *lcv;
    144 	pcitag_t bustag;
    145 	int buspin, line;
    146 	pci_intr_handle_t *ihp;
    147 {
    148 	struct lca_config *lcp = lcv;
    149 	pci_chipset_tag_t pc = &lcp->lc_pc;
    150 	int device, irq;
    151 
    152 	if (buspin == 0) {
    153 		/* No IRQ used. */
    154 		return 1;
    155 	}
    156 	if (buspin > 4) {
    157 		printf("dec_alphabook1_intr_map: bad interrupt pin %d\n",
    158 		    buspin);
    159 		return 1;
    160 	}
    161 
    162 	alpha_pci_decompose_tag(pc, bustag, NULL, &device, NULL);
    163 
    164 	/*
    165 	 * There is only one interrupting PCI device on the AlphaBook: an
    166 	 * NCR SCSI at device 6.  Devices 7 and 8 are the SIO and a
    167 	 * Cirrus PD6729 PCMCIA controller.  There are no option slots
    168 	 * available.
    169 	 *
    170 	 * NOTE!  Apparently, there was a later AlphaBook which uses
    171 	 * a different interrupt scheme, and has a built-in Tulip Ethernet
    172 	 * interface!  We do not handle that here!
    173 	 */
    174 
    175 	switch (device) {
    176 	case 6:					/* NCR SCSI */
    177 		irq = 14;
    178 		break;
    179 
    180 	default:
    181                 printf("dec_alphabook1_intr_map: weird device number %d\n",
    182 		    device);
    183                 return 1;
    184 	}
    185 
    186 	*ihp = irq;
    187 	return (0);
    188 }
    189 
    190 const char *
    191 dec_alphabook1_intr_string(lcv, ih)
    192 	void *lcv;
    193 	pci_intr_handle_t ih;
    194 {
    195 #if 0
    196 	struct lca_config *lcp = lcv;
    197 #endif
    198 
    199 	return sio_intr_string(NULL /*XXX*/, ih);
    200 }
    201 
    202 const struct evcnt *
    203 dec_alphabook1_intr_evcnt(lcv, ih)
    204 	void *lcv;
    205 	pci_intr_handle_t ih;
    206 {
    207 #if 0
    208 	struct lca_config *lcp = lcv;
    209 #endif
    210 
    211 	return sio_intr_evcnt(NULL /*XXX*/, ih);
    212 }
    213 
    214 void *
    215 dec_alphabook1_intr_establish(lcv, ih, level, func, arg)
    216 	void *lcv, *arg;
    217 	pci_intr_handle_t ih;
    218 	int level;
    219 	int (*func) __P((void *));
    220 {
    221 #if 0
    222 	struct lca_config *lcp = lcv;
    223 #endif
    224 
    225 	return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func,
    226 	    arg);
    227 }
    228 
    229 void
    230 dec_alphabook1_intr_disestablish(lcv, cookie)
    231 	void *lcv, *cookie;
    232 {
    233 #if 0
    234 	struct lca_config *lcp = lcv;
    235 #endif
    236 
    237 	sio_intr_disestablish(NULL /*XXX*/, cookie);
    238 }
    239