1 /* $NetBSD: pci_machdep.h,v 1.7 2008/01/17 23:42:58 garbled Exp $ */
4 * Copyright (c) 2002,2007 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein and Tim Rightnour
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _PCI_MACHDEP_H_
33 #define _PCI_MACHDEP_H_
35 #include <prop/proplib.h>
38 * Machine-specific definitions for PCI autoconfiguration.
41 #define __HAVE_PCI_CONF_HOOK
44 * Types provided to machine-independent PCI code
46 typedef struct genppc_pci_chipset
*pci_chipset_tag_t
;
48 typedef int pci_intr_handle_t
;
50 extern struct powerpc_bus_dma_tag pci_bus_dma_tag
;
53 * Forward declarations.
55 struct pci_attach_args
;
57 /* Per bus information structure */
58 struct genppc_pci_chipset_businfo
{
59 SIMPLEQ_ENTRY(genppc_pci_chipset_businfo
) next
;
60 prop_dictionary_t pbi_properties
; /* chipset properties */
64 * Generic PPC PCI structure and type definitions.
65 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
67 struct genppc_pci_chipset
{
69 void (*pc_attach_hook
)(struct device
*,
70 struct device
*, struct pcibus_attach_args
*);
71 int (*pc_bus_maxdevs
)(pci_chipset_tag_t
, int);
72 pcitag_t (*pc_make_tag
)(void *, int, int, int);
73 pcireg_t (*pc_conf_read
)(void *, pcitag_t
, int);
74 void (*pc_conf_write
)(void *, pcitag_t
, int, pcireg_t
);
77 int (*pc_intr_map
)(struct pci_attach_args
*,
79 const char *(*pc_intr_string
)(void *, pci_intr_handle_t
);
80 const struct evcnt
*(*pc_intr_evcnt
)(void *, pci_intr_handle_t
);
81 void *(*pc_intr_establish
)(void *, pci_intr_handle_t
,
82 int, int (*)(void *), void *);
83 void (*pc_intr_disestablish
)(void *, void *);
84 void (*pc_conf_interrupt
)(pci_chipset_tag_t
, int, int, int,
86 void (*pc_decompose_tag
)(void *, pcitag_t
, int *,
88 int (*pc_conf_hook
)(pci_chipset_tag_t
, int, int, int,
96 bus_space_tag_t pc_memt
;
97 bus_space_tag_t pc_iot
;
99 SIMPLEQ_HEAD(, genppc_pci_chipset_businfo
) pc_pbi
;
103 * Functions provided to machine-independent PCI code.
105 #define pci_attach_hook(p, s, pba) \
106 (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
107 #define pci_bus_maxdevs(c, b) \
108 (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
109 #define pci_make_tag(c, b, d, f) \
110 (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
111 #define pci_conf_read(c, t, r) \
112 (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
113 #define pci_conf_write(c, t, r, v) \
114 (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
115 #define pci_intr_map(pa, ihp) \
116 (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
117 #define pci_intr_string(c, ih) \
118 (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
119 #define pci_intr_evcnt(c, ih) \
120 (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
121 #define pci_intr_establish(c, ih, l, h, a) \
122 (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
123 #define pci_intr_disestablish(c, iv) \
124 (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
125 #define pci_conf_interrupt(c, b, d, p, s, ip) \
126 (*(c)->pc_conf_interrupt)((c)->pc_conf_v, (b), (d), (p), (s), (ip))
127 #define pci_decompose_tag(c, t, bp, dp, fp) \
128 (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
129 #define pci_conf_hook(c, b, d, f, i) \
130 (*(c)->pc_conf_hook)((c)->pc_conf_v, (b), (d), (f), (i))
135 * Generic PowerPC PCI functions. Override if necc.
138 int genppc_pci_bus_maxdevs(pci_chipset_tag_t
, int);
139 const char *genppc_pci_intr_string(void *, pci_intr_handle_t
);
140 const struct evcnt
*genppc_pci_intr_evcnt(void *, pci_intr_handle_t
);
141 void *genppc_pci_intr_establish(void *, pci_intr_handle_t
, int, int (*)(void *),
143 void genppc_pci_intr_disestablish(void *, void *);
144 void genppc_pci_conf_interrupt(pci_chipset_tag_t
, int, int, int, int, int *);
145 int genppc_pci_conf_hook(pci_chipset_tag_t
, int, int, int, pcireg_t
);
146 int genppc_pci_intr_map(struct pci_attach_args
*pa
, pci_intr_handle_t
*ihp
);
148 /* generic indirect PCI functions */
149 void genppc_pci_indirect_attach_hook(struct device
*, struct device
*,
150 struct pcibus_attach_args
*);
151 pcitag_t
genppc_pci_indirect_make_tag(void *, int, int, int);
152 pcireg_t
genppc_pci_indirect_conf_read(void *, pcitag_t
, int);
153 void genppc_pci_indirect_conf_write(void *, pcitag_t
, int, pcireg_t
);
154 void genppc_pci_indirect_decompose_tag(void *, pcitag_t
, int *, int *, int *);
156 /* generic OFW method PCI functions */
157 void genppc_pci_ofmethod_attach_hook(struct device
*, struct device
*,
158 struct pcibus_attach_args
*);
159 pcitag_t
genppc_pci_ofmethod_make_tag(void *, int, int, int);
160 pcireg_t
genppc_pci_ofmethod_conf_read(void *, pcitag_t
, int);
161 void genppc_pci_ofmethod_conf_write(void *, pcitag_t
, int, pcireg_t
);
162 void genppc_pci_ofmethod_decompose_tag(void *, pcitag_t
, int *, int *, int *);
164 /* Generic OFW PCI functions */
166 int genofw_find_picnode(int);
167 void genofw_find_ofpics(int);
168 void genofw_fixup_picnode_offsets(void);
169 void genofw_setup_pciintr_map(void *, struct genppc_pci_chipset_businfo
*, int);
170 int genofw_find_node_by_devfunc(int, int, int, int);
171 int genofw_pci_intr_map(struct pci_attach_args
*, pci_intr_handle_t
*);
172 int genofw_pci_conf_hook(pci_chipset_tag_t
, int, int, int, pcireg_t
);
175 /* OFW PCI structures and defines */
176 #define PICNODE_TYPE_OPENPIC 1
177 #define PICNODE_TYPE_8259 2
178 #define PICNODE_TYPE_HEATHROW 3
179 #define PICNODE_TYPE_OHARE 4
180 #define PICNODE_TYPE_IVR 5
182 typedef struct _ofw_pic_node_t
{
193 #endif /* _PCI_MACHDEP_H_ */