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 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
32 #ifndef _BHND_BHNDB_H_
33 #define _BHND_BHNDB_H_
35 #include <sys/param.h>
38 #include <machine/bus.h>
40 #include <machine/resource.h>
42 #include <dev/bhnd/bhnd.h>
44 #include "bhndb_bus_if.h"
46 extern devclass_t bhndb_devclass;
47 DECLARE_CLASS(bhnd_bhndb_driver);
49 int bhndb_attach_bridge(device_t parent, device_t *bhndb, int unit);
52 * bhndb register window types.
55 BHNDB_REGWIN_T_CORE, /**< Fixed mapping of a core port region. */
56 BHNDB_REGWIN_T_SPROM, /**< Fixed mapping of device SPROM */
57 BHNDB_REGWIN_T_DYN, /**< A dynamically configurable window */
58 BHNDB_REGWIN_T_INVALID /**< Invalid type */
59 } bhndb_regwin_type_t;
62 * Evaluates to true if @p _rt defines a static mapping.
64 * @param _rt A bhndb_regwin_type_t value.
66 #define BHNDB_REGWIN_T_IS_STATIC(_rt) \
67 ((_rt) == BHNDB_REGWIN_T_CORE || \
68 (_rt) == BHNDB_REGWIN_T_SPROM)
71 * bhndb register window definition.
74 bhndb_regwin_type_t win_type; /**< window type */
75 bus_size_t win_offset; /**< offset of the window within the resource */
76 bus_size_t win_size; /**< size of the window */
78 /** Resource identification */
80 int type; /**< resource type */
81 int rid; /**< resource id */
86 /** Core-specific register window (BHNDB_REGWIN_T_CORE). */
88 bhnd_devclass_t class; /**< mapped core's class */
89 u_int unit; /**< mapped core's unit */
90 bhnd_port_type port_type; /**< mapped port type */
91 u_int port; /**< mapped port number */
92 u_int region; /**< mapped region number */
95 /** SPROM register window (BHNDB_REGWIN_T_SPROM). */
98 /** Dynamic register window (BHNDB_REGWIN_T_DYN). */
100 bus_size_t cfg_offset; /**< window address config offset. */
105 #define BHNDB_REGWIN_TABLE_END { BHNDB_REGWIN_T_INVALID, 0, 0, { 0, 0 } }
108 * Bridge hardware configuration.
110 * Provides the bridge's register/address mappings, and the resources
111 * via which those mappings may be accessed.
114 const struct resource_spec *resource_specs;
115 const struct bhndb_regwin *register_windows;
119 * Hardware specification entry.
121 * Defines a set of match criteria that may be used to determine the
122 * register map and resource configuration for a bhndb bridge device.
125 const char *name; /**< configuration name */
126 const struct bhnd_core_match *hw_reqs; /**< match requirements */
127 u_int num_hw_reqs; /**< number of match requirements */
128 const struct bhndb_hwcfg *cfg; /**< associated hardware configuration */
133 * bhndb resource allocation priorities.
136 /** No direct resources should ever be allocated for this device. */
137 BHNDB_PRIORITY_NONE = 0,
139 /** Allocate a direct resource if available after serving all other
140 * higher-priority requests. */
141 BHNDB_PRIORITY_LOW = 1,
143 /** Direct resource allocation is preferred, but not necessary
144 * for reasonable runtime performance. */
145 BHNDB_PRIORITY_DEFAULT = 2,
147 /** Indirect resource allocation would incur high runtime overhead. */
148 BHNDB_PRIORITY_HIGH = 3
152 * Port resource priority descriptor.
154 struct bhndb_port_priority {
155 bhnd_port_type type; /**< port type. */
156 u_int port; /**< port */
157 u_int region; /**< region */
158 bhndb_priority_t priority; /**< port priority */
162 * Core resource priority descriptor.
164 struct bhndb_hw_priority {
165 struct bhnd_core_match match; /**< core match descriptor */
166 bhndb_priority_t priority; /**< core-level priority */
167 const struct bhndb_port_priority *ports; /**< port priorities */
168 u_int num_ports; /**< number of port priority records. */
171 #define BHNDB_HW_PRIORITY_TABLE_END { {}, BHNDB_PRIORITY_NONE, NULL, 0 }
174 #endif /* _BHND_BHNDB_H_ */