pci_machdep.h revision 1.13
1/* $NetBSD: pci_machdep.h,v 1.13 2006/06/09 01:19:10 garbled 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@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#include <prop/proplib.h>
31
32/*
33 * Machine-specific definitions for PCI autoconfiguration.
34 */
35
36#define __HAVE_PCI_CONF_HOOK
37
38/*
39 * Types provided to machine-independent PCI code
40 */
41typedef struct prep_pci_chipset *pci_chipset_tag_t;
42typedef int pcitag_t;
43typedef int pci_intr_handle_t;
44
45/*
46 * Forward declarations.
47 */
48struct pci_attach_args;
49
50/* Per bus information structure */
51struct prep_pci_chipset_businfo {
52	SIMPLEQ_ENTRY(prep_pci_chipset_businfo) next;
53	prop_dictionary_t	pbi_properties; /* chipset properties */
54};
55
56/*
57 * prep-specific PCI structure and type definitions.
58 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
59 */
60struct prep_pci_chipset {
61	void		*pc_conf_v;
62	void		(*pc_attach_hook)(struct device *,
63			    struct device *, struct pcibus_attach_args *);
64	int		(*pc_bus_maxdevs)(pci_chipset_tag_t, int);
65	pcitag_t	(*pc_make_tag)(void *, int, int, int);
66	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
67	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
68
69	void		*pc_intr_v;
70	int		(*pc_intr_map)(struct pci_attach_args *,
71			    pci_intr_handle_t *);
72	const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
73	const struct evcnt *(*pc_intr_evcnt)(void *, pci_intr_handle_t);
74	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
75			    int, int (*)(void *), void *);
76	void		(*pc_intr_disestablish)(void *, void *);
77	void		(*pc_conf_interrupt)(void *, int, int, int, int, int *);
78	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
79			    int *, int *);
80	int		(*pc_conf_hook)(pci_chipset_tag_t, int, int, int,
81			    pcireg_t);
82	SIMPLEQ_HEAD(, prep_pci_chipset_businfo) pc_pbi;
83};
84
85/*
86 * Functions provided to machine-independent PCI code.
87 */
88#define	pci_attach_hook(p, s, pba)					\
89    (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
90#define	pci_bus_maxdevs(c, b)						\
91    (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
92#define	pci_make_tag(c, b, d, f)					\
93    (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
94#define	pci_conf_read(c, t, r)						\
95    (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
96#define	pci_conf_write(c, t, r, v)					\
97    (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
98#define	pci_intr_map(pa, ihp)						\
99    (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
100#define	pci_intr_string(c, ih)						\
101    (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
102#define	pci_intr_evcnt(c, ih)						\
103    (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
104#define	pci_intr_establish(c, ih, l, h, a)				\
105    (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
106#define	pci_intr_disestablish(c, iv)					\
107    (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
108#define	pci_conf_interrupt(c, b, d, p, s, ip)				\
109    (*(c)->pc_conf_interrupt)((c)->pc_conf_v, (b), (d), (p), (s), (ip))
110#define	pci_decompose_tag(c, t, bp, dp, fp)				\
111    (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
112#define	pci_conf_hook(c, b, d, f, i)					\
113    (*(c)->pc_conf_hook)((c)->pc_conf_v, (b), (d), (f), (i))
114
115#ifdef _KERNEL
116/*
117 * prep-specific PCI functions.
118 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
119 */
120int prep_pci_bus_maxdevs(pci_chipset_tag_t, int);
121int prep_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
122const char *prep_pci_intr_string(void *, pci_intr_handle_t);
123const struct evcnt *prep_pci_intr_evcnt(void *, pci_intr_handle_t);
124void *prep_pci_intr_establish(void *, pci_intr_handle_t, int, int (*)(void *),
125    void *);
126void prep_pci_intr_disestablish(void *, void *);
127void prep_pci_conf_interrupt(void *, int, int, int, int, int *);
128int prep_pci_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
129
130void prep_pci_get_chipset_tag_direct(pci_chipset_tag_t);
131void prep_pci_get_chipset_tag_indirect(pci_chipset_tag_t);
132void prep_pci_get_chipset_tag(pci_chipset_tag_t pc);
133
134/*
135 * prep-specific PCI data.
136 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
137 */
138extern struct powerpc_bus_dma_tag pci_bus_dma_tag;
139#endif
140