Home | History | Annotate | Line # | Download | only in pci
pcivar.h revision 1.22.2.1
      1  1.22.2.1  thorpej /*	$NetBSD: pcivar.h,v 1.22.2.1 1997/05/13 03:54:11 thorpej 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.1  mycroft  * Copyright (c) 1994 Charles 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.1  mycroft  *	This product includes software developed by Charles 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.12      cgd #include <machine/bus.h>
     45      1.14      cgd #include <dev/pci/pcireg.h>
     46      1.12      cgd 
     47      1.14      cgd /*
     48      1.14      cgd  * Structures and definitions needed by the machine-dependent header.
     49      1.14      cgd  */
     50      1.14      cgd typedef u_int32_t pcireg_t;		/* configuration space register XXX */
     51      1.14      cgd struct pcibus_attach_args;
     52      1.14      cgd 
     53      1.14      cgd /*
     54      1.14      cgd  * Machine-dependent definitions.
     55      1.14      cgd  */
     56      1.18      leo #if (alpha + atari + i386 != 1)
     57       1.4      cgd ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
     58       1.4      cgd #endif
     59       1.7      cgd #if alpha
     60       1.7      cgd #include <alpha/pci/pci_machdep.h>
     61      1.18      leo #endif
     62      1.18      leo #if atari
     63      1.18      leo #include <atari/pci/pci_machdep.h>
     64       1.7      cgd #endif
     65       1.4      cgd #if i386
     66       1.1  mycroft #include <i386/pci/pci_machdep.h>
     67       1.4      cgd #endif
     68       1.4      cgd 
     69      1.11      cgd /*
     70      1.11      cgd  * PCI bus attach arguments.
     71      1.11      cgd  */
     72      1.11      cgd struct pcibus_attach_args {
     73      1.19      cgd 	char		*pba_busname;	/* XXX should be common */
     74      1.16  thorpej 	bus_space_tag_t pba_iot;	/* pci i/o space tag */
     75      1.16  thorpej 	bus_space_tag_t pba_memt;	/* pci mem space tag */
     76  1.22.2.1  thorpej 	bus_dma_tag_t pba_dmat;		/* DMA tag */
     77      1.14      cgd 	pci_chipset_tag_t pba_pc;
     78      1.19      cgd 	int		pba_flags;	/* flags; see below */
     79      1.11      cgd 
     80      1.11      cgd 	int		pba_bus;	/* PCI bus number */
     81      1.14      cgd 
     82      1.14      cgd 	/*
     83      1.14      cgd 	 * Interrupt swizzling information.  These fields
     84      1.14      cgd 	 * are only used by secondary busses.
     85      1.14      cgd 	 */
     86      1.14      cgd 	u_int		pba_intrswiz;	/* how to swizzle pins */
     87      1.14      cgd 	pcitag_t	pba_intrtag;	/* intr. appears to come from here */
     88      1.11      cgd };
     89      1.11      cgd 
     90      1.11      cgd /*
     91      1.11      cgd  * PCI device attach arguments.
     92      1.11      cgd  */
     93       1.1  mycroft struct pci_attach_args {
     94      1.16  thorpej 	bus_space_tag_t pa_iot;		/* pci i/o space tag */
     95      1.16  thorpej 	bus_space_tag_t pa_memt;	/* pci mem space tag */
     96  1.22.2.1  thorpej 	bus_dma_tag_t pa_dmat;		/* DMA tag */
     97      1.14      cgd 	pci_chipset_tag_t pa_pc;
     98      1.19      cgd 	int		pa_flags;	/* flags; see below */
     99      1.12      cgd 
    100      1.15      cgd 	u_int		pa_device;
    101      1.15      cgd 	u_int		pa_function;
    102      1.11      cgd 	pcitag_t	pa_tag;
    103      1.11      cgd 	pcireg_t	pa_id, pa_class;
    104      1.14      cgd 
    105      1.14      cgd 	/*
    106      1.14      cgd 	 * Interrupt information.
    107      1.14      cgd 	 *
    108      1.14      cgd 	 * "Intrline" is used on systems whose firmware puts
    109      1.14      cgd 	 * the right routing data into the line register in
    110      1.14      cgd 	 * configuration space.  The rest are used on systems
    111      1.14      cgd 	 * that do not.
    112      1.14      cgd 	 */
    113      1.14      cgd 	u_int		pa_intrswiz;	/* how to swizzle pins if ppb */
    114      1.14      cgd 	pcitag_t	pa_intrtag;	/* intr. appears to come from here */
    115      1.14      cgd 	pci_intr_pin_t	pa_intrpin;	/* intr. appears on this pin */
    116      1.14      cgd 	pci_intr_line_t	pa_intrline;	/* intr. routing information */
    117       1.1  mycroft };
    118      1.19      cgd 
    119      1.19      cgd /*
    120      1.19      cgd  * Flags given in the bus and device attachment args.
    121      1.19      cgd  */
    122      1.19      cgd #define	PCI_FLAGS_IO_ENABLED	0x01		/* I/O space is enabled */
    123      1.19      cgd #define	PCI_FLAGS_MEM_ENABLED	0x02		/* memory space is enabled */
    124      1.13      cgd 
    125      1.13      cgd /*
    126      1.13      cgd  * Locators devices that attach to 'pcibus', as specified to config.
    127      1.13      cgd  */
    128      1.13      cgd #define	pcibuscf_bus		cf_loc[0]
    129      1.13      cgd #define	PCIBUS_UNK_BUS		-1		/* wildcarded 'bus' */
    130      1.13      cgd 
    131      1.13      cgd /*
    132      1.13      cgd  * Locators for PCI devices, as specified to config.
    133      1.13      cgd  */
    134      1.13      cgd #define	pcicf_dev		cf_loc[0]
    135      1.13      cgd #define	PCI_UNK_DEV		-1		/* wildcarded 'dev' */
    136      1.13      cgd 
    137      1.13      cgd #define	pcicf_function		cf_loc[1]
    138      1.13      cgd #define	PCI_UNK_FUNCTION	-1		/* wildcarded 'function' */
    139       1.1  mycroft 
    140      1.14      cgd /*
    141      1.14      cgd  * Configuration space access and utility functions.  (Note that most,
    142      1.14      cgd  * e.g. make_tag, conf_read, conf_write are declared by pci_machdep.h.)
    143      1.14      cgd  */
    144      1.22      cgd int	pci_mapreg_info __P((pci_chipset_tag_t, pcitag_t, int, pcireg_t,
    145      1.22      cgd 	    bus_addr_t *, bus_size_t *, int *));
    146      1.21      cgd int	pci_mapreg_map __P((struct pci_attach_args *, int, pcireg_t, int,
    147      1.20      cgd 	    bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
    148      1.16  thorpej 	    bus_size_t *));
    149      1.14      cgd 
    150      1.14      cgd /*
    151      1.14      cgd  * Helper functions for autoconfiguration.
    152      1.14      cgd  */
    153      1.14      cgd void	pci_devinfo __P((pcireg_t, pcireg_t, int, char *));
    154      1.17      cgd void	set_pci_isa_bridge_callback __P((void (*)(void *), void *));
    155      1.20      cgd 
    156      1.20      cgd /*
    157      1.20      cgd  * Backward compatibility functions.  NO NEW CODE SHOULD USE THESE.
    158      1.20      cgd  *
    159      1.20      cgd  * pci_io_find() and pci_mem_find() deprecated as of April 13, 1997.
    160      1.20      cgd  */
    161      1.20      cgd int	pci_io_find __P((pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
    162      1.20      cgd 	    bus_size_t *));
    163      1.20      cgd int	pci_mem_find __P((pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
    164      1.20      cgd 	    bus_size_t *, int *));
    165      1.12      cgd 
    166      1.12      cgd #endif /* _DEV_PCI_PCIVAR_H_ */
    167