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