Home | History | Annotate | Line # | Download | only in pci
pci_2100_a50.c revision 1.42.6.1
      1  1.42.6.1   thorpej /* $NetBSD: pci_2100_a50.c,v 1.42.6.1 2021/08/01 22:42:02 thorpej Exp $ */
      2       1.1       cgd 
      3       1.1       cgd /*
      4       1.6       cgd  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5       1.1       cgd  * All rights reserved.
      6       1.1       cgd  *
      7       1.1       cgd  * Author: Chris G. Demetriou
      8      1.40      matt  *
      9       1.1       cgd  * Permission to use, copy, modify and distribute this software and
     10       1.1       cgd  * its documentation is hereby granted, provided that both the copyright
     11       1.1       cgd  * notice and this permission notice appear in all copies of the
     12       1.1       cgd  * software, derivative works or modified versions, and any portions
     13       1.1       cgd  * thereof, and that both notices appear in supporting documentation.
     14      1.40      matt  *
     15      1.40      matt  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16      1.40      matt  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17       1.1       cgd  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18      1.40      matt  *
     19       1.1       cgd  * Carnegie Mellon requests users of this software to return to
     20       1.1       cgd  *
     21       1.1       cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22       1.1       cgd  *  School of Computer Science
     23       1.1       cgd  *  Carnegie Mellon University
     24       1.1       cgd  *  Pittsburgh PA 15213-3890
     25       1.1       cgd  *
     26       1.1       cgd  * any improvements or extensions that they make and grant Carnegie the
     27       1.1       cgd  * rights to redistribute these changes.
     28       1.1       cgd  */
     29      1.13       cgd 
     30      1.14       cgd #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     31      1.14       cgd 
     32  1.42.6.1   thorpej __KERNEL_RCSID(0, "$NetBSD: pci_2100_a50.c,v 1.42.6.1 2021/08/01 22:42:02 thorpej Exp $");
     33       1.1       cgd 
     34       1.1       cgd #include <sys/types.h>
     35       1.1       cgd #include <sys/param.h>
     36       1.1       cgd #include <sys/time.h>
     37       1.1       cgd #include <sys/systm.h>
     38       1.1       cgd #include <sys/errno.h>
     39       1.1       cgd #include <sys/device.h>
     40      1.28       mrg 
     41       1.8       cgd #include <machine/autoconf.h>
     42  1.42.6.1   thorpej #include <machine/rpb.h>
     43      1.39    dyoung #include <sys/bus.h>
     44       1.5       cgd #include <machine/intr.h>
     45       1.5       cgd 
     46       1.1       cgd #include <dev/isa/isavar.h>
     47       1.3       cgd #include <dev/pci/pcireg.h>
     48       1.1       cgd #include <dev/pci/pcivar.h>
     49       1.1       cgd 
     50       1.3       cgd #include <alpha/pci/apecsvar.h>
     51       1.1       cgd 
     52       1.3       cgd #include <alpha/pci/siovar.h>
     53       1.7       cgd #include <alpha/pci/sioreg.h>
     54       1.1       cgd 
     55       1.3       cgd #include "sio.h"
     56       1.1       cgd 
     57      1.42   thorpej static int	dec_2100_a50_intr_map(const struct pci_attach_args *,
     58      1.42   thorpej 		    pci_intr_handle_t *);
     59       1.5       cgd 
     60  1.42.6.1   thorpej static void
     61  1.42.6.1   thorpej pci_2100_a50_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt,
     62  1.42.6.1   thorpej     pci_chipset_tag_t pc)
     63       1.5       cgd {
     64       1.5       cgd 
     65  1.42.6.1   thorpej 	pc->pc_intr_v = core;
     66       1.5       cgd 	pc->pc_intr_map = dec_2100_a50_intr_map;
     67      1.42   thorpej 	pc->pc_intr_string = sio_pci_intr_string;
     68      1.42   thorpej 	pc->pc_intr_evcnt = sio_pci_intr_evcnt;
     69      1.42   thorpej 	pc->pc_intr_establish = sio_pci_intr_establish;
     70      1.42   thorpej 	pc->pc_intr_disestablish = sio_pci_intr_disestablish;
     71      1.22   thorpej 
     72      1.23    mjacob 	/* Not supported on 2100 A50. */
     73      1.22   thorpej 	pc->pc_pciide_compat_intr_establish = NULL;
     74       1.1       cgd 
     75       1.5       cgd #if NSIO
     76      1.20   thorpej 	sio_intr_setup(pc, iot);
     77       1.5       cgd #else
     78       1.5       cgd 	panic("pci_2100_a50_pickintr: no I/O interrupt handler (no sio)");
     79       1.5       cgd #endif
     80       1.5       cgd }
     81  1.42.6.1   thorpej ALPHA_PCI_INTR_INIT(ST_DEC_2100_A50, pci_2100_a50_pickintr)
     82       1.5       cgd 
     83       1.5       cgd int
     84      1.38    dyoung dec_2100_a50_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
     85       1.1       cgd {
     86      1.40      matt 	pcitag_t bustag = pa->pa_intrtag;
     87      1.29  sommerfe 	int buspin = pa->pa_intrpin;
     88      1.29  sommerfe 	pci_chipset_tag_t pc = pa->pa_pc;
     89       1.5       cgd 	int device, pirq;
     90      1.15       cgd 
     91      1.15       cgd #ifndef DIAGNOSTIC
     92      1.15       cgd 	pirq = 0;				/* XXX gcc -Wuninitialized */
     93      1.15       cgd #endif
     94       1.1       cgd 
     95      1.24   thorpej 	if (buspin == 0) {
     96      1.24   thorpej 		/* No IRQ used. */
     97      1.24   thorpej 		return 1;
     98      1.24   thorpej 	}
     99      1.42   thorpej 	if (buspin < 0 || buspin > 4) {
    100      1.24   thorpej 		printf("dec_2100_a50_intr_map: bad interrupt pin %d\n",
    101      1.12       cgd 		    buspin);
    102      1.24   thorpej 		return 1;
    103      1.24   thorpej 	}
    104       1.1       cgd 
    105      1.31   thorpej 	pci_decompose_tag(pc, bustag, NULL, &device, NULL);
    106       1.1       cgd 
    107       1.1       cgd 	switch (device) {
    108       1.1       cgd 	case 6:					/* NCR SCSI */
    109       1.1       cgd 		pirq = 3;
    110       1.1       cgd 		break;
    111       1.1       cgd 
    112       1.1       cgd 	case 11:				/* slot 1 */
    113       1.5       cgd 	case 14:				/* slot 3 */
    114       1.5       cgd 		switch (buspin) {
    115       1.1       cgd 		case PCI_INTERRUPT_PIN_A:
    116       1.1       cgd 		case PCI_INTERRUPT_PIN_D:
    117       1.1       cgd 			pirq = 0;
    118       1.1       cgd 			break;
    119       1.1       cgd 		case PCI_INTERRUPT_PIN_B:
    120       1.1       cgd 			pirq = 2;
    121       1.1       cgd 			break;
    122       1.1       cgd 		case PCI_INTERRUPT_PIN_C:
    123       1.1       cgd 			pirq = 1;
    124       1.1       cgd 			break;
    125      1.12       cgd #ifdef DIAGNOSTIC
    126      1.12       cgd 		default:			/* XXX gcc -Wuninitialized */
    127      1.32    provos 			panic("dec_2100_a50_intr_map bogus PCI pin %d",
    128      1.12       cgd 			    buspin);
    129      1.12       cgd #endif
    130       1.1       cgd 		};
    131       1.1       cgd 		break;
    132       1.1       cgd 
    133       1.1       cgd 	case 12:				/* slot 2 */
    134       1.5       cgd 		switch (buspin) {
    135       1.1       cgd 		case PCI_INTERRUPT_PIN_A:
    136       1.1       cgd 		case PCI_INTERRUPT_PIN_D:
    137       1.1       cgd 			pirq = 1;
    138       1.1       cgd 			break;
    139       1.1       cgd 		case PCI_INTERRUPT_PIN_B:
    140       1.1       cgd 			pirq = 0;
    141       1.1       cgd 			break;
    142       1.1       cgd 		case PCI_INTERRUPT_PIN_C:
    143       1.1       cgd 			pirq = 2;
    144       1.1       cgd 			break;
    145      1.12       cgd #ifdef DIAGNOSTIC
    146      1.12       cgd 		default:			/* XXX gcc -Wuninitialized */
    147      1.32    provos 			panic("dec_2100_a50_intr_map bogus PCI pin %d",
    148      1.12       cgd 			    buspin);
    149      1.12       cgd #endif
    150       1.1       cgd 		};
    151       1.1       cgd 		break;
    152       1.1       cgd 
    153       1.1       cgd 	case 13:				/* slot 3 */
    154       1.5       cgd 		switch (buspin) {
    155       1.1       cgd 		case PCI_INTERRUPT_PIN_A:
    156       1.1       cgd 		case PCI_INTERRUPT_PIN_D:
    157       1.1       cgd 			pirq = 2;
    158       1.1       cgd 			break;
    159       1.1       cgd 		case PCI_INTERRUPT_PIN_B:
    160       1.1       cgd 			pirq = 1;
    161       1.1       cgd 			break;
    162       1.1       cgd 		case PCI_INTERRUPT_PIN_C:
    163       1.1       cgd 			pirq = 0;
    164       1.1       cgd 			break;
    165      1.12       cgd #ifdef DIAGNOSTIC
    166      1.12       cgd 		default:			/* XXX gcc -Wuninitialized */
    167      1.32    provos 			panic("dec_2100_a50_intr_map bogus PCI pin %d",
    168      1.12       cgd 			    buspin);
    169      1.12       cgd #endif
    170       1.1       cgd 		};
    171       1.1       cgd 		break;
    172      1.12       cgd 
    173      1.12       cgd 	default:
    174      1.40      matt 	        printf("dec_2100_a50_intr_map: weird device number %d\n",
    175      1.12       cgd 		    device);
    176      1.40      matt 	        return 1;
    177       1.1       cgd 	}
    178       1.1       cgd 
    179       1.1       cgd #if 0
    180  1.42.6.1   thorpej 	printf("pci_2100_a50_intr_map: device %d pin %c: pirq %d\n",
    181  1.42.6.1   thorpej 		device, '@' + buspin, pirq);
    182       1.1       cgd #endif
    183       1.1       cgd 
    184  1.42.6.1   thorpej 	return sio_pirq_intr_map(pc, pirq, ihp);
    185       1.3       cgd }
    186