2 # Copyright (c) 2015 Landon Fuller <landon@landonf.org>
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 # IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/param.h>
30 #include <machine/bus.h>
32 #include <machine/resource.h>
34 #include <dev/bhnd/bhnd.h>
37 # bhndb bridge device interface.
45 struct bhndb_hw_priority;
49 #include <sys/systm.h>
50 #include <dev/bhnd/bhndb/bhndbvar.h>
52 static const struct bhnd_chipid *
53 bhndb_null_get_chipid(device_t dev, device_t child)
55 panic("bhndb_get_chipid unimplemented");
59 bhndb_null_populate_board_info(device_t dev, device_t child,
60 struct bhnd_board_info *info)
62 panic("bhndb_populate_board_info unimplemented");
66 bhndb_null_is_core_disabled(device_t dev, device_t child,
67 struct bhnd_core_info *core)
69 panic("bhndb_is_core_disabled unimplemented");
73 bhndb_null_get_hostb_core(device_t dev, device_t child,
74 struct bhnd_core_info *core)
76 panic("bhndb_get_hostb_core unimplemented");
80 bhndb_null_suspend_resource(device_t dev, device_t child, int type,
83 panic("bhndb_suspend_resource unimplemented");
87 bhndb_null_resume_resource(device_t dev, device_t child, int type,
90 panic("bhndb_resume_resource unimplemented");
94 bhndb_null_set_window_addr(device_t dev,
95 const struct bhndb_regwin *rw, bhnd_addr_t addr)
97 panic("bhndb_set_window_addr unimplemented");
102 * Return the chip identification information for @p child.
104 * @param dev The parent device of @p child.
105 * @param child The bhndb-attached device.
107 METHOD const struct bhnd_chipid * get_chipid {
110 } DEFAULT bhndb_null_get_chipid;
113 * Populate @p info with board info known only to the bridge,
114 * deferring to any existing initialized fields in @p info.
116 * @param dev The parent device of @p child.
117 * @param child The bhndb-attached device.
118 * @param[in,out] info A board info structure previously initialized with any
119 * information available from NVRAM.
121 METHOD int populate_board_info {
124 struct bhnd_board_info *info;
125 } DEFAULT bhndb_null_populate_board_info;
128 * Return true if the hardware required by @p core is unpopulated or
129 * otherwise unusable.
131 * In some cases, the core's pins may be left floating, or the hardware
132 * may otherwise be non-functional; this method allows the parent device
133 * to explicitly specify whether @p core should be disabled.
135 * @param dev The parent device of @p child.
136 * @param child The attached bhnd device.
137 * @param core A core discovered on @p child.
139 METHOD bool is_core_disabled {
142 struct bhnd_core_info *core;
143 } DEFAULT bhndb_null_is_core_disabled;
146 * Get the host bridge core info for the attached bhnd bus.
148 * @param dev The bridge device.
149 * @param child The bhnd bus device attached to @p dev.
150 * @param[out] core Will be populated with the host bridge core info, if
154 * @retval ENOENT No host bridge core found.
155 * @retval non-zero If locating the host bridge core otherwise fails, a
156 * regular UNIX error code should be returned.
158 METHOD int get_hostb_core {
161 struct bhnd_core_info *core;
162 } DEFAULT bhndb_null_get_hostb_core;
165 * Mark a resource as 'suspended', gauranteeing to the bridge that no
166 * further use of the resource will be made until BHNDB_RESUME_RESOURCE()
169 * Bridge resources consumed by the reference may be released; these will
170 * be reacquired if BHNDB_RESUME_RESOURCE() completes successfully.
172 * Requests to suspend a suspended resource will be ignored.
174 * @param dev The bridge device.
175 * @param child The child device requesting resource suspension. This does
176 * not need to be the owner of @p r.
177 * @param type The resource type.
178 * @param r The resource to be suspended.
180 METHOD void suspend_resource {
185 } DEFAULT bhndb_null_suspend_resource;
188 * Attempt to re-enable a resource previously suspended by
189 * BHNDB_SUSPEND_RESOURCE().
191 * Bridge resources required by the reference may not be available, in which
192 * case an error will be returned and the resource mapped by @p r must not be
193 * used in any capacity.
195 * Requests to resume a non-suspended resource will be ignored.
197 * @param dev The bridge device.
198 * @param child The child device requesting resource suspension. This does
199 * not need to be the owner of @p r.
200 * @param type The resource type.
201 * @param r The resource to be suspended.
203 METHOD int resume_resource {
208 } DEFAULT bhndb_null_resume_resource;
211 * Set a given register window's base address.
213 * @param dev The bridge device.
214 * @param win The register window.
215 * @param addr The address to be configured for @p win.
218 * @retval ENODEV The provided @p win is not memory-mapped on the bus or does
219 * not support setting a base address.
220 * @retval non-zero failure
222 METHOD int set_window_addr {
224 const struct bhndb_regwin *win;
226 } DEFAULT bhndb_null_set_window_addr;