2 # Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
3 # Copyright (c) 2017 The FreeBSD Foundation
6 # Portions of this software were developed by Landon Fuller
7 # under sponsorship from the FreeBSD Foundation.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 # IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/param.h>
34 #include <machine/bus.h>
36 #include <machine/resource.h>
38 #include <dev/bhnd/bhnd.h>
41 # bhndb bridge device interface.
47 struct bhndb_intr_isrc;
50 struct bhndb_hw_priority;
54 #include <sys/systm.h>
55 #include <dev/bhnd/bhndb/bhndbvar.h>
57 static const struct bhnd_chipid *
58 bhndb_null_get_chipid(device_t dev, device_t child)
60 panic("bhndb_get_chipid unimplemented");
64 bhndb_null_populate_board_info(device_t dev, device_t child,
65 struct bhnd_board_info *info)
67 panic("bhndb_populate_board_info unimplemented");
71 bhndb_null_is_core_disabled(device_t dev, device_t child,
72 struct bhnd_core_info *core)
74 panic("bhndb_is_core_disabled unimplemented");
78 bhndb_null_get_hostb_core(device_t dev, device_t child,
79 struct bhnd_core_info *core)
81 panic("bhndb_get_hostb_core unimplemented");
85 bhndb_null_suspend_resource(device_t dev, device_t child, int type,
88 panic("bhndb_suspend_resource unimplemented");
92 bhndb_null_resume_resource(device_t dev, device_t child, int type,
95 panic("bhndb_resume_resource unimplemented");
99 bhndb_null_route_interrupts(device_t dev, device_t child)
101 panic("bhndb_route_interrupts unimplemented");
105 bhndb_null_set_window_addr(device_t dev,
106 const struct bhndb_regwin *rw, bhnd_addr_t addr)
108 panic("bhndb_set_window_addr unimplemented");
112 bhndb_null_map_intr_isrc(device_t dev, struct resource *irq,
113 struct bhndb_intr_isrc **isrc)
115 panic("bhndb_map_intr_isrc unimplemented");
120 * Return the chip identification information for @p child.
122 * @param dev The parent device of @p child.
123 * @param child The bhndb-attached device.
125 METHOD const struct bhnd_chipid * get_chipid {
128 } DEFAULT bhndb_null_get_chipid;
131 * Populate @p info with board info known only to the bridge,
132 * deferring to any existing initialized fields in @p info.
134 * @param dev The parent device of @p child.
135 * @param child The bhndb-attached device.
136 * @param[in,out] info A board info structure previously initialized with any
137 * information available from NVRAM.
139 METHOD int populate_board_info {
142 struct bhnd_board_info *info;
143 } DEFAULT bhndb_null_populate_board_info;
146 * Return true if the hardware required by @p core is unpopulated or
147 * otherwise unusable.
149 * In some cases, the core's pins may be left floating, or the hardware
150 * may otherwise be non-functional; this method allows the parent device
151 * to explicitly specify whether @p core should be disabled.
153 * @param dev The parent device of @p child.
154 * @param child The attached bhnd device.
155 * @param core A core discovered on @p child.
157 METHOD bool is_core_disabled {
160 struct bhnd_core_info *core;
161 } DEFAULT bhndb_null_is_core_disabled;
164 * Get the host bridge core info for the attached bhnd bus.
166 * @param dev The bridge device.
167 * @param child The bhnd bus device attached to @p dev.
168 * @param[out] core Will be populated with the host bridge core info, if
172 * @retval ENOENT No host bridge core found.
173 * @retval non-zero If locating the host bridge core otherwise fails, a
174 * regular UNIX error code should be returned.
176 METHOD int get_hostb_core {
179 struct bhnd_core_info *core;
180 } DEFAULT bhndb_null_get_hostb_core;
183 * Mark a resource as 'suspended', gauranteeing to the bridge that no
184 * further use of the resource will be made until BHNDB_RESUME_RESOURCE()
187 * Bridge resources consumed by the reference may be released; these will
188 * be reacquired if BHNDB_RESUME_RESOURCE() completes successfully.
190 * Requests to suspend a suspended resource will be ignored.
192 * @param dev The bridge device.
193 * @param child The child device requesting resource suspension. This does
194 * not need to be the owner of @p r.
195 * @param type The resource type.
196 * @param r The resource to be suspended.
198 METHOD void suspend_resource {
203 } DEFAULT bhndb_null_suspend_resource;
206 * Attempt to re-enable a resource previously suspended by
207 * BHNDB_SUSPEND_RESOURCE().
209 * Bridge resources required by the reference may not be available, in which
210 * case an error will be returned and the resource mapped by @p r must not be
211 * used in any capacity.
213 * Requests to resume a non-suspended resource will be ignored.
215 * @param dev The bridge device.
216 * @param child The child device requesting resource suspension. This does
217 * not need to be the owner of @p r.
218 * @param type The resource type.
219 * @param r The resource to be suspended.
221 METHOD int resume_resource {
226 } DEFAULT bhndb_null_resume_resource;
229 * Enable bridge-level interrupt routing for @p child.
231 * @param dev The bridge device.
232 * @param child The bhnd child device for which interrupts should be routed.
234 METHOD int route_interrupts {
237 } DEFAULT bhndb_null_route_interrupts;
240 * Set a given register window's base address.
242 * @param dev The bridge device.
243 * @param win The register window.
244 * @param addr The address to be configured for @p win.
247 * @retval ENODEV The provided @p win is not memory-mapped on the bus or does
248 * not support setting a base address.
249 * @retval non-zero failure
251 METHOD int set_window_addr {
253 const struct bhndb_regwin *win;
255 } DEFAULT bhndb_null_set_window_addr;
258 * Map a bridged interrupt resource to its corresponding host interrupt source,
261 * @param dev The bridge device.
262 * @param irq The bridged interrupt resource.
263 * @param[out] isrc The host interrupt source to which the bridged interrupt
267 * @retval non-zero if mapping @p irq otherwise fails, a regular unix error code
270 METHOD int map_intr_isrc {
272 struct resource *irq;
273 struct bhndb_intr_isrc **isrc;
274 } DEFAULT bhndb_null_map_intr_isrc;