Home | History | Annotate | Line # | Download | only in pci
      1  1.29  thorpej /* $NetBSD: pci_eb64plus.c,v 1.29 2021/07/04 22:42:36 thorpej 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  *
     20   1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21   1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22   1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23   1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24   1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25   1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26   1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27   1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28   1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29   1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30   1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     31   1.1  thorpej  */
     32   1.1  thorpej 
     33   1.1  thorpej /*
     34   1.1  thorpej  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
     35   1.1  thorpej  * All rights reserved.
     36   1.1  thorpej  *
     37   1.1  thorpej  * Author: Chris G. Demetriou
     38  1.23     matt  *
     39   1.1  thorpej  * Permission to use, copy, modify and distribute this software and
     40   1.1  thorpej  * its documentation is hereby granted, provided that both the copyright
     41   1.1  thorpej  * notice and this permission notice appear in all copies of the
     42   1.1  thorpej  * software, derivative works or modified versions, and any portions
     43   1.1  thorpej  * thereof, and that both notices appear in supporting documentation.
     44  1.23     matt  *
     45  1.23     matt  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     46  1.23     matt  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     47   1.1  thorpej  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     48  1.23     matt  *
     49   1.1  thorpej  * Carnegie Mellon requests users of this software to return to
     50   1.1  thorpej  *
     51   1.1  thorpej  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     52   1.1  thorpej  *  School of Computer Science
     53   1.1  thorpej  *  Carnegie Mellon University
     54   1.1  thorpej  *  Pittsburgh PA 15213-3890
     55   1.1  thorpej  *
     56   1.1  thorpej  * any improvements or extensions that they make and grant Carnegie the
     57   1.1  thorpej  * rights to redistribute these changes.
     58   1.1  thorpej  */
     59   1.1  thorpej 
     60   1.1  thorpej #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     61   1.1  thorpej 
     62  1.29  thorpej __KERNEL_RCSID(0, "$NetBSD: pci_eb64plus.c,v 1.29 2021/07/04 22:42:36 thorpej Exp $");
     63   1.1  thorpej 
     64   1.1  thorpej #include <sys/types.h>
     65   1.1  thorpej #include <sys/param.h>
     66   1.1  thorpej #include <sys/time.h>
     67   1.1  thorpej #include <sys/systm.h>
     68   1.1  thorpej #include <sys/errno.h>
     69   1.1  thorpej #include <sys/device.h>
     70   1.1  thorpej #include <sys/syslog.h>
     71   1.1  thorpej 
     72   1.1  thorpej #include <machine/autoconf.h>
     73  1.26  thorpej #include <machine/rpb.h>
     74   1.1  thorpej 
     75   1.1  thorpej #include <dev/pci/pcireg.h>
     76   1.1  thorpej #include <dev/pci/pcivar.h>
     77   1.1  thorpej 
     78   1.1  thorpej #include <alpha/pci/apecsreg.h>
     79   1.1  thorpej #include <alpha/pci/apecsvar.h>
     80   1.1  thorpej 
     81   1.1  thorpej #include "sio.h"
     82   1.1  thorpej #if NSIO
     83   1.1  thorpej #include <alpha/pci/siovar.h>
     84   1.1  thorpej #endif
     85   1.1  thorpej 
     86   1.1  thorpej #define	EB64PLUS_MAX_IRQ	32
     87   1.1  thorpej #define	PCI_STRAY_MAX		5
     88   1.1  thorpej 
     89  1.25  thorpej static bus_space_tag_t eb64plus_intrgate_iot;
     90  1.25  thorpej static bus_space_handle_t eb64plus_intrgate_ioh;
     91   1.1  thorpej 
     92  1.25  thorpej /* See pci_eb64plus_intr.s */
     93  1.25  thorpej extern void	eb64plus_intr_enable(pci_chipset_tag_t, int irq);
     94  1.25  thorpej extern void	eb64plus_intr_disable(pci_chipset_tag_t, int irq);
     95   1.1  thorpej 
     96  1.26  thorpej static void
     97  1.26  thorpej pci_eb64plus_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt,
     98  1.26  thorpej     pci_chipset_tag_t pc)
     99   1.1  thorpej {
    100   1.1  thorpej 	int i;
    101   1.1  thorpej 
    102  1.26  thorpej 	pc->pc_intr_v = core;
    103  1.25  thorpej 	pc->pc_intr_map = alpha_pci_generic_intr_map;
    104  1.25  thorpej 	pc->pc_intr_string = alpha_pci_generic_intr_string;
    105  1.25  thorpej 	pc->pc_intr_evcnt = alpha_pci_generic_intr_evcnt;
    106  1.25  thorpej 	pc->pc_intr_establish = alpha_pci_generic_intr_establish;
    107  1.25  thorpej 	pc->pc_intr_disestablish = alpha_pci_generic_intr_disestablish;
    108   1.1  thorpej 
    109   1.1  thorpej 	/* Not supported on the EB64+. */
    110   1.1  thorpej 	pc->pc_pciide_compat_intr_establish = NULL;
    111   1.1  thorpej 
    112   1.1  thorpej 	eb64plus_intrgate_iot = iot;
    113   1.1  thorpej 	if (bus_space_map(eb64plus_intrgate_iot, 0x804, 3, 0,
    114   1.1  thorpej 	    &eb64plus_intrgate_ioh) != 0)
    115   1.1  thorpej 		panic("pci_eb64plus_pickintr: couldn't map interrupt PLD");
    116   1.1  thorpej 
    117  1.27  thorpej 	pc->pc_intr_desc = "eb64+";
    118  1.25  thorpej 	pc->pc_vecbase = 0x900;
    119  1.25  thorpej 	pc->pc_nirq = EB64PLUS_MAX_IRQ;
    120  1.25  thorpej 
    121  1.25  thorpej 	pc->pc_intr_enable = eb64plus_intr_enable;
    122  1.25  thorpej 	pc->pc_intr_disable = eb64plus_intr_disable;
    123  1.25  thorpej 
    124   1.7  thorpej 	for (i = 0; i < EB64PLUS_MAX_IRQ; i++) {
    125  1.28  thorpej 		eb64plus_intr_disable(pc, i);
    126   1.7  thorpej 	}
    127   1.1  thorpej 
    128  1.28  thorpej 	alpha_pci_intr_alloc(pc, PCI_STRAY_MAX);
    129  1.28  thorpej 
    130   1.1  thorpej #if NSIO
    131   1.1  thorpej 	sio_intr_setup(pc, iot);
    132   1.1  thorpej #endif
    133   1.1  thorpej }
    134  1.26  thorpej ALPHA_PCI_INTR_INIT(ST_EB64P, pci_eb64plus_pickintr)
    135   1.1  thorpej 
    136   1.1  thorpej #if 0		/* THIS DOES NOT WORK!  see pci_eb64plus_intr.S. */
    137  1.23     matt uint8_t eb64plus_intr_mask[3] = { 0xff, 0xff, 0xff };
    138   1.1  thorpej 
    139   1.1  thorpej void
    140  1.25  thorpej eb64plus_intr_enable(pci_chipset_tag_t pc __unused, int irq)
    141   1.1  thorpej {
    142   1.1  thorpej 	int byte = (irq / 8), bit = (irq % 8);
    143   1.1  thorpej 
    144   1.1  thorpej #if 1
    145   1.1  thorpej 	printf("eb64plus_intr_enable: enabling %d (%d:%d)\n", irq, byte, bit);
    146   1.1  thorpej #endif
    147   1.1  thorpej 	eb64plus_intr_mask[byte] &= ~(1 << bit);
    148   1.1  thorpej 
    149   1.1  thorpej 	bus_space_write_1(eb64plus_intrgate_iot, eb64plus_intrgate_ioh, byte,
    150   1.1  thorpej 	    eb64plus_intr_mask[byte]);
    151   1.1  thorpej }
    152   1.1  thorpej 
    153   1.1  thorpej void
    154  1.25  thorpej eb64plus_intr_disable(pci_chipset_tag_t pc __unused, int irq)
    155   1.1  thorpej {
    156   1.1  thorpej 	int byte = (irq / 8), bit = (irq % 8);
    157   1.1  thorpej 
    158   1.1  thorpej #if 1
    159   1.1  thorpej 	printf("eb64plus_intr_disable: disabling %d (%d:%d)\n", irq, byte, bit);
    160   1.1  thorpej #endif
    161   1.1  thorpej 	eb64plus_intr_mask[byte] |= (1 << bit);
    162   1.1  thorpej 
    163   1.1  thorpej 	bus_space_write_1(eb64plus_intrgate_iot, eb64plus_intrgate_ioh, byte,
    164   1.1  thorpej 	    eb64plus_intr_mask[byte]);
    165   1.1  thorpej }
    166   1.1  thorpej #endif
    167