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