Home | History | Annotate | Line # | Download | only in pci
pci_machdep.c revision 1.3
      1 /*	$NetBSD: pci_machdep.c,v 1.3 2000/06/29 07:44:10 mrg Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2000 Soren S. Jorvang
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *          This product includes software developed for the
     18  *          NetBSD Project.  See http://www.netbsd.org/ for
     19  *          information about NetBSD.
     20  * 4. The name of the author may not be used to endorse or promote products
     21  *    derived from this software without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 
     35 #include <sys/types.h>
     36 #include <sys/param.h>
     37 #include <sys/time.h>
     38 #include <sys/systm.h>
     39 #include <sys/errno.h>
     40 #include <sys/device.h>
     41 
     42 #include <uvm/uvm_extern.h>
     43 
     44 #define _SGIMIPS_BUS_DMA_PRIVATE
     45 #include <machine/bus.h>
     46 #include <machine/intr.h>
     47 
     48 #include <dev/pci/pcivar.h>
     49 #include <dev/pci/pcireg.h>
     50 #include <dev/pci/pcidevs.h>
     51 
     52 /*
     53  * PCI doesn't have any special needs; just use
     54  * the generic versions of these functions.
     55  */
     56 struct sgimips_bus_dma_tag pci_bus_dma_tag = {
     57 	_bus_dmamap_create,
     58 	_bus_dmamap_destroy,
     59 	_bus_dmamap_load,
     60 	_bus_dmamap_load_mbuf,
     61 	_bus_dmamap_load_uio,
     62 	_bus_dmamap_load_raw,
     63 	_bus_dmamap_unload,
     64 	_bus_dmamap_sync,
     65 	_bus_dmamem_alloc,
     66 	_bus_dmamem_free,
     67 	_bus_dmamem_map,
     68 	_bus_dmamem_unmap,
     69 	_bus_dmamem_mmap,
     70 };
     71 
     72 void
     73 pci_attach_hook(parent, self, pba)
     74 	struct device *parent, *self;
     75 	struct pcibus_attach_args *pba;
     76 {
     77 	/* XXX */
     78 
     79 	return;
     80 }
     81 
     82 int
     83 pci_bus_maxdevs(pc, busno)
     84 	pci_chipset_tag_t pc;
     85 	int busno;
     86 {
     87 #if 0
     88 	return 32;
     89 #else
     90 	return 4;		/* XXX O2 master aborts.. */
     91 #endif
     92 }
     93 
     94 pcitag_t
     95 pci_make_tag(pc, bus, device, function)
     96 	pci_chipset_tag_t pc;
     97 	int bus, device, function;
     98 {
     99 	return (bus << 16) | (device << 11) | (function << 8);
    100 }
    101 
    102 void
    103 pci_decompose_tag(pc, tag, bp, dp, fp)
    104 	pci_chipset_tag_t pc;
    105 	pcitag_t tag;
    106 	int *bp, *dp, *fp;
    107 {
    108 	if (bp != NULL)
    109 		*bp = (tag >> 16) & 0xff;
    110 	if (dp != NULL)
    111 		*dp = (tag >> 11) & 0x1f;
    112 	if (fp != NULL)
    113 		*fp = (tag >> 8) & 0x07;
    114 }
    115 
    116 pcireg_t
    117 pci_conf_read(pc, tag, reg)
    118 	pci_chipset_tag_t pc;
    119 	pcitag_t tag;
    120 	int reg;
    121 {
    122 	return (*pc->pc_conf_read)(pc, tag, reg);
    123 }
    124 
    125 void
    126 pci_conf_write(pc, tag, reg, data)
    127 	pci_chipset_tag_t pc;
    128 	pcitag_t tag;
    129 	int reg;
    130 	pcireg_t data;
    131 {
    132 	(*pc->pc_conf_write)(pc, tag, reg, data);
    133 }
    134 
    135 int
    136 pci_intr_map(pc, intrtag, pin, line, ihp)
    137 	pci_chipset_tag_t pc;
    138 	pcitag_t intrtag;
    139 	int pin, line;
    140 	pci_intr_handle_t *ihp;
    141 {
    142 	int bus, dev, func;
    143 
    144 	pci_decompose_tag(pc, intrtag, &bus, &dev, &func);
    145 
    146 	*ihp = line;
    147 
    148 	return 0;
    149 }
    150 
    151 const char *
    152 pci_intr_string(pc, ih)
    153 	pci_chipset_tag_t pc;
    154 	pci_intr_handle_t ih;
    155 {
    156 	static char irqstr[8];
    157 
    158 #if 0
    159 	sprintf(irqstr, "mace %d", ih);
    160 #else
    161 	sprintf(irqstr, "mace");
    162 #endif
    163 
    164 	return irqstr;
    165 }
    166 
    167 const struct evcnt *
    168 pci_intr_evcnt(pc, ih)
    169 	pci_chipset_tag_t pc;
    170 	pci_intr_handle_t ih;
    171 {
    172 
    173 	/* XXX for now, no evcnt parent reported */
    174 	return NULL;
    175 }
    176 
    177 extern void *	crime_intr_establish(int, int, int, int (*)(void *), void *);
    178 
    179 void *
    180 pci_intr_establish(pc, ih, level, func, arg)
    181 	pci_chipset_tag_t pc;
    182 	pci_intr_handle_t ih;
    183 	int level, (*func)(void *);
    184 	void *arg;
    185 {
    186 	crime_intr_establish(0, 0, 0, func, arg);
    187 
    188 	return (void *)-1;	/* XXX */
    189 }
    190 
    191 void
    192 pci_intr_disestablish(pc, cookie)
    193 	pci_chipset_tag_t pc;
    194 	void *cookie;
    195 {
    196 	panic("pci_intr_disestablish: not implemented");
    197 
    198 	return;
    199 }
    200