Home | History | Annotate | Line # | Download | only in include
pci_machdep.h revision 1.4.12.1
      1  1.4.12.1   bouyer /* $NetBSD: pci_machdep.h,v 1.4.12.1 2008/01/02 21:49:07 bouyer 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.4.12.1   bouyer extern struct powerpc_bus_dma_tag pci_bus_dma_tag;
     58  1.4.12.1   bouyer 
     59       1.2  garbled /*
     60       1.2  garbled  * Forward declarations.
     61       1.2  garbled  */
     62       1.2  garbled struct pci_attach_args;
     63       1.2  garbled 
     64       1.2  garbled /* Per bus information structure */
     65       1.2  garbled struct genppc_pci_chipset_businfo {
     66       1.2  garbled 	SIMPLEQ_ENTRY(genppc_pci_chipset_businfo) next;
     67       1.2  garbled 	prop_dictionary_t	pbi_properties; /* chipset properties */
     68       1.2  garbled };
     69       1.2  garbled 
     70       1.2  garbled /*
     71       1.2  garbled  * Generic PPC PCI structure and type definitions.
     72       1.2  garbled  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
     73       1.2  garbled  */
     74       1.2  garbled struct genppc_pci_chipset {
     75       1.2  garbled 	void		*pc_conf_v;
     76       1.2  garbled 	void		(*pc_attach_hook)(struct device *,
     77       1.2  garbled 			    struct device *, struct pcibus_attach_args *);
     78       1.2  garbled 	int		(*pc_bus_maxdevs)(pci_chipset_tag_t, int);
     79       1.2  garbled 	pcitag_t	(*pc_make_tag)(void *, int, int, int);
     80       1.2  garbled 	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
     81       1.2  garbled 	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
     82       1.2  garbled 
     83       1.2  garbled 	void		*pc_intr_v;
     84       1.2  garbled 	int		(*pc_intr_map)(struct pci_attach_args *,
     85       1.2  garbled 			    pci_intr_handle_t *);
     86       1.2  garbled 	const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
     87       1.2  garbled 	const struct evcnt *(*pc_intr_evcnt)(void *, pci_intr_handle_t);
     88       1.2  garbled 	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
     89       1.2  garbled 			    int, int (*)(void *), void *);
     90       1.2  garbled 	void		(*pc_intr_disestablish)(void *, void *);
     91       1.2  garbled 	void		(*pc_conf_interrupt)(pci_chipset_tag_t, int, int, int,
     92       1.2  garbled 			    int, int *);
     93       1.2  garbled 	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
     94       1.2  garbled 			    int *, int *);
     95       1.2  garbled 	int		(*pc_conf_hook)(pci_chipset_tag_t, int, int, int,
     96       1.2  garbled 			    pcireg_t);
     97       1.2  garbled 
     98       1.2  garbled 	u_int32_t	*pc_addr;
     99       1.2  garbled 	u_int32_t	*pc_data;
    100       1.2  garbled 	int		pc_node;
    101       1.3  garbled 	int		pc_ihandle;
    102       1.2  garbled 	int		pc_bus;
    103       1.2  garbled 	bus_space_tag_t	pc_memt;
    104       1.2  garbled 	bus_space_tag_t	pc_iot;
    105       1.2  garbled 
    106       1.2  garbled 	SIMPLEQ_HEAD(, genppc_pci_chipset_businfo) pc_pbi;
    107       1.2  garbled };
    108       1.2  garbled 
    109       1.2  garbled /*
    110       1.2  garbled  * Functions provided to machine-independent PCI code.
    111       1.2  garbled  */
    112       1.2  garbled #define	pci_attach_hook(p, s, pba)					\
    113       1.2  garbled     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
    114       1.2  garbled #define	pci_bus_maxdevs(c, b)						\
    115       1.2  garbled     (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
    116       1.2  garbled #define	pci_make_tag(c, b, d, f)					\
    117       1.2  garbled     (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
    118       1.2  garbled #define	pci_conf_read(c, t, r)						\
    119       1.2  garbled     (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
    120       1.2  garbled #define	pci_conf_write(c, t, r, v)					\
    121       1.2  garbled     (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
    122       1.2  garbled #define	pci_intr_map(pa, ihp)						\
    123       1.2  garbled     (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
    124       1.2  garbled #define	pci_intr_string(c, ih)						\
    125       1.2  garbled     (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
    126       1.2  garbled #define	pci_intr_evcnt(c, ih)						\
    127       1.2  garbled     (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
    128       1.2  garbled #define	pci_intr_establish(c, ih, l, h, a)				\
    129       1.2  garbled     (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
    130       1.2  garbled #define	pci_intr_disestablish(c, iv)					\
    131       1.2  garbled     (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
    132       1.2  garbled #define	pci_conf_interrupt(c, b, d, p, s, ip)				\
    133       1.2  garbled     (*(c)->pc_conf_interrupt)((c)->pc_conf_v, (b), (d), (p), (s), (ip))
    134       1.2  garbled #define	pci_decompose_tag(c, t, bp, dp, fp)				\
    135       1.2  garbled     (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
    136       1.2  garbled #define	pci_conf_hook(c, b, d, f, i)					\
    137       1.2  garbled     (*(c)->pc_conf_hook)((c)->pc_conf_v, (b), (d), (f), (i))
    138       1.2  garbled 
    139       1.2  garbled #ifdef _KERNEL
    140       1.2  garbled 
    141       1.2  garbled /*
    142       1.2  garbled  * Generic PowerPC PCI functions.  Override if necc.
    143       1.2  garbled  */
    144       1.2  garbled 
    145       1.2  garbled int genppc_pci_bus_maxdevs(pci_chipset_tag_t, int);
    146       1.2  garbled const char *genppc_pci_intr_string(void *, pci_intr_handle_t);
    147       1.2  garbled const struct evcnt *genppc_pci_intr_evcnt(void *, pci_intr_handle_t);
    148       1.2  garbled void *genppc_pci_intr_establish(void *, pci_intr_handle_t, int, int (*)(void *),
    149       1.2  garbled     void *);
    150       1.2  garbled void genppc_pci_intr_disestablish(void *, void *);
    151       1.2  garbled void genppc_pci_conf_interrupt(pci_chipset_tag_t, int, int, int, int, int *);
    152       1.2  garbled int genppc_pci_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
    153       1.2  garbled int genppc_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp);
    154       1.2  garbled 
    155       1.2  garbled /* generic indirect PCI functions */
    156       1.2  garbled void genppc_pci_indirect_attach_hook(struct device *, struct device *,
    157       1.2  garbled     struct pcibus_attach_args *);
    158       1.2  garbled pcitag_t genppc_pci_indirect_make_tag(void *, int, int, int);
    159       1.2  garbled pcireg_t genppc_pci_indirect_conf_read(void *, pcitag_t, int);
    160       1.2  garbled void genppc_pci_indirect_conf_write(void *, pcitag_t, int, pcireg_t);
    161       1.2  garbled void genppc_pci_indirect_decompose_tag(void *, pcitag_t, int *, int *, int *);
    162       1.2  garbled 
    163       1.3  garbled /* generic OFW method PCI functions */
    164       1.3  garbled void genppc_pci_ofmethod_attach_hook(struct device *, struct device *,
    165       1.3  garbled     struct pcibus_attach_args *);
    166       1.3  garbled pcitag_t genppc_pci_ofmethod_make_tag(void *, int, int, int);
    167       1.3  garbled pcireg_t genppc_pci_ofmethod_conf_read(void *, pcitag_t, int);
    168       1.3  garbled void genppc_pci_ofmethod_conf_write(void *, pcitag_t, int, pcireg_t);
    169       1.3  garbled void genppc_pci_ofmethod_decompose_tag(void *, pcitag_t, int *, int *, int *);
    170       1.3  garbled 
    171       1.2  garbled /* Generic OFW PCI functions */
    172       1.2  garbled 
    173       1.2  garbled int genofw_find_picnode(int);
    174       1.2  garbled void genofw_find_ofpics(int);
    175       1.2  garbled void genofw_fixup_picnode_offsets(void);
    176       1.4  garbled void genofw_setup_pciintr_map(void *, struct genppc_pci_chipset_businfo *, int);
    177       1.2  garbled int genofw_find_node_by_devfunc(int, int, int, int);
    178       1.2  garbled int genofw_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
    179       1.2  garbled int genofw_pci_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
    180       1.2  garbled 
    181       1.2  garbled 
    182       1.2  garbled /* OFW PCI structures and defines */
    183       1.2  garbled #define PICNODE_TYPE_OPENPIC	1
    184       1.2  garbled #define PICNODE_TYPE_8259	2
    185       1.2  garbled #define PICNODE_TYPE_HEATHROW	3
    186       1.2  garbled #define PICNODE_TYPE_OHARE	4
    187       1.2  garbled 
    188       1.2  garbled typedef struct _ofw_pic_node_t {
    189       1.2  garbled 	int node;
    190       1.2  garbled 	int parent;
    191       1.2  garbled 	int16_t cells;
    192       1.2  garbled 	int16_t intrs;
    193       1.2  garbled 	int16_t offset;
    194       1.2  garbled 	int16_t type;
    195       1.2  garbled } ofw_pic_node_t;
    196       1.2  garbled 
    197       1.2  garbled #endif /* _KERNEL */
    198       1.2  garbled 
    199       1.2  garbled #endif /* _PCI_MACHDEP_H_ */
    200