Home | History | Annotate | Line # | Download | only in include
pci_machdep.h revision 1.3
      1 /* $NetBSD: pci_machdep.h,v 1.3 2005/12/11 12:17:50 christos Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1996 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Author: Chris G. Demetriou
      8  *
      9  * Permission to use, copy, modify and distribute this software and
     10  * its documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie the
     27  * rights to redistribute these changes.
     28  */
     29 
     30 /*
     31  * Machine-specific definitions for PCI autoconfiguration.
     32  */
     33 
     34 #define __HAVE_PCI_CONF_HOOK
     35 
     36 /*
     37  * Types provided to machine-independent PCI code
     38  */
     39 typedef struct ibmnws_pci_chipset *pci_chipset_tag_t;
     40 typedef int pcitag_t;
     41 typedef int pci_intr_handle_t;
     42 
     43 /*
     44  * Forward declarations.
     45  */
     46 struct pci_attach_args;
     47 
     48 /*
     49  * ibmnws-specific PCI structure and type definitions.
     50  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
     51  */
     52 struct ibmnws_pci_chipset {
     53 	void		*pc_conf_v;
     54 	void		(*pc_attach_hook)(struct device *,
     55 			    struct device *, struct pcibus_attach_args *);
     56 	int		(*pc_bus_maxdevs)(void *, int);
     57 	pcitag_t	(*pc_make_tag)(void *, int, int, int);
     58 	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
     59 	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
     60 
     61 	void		*pc_intr_v;
     62 	int		(*pc_intr_map)(struct pci_attach_args *,
     63 			    pci_intr_handle_t *);
     64 	const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
     65 	const struct evcnt *(*pc_intr_evcnt)(void *, pci_intr_handle_t);
     66 	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
     67 			    int, int (*)(void *), void *);
     68 	void		(*pc_intr_disestablish)(void *, void *);
     69 	void		(*pc_conf_interrupt)(void *, int, int, int, int, int *);
     70 	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
     71 			    int *, int *);
     72 	int		(*pc_conf_hook)(void *, int, int, int, pcireg_t);
     73 };
     74 
     75 /*
     76  * Functions provided to machine-independent PCI code.
     77  */
     78 #define	pci_attach_hook(p, s, pba)					\
     79     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
     80 #define	pci_bus_maxdevs(c, b)						\
     81     (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
     82 #define	pci_make_tag(c, b, d, f)					\
     83     (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
     84 #define	pci_conf_read(c, t, r)						\
     85     (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
     86 #define	pci_conf_write(c, t, r, v)					\
     87     (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
     88 #define	pci_intr_map(pa, ihp)						\
     89     (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
     90 #define	pci_intr_string(c, ih)						\
     91     (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
     92 #define	pci_intr_evcnt(c, ih)						\
     93     (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
     94 #define	pci_intr_establish(c, ih, l, h, a)				\
     95     (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
     96 #define	pci_intr_disestablish(c, iv)					\
     97     (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
     98 #define pci_conf_interrupt(c, b, d, p, s, ip)                           \
     99     (*(c)->pc_conf_interrupt)((c)->pc_conf_v, (b), (d), (p), (s), (ip))
    100 #define	pci_decompose_tag(c, t, bp, dp, fp)				\
    101     (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
    102 #define	pci_conf_hook(c, b, d, f, i)					\
    103     (*(c)->pc_conf_hook)((c)->pc_conf_v, (b), (d), (f), (i))
    104 
    105 #ifdef _KERNEL
    106 /*
    107  * ibmnws-specific PCI functions.
    108  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
    109  */
    110 int ibmnws_pci_bus_maxdevs(void *, int);
    111 int ibmnws_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
    112 const char *ibmnws_pci_intr_string(void *, pci_intr_handle_t);
    113 const struct evcnt *ibmnws_pci_intr_evcnt(void *, pci_intr_handle_t);
    114 void *ibmnws_pci_intr_establish(void *, pci_intr_handle_t, int, int (*)(void *),
    115     void *);
    116 void ibmnws_pci_intr_disestablish(void *, void *);
    117 void ibmnws_pci_conf_interrupt(void *, int, int, int, int, int *);
    118 int ibmnws_pci_conf_hook(void *, int, int, int, pcireg_t);
    119 
    120 void ibmnws_pci_get_chipset_tag_direct(pci_chipset_tag_t);
    121 void ibmnws_pci_get_chipset_tag_indirect(pci_chipset_tag_t);
    122 
    123 /*
    124  * ibmnws-specific PCI data.
    125  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
    126  */
    127 extern struct powerpc_bus_dma_tag pci_bus_dma_tag;
    128 #endif
    129