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