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