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