Home | History | Annotate | Line # | Download | only in include
pci_machdep.h revision 1.3
      1  1.3  garbled /* $NetBSD: pci_machdep.h,v 1.3 2007/10/25 16:55:50 garbled Exp $ */
      2  1.2  garbled 
      3  1.2  garbled /*-
      4  1.2  garbled  * Copyright (c) 2002,2007 The NetBSD Foundation, Inc.
      5  1.2  garbled  * All rights reserved.
      6  1.2  garbled  *
      7  1.2  garbled  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2  garbled  * by Klaus Klein and Tim Rightnour
      9  1.2  garbled  *
     10  1.2  garbled  * Redistribution and use in source and binary forms, with or without
     11  1.2  garbled  * modification, are permitted provided that the following conditions
     12  1.2  garbled  * are met:
     13  1.2  garbled  * 1. Redistributions of source code must retain the above copyright
     14  1.2  garbled  *    notice, this list of conditions and the following disclaimer.
     15  1.2  garbled  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2  garbled  *    notice, this list of conditions and the following disclaimer in the
     17  1.2  garbled  *    documentation and/or other materials provided with the distribution.
     18  1.2  garbled  * 3. All advertising materials mentioning features or use of this software
     19  1.2  garbled  *    must display the following acknowledgement:
     20  1.2  garbled  *        This product includes software developed by the NetBSD
     21  1.2  garbled  *        Foundation, Inc. and its contributors.
     22  1.2  garbled  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.2  garbled  *    contributors may be used to endorse or promote products derived
     24  1.2  garbled  *    from this software without specific prior written permission.
     25  1.2  garbled  *
     26  1.2  garbled  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.2  garbled  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.2  garbled  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2  garbled  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2  garbled  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.2  garbled  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.2  garbled  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.2  garbled  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.2  garbled  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.2  garbled  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.2  garbled  * POSSIBILITY OF SUCH DAMAGE.
     37  1.2  garbled  */
     38  1.2  garbled 
     39  1.2  garbled #ifndef _PCI_MACHDEP_H_
     40  1.2  garbled #define _PCI_MACHDEP_H_
     41  1.2  garbled 
     42  1.2  garbled #include <prop/proplib.h>
     43  1.2  garbled 
     44  1.2  garbled /*
     45  1.2  garbled  * Machine-specific definitions for PCI autoconfiguration.
     46  1.2  garbled  */
     47  1.2  garbled 
     48  1.2  garbled #define __HAVE_PCI_CONF_HOOK
     49  1.2  garbled 
     50  1.2  garbled /*
     51  1.2  garbled  * Types provided to machine-independent PCI code
     52  1.2  garbled  */
     53  1.2  garbled typedef struct genppc_pci_chipset *pci_chipset_tag_t;
     54  1.2  garbled typedef int pcitag_t;
     55  1.2  garbled typedef int pci_intr_handle_t;
     56  1.2  garbled 
     57  1.2  garbled /*
     58  1.2  garbled  * Forward declarations.
     59  1.2  garbled  */
     60  1.2  garbled struct pci_attach_args;
     61  1.2  garbled 
     62  1.2  garbled /* Per bus information structure */
     63  1.2  garbled struct genppc_pci_chipset_businfo {
     64  1.2  garbled 	SIMPLEQ_ENTRY(genppc_pci_chipset_businfo) next;
     65  1.2  garbled 	prop_dictionary_t	pbi_properties; /* chipset properties */
     66  1.2  garbled };
     67  1.2  garbled 
     68  1.2  garbled /*
     69  1.2  garbled  * Generic PPC PCI structure and type definitions.
     70  1.2  garbled  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
     71  1.2  garbled  */
     72  1.2  garbled struct genppc_pci_chipset {
     73  1.2  garbled 	void		*pc_conf_v;
     74  1.2  garbled 	void		(*pc_attach_hook)(struct device *,
     75  1.2  garbled 			    struct device *, struct pcibus_attach_args *);
     76  1.2  garbled 	int		(*pc_bus_maxdevs)(pci_chipset_tag_t, int);
     77  1.2  garbled 	pcitag_t	(*pc_make_tag)(void *, int, int, int);
     78  1.2  garbled 	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
     79  1.2  garbled 	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
     80  1.2  garbled 
     81  1.2  garbled 	void		*pc_intr_v;
     82  1.2  garbled 	int		(*pc_intr_map)(struct pci_attach_args *,
     83  1.2  garbled 			    pci_intr_handle_t *);
     84  1.2  garbled 	const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
     85  1.2  garbled 	const struct evcnt *(*pc_intr_evcnt)(void *, pci_intr_handle_t);
     86  1.2  garbled 	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
     87  1.2  garbled 			    int, int (*)(void *), void *);
     88  1.2  garbled 	void		(*pc_intr_disestablish)(void *, void *);
     89  1.2  garbled 	void		(*pc_conf_interrupt)(pci_chipset_tag_t, int, int, int,
     90  1.2  garbled 			    int, int *);
     91  1.2  garbled 	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
     92  1.2  garbled 			    int *, int *);
     93  1.2  garbled 	int		(*pc_conf_hook)(pci_chipset_tag_t, int, int, int,
     94  1.2  garbled 			    pcireg_t);
     95  1.2  garbled 
     96  1.2  garbled 	u_int32_t	*pc_addr;
     97  1.2  garbled 	u_int32_t	*pc_data;
     98  1.2  garbled 	int		pc_node;
     99  1.3  garbled 	int		pc_ihandle;
    100  1.2  garbled 	int		pc_bus;
    101  1.2  garbled 	bus_space_tag_t	pc_memt;
    102  1.2  garbled 	bus_space_tag_t	pc_iot;
    103  1.2  garbled 
    104  1.2  garbled 	SIMPLEQ_HEAD(, genppc_pci_chipset_businfo) pc_pbi;
    105  1.2  garbled };
    106  1.2  garbled 
    107  1.2  garbled /*
    108  1.2  garbled  * Functions provided to machine-independent PCI code.
    109  1.2  garbled  */
    110  1.2  garbled #define	pci_attach_hook(p, s, pba)					\
    111  1.2  garbled     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
    112  1.2  garbled #define	pci_bus_maxdevs(c, b)						\
    113  1.2  garbled     (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
    114  1.2  garbled #define	pci_make_tag(c, b, d, f)					\
    115  1.2  garbled     (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
    116  1.2  garbled #define	pci_conf_read(c, t, r)						\
    117  1.2  garbled     (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
    118  1.2  garbled #define	pci_conf_write(c, t, r, v)					\
    119  1.2  garbled     (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
    120  1.2  garbled #define	pci_intr_map(pa, ihp)						\
    121  1.2  garbled     (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
    122  1.2  garbled #define	pci_intr_string(c, ih)						\
    123  1.2  garbled     (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
    124  1.2  garbled #define	pci_intr_evcnt(c, ih)						\
    125  1.2  garbled     (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
    126  1.2  garbled #define	pci_intr_establish(c, ih, l, h, a)				\
    127  1.2  garbled     (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
    128  1.2  garbled #define	pci_intr_disestablish(c, iv)					\
    129  1.2  garbled     (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
    130  1.2  garbled #define	pci_conf_interrupt(c, b, d, p, s, ip)				\
    131  1.2  garbled     (*(c)->pc_conf_interrupt)((c)->pc_conf_v, (b), (d), (p), (s), (ip))
    132  1.2  garbled #define	pci_decompose_tag(c, t, bp, dp, fp)				\
    133  1.2  garbled     (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
    134  1.2  garbled #define	pci_conf_hook(c, b, d, f, i)					\
    135  1.2  garbled     (*(c)->pc_conf_hook)((c)->pc_conf_v, (b), (d), (f), (i))
    136  1.2  garbled 
    137  1.2  garbled #ifdef _KERNEL
    138  1.2  garbled 
    139  1.2  garbled /*
    140  1.2  garbled  * Generic PowerPC PCI functions.  Override if necc.
    141  1.2  garbled  */
    142  1.2  garbled 
    143  1.2  garbled int genppc_pci_bus_maxdevs(pci_chipset_tag_t, int);
    144  1.2  garbled const char *genppc_pci_intr_string(void *, pci_intr_handle_t);
    145  1.2  garbled const struct evcnt *genppc_pci_intr_evcnt(void *, pci_intr_handle_t);
    146  1.2  garbled void *genppc_pci_intr_establish(void *, pci_intr_handle_t, int, int (*)(void *),
    147  1.2  garbled     void *);
    148  1.2  garbled void genppc_pci_intr_disestablish(void *, void *);
    149  1.2  garbled void genppc_pci_conf_interrupt(pci_chipset_tag_t, int, int, int, int, int *);
    150  1.2  garbled int genppc_pci_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
    151  1.2  garbled int genppc_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp);
    152  1.2  garbled 
    153  1.2  garbled /* generic indirect PCI functions */
    154  1.2  garbled void genppc_pci_indirect_attach_hook(struct device *, struct device *,
    155  1.2  garbled     struct pcibus_attach_args *);
    156  1.2  garbled pcitag_t genppc_pci_indirect_make_tag(void *, int, int, int);
    157  1.2  garbled pcireg_t genppc_pci_indirect_conf_read(void *, pcitag_t, int);
    158  1.2  garbled void genppc_pci_indirect_conf_write(void *, pcitag_t, int, pcireg_t);
    159  1.2  garbled void genppc_pci_indirect_decompose_tag(void *, pcitag_t, int *, int *, int *);
    160  1.2  garbled 
    161  1.3  garbled /* generic OFW method PCI functions */
    162  1.3  garbled void genppc_pci_ofmethod_attach_hook(struct device *, struct device *,
    163  1.3  garbled     struct pcibus_attach_args *);
    164  1.3  garbled pcitag_t genppc_pci_ofmethod_make_tag(void *, int, int, int);
    165  1.3  garbled pcireg_t genppc_pci_ofmethod_conf_read(void *, pcitag_t, int);
    166  1.3  garbled void genppc_pci_ofmethod_conf_write(void *, pcitag_t, int, pcireg_t);
    167  1.3  garbled void genppc_pci_ofmethod_decompose_tag(void *, pcitag_t, int *, int *, int *);
    168  1.3  garbled 
    169  1.2  garbled /* XXX for now macppc needs its own pci_bus_dma_tag */
    170  1.2  garbled #ifndef macppc
    171  1.2  garbled extern struct powerpc_bus_dma_tag pci_bus_dma_tag;
    172  1.2  garbled #endif
    173  1.2  garbled 
    174  1.2  garbled /* Generic OFW PCI functions */
    175  1.2  garbled 
    176  1.2  garbled int genofw_find_picnode(int);
    177  1.2  garbled void genofw_find_ofpics(int);
    178  1.2  garbled void genofw_fixup_picnode_offsets(void);
    179  1.2  garbled void genofw_setup_pciintr_map(struct genppc_pci_chipset_businfo *, int);
    180  1.2  garbled int genofw_find_node_by_devfunc(int, int, int, int);
    181  1.2  garbled int genofw_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
    182  1.2  garbled int genofw_pci_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
    183  1.2  garbled 
    184  1.2  garbled 
    185  1.2  garbled /* OFW PCI structures and defines */
    186  1.2  garbled #define PICNODE_TYPE_OPENPIC	1
    187  1.2  garbled #define PICNODE_TYPE_8259	2
    188  1.2  garbled #define PICNODE_TYPE_HEATHROW	3
    189  1.2  garbled #define PICNODE_TYPE_OHARE	4
    190  1.2  garbled 
    191  1.2  garbled typedef struct _ofw_pic_node_t {
    192  1.2  garbled 	int node;
    193  1.2  garbled 	int parent;
    194  1.2  garbled 	int16_t cells;
    195  1.2  garbled 	int16_t intrs;
    196  1.2  garbled 	int16_t offset;
    197  1.2  garbled 	int16_t type;
    198  1.2  garbled } ofw_pic_node_t;
    199  1.2  garbled 
    200  1.2  garbled #endif /* _KERNEL */
    201  1.2  garbled 
    202  1.2  garbled #endif /* _PCI_MACHDEP_H_ */
    203