Home | History | Annotate | Line # | Download | only in ifpga
ifpga_pci.c revision 1.20.10.1
      1  1.20.10.1  pgoyette /*	$NetBSD: ifpga_pci.c,v 1.20.10.1 2018/11/26 01:52:22 pgoyette Exp $	*/
      2        1.1  rearnsha 
      3        1.1  rearnsha /*
      4        1.1  rearnsha  * Copyright (c) 2001 ARM Ltd
      5        1.1  rearnsha  * All rights reserved.
      6        1.1  rearnsha  *
      7        1.1  rearnsha  * Redistribution and use in source and binary forms, with or without
      8        1.1  rearnsha  * modification, are permitted provided that the following conditions
      9        1.1  rearnsha  * are met:
     10        1.1  rearnsha  * 1. Redistributions of source code must retain the above copyright
     11        1.1  rearnsha  *    notice, this list of conditions and the following disclaimer.
     12        1.1  rearnsha  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1  rearnsha  *    notice, this list of conditions and the following disclaimer in the
     14        1.1  rearnsha  *    documentation and/or other materials provided with the distribution.
     15        1.1  rearnsha  * 3. The name of the company may not be used to endorse or promote
     16        1.1  rearnsha  *    products derived from this software without specific prior written
     17        1.1  rearnsha  *    permission.
     18        1.1  rearnsha  *
     19        1.1  rearnsha  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     20        1.1  rearnsha  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     21        1.1  rearnsha  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22        1.1  rearnsha  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23        1.1  rearnsha  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24        1.1  rearnsha  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25        1.1  rearnsha  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26        1.1  rearnsha  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27        1.1  rearnsha  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28        1.1  rearnsha  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29        1.1  rearnsha  * SUCH DAMAGE.
     30        1.1  rearnsha  *
     31        1.1  rearnsha  * Copyright (c) 1997,1998 Mark Brinicombe.
     32        1.1  rearnsha  * Copyright (c) 1997,1998 Causality Limited
     33        1.1  rearnsha  * All rights reserved.
     34        1.1  rearnsha  *
     35        1.1  rearnsha  * Redistribution and use in source and binary forms, with or without
     36        1.1  rearnsha  * modification, are permitted provided that the following conditions
     37        1.1  rearnsha  * are met:
     38        1.1  rearnsha  * 1. Redistributions of source code must retain the above copyright
     39        1.1  rearnsha  *    notice, this list of conditions and the following disclaimer.
     40        1.1  rearnsha  * 2. Redistributions in binary form must reproduce the above copyright
     41        1.1  rearnsha  *    notice, this list of conditions and the following disclaimer in the
     42        1.1  rearnsha  *    documentation and/or other materials provided with the distribution.
     43        1.1  rearnsha  * 3. All advertising materials mentioning features or use of this software
     44        1.1  rearnsha  *    must display the following acknowledgement:
     45        1.1  rearnsha  *	This product includes software developed by Mark Brinicombe
     46        1.1  rearnsha  *	for the NetBSD Project.
     47        1.1  rearnsha  * 4. The name of the company nor the name of the author may be used to
     48        1.1  rearnsha  *    endorse or promote products derived from this software without specific
     49        1.1  rearnsha  *    prior written permission.
     50        1.1  rearnsha  *
     51        1.1  rearnsha  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     52        1.1  rearnsha  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     53        1.1  rearnsha  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     54        1.1  rearnsha  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     55        1.1  rearnsha  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     56        1.1  rearnsha  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     57        1.1  rearnsha  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     58        1.1  rearnsha  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     59        1.1  rearnsha  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     60        1.1  rearnsha  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     61        1.1  rearnsha  * SUCH DAMAGE.
     62        1.1  rearnsha  */
     63        1.6     lukem 
     64        1.8  rearnsha #define _ARM32_BUS_DMA_PRIVATE
     65        1.8  rearnsha 
     66        1.6     lukem #include <sys/cdefs.h>
     67  1.20.10.1  pgoyette __KERNEL_RCSID(0, "$NetBSD: ifpga_pci.c,v 1.20.10.1 2018/11/26 01:52:22 pgoyette Exp $");
     68        1.1  rearnsha 
     69        1.1  rearnsha #include <sys/param.h>
     70        1.1  rearnsha #include <sys/systm.h>
     71        1.1  rearnsha #include <sys/conf.h>
     72        1.1  rearnsha #include <sys/malloc.h>
     73        1.1  rearnsha #include <sys/device.h>
     74        1.1  rearnsha 
     75        1.1  rearnsha #include <evbarm/integrator/int_bus_dma.h>
     76        1.1  rearnsha 
     77        1.1  rearnsha #include <machine/intr.h>
     78        1.1  rearnsha 
     79        1.1  rearnsha #include <dev/pci/pcireg.h>
     80        1.1  rearnsha #include <dev/pci/pcivar.h>
     81        1.1  rearnsha 
     82        1.1  rearnsha #include <evbarm/ifpga/ifpgareg.h>
     83        1.1  rearnsha #include <evbarm/ifpga/ifpgamem.h>
     84        1.1  rearnsha #include <evbarm/ifpga/ifpga_pcivar.h>
     85        1.1  rearnsha #include <evbarm/dev/v360reg.h>
     86        1.1  rearnsha 
     87        1.1  rearnsha 
     88       1.13    dyoung void		ifpga_pci_attach_hook (device_t, device_t,
     89        1.1  rearnsha 		    struct pcibus_attach_args *);
     90        1.1  rearnsha int		ifpga_pci_bus_maxdevs (void *, int);
     91        1.1  rearnsha pcitag_t	ifpga_pci_make_tag (void *, int, int, int);
     92        1.1  rearnsha void		ifpga_pci_decompose_tag (void *, pcitag_t, int *, int *,
     93        1.1  rearnsha 		    int *);
     94        1.1  rearnsha pcireg_t	ifpga_pci_conf_read (void *, pcitag_t, int);
     95        1.1  rearnsha void		ifpga_pci_conf_write (void *, pcitag_t, int, pcireg_t);
     96       1.14    dyoung int		ifpga_pci_intr_map (const struct pci_attach_args *,
     97        1.1  rearnsha 		    pci_intr_handle_t *);
     98       1.18  christos const char	*ifpga_pci_intr_string (void *, pci_intr_handle_t, char *, size_t);
     99        1.1  rearnsha const struct evcnt *ifpga_pci_intr_evcnt (void *, pci_intr_handle_t);
    100        1.1  rearnsha void		*ifpga_pci_intr_establish (void *, pci_intr_handle_t, int,
    101  1.20.10.1  pgoyette 		    int (*)(void *), void *, const char *);
    102        1.1  rearnsha void		ifpga_pci_intr_disestablish (void *, void *);
    103        1.1  rearnsha 
    104        1.1  rearnsha struct arm32_pci_chipset ifpga_pci_chipset = {
    105        1.1  rearnsha 	NULL,	/* conf_v */
    106        1.1  rearnsha 	ifpga_pci_attach_hook,
    107        1.1  rearnsha 	ifpga_pci_bus_maxdevs,
    108        1.1  rearnsha 	ifpga_pci_make_tag,
    109        1.1  rearnsha 	ifpga_pci_decompose_tag,
    110  1.20.10.1  pgoyette 	NULL,
    111        1.1  rearnsha 	ifpga_pci_conf_read,
    112        1.1  rearnsha 	ifpga_pci_conf_write,
    113        1.1  rearnsha 	NULL,	/* intr_v */
    114        1.1  rearnsha 	ifpga_pci_intr_map,
    115        1.1  rearnsha 	ifpga_pci_intr_string,
    116        1.1  rearnsha 	ifpga_pci_intr_evcnt,
    117       1.20  jmcneill 	NULL,	/* intr_setattr */
    118        1.1  rearnsha 	ifpga_pci_intr_establish,
    119       1.15      matt 	ifpga_pci_intr_disestablish,
    120       1.15      matt #ifdef __HAVE_PCI_CONF_HOOK
    121       1.15      matt 	NULL,
    122       1.15      matt #endif
    123       1.15      matt 	ifpga_pci_conf_interrupt,
    124        1.1  rearnsha };
    125        1.1  rearnsha 
    126        1.1  rearnsha /*
    127        1.1  rearnsha  * Use the integrator-specific bus_dma routines.
    128        1.1  rearnsha  */
    129        1.1  rearnsha struct arm32_bus_dma_tag ifpga_pci_bus_dma_tag = {
    130        1.1  rearnsha 	0,
    131        1.1  rearnsha 	0,
    132        1.7        he 	NULL,
    133        1.1  rearnsha 	_bus_dmamap_create,
    134        1.1  rearnsha 	_bus_dmamap_destroy,
    135        1.3   thorpej 	_bus_dmamap_load,
    136        1.3   thorpej 	_bus_dmamap_load_mbuf,
    137        1.3   thorpej 	_bus_dmamap_load_uio,
    138        1.1  rearnsha 	_bus_dmamap_load_raw,
    139        1.1  rearnsha 	_bus_dmamap_unload,
    140        1.4   thorpej 	_bus_dmamap_sync,	/* pre */
    141        1.4   thorpej 	NULL,			/* post */
    142        1.3   thorpej 	_bus_dmamem_alloc,
    143        1.3   thorpej 	_bus_dmamem_free,
    144        1.3   thorpej 	_bus_dmamem_map,
    145        1.1  rearnsha 	_bus_dmamem_unmap,
    146        1.3   thorpej 	_bus_dmamem_mmap,
    147        1.1  rearnsha };
    148        1.1  rearnsha 
    149        1.1  rearnsha /*
    150        1.1  rearnsha  * Currently we only support 12 devices as we select directly in the
    151        1.1  rearnsha  * type 0 config cycle
    152        1.1  rearnsha  * (See conf_{read,write} for more detail
    153        1.1  rearnsha  */
    154        1.1  rearnsha #define MAX_PCI_DEVICES	21
    155        1.1  rearnsha 
    156        1.1  rearnsha /*static int
    157        1.1  rearnsha pci_intr(void *arg)
    158        1.1  rearnsha {
    159        1.1  rearnsha 	printf("pci int %x\n", (int)arg);
    160        1.1  rearnsha 	return 0;
    161        1.1  rearnsha }*/
    162        1.1  rearnsha 
    163        1.1  rearnsha 
    164        1.1  rearnsha void
    165       1.13    dyoung ifpga_pci_attach_hook(device_t parent, device_t self,
    166        1.1  rearnsha     struct pcibus_attach_args *pba)
    167        1.1  rearnsha {
    168        1.1  rearnsha #ifdef PCI_DEBUG
    169        1.1  rearnsha 	printf("ifpga_pci_attach_hook()\n");
    170        1.1  rearnsha #endif
    171        1.1  rearnsha }
    172        1.1  rearnsha 
    173        1.1  rearnsha int
    174        1.1  rearnsha ifpga_pci_bus_maxdevs(void *pcv, int busno)
    175        1.1  rearnsha {
    176        1.1  rearnsha #ifdef PCI_DEBUG
    177        1.1  rearnsha 	printf("ifpga_pci_bus_maxdevs(pcv=%p, busno=%d)\n", pcv, busno);
    178        1.1  rearnsha #endif
    179        1.1  rearnsha 	return MAX_PCI_DEVICES;
    180        1.1  rearnsha }
    181        1.1  rearnsha 
    182        1.1  rearnsha pcitag_t
    183        1.1  rearnsha ifpga_pci_make_tag(void *pcv, int bus, int device, int function)
    184        1.1  rearnsha {
    185        1.1  rearnsha #ifdef PCI_DEBUG
    186        1.1  rearnsha 	printf("ifpga_pci_make_tag(pcv=%p, bus=%d, device=%d, function=%d)\n",
    187        1.1  rearnsha 	    pcv, bus, device, function);
    188        1.1  rearnsha #endif
    189        1.1  rearnsha 	return (bus << 16) | (device << 11) | (function << 8);
    190        1.1  rearnsha }
    191        1.1  rearnsha 
    192        1.1  rearnsha void
    193        1.1  rearnsha ifpga_pci_decompose_tag(void *pcv, pcitag_t tag, int *busp, int *devicep,
    194        1.1  rearnsha     int *functionp)
    195        1.1  rearnsha {
    196        1.1  rearnsha #ifdef PCI_DEBUG
    197        1.1  rearnsha 	printf("ifpga_pci_decompose_tag(pcv=%p, tag=0x%08lx, bp=%p, dp=%p, "
    198        1.1  rearnsha 	    "fp=%p)\n", pcv, tag, busp, devicep, functionp);
    199        1.1  rearnsha #endif
    200        1.1  rearnsha 
    201        1.1  rearnsha 	if (busp != NULL)
    202        1.1  rearnsha 		*busp = (tag >> 16) & 0xff;
    203        1.1  rearnsha 	if (devicep != NULL)
    204        1.1  rearnsha 		*devicep = (tag >> 11) & 0x1f;
    205        1.1  rearnsha 	if (functionp != NULL)
    206        1.1  rearnsha 		*functionp = (tag >> 8) & 0x7;
    207        1.1  rearnsha }
    208        1.1  rearnsha 
    209        1.1  rearnsha pcireg_t
    210        1.1  rearnsha ifpga_pci_conf_read(void *pcv, pcitag_t tag, int reg)
    211        1.1  rearnsha {
    212        1.1  rearnsha 	pcireg_t data;
    213        1.1  rearnsha 	struct ifpga_pci_softc *sc = (struct ifpga_pci_softc *)pcv;
    214        1.1  rearnsha 	int bus, device, function;
    215        1.1  rearnsha 	u_int address;
    216        1.1  rearnsha 
    217       1.19   msaitoh 	if ((unsigned int)reg >= PCI_CONF_SIZE)
    218       1.19   msaitoh 		return (pcireg_t) -1;
    219       1.19   msaitoh 
    220        1.1  rearnsha 	ifpga_pci_decompose_tag(pcv, tag, &bus, &device, &function);
    221        1.1  rearnsha 
    222        1.1  rearnsha 	/* Reset the appertures so that we can talk to the register space.  */
    223        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE0,
    224        1.1  rearnsha 	    IFPGA_PCI_APP0_512MB_BASE);
    225        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE1,
    226        1.1  rearnsha 	    IFPGA_PCI_APP1_CONF_BASE);
    227        1.1  rearnsha 
    228        1.1  rearnsha 	if (bus == 0) {
    229        1.1  rearnsha 		address = (1 << (device + 11)) | reg;
    230        1.1  rearnsha 		bus_space_write_2(sc->sc_memt, sc->sc_reg_ioh, V360_LB_MAP1,
    231        1.1  rearnsha 		    IFPGA_PCI_APP1_CONF_T0_MAP | ((address >> 16) & 0xff00));
    232        1.1  rearnsha 
    233        1.1  rearnsha 		/* Read the value from the bus...  */
    234        1.1  rearnsha 		data = bus_space_read_4(sc->sc_iot, sc->sc_conf_ioh,
    235        1.1  rearnsha 		    address & 0x00ffffff);
    236        1.1  rearnsha 
    237        1.1  rearnsha 	} else {
    238        1.1  rearnsha 		bus_space_write_2(sc->sc_memt, sc->sc_reg_ioh, V360_LB_MAP1,
    239        1.1  rearnsha 		    IFPGA_PCI_APP1_CONF_T1_MAP);
    240        1.1  rearnsha 
    241        1.1  rearnsha 		/* Read the value from the bus... */
    242        1.1  rearnsha 		data = bus_space_read_4(sc->sc_iot, sc->sc_conf_ioh,
    243        1.1  rearnsha 		    tag | reg);
    244        1.1  rearnsha 	}
    245        1.1  rearnsha 	/* ... and put the memory spaces back again.  */
    246        1.1  rearnsha 
    247        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE1,
    248        1.1  rearnsha 	    IFPGA_PCI_APP1_256MB_BASE);
    249        1.1  rearnsha 	bus_space_write_2(sc->sc_memt, sc->sc_reg_ioh, V360_LB_MAP1,
    250        1.1  rearnsha 	    IFPGA_PCI_APP1_256MB_MAP);
    251        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE0,
    252        1.1  rearnsha 	    IFPGA_PCI_APP0_256MB_BASE);
    253        1.1  rearnsha #ifdef PCI_DEBUG
    254        1.1  rearnsha 	printf("ifpga_pci_conf_read(pcv=%p tag=0x%08lx reg=0x%02x)=0x%08x\n",
    255        1.1  rearnsha 	    pcv, tag, reg, data);
    256        1.1  rearnsha #endif
    257        1.1  rearnsha 	return data;
    258        1.1  rearnsha }
    259        1.1  rearnsha 
    260        1.1  rearnsha void
    261        1.1  rearnsha ifpga_pci_conf_write(void *pcv, pcitag_t tag, int reg, pcireg_t data)
    262        1.1  rearnsha {
    263        1.1  rearnsha 	struct ifpga_pci_softc *sc = (struct ifpga_pci_softc *)pcv;
    264        1.1  rearnsha 	int bus, device, function;
    265        1.1  rearnsha 	u_int address;
    266        1.1  rearnsha 
    267        1.1  rearnsha #ifdef PCI_DEBUG
    268        1.1  rearnsha 	printf("ifpga_pci_conf_write(pcv=%p tag=0x%08lx reg=0x%02x, 0x%08x)\n",
    269        1.1  rearnsha 	    pcv, tag, reg, data);
    270        1.1  rearnsha #endif
    271        1.1  rearnsha 
    272       1.19   msaitoh 	if ((unsigned int)reg >= PCI_CONF_SIZE)
    273       1.19   msaitoh 		return;
    274       1.19   msaitoh 
    275        1.1  rearnsha 	ifpga_pci_decompose_tag(pcv, tag, &bus, &device, &function);
    276        1.1  rearnsha 
    277        1.1  rearnsha 	/* Reset the appertures so that we can talk to the register space.  */
    278        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE0,
    279        1.1  rearnsha 	    IFPGA_PCI_APP0_512MB_BASE);
    280        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE1,
    281        1.1  rearnsha 	    IFPGA_PCI_APP1_CONF_BASE);
    282        1.1  rearnsha 
    283        1.1  rearnsha 	if (bus == 0) {
    284        1.1  rearnsha 		address = (1 << (device + 11)) | reg;
    285        1.1  rearnsha 		bus_space_write_2(sc->sc_memt, sc->sc_reg_ioh, V360_LB_MAP1,
    286        1.1  rearnsha 		    IFPGA_PCI_APP1_CONF_T0_MAP | ((address >> 16) & 0xff00));
    287        1.1  rearnsha 
    288       1.10  rearnsha 		/* Write the value to the bus...  */
    289        1.1  rearnsha 		bus_space_write_4(sc->sc_iot, sc->sc_conf_ioh,
    290        1.1  rearnsha 		    address & 0x00ffffff, data);
    291        1.1  rearnsha 
    292        1.1  rearnsha 	} else {
    293        1.1  rearnsha 		bus_space_write_2(sc->sc_memt, sc->sc_reg_ioh, V360_LB_MAP1,
    294        1.1  rearnsha 		    IFPGA_PCI_APP1_CONF_T1_MAP);
    295        1.1  rearnsha 
    296       1.10  rearnsha 		/* Write the value to the bus... */
    297        1.1  rearnsha 		bus_space_write_4(sc->sc_iot, sc->sc_conf_ioh, tag | reg,
    298        1.1  rearnsha 		    data);
    299        1.1  rearnsha 	}
    300        1.1  rearnsha 	/* ... and put the memory spaces back again.  */
    301        1.1  rearnsha 
    302        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE1,
    303        1.1  rearnsha 	    IFPGA_PCI_APP1_256MB_BASE);
    304        1.1  rearnsha 	bus_space_write_2(sc->sc_memt, sc->sc_reg_ioh, V360_LB_MAP1,
    305        1.1  rearnsha 	    IFPGA_PCI_APP1_256MB_MAP);
    306        1.1  rearnsha 	bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE0,
    307        1.1  rearnsha 	    IFPGA_PCI_APP0_256MB_BASE);
    308        1.1  rearnsha }
    309        1.1  rearnsha 
    310        1.1  rearnsha int
    311       1.14    dyoung ifpga_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    312        1.1  rearnsha {
    313        1.1  rearnsha 	int line = pa->pa_intrline;
    314        1.1  rearnsha 
    315        1.1  rearnsha #ifdef PCI_DEBUG
    316        1.1  rearnsha 	int pin = pa->pa_intrpin;
    317        1.1  rearnsha 	void *pcv = pa->pa_pc;
    318        1.1  rearnsha 	pcitag_t intrtag = pa->pa_intrtag;
    319        1.1  rearnsha 	int bus, device, function;
    320        1.1  rearnsha 
    321        1.1  rearnsha 	ifpga_pci_decompose_tag(pcv, intrtag, &bus, &device, &function);
    322        1.1  rearnsha 	printf("ifpga_pci_intr_map: pcv=%p, tag=%08lx pin=%d line=%d "
    323        1.1  rearnsha 	    "dev=%d\n", pcv, intrtag, pin, line, device);
    324        1.1  rearnsha #endif
    325        1.1  rearnsha 
    326        1.1  rearnsha 
    327        1.1  rearnsha #ifdef PCI_DEBUG
    328        1.1  rearnsha 	printf("pin %d, line %d mapped to int %d\n", pin, line, line);
    329        1.1  rearnsha #endif
    330        1.1  rearnsha 
    331        1.1  rearnsha 	*ihp = line;
    332        1.1  rearnsha 	return 0;
    333        1.1  rearnsha }
    334        1.1  rearnsha 
    335        1.1  rearnsha const char *
    336       1.18  christos ifpga_pci_intr_string(void *pcv, pci_intr_handle_t ih, char *buf, size_t len)
    337        1.1  rearnsha {
    338        1.1  rearnsha #ifdef PCI_DEBUG
    339  1.20.10.1  pgoyette 	printf("ifpga_pci_intr_string(pcv=%p, ih=0x%" PRIu64 ")\n", pcv, ih);
    340        1.1  rearnsha #endif
    341        1.1  rearnsha 	if (ih == 0)
    342  1.20.10.1  pgoyette 		panic("ifpga_pci_intr_string: bogus handle 0x%" PRIu64, ih);
    343        1.1  rearnsha 
    344  1.20.10.1  pgoyette 	snprintf(buf, len, "pciint%" PRIu64, ih - IFPGA_INTRNUM_PCIINT0);
    345       1.18  christos 	return buf;
    346        1.1  rearnsha }
    347        1.1  rearnsha 
    348        1.1  rearnsha const struct evcnt *
    349        1.1  rearnsha ifpga_pci_intr_evcnt(void *pcv, pci_intr_handle_t ih)
    350        1.1  rearnsha {
    351        1.1  rearnsha 
    352        1.1  rearnsha 	/* XXX for now, no evcnt parent reported */
    353        1.1  rearnsha 	return NULL;
    354        1.1  rearnsha }
    355        1.1  rearnsha 
    356        1.1  rearnsha void *
    357        1.1  rearnsha ifpga_pci_intr_establish(void *pcv, pci_intr_handle_t ih, int level,
    358  1.20.10.1  pgoyette     int (*func) (void *), void *arg, const char *xname)
    359        1.1  rearnsha {
    360        1.1  rearnsha 	void *intr;
    361        1.1  rearnsha 
    362        1.1  rearnsha #ifdef PCI_DEBUG
    363  1.20.10.1  pgoyette 	printf("ifpga_pci_intr_establish(pcv=%p, ih=0x%" PRIu64 ", level=%d, "
    364  1.20.10.1  pgoyette 	    "func=%p, arg=%p, xname=%s)\n", pcv, ih, level, func, arg, xname);
    365        1.1  rearnsha #endif
    366        1.1  rearnsha 
    367        1.8  rearnsha 	intr = ifpga_intr_establish(ih, level, func, arg);
    368        1.1  rearnsha 
    369        1.1  rearnsha 	return intr;
    370        1.1  rearnsha }
    371        1.1  rearnsha 
    372        1.1  rearnsha void
    373        1.1  rearnsha ifpga_pci_intr_disestablish(void *pcv, void *cookie)
    374        1.1  rearnsha {
    375        1.1  rearnsha #ifdef PCI_DEBUG
    376        1.1  rearnsha 	printf("ifpga_pci_intr_disestablish(pcv=%p, cookie=%p)\n",
    377        1.1  rearnsha 	    pcv, cookie);
    378        1.1  rearnsha #endif
    379        1.8  rearnsha 	ifpga_intr_disestablish(cookie);
    380        1.1  rearnsha }
    381