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