Home | History | Annotate | Line # | Download | only in pci
      1  1.11   nonaka /*	$NetBSD: pci_machdep.c,v 1.11 2016/10/19 00:08:41 nonaka Exp $	*/
      2   1.1      scw 
      3   1.1      scw /*
      4   1.1      scw  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
      5   1.1      scw  * Copyright (c) 1994 Charles M. Hannum.  All rights reserved.
      6   1.1      scw  *
      7   1.1      scw  * Redistribution and use in source and binary forms, with or without
      8   1.1      scw  * modification, are permitted provided that the following conditions
      9   1.1      scw  * are met:
     10   1.1      scw  * 1. Redistributions of source code must retain the above copyright
     11   1.1      scw  *    notice, this list of conditions and the following disclaimer.
     12   1.1      scw  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1      scw  *    notice, this list of conditions and the following disclaimer in the
     14   1.1      scw  *    documentation and/or other materials provided with the distribution.
     15   1.1      scw  * 3. All advertising materials mentioning features or use of this software
     16   1.1      scw  *    must display the following acknowledgement:
     17   1.1      scw  *	This product includes software developed by Charles M. Hannum.
     18   1.1      scw  * 4. The name of the author may not be used to endorse or promote products
     19   1.1      scw  *    derived from this software without specific prior written permission.
     20   1.1      scw  *
     21   1.1      scw  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.1      scw  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.1      scw  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.1      scw  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.1      scw  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.1      scw  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.1      scw  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.1      scw  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.1      scw  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.1      scw  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1      scw  */
     32   1.1      scw 
     33   1.1      scw /*
     34   1.1      scw  * Machine-specific functions for PCI autoconfiguration.
     35   1.1      scw  *
     36   1.1      scw  * On PCs, there are two methods of generating PCI configuration cycles.
     37   1.1      scw  * We try to detect the appropriate mechanism for this machine and set
     38   1.1      scw  * up a few function pointers to access the correct method directly.
     39   1.1      scw  */
     40   1.4    lukem 
     41   1.4    lukem #include <sys/cdefs.h>
     42  1.11   nonaka __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.11 2016/10/19 00:08:41 nonaka Exp $");
     43   1.1      scw 
     44   1.1      scw #include <sys/types.h>
     45   1.1      scw #include <sys/param.h>
     46   1.1      scw #include <sys/time.h>
     47   1.1      scw #include <sys/systm.h>
     48   1.1      scw #include <sys/errno.h>
     49   1.1      scw #include <sys/device.h>
     50   1.1      scw 
     51   1.1      scw #define _POWERPC_BUS_DMA_PRIVATE
     52  1.10   dyoung #include <sys/bus.h>
     53   1.1      scw #include <machine/intr.h>
     54   1.1      scw #include <machine/platform.h>
     55   1.3     matt 
     56   1.3     matt #include <powerpc/pio.h>
     57   1.1      scw 
     58   1.1      scw #include <dev/isa/isavar.h>
     59   1.1      scw #include <dev/pci/pcivar.h>
     60   1.1      scw #include <dev/pci/pcireg.h>
     61   1.1      scw #include <dev/pci/pcidevs.h>
     62   1.1      scw 
     63   1.6  garbled #include <machine/pci_machdep.h>
     64   1.1      scw 
     65   1.6  garbled extern struct genppc_pci_chipset *genppc_pct;
     66   1.6  garbled 
     67   1.6  garbled #define	PCI_MODE1_ADDRESS_REG	(PREP_BUS_SPACE_IO + 0xcf8)
     68   1.6  garbled #define	PCI_MODE1_DATA_REG	(PREP_BUS_SPACE_IO + 0xcfc)
     69   1.1      scw 
     70   1.1      scw void pci_intr_fixup(int, int, int *);
     71   1.1      scw 
     72   1.1      scw void
     73   1.6  garbled mvmeppc_pci_get_chipset_tag(pci_chipset_tag_t pc)
     74   1.1      scw {
     75   1.6  garbled 	pc->pc_conf_v = (void *)pc;
     76   1.1      scw 
     77   1.6  garbled 	pc->pc_attach_hook = genppc_pci_indirect_attach_hook;
     78   1.6  garbled 	pc->pc_bus_maxdevs = genppc_pci_bus_maxdevs;
     79   1.6  garbled 	pc->pc_make_tag = genppc_pci_indirect_make_tag;
     80   1.6  garbled 	pc->pc_conf_read = genppc_pci_indirect_conf_read;
     81   1.6  garbled 	pc->pc_conf_write = genppc_pci_indirect_conf_write;
     82   1.6  garbled 
     83   1.6  garbled 	pc->pc_intr_v = (void *)pc;
     84   1.6  garbled 
     85   1.6  garbled 	pc->pc_intr_map = genppc_pci_intr_map;
     86   1.6  garbled 	pc->pc_intr_string = genppc_pci_intr_string;
     87   1.6  garbled 	pc->pc_intr_evcnt = genppc_pci_intr_evcnt;
     88   1.6  garbled 	pc->pc_intr_establish = genppc_pci_intr_establish;
     89   1.6  garbled 	pc->pc_intr_disestablish = genppc_pci_intr_disestablish;
     90   1.8     matt 	pc->pc_intr_setattr = genppc_pci_intr_setattr;
     91  1.11   nonaka 	pc->pc_intr_type = genppc_pci_intr_type;
     92  1.11   nonaka 	pc->pc_intr_alloc = genppc_pci_intr_alloc;
     93  1.11   nonaka 	pc->pc_intr_release = genppc_pci_intr_release;
     94  1.11   nonaka 	pc->pc_intx_alloc = genppc_pci_intx_alloc;
     95  1.11   nonaka 
     96  1.11   nonaka 	pc->pc_msi_v = (void *)pc;
     97  1.11   nonaka 	genppc_pci_chipset_msi_init(pc);
     98  1.11   nonaka 
     99  1.11   nonaka 	pc->pc_msix_v = (void *)pc;
    100  1.11   nonaka 	genppc_pci_chipset_msix_init(pc);
    101   1.6  garbled 
    102   1.6  garbled 	pc->pc_conf_interrupt = mvmeppc_pci_conf_interrupt;
    103   1.6  garbled 	pc->pc_decompose_tag = genppc_pci_indirect_decompose_tag;
    104   1.6  garbled 	pc->pc_conf_hook = genppc_pci_conf_hook;
    105   1.6  garbled 
    106   1.9     matt 	pc->pc_addr = mapiodev(PCI_MODE1_ADDRESS_REG, 4, false);
    107   1.9     matt 	pc->pc_data = mapiodev(PCI_MODE1_DATA_REG, 4, false);
    108   1.6  garbled 	pc->pc_bus = 0;
    109   1.6  garbled 	pc->pc_node = 0;
    110   1.6  garbled 	pc->pc_memt = 0;
    111   1.6  garbled 	pc->pc_iot = 0;
    112   1.1      scw }
    113   1.1      scw 
    114   1.1      scw void
    115   1.8     matt mvmeppc_pci_conf_interrupt(void *v, int bus, int dev, int pin,
    116   1.1      scw     int swiz, int *iline)
    117   1.1      scw {
    118   1.1      scw 
    119   1.1      scw 	(*platform->pci_intr_fixup)(bus, dev, iline);
    120   1.1      scw }
    121