Home | History | Annotate | Line # | Download | only in pci
pcivar.h revision 1.114.6.1
      1  1.114.6.1      cjep /*	$NetBSD: pcivar.h,v 1.114.6.1 2021/05/31 22:15:18 cjep Exp $	*/
      2        1.2       cgd 
      3        1.1   mycroft /*
      4       1.19       cgd  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
      5       1.36   mycroft  * Copyright (c) 1994 Charles M. Hannum.  All rights reserved.
      6        1.1   mycroft  *
      7        1.1   mycroft  * Redistribution and use in source and binary forms, with or without
      8        1.1   mycroft  * modification, are permitted provided that the following conditions
      9        1.1   mycroft  * are met:
     10        1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     11        1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     12        1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     14        1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     15        1.1   mycroft  * 3. All advertising materials mentioning features or use of this software
     16        1.1   mycroft  *    must display the following acknowledgement:
     17       1.36   mycroft  *	This product includes software developed by Charles M. Hannum.
     18        1.1   mycroft  * 4. The name of the author may not be used to endorse or promote products
     19        1.1   mycroft  *    derived from this software without specific prior written permission.
     20        1.1   mycroft  *
     21        1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22        1.1   mycroft  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23        1.1   mycroft  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24        1.1   mycroft  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25        1.1   mycroft  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26        1.1   mycroft  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27        1.1   mycroft  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28        1.1   mycroft  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29        1.1   mycroft  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30        1.1   mycroft  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31        1.1   mycroft  */
     32        1.1   mycroft 
     33       1.12       cgd #ifndef _DEV_PCI_PCIVAR_H_
     34       1.12       cgd #define	_DEV_PCI_PCIVAR_H_
     35       1.12       cgd 
     36        1.1   mycroft /*
     37        1.1   mycroft  * Definitions for PCI autoconfiguration.
     38        1.1   mycroft  *
     39        1.1   mycroft  * This file describes types and functions which are used for PCI
     40        1.1   mycroft  * configuration.  Some of this information is machine-specific, and is
     41       1.14       cgd  * provided by pci_machdep.h.
     42        1.1   mycroft  */
     43        1.1   mycroft 
     44       1.48   thorpej #include <sys/device.h>
     45       1.77  jmcneill #include <sys/pmf.h>
     46       1.75        ad #include <sys/bus.h>
     47       1.14       cgd #include <dev/pci/pcireg.h>
     48       1.89  pgoyette #include <dev/pci/pci_verbose.h>
     49       1.12       cgd 
     50       1.14       cgd /*
     51       1.14       cgd  * Structures and definitions needed by the machine-dependent header.
     52       1.14       cgd  */
     53       1.14       cgd struct pcibus_attach_args;
     54       1.90       mrg struct pci_attach_args;
     55       1.50   thorpej struct pci_softc;
     56       1.14       cgd 
     57       1.48   thorpej #ifdef _KERNEL
     58       1.14       cgd /*
     59       1.14       cgd  * Machine-dependent definitions.
     60       1.14       cgd  */
     61       1.38       cgd #include <machine/pci_machdep.h>
     62        1.4       cgd 
     63       1.86    dyoung enum pci_override_idx {
     64       1.86    dyoung 	  PCI_OVERRIDE_CONF_READ		= __BIT(0)
     65       1.86    dyoung 	, PCI_OVERRIDE_CONF_WRITE		= __BIT(1)
     66       1.86    dyoung 	, PCI_OVERRIDE_INTR_MAP			= __BIT(2)
     67       1.86    dyoung 	, PCI_OVERRIDE_INTR_STRING		= __BIT(3)
     68       1.86    dyoung 	, PCI_OVERRIDE_INTR_EVCNT		= __BIT(4)
     69       1.86    dyoung 	, PCI_OVERRIDE_INTR_ESTABLISH		= __BIT(5)
     70       1.86    dyoung 	, PCI_OVERRIDE_INTR_DISESTABLISH	= __BIT(6)
     71       1.86    dyoung 	, PCI_OVERRIDE_MAKE_TAG			= __BIT(7)
     72       1.86    dyoung 	, PCI_OVERRIDE_DECOMPOSE_TAG		= __BIT(8)
     73       1.86    dyoung };
     74       1.86    dyoung 
     75       1.86    dyoung /* Only add new fields to the end of this structure! */
     76       1.86    dyoung struct pci_overrides {
     77       1.86    dyoung 	pcireg_t (*ov_conf_read)(void *, pci_chipset_tag_t, pcitag_t, int);
     78       1.86    dyoung 	void (*ov_conf_write)(void *, pci_chipset_tag_t, pcitag_t, int,
     79       1.86    dyoung 	    pcireg_t);
     80       1.92    dyoung 	int (*ov_intr_map)(void *, const struct pci_attach_args *,
     81       1.86    dyoung 	   pci_intr_handle_t *);
     82       1.86    dyoung 	const char *(*ov_intr_string)(void *, pci_chipset_tag_t,
     83       1.99  christos 	    pci_intr_handle_t, char *, size_t);
     84       1.86    dyoung 	const struct evcnt *(*ov_intr_evcnt)(void *, pci_chipset_tag_t,
     85       1.86    dyoung 	    pci_intr_handle_t);
     86       1.86    dyoung 	void *(*ov_intr_establish)(void *, pci_chipset_tag_t, pci_intr_handle_t,
     87       1.86    dyoung 	    int, int (*)(void *), void *);
     88       1.86    dyoung 	void (*ov_intr_disestablish)(void *, pci_chipset_tag_t, void *);
     89       1.86    dyoung 	pcitag_t (*ov_make_tag)(void *, pci_chipset_tag_t, int, int, int);
     90       1.86    dyoung 	void (*ov_decompose_tag)(void *, pci_chipset_tag_t, pcitag_t,
     91       1.86    dyoung 	    int *, int *, int *);
     92       1.86    dyoung };
     93       1.86    dyoung 
     94       1.11       cgd /*
     95       1.11       cgd  * PCI bus attach arguments.
     96       1.11       cgd  */
     97       1.11       cgd struct pcibus_attach_args {
     98       1.66  drochner 	char		*_pba_busname;	/* XXX placeholder */
     99       1.16   thorpej 	bus_space_tag_t pba_iot;	/* pci i/o space tag */
    100       1.16   thorpej 	bus_space_tag_t pba_memt;	/* pci mem space tag */
    101       1.23   thorpej 	bus_dma_tag_t pba_dmat;		/* DMA tag */
    102       1.56      fvdl 	bus_dma_tag_t pba_dmat64;	/* DMA tag */
    103       1.14       cgd 	pci_chipset_tag_t pba_pc;
    104       1.19       cgd 	int		pba_flags;	/* flags; see below */
    105       1.11       cgd 
    106       1.11       cgd 	int		pba_bus;	/* PCI bus number */
    107       1.96    dyoung 	int		pba_sub;	/* pba_bus >= pba_sub: no
    108       1.96    dyoung 					 * buses are subordinate to
    109       1.96    dyoung 					 * pba_bus.
    110       1.96    dyoung 					 *
    111       1.96    dyoung 					 * pba_bus < pba_sub: buses
    112       1.96    dyoung 					 * [pba_bus + 1, pba_sub] are
    113       1.96    dyoung 					 * subordinate to pba_bus.
    114       1.96    dyoung 					 */
    115       1.14       cgd 
    116       1.14       cgd 	/*
    117       1.50   thorpej 	 * Pointer to the pcitag of our parent bridge.  If there is no
    118       1.50   thorpej 	 * parent bridge, then we assume we are a root bus.
    119       1.50   thorpej 	 */
    120       1.50   thorpej 	pcitag_t	*pba_bridgetag;
    121       1.50   thorpej 
    122       1.50   thorpej 	/*
    123       1.14       cgd 	 * Interrupt swizzling information.  These fields
    124       1.14       cgd 	 * are only used by secondary busses.
    125       1.14       cgd 	 */
    126       1.14       cgd 	u_int		pba_intrswiz;	/* how to swizzle pins */
    127       1.14       cgd 	pcitag_t	pba_intrtag;	/* intr. appears to come from here */
    128       1.11       cgd };
    129       1.11       cgd 
    130       1.11       cgd /*
    131       1.94      matt  * This is used by <machine/pci_machdep.h> to access the pba_pc member.  It
    132       1.94      matt  * can't use it directly since pcibus_attach_args has yet to be defined.
    133       1.94      matt  */
    134      1.111  christos static __inline pci_chipset_tag_t
    135       1.94      matt pcibus_attach_args_pc(struct pcibus_attach_args *pba)
    136       1.94      matt {
    137       1.94      matt 	return pba->pba_pc;
    138       1.94      matt }
    139       1.94      matt 
    140       1.94      matt /*
    141       1.11       cgd  * PCI device attach arguments.
    142       1.11       cgd  */
    143        1.1   mycroft struct pci_attach_args {
    144       1.16   thorpej 	bus_space_tag_t pa_iot;		/* pci i/o space tag */
    145       1.16   thorpej 	bus_space_tag_t pa_memt;	/* pci mem space tag */
    146       1.23   thorpej 	bus_dma_tag_t pa_dmat;		/* DMA tag */
    147       1.56      fvdl 	bus_dma_tag_t pa_dmat64;	/* DMA tag */
    148       1.14       cgd 	pci_chipset_tag_t pa_pc;
    149       1.19       cgd 	int		pa_flags;	/* flags; see below */
    150       1.12       cgd 
    151       1.46    bouyer 	u_int		pa_bus;
    152       1.15       cgd 	u_int		pa_device;
    153       1.15       cgd 	u_int		pa_function;
    154       1.11       cgd 	pcitag_t	pa_tag;
    155       1.11       cgd 	pcireg_t	pa_id, pa_class;
    156       1.14       cgd 
    157       1.14       cgd 	/*
    158       1.14       cgd 	 * Interrupt information.
    159       1.14       cgd 	 *
    160       1.14       cgd 	 * "Intrline" is used on systems whose firmware puts
    161       1.14       cgd 	 * the right routing data into the line register in
    162       1.14       cgd 	 * configuration space.  The rest are used on systems
    163       1.14       cgd 	 * that do not.
    164       1.14       cgd 	 */
    165       1.14       cgd 	u_int		pa_intrswiz;	/* how to swizzle pins if ppb */
    166       1.14       cgd 	pcitag_t	pa_intrtag;	/* intr. appears to come from here */
    167       1.14       cgd 	pci_intr_pin_t	pa_intrpin;	/* intr. appears on this pin */
    168       1.14       cgd 	pci_intr_line_t	pa_intrline;	/* intr. routing information */
    169       1.51  sommerfe 	pci_intr_pin_t  pa_rawintrpin; 	/* unswizzled pin */
    170        1.1   mycroft };
    171       1.19       cgd 
    172       1.19       cgd /*
    173       1.94      matt  * This is used by <machine/pci_machdep.h> to access the pa_pc member.  It
    174       1.94      matt  * can't use it directly since pci_attach_args has yet to be defined.
    175       1.94      matt  */
    176      1.111  christos static __inline pci_chipset_tag_t
    177       1.94      matt pci_attach_args_pc(const struct pci_attach_args *pa)
    178       1.94      matt {
    179       1.94      matt 	return pa->pa_pc;
    180       1.94      matt }
    181       1.94      matt 
    182       1.94      matt /*
    183       1.19       cgd  * Flags given in the bus and device attachment args.
    184       1.19       cgd  */
    185       1.93    dyoung #define	PCI_FLAGS_IO_OKAY	0x01		/* I/O space is okay */
    186       1.93    dyoung #define	PCI_FLAGS_MEM_OKAY	0x02		/* memory space is okay */
    187       1.41   thorpej #define	PCI_FLAGS_MRL_OKAY	0x04		/* Memory Read Line okay */
    188       1.41   thorpej #define	PCI_FLAGS_MRM_OKAY	0x08		/* Memory Read Multiple okay */
    189       1.41   thorpej #define	PCI_FLAGS_MWI_OKAY	0x10		/* Memory Write and Invalidate
    190       1.41   thorpej 						   okay */
    191       1.85      matt #define	PCI_FLAGS_MSI_OKAY	0x20		/* Message Signaled Interrupts
    192       1.85      matt 						   okay */
    193       1.85      matt #define	PCI_FLAGS_MSIX_OKAY	0x40		/* Message Signaled Interrupts
    194       1.85      matt 						   (Extended) okay */
    195       1.13       cgd 
    196       1.33       cgd /*
    197       1.33       cgd  * PCI device 'quirks'.
    198       1.33       cgd  *
    199       1.33       cgd  * In general strange behaviour which can be handled by a driver (e.g.
    200       1.33       cgd  * a bridge's inability to pass a type of access correctly) should be.
    201       1.33       cgd  * The quirks table should only contain information which impacts
    202       1.33       cgd  * the operation of the MI PCI code and which can't be pushed lower
    203       1.33       cgd  * (e.g. because it's unacceptable to require a driver to be present
    204       1.33       cgd  * for the information to be known).
    205       1.33       cgd  */
    206       1.33       cgd struct pci_quirkdata {
    207       1.33       cgd 	pci_vendor_id_t		vendor;		/* Vendor ID */
    208       1.33       cgd 	pci_product_id_t	product;	/* Product ID */
    209       1.33       cgd 	int			quirks;		/* quirks; see below */
    210       1.33       cgd };
    211      1.110   msaitoh #define	PCI_QUIRK_MULTIFUNCTION		__BIT(0)
    212      1.110   msaitoh #define	PCI_QUIRK_MONOFUNCTION		__BIT(1)
    213       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC(n)		(4 << n)
    214       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC0		PCI_QUIRK_SKIP_FUNC(0)
    215       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC1		PCI_QUIRK_SKIP_FUNC(1)
    216       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC2		PCI_QUIRK_SKIP_FUNC(2)
    217       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC3		PCI_QUIRK_SKIP_FUNC(3)
    218       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC4		PCI_QUIRK_SKIP_FUNC(4)
    219       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC5		PCI_QUIRK_SKIP_FUNC(5)
    220       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC6		PCI_QUIRK_SKIP_FUNC(6)
    221       1.59    itojun #define	PCI_QUIRK_SKIP_FUNC7		PCI_QUIRK_SKIP_FUNC(7)
    222      1.110   msaitoh #define	PCI_QUIRK_HASEXTCNF		__BIT(10)
    223      1.110   msaitoh #define	PCI_QUIRK_NOEXTCNF		__BIT(11)
    224       1.48   thorpej 
    225       1.81    dyoung struct pci_conf_state {
    226       1.81    dyoung 	pcireg_t reg[16];
    227      1.113   msaitoh 
    228      1.113   msaitoh 	/* For PCI-X */
    229      1.113   msaitoh 	pcireg_t x_csr;		/* Upper 16bits. Lower 16bits are read only */
    230      1.113   msaitoh 
    231      1.113   msaitoh 	/* For PCIe */
    232      1.113   msaitoh 	uint16_t e_dcr;
    233      1.113   msaitoh 	uint16_t e_lcr;
    234      1.113   msaitoh 	uint16_t e_slcr;
    235      1.113   msaitoh 	uint16_t e_rcr;
    236      1.113   msaitoh 	uint16_t e_dcr2;
    237      1.113   msaitoh 	uint16_t e_lcr2;
    238      1.113   msaitoh 
    239      1.113   msaitoh 	/* For MSI */
    240      1.113   msaitoh 	pcireg_t msi_ctl;	/* Upper 16bits. Lower 16bits are read only */
    241      1.113   msaitoh 	pcireg_t msi_maddr;
    242      1.113   msaitoh 	pcireg_t msi_maddr64_hi;
    243      1.113   msaitoh 	pcireg_t msi_mdata;
    244      1.113   msaitoh 	pcireg_t msi_mask;
    245      1.113   msaitoh 
    246      1.113   msaitoh 	/* For MSI-X */
    247      1.113   msaitoh 	pcireg_t msix_ctl;	/* Upper 16bits. Lower 16bits are read only */
    248       1.81    dyoung };
    249       1.81    dyoung 
    250       1.91  jmcneill struct pci_range {
    251       1.91  jmcneill 	bus_addr_t		r_offset;
    252       1.91  jmcneill 	bus_size_t		r_size;
    253       1.91  jmcneill 	int			r_flags;
    254       1.91  jmcneill };
    255       1.91  jmcneill 
    256       1.81    dyoung struct pci_child {
    257       1.81    dyoung 	device_t		c_dev;
    258       1.81    dyoung 	bool			c_psok;
    259       1.81    dyoung 	pcireg_t		c_powerstate;
    260       1.81    dyoung 	struct pci_conf_state	c_conf;
    261       1.91  jmcneill 	struct pci_range	c_range[8];
    262       1.81    dyoung };
    263       1.81    dyoung 
    264       1.48   thorpej struct pci_softc {
    265       1.79      cube 	device_t sc_dev;
    266       1.48   thorpej 	bus_space_tag_t sc_iot, sc_memt;
    267       1.51  sommerfe 	bus_dma_tag_t sc_dmat;
    268       1.56      fvdl 	bus_dma_tag_t sc_dmat64;
    269       1.51  sommerfe 	pci_chipset_tag_t sc_pc;
    270       1.48   thorpej 	int sc_bus, sc_maxndevs;
    271       1.50   thorpej 	pcitag_t *sc_bridgetag;
    272       1.48   thorpej 	u_int sc_intrswiz;
    273       1.48   thorpej 	pcitag_t sc_intrtag;
    274       1.48   thorpej 	int sc_flags;
    275       1.64  drochner 	/* accounting of child devices */
    276       1.81    dyoung 	struct pci_child sc_devices[32*8];
    277       1.64  drochner #define PCI_SC_DEVICESC(d, f) sc_devices[(d) * 8 + (f)]
    278       1.48   thorpej };
    279       1.48   thorpej 
    280  1.114.6.1      cjep /*
    281  1.114.6.1      cjep  * pci-bus-get-child-devhandle device call
    282  1.114.6.1      cjep  *
    283  1.114.6.1      cjep  *	Called to get the device handle for a device, represented
    284  1.114.6.1      cjep  *	by the pcitag_t with the PCI segment represented by the
    285  1.114.6.1      cjep  *	pci_chipset_tag_t.  The PCI bus's device_t is the one
    286  1.114.6.1      cjep  *	passed to device_call(), and the device whose handle is
    287  1.114.6.1      cjep  *	being requested must be a direct child of that bus,
    288  1.114.6.1      cjep  *	otherwise the behavior is undefined.
    289  1.114.6.1      cjep  *
    290  1.114.6.1      cjep  *	Call returns 0 if successful, or an error code upon failure:
    291  1.114.6.1      cjep  *
    292  1.114.6.1      cjep  *	ENOTSUP		The device handle implementation for the
    293  1.114.6.1      cjep  *			PCI bus does not support this device call.
    294  1.114.6.1      cjep  *
    295  1.114.6.1      cjep  *	ENODEV		The PCI device represented by the pcitag_t
    296  1.114.6.1      cjep  *			was not found in a bus-scoped search of the
    297  1.114.6.1      cjep  *			platform device tree.
    298  1.114.6.1      cjep  */
    299  1.114.6.1      cjep struct pci_bus_get_child_devhandle_args {
    300  1.114.6.1      cjep 	pci_chipset_tag_t pc;		/* IN */
    301  1.114.6.1      cjep 	pcitag_t tag;			/* IN */
    302  1.114.6.1      cjep 	devhandle_t devhandle;		/* OUT */
    303  1.114.6.1      cjep };
    304  1.114.6.1      cjep 
    305       1.48   thorpej extern struct cfdriver pci_cd;
    306       1.24       jtk 
    307      1.112  jakllsch extern bool pci_mapreg_map_enable_decode;
    308      1.112  jakllsch 
    309       1.65  drochner int pcibusprint(void *, const char *);
    310       1.65  drochner 
    311       1.14       cgd /*
    312       1.14       cgd  * Configuration space access and utility functions.  (Note that most,
    313       1.14       cgd  * e.g. make_tag, conf_read, conf_write are declared by pci_machdep.h.)
    314       1.14       cgd  */
    315       1.69     perry int	pci_mapreg_probe(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
    316       1.69     perry pcireg_t pci_mapreg_type(pci_chipset_tag_t, pcitag_t, int);
    317       1.69     perry int	pci_mapreg_info(pci_chipset_tag_t, pcitag_t, int, pcireg_t,
    318       1.69     perry 	    bus_addr_t *, bus_size_t *, int *);
    319       1.92    dyoung int	pci_mapreg_map(const struct pci_attach_args *, int, pcireg_t, int,
    320       1.20       cgd 	    bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
    321       1.69     perry 	    bus_size_t *);
    322      1.101   msaitoh int	pci_mapreg_submap(const struct pci_attach_args *, int, pcireg_t, int,
    323      1.101   msaitoh 	    bus_size_t, bus_size_t, bus_space_tag_t *, bus_space_handle_t *,
    324      1.101   msaitoh 	    bus_addr_t *, bus_size_t *);
    325      1.101   msaitoh 
    326       1.92    dyoung int pci_find_rom(const struct pci_attach_args *, bus_space_tag_t,
    327      1.100  riastrad 	    bus_space_handle_t, bus_size_t,
    328       1.71   gdamore 	    int, bus_space_handle_t *, bus_size_t *);
    329       1.71   gdamore 
    330      1.105   msaitoh int	pci_get_capability(pci_chipset_tag_t, pcitag_t, int, int *, pcireg_t *);
    331      1.105   msaitoh int	pci_get_ht_capability(pci_chipset_tag_t, pcitag_t, int, int *,
    332      1.105   msaitoh 	    pcireg_t *);
    333      1.105   msaitoh int	pci_get_ext_capability(pci_chipset_tag_t, pcitag_t, int, int *,
    334      1.105   msaitoh 	    pcireg_t *);
    335      1.105   msaitoh 
    336      1.103   msaitoh int	pci_msi_count(pci_chipset_tag_t, pcitag_t);
    337      1.103   msaitoh int	pci_msix_count(pci_chipset_tag_t, pcitag_t);
    338       1.14       cgd 
    339       1.14       cgd /*
    340       1.14       cgd  * Helper functions for autoconfiguration.
    341       1.14       cgd  */
    342      1.114   thorpej 
    343      1.114   thorpej #define	PCI_COMPAT_EOL_VALUE	(0xffffffffU)
    344      1.114   thorpej #define	PCI_COMPAT_EOL		{ .id = PCI_COMPAT_EOL_VALUE }
    345      1.114   thorpej 
    346      1.114   thorpej const struct device_compatible_entry *
    347      1.114   thorpej 	pci_compatible_lookup_id(pcireg_t,
    348      1.114   thorpej 	    const struct device_compatible_entry *);
    349      1.114   thorpej const struct device_compatible_entry *
    350      1.114   thorpej 	pci_compatible_lookup(const struct pci_attach_args *,
    351      1.114   thorpej 	    const struct device_compatible_entry *);
    352      1.114   thorpej int	pci_compatible_match(const struct pci_attach_args *,
    353      1.114   thorpej 	    const struct device_compatible_entry *);
    354      1.114   thorpej const struct device_compatible_entry *
    355      1.114   thorpej 	pci_compatible_lookup_subsys(const struct pci_attach_args *,
    356      1.114   thorpej 	    const struct device_compatible_entry *);
    357      1.114   thorpej int	pci_compatible_match_subsys(const struct pci_attach_args *,
    358      1.114   thorpej 	    const struct device_compatible_entry *);
    359      1.105   msaitoh #ifndef PCI_MACHDEP_ENUMERATE_BUS
    360      1.105   msaitoh int	pci_enumerate_bus(struct pci_softc *, const int *,
    361      1.105   msaitoh 	    int (*)(const struct pci_attach_args *), struct pci_attach_args *);
    362      1.105   msaitoh #endif
    363       1.49   thorpej int	pci_probe_device(struct pci_softc *, pcitag_t tag,
    364       1.92    dyoung 	    int (*)(const struct pci_attach_args *),
    365       1.92    dyoung 	    struct pci_attach_args *);
    366       1.69     perry void	pci_devinfo(pcireg_t, pcireg_t, int, char *, size_t);
    367       1.98  drochner void	pci_aprint_devinfo_fancy(const struct pci_attach_args *,
    368       1.98  drochner 				 const char *, const char *, int);
    369       1.98  drochner #define pci_aprint_devinfo(pap, naive) \
    370       1.98  drochner 	pci_aprint_devinfo_fancy(pap, naive, NULL, 0);
    371       1.69     perry void	pci_conf_print(pci_chipset_tag_t, pcitag_t,
    372       1.69     perry 	    void (*)(pci_chipset_tag_t, pcitag_t, const pcireg_t *));
    373       1.33       cgd const struct pci_quirkdata *
    374       1.69     perry 	pci_lookup_quirkdata(pci_vendor_id_t, pci_product_id_t);
    375       1.35  augustss 
    376       1.35  augustss /*
    377       1.48   thorpej  * Helper functions for user access to the PCI bus.
    378       1.48   thorpej  */
    379       1.48   thorpej struct proc;
    380       1.74  christos int	pci_devioctl(pci_chipset_tag_t, pcitag_t, u_long, void *,
    381       1.70  christos 	    int flag, struct lwp *);
    382       1.53  tshiozak 
    383       1.53  tshiozak /*
    384       1.53  tshiozak  * Power Management (PCI 2.2)
    385       1.53  tshiozak  */
    386       1.53  tshiozak 
    387       1.53  tshiozak #define PCI_PWR_D0	0
    388       1.53  tshiozak #define PCI_PWR_D1	1
    389       1.53  tshiozak #define PCI_PWR_D2	2
    390       1.53  tshiozak #define PCI_PWR_D3	3
    391       1.69     perry int	pci_powerstate(pci_chipset_tag_t, pcitag_t, const int *, int *);
    392       1.55   thorpej 
    393       1.55   thorpej /*
    394       1.55   thorpej  * Vital Product Data (PCI 2.2)
    395       1.55   thorpej  */
    396       1.69     perry int	pci_vpd_read(pci_chipset_tag_t, pcitag_t, int, int, pcireg_t *);
    397       1.69     perry int	pci_vpd_write(pci_chipset_tag_t, pcitag_t, int, int, pcireg_t *);
    398       1.48   thorpej 
    399       1.48   thorpej /*
    400       1.35  augustss  * Misc.
    401       1.35  augustss  */
    402       1.47      fvdl int	pci_find_device(struct pci_attach_args *pa,
    403       1.92    dyoung 			int (*match)(const struct pci_attach_args *));
    404       1.92    dyoung int	pci_dma64_available(const struct pci_attach_args *);
    405       1.68  jmcneill void	pci_conf_capture(pci_chipset_tag_t, pcitag_t, struct pci_conf_state *);
    406       1.68  jmcneill void	pci_conf_restore(pci_chipset_tag_t, pcitag_t, struct pci_conf_state *);
    407       1.72  christos int	pci_get_powerstate(pci_chipset_tag_t, pcitag_t, pcireg_t *);
    408       1.72  christos int	pci_set_powerstate(pci_chipset_tag_t, pcitag_t, pcireg_t);
    409       1.78    dyoung int	pci_activate(pci_chipset_tag_t, pcitag_t, device_t,
    410       1.78    dyoung     int (*)(pci_chipset_tag_t, pcitag_t, device_t, pcireg_t));
    411       1.78    dyoung int	pci_activate_null(pci_chipset_tag_t, pcitag_t, device_t, pcireg_t);
    412       1.86    dyoung int	pci_chipset_tag_create(pci_chipset_tag_t, uint64_t,
    413       1.86    dyoung 	                       const struct pci_overrides *,
    414       1.86    dyoung 	                       void *, pci_chipset_tag_t *);
    415       1.86    dyoung void	pci_chipset_tag_destroy(pci_chipset_tag_t);
    416       1.95    dyoung int	pci_bus_devorder(pci_chipset_tag_t, int, uint8_t *, int);
    417      1.104  knakahar void	*pci_intr_establish_xname(pci_chipset_tag_t, pci_intr_handle_t,
    418      1.104  knakahar 				  int, int (*)(void *), void *, const char *);
    419      1.106  knakahar #ifndef __HAVE_PCI_MSI_MSIX
    420      1.106  knakahar typedef enum {
    421      1.106  knakahar 	PCI_INTR_TYPE_INTX = 0,
    422      1.106  knakahar 	PCI_INTR_TYPE_MSI,
    423      1.106  knakahar 	PCI_INTR_TYPE_MSIX,
    424      1.106  knakahar 	PCI_INTR_TYPE_SIZE,
    425      1.106  knakahar } pci_intr_type_t;
    426      1.106  knakahar 
    427      1.106  knakahar pci_intr_type_t
    428      1.108  knakahar 	pci_intr_type(pci_chipset_tag_t, pci_intr_handle_t);
    429      1.106  knakahar int	pci_intr_alloc(const struct pci_attach_args *, pci_intr_handle_t **,
    430      1.109  knakahar 	    int *, pci_intr_type_t);
    431      1.106  knakahar void	pci_intr_release(pci_chipset_tag_t, pci_intr_handle_t *, int);
    432      1.109  knakahar int	pci_intx_alloc(const struct pci_attach_args *, pci_intr_handle_t **);
    433      1.109  knakahar int	pci_msi_alloc(const struct pci_attach_args *, pci_intr_handle_t **,
    434      1.109  knakahar 	    int *);
    435      1.109  knakahar int	pci_msi_alloc_exact(const struct pci_attach_args *,
    436      1.109  knakahar 	    pci_intr_handle_t **, int);
    437      1.109  knakahar int	pci_msix_alloc(const struct pci_attach_args *, pci_intr_handle_t **,
    438      1.109  knakahar 	    int *);
    439      1.109  knakahar int	pci_msix_alloc_exact(const struct pci_attach_args *,
    440      1.109  knakahar 	    pci_intr_handle_t **, int);
    441      1.109  knakahar int	pci_msix_alloc_map(const struct pci_attach_args *, pci_intr_handle_t **,
    442      1.109  knakahar 	    u_int *, int);
    443      1.106  knakahar #endif
    444       1.47      fvdl 
    445       1.82        ad /*
    446       1.82        ad  * Device abstraction for inheritance by elanpci(4), for example.
    447       1.82        ad  */
    448       1.80    dyoung int pcimatch(device_t, cfdata_t, void *);
    449       1.80    dyoung void pciattach(device_t, device_t, void *);
    450       1.80    dyoung int pcidetach(device_t, int);
    451       1.80    dyoung void pcidevdetached(device_t, device_t);
    452       1.80    dyoung int pcirescan(device_t, const char *, const int *);
    453       1.80    dyoung 
    454       1.82        ad /*
    455       1.82        ad  * Interrupts.
    456       1.82        ad  */
    457       1.82        ad #define	PCI_INTR_MPSAFE		1
    458       1.82        ad 
    459       1.82        ad int	pci_intr_setattr(pci_chipset_tag_t, pci_intr_handle_t *, int, uint64_t);
    460       1.82        ad 
    461      1.107   msaitoh /*
    462      1.107   msaitoh  * Local constants
    463      1.107   msaitoh  */
    464      1.107   msaitoh #define PCI_INTRSTR_LEN			64
    465      1.107   msaitoh 
    466       1.48   thorpej #endif /* _KERNEL */
    467       1.12       cgd 
    468       1.12       cgd #endif /* _DEV_PCI_PCIVAR_H_ */
    469