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.
35 #include <sys/types.h>
38 #include <machine/bus.h>
41 #include "bhnd_types.h"
42 #include "bhnd_erom_types.h"
43 #include "bhnd_debug.h"
44 #include "bhnd_bus_if.h"
45 #include "bhnd_match.h"
47 #include "nvram/bhnd_nvram.h"
49 struct bhnd_core_pmu_info;
51 extern devclass_t bhnd_devclass;
52 extern devclass_t bhnd_hostb_devclass;
53 extern devclass_t bhnd_nvram_devclass;
55 #define BHND_CHIPID_MAX_NAMELEN 32 /**< maximum buffer required for a
56 bhnd_format_chip_id() */
59 * bhnd child instance variables
61 enum bhnd_device_vars {
62 BHND_IVAR_VENDOR, /**< Designer's JEP-106 manufacturer ID. */
63 BHND_IVAR_DEVICE, /**< Part number */
64 BHND_IVAR_HWREV, /**< Core revision */
65 BHND_IVAR_DEVICE_CLASS, /**< Core class (@sa bhnd_devclass_t) */
66 BHND_IVAR_VENDOR_NAME, /**< Core vendor name */
67 BHND_IVAR_DEVICE_NAME, /**< Core name */
68 BHND_IVAR_CORE_INDEX, /**< Bus-assigned core number */
69 BHND_IVAR_CORE_UNIT, /**< Bus-assigned core unit number,
70 assigned sequentially (starting at 0) for
71 each vendor/device pair. */
72 BHND_IVAR_PMU_INFO, /**< Internal bus-managed PMU state */
76 * bhnd device probe priority bands.
79 BHND_PROBE_ROOT = 0, /**< Nexus or host bridge */
80 BHND_PROBE_BUS = 1000, /**< Busses and bridges */
81 BHND_PROBE_CPU = 2000, /**< CPU devices */
82 BHND_PROBE_INTERRUPT = 3000, /**< Interrupt controllers. */
83 BHND_PROBE_TIMER = 4000, /**< Timers and clocks. */
84 BHND_PROBE_RESOURCE = 5000, /**< Resource discovery (including NVRAM/SPROM) */
85 BHND_PROBE_DEFAULT = 6000, /**< Default device priority */
89 * Constants defining fine grained ordering within a BHND_PROBE_* priority band.
93 * BHND_PROBE_BUS + BHND_PROBE_ORDER_FIRST
97 BHND_PROBE_ORDER_FIRST = 0,
98 BHND_PROBE_ORDER_EARLY = 25,
99 BHND_PROBE_ORDER_MIDDLE = 50,
100 BHND_PROBE_ORDER_LATE = 75,
101 BHND_PROBE_ORDER_LAST = 100
107 * Per-core IOCTL flags common to all bhnd(4) cores.
110 BHND_IOCTL_BIST = 0x8000, /**< Initiate a built-in self-test (BIST). Must be cleared
111 after BIST results are read via BHND_IOST_BIST_* */
112 BHND_IOCTL_PME = 0x4000, /**< Enable posting of power management events by the core. */
113 BHND_IOCTL_CFLAGS = 0x3FFC, /**< Reserved for core-specific ioctl flags. */
114 BHND_IOCTL_CLK_FORCE = 0x0002, /**< Force disable of clock gating, resulting in all clocks
115 being distributed within the core. Should be set when
116 asserting/deasserting reset to ensure the reset signal
117 fully propagates to the entire core. */
118 BHND_IOCTL_CLK_EN = 0x0001, /**< If cleared, the core clock will be disabled. Should be
119 set during normal operation, and cleared when the core is
124 * Per-core IOST flags common to all bhnd(4) cores.
127 BHND_IOST_BIST_DONE = 0x8000, /**< Set upon BIST completion (see BHND_IOCTL_BIST), and cleared
128 if 0 is written to BHND_IOCTL_BIST. */
129 BHND_IOST_BIST_FAIL = 0x4000, /**< Set upon detection of a BIST error; the value is unspecified
130 if BIST has not completed and BHND_IOST_BIST_DONE is not set. */
131 BHND_IOST_CLK = 0x2000, /**< Set if the core has requested that gated clocks be enabled, or
132 cleared otherwise. The value is undefined if a core does not
133 support clock gating. */
134 BHND_IOST_DMA64 = 0x1000, /**< Set if this core supports 64-bit DMA */
135 BHND_IOST_CFLAGS = 0x0FFC, /**< Reserved for core-specific status flags. */
139 * Simplified accessors for bhnd device ivars
141 #define BHND_ACCESSOR(var, ivar, type) \
142 __BUS_ACCESSOR(bhnd, var, BHND, ivar, type)
144 BHND_ACCESSOR(vendor, VENDOR, uint16_t);
145 BHND_ACCESSOR(device, DEVICE, uint16_t);
146 BHND_ACCESSOR(hwrev, HWREV, uint8_t);
147 BHND_ACCESSOR(class, DEVICE_CLASS, bhnd_devclass_t);
148 BHND_ACCESSOR(vendor_name, VENDOR_NAME, const char *);
149 BHND_ACCESSOR(device_name, DEVICE_NAME, const char *);
150 BHND_ACCESSOR(core_index, CORE_INDEX, u_int);
151 BHND_ACCESSOR(core_unit, CORE_UNIT, int);
152 BHND_ACCESSOR(pmu_info, PMU_INFO, struct bhnd_core_pmu_info *);
157 * A bhnd(4) board descriptor.
159 struct bhnd_board_info {
160 uint16_t board_vendor; /**< PCI-SIG vendor ID (even on non-PCI
163 * On PCI devices, this will generally
164 * be the subsystem vendor ID, but the
165 * value may be overridden in device
168 uint16_t board_type; /**< Board type (See BHND_BOARD_*)
170 * On PCI devices, this will generally
171 * be the subsystem device ID, but the
172 * value may be overridden in device
175 uint16_t board_rev; /**< Board revision. */
176 uint8_t board_srom_rev; /**< Board SROM format revision */
178 uint32_t board_flags; /**< Board flags (see BHND_BFL_*) */
179 uint32_t board_flags2; /**< Board flags 2 (see BHND_BFL2_*) */
180 uint32_t board_flags3; /**< Board flags 3 (see BHND_BFL3_*) */
185 * Chip Identification
187 * This is read from the ChipCommon ID register; on earlier bhnd(4) devices
188 * where ChipCommon is unavailable, known values must be supplied.
191 uint16_t chip_id; /**< chip id (BHND_CHIPID_*) */
192 uint8_t chip_rev; /**< chip revision */
193 uint8_t chip_pkg; /**< chip package (BHND_PKGID_*) */
194 uint8_t chip_type; /**< chip type (BHND_CHIPTYPE_*) */
196 bhnd_addr_t enum_addr; /**< chip_type-specific enumeration
197 * address; either the siba(4) base
198 * core register block, or the bcma(4)
199 * EROM core address. */
201 uint8_t ncores; /**< number of cores, if known. 0 if
206 * A bhnd(4) core descriptor.
208 struct bhnd_core_info {
209 uint16_t vendor; /**< JEP-106 vendor (BHND_MFGID_*) */
210 uint16_t device; /**< device */
211 uint16_t hwrev; /**< hardware revision */
212 u_int core_idx; /**< bus-assigned core index */
213 int unit; /**< bus-assigned core unit */
217 * A bhnd(4) bus resource.
219 * This provides an abstract interface to per-core resources that may require
220 * bus-level remapping of address windows prior to access.
222 struct bhnd_resource {
223 struct resource *res; /**< the system resource. */
224 bool direct; /**< false if the resource requires
225 * bus window remapping before it
226 * is MMIO accessible. */
229 /** Wrap the active resource @p _r in a bhnd_resource structure */
230 #define BHND_DIRECT_RESOURCE(_r) ((struct bhnd_resource) { \
236 * Device quirk table descriptor.
238 struct bhnd_device_quirk {
239 struct bhnd_device_match desc; /**< device match descriptor */
240 uint32_t quirks; /**< quirk flags */
243 #define BHND_CORE_QUIRK(_rev, _flags) \
244 {{ BHND_MATCH_CORE_REV(_rev) }, (_flags) }
246 #define BHND_CHIP_QUIRK(_chip, _rev, _flags) \
247 {{ BHND_CHIP_IR(BCM ## _chip, _rev) }, (_flags) }
249 #define BHND_PKG_QUIRK(_chip, _pkg, _flags) \
250 {{ BHND_CHIP_IP(BCM ## _chip, BCM ## _chip ## _pkg) }, (_flags) }
252 #define BHND_BOARD_QUIRK(_board, _flags) \
253 {{ BHND_MATCH_BOARD_TYPE(_board) }, \
256 #define BHND_DEVICE_QUIRK_END { { BHND_MATCH_ANY }, 0 }
257 #define BHND_DEVICE_QUIRK_IS_END(_q) \
258 (((_q)->desc.m.match_flags == 0) && (_q)->quirks == 0)
262 BHND_DF_HOSTB = (1<<0), /**< core is serving as the bus' host
263 * bridge. implies BHND_DF_ADAPTER */
264 BHND_DF_SOC = (1<<1), /**< core is attached to a native
265 bus (BHND_ATTACH_NATIVE) */
266 BHND_DF_ADAPTER = (1<<2), /**< core is attached to a bridged
267 * adapter (BHND_ATTACH_ADAPTER) */
270 /** Device probe table descriptor */
272 const struct bhnd_device_match core; /**< core match descriptor */
273 const char *desc; /**< device description, or NULL. */
274 const struct bhnd_device_quirk *quirks_table; /**< quirks table for this device, or NULL */
275 uint32_t device_flags; /**< required BHND_DF_* flags */
278 #define _BHND_DEVICE(_vendor, _device, _desc, _quirks, \
280 { { BHND_MATCH_CORE(BHND_MFGID_ ## _vendor, \
281 BHND_COREID_ ## _device) }, _desc, _quirks, \
284 #define BHND_DEVICE(_vendor, _device, _desc, _quirks, ...) \
285 _BHND_DEVICE(_vendor, _device, _desc, _quirks, \
288 #define BHND_DEVICE_END { { BHND_MATCH_ANY }, NULL, NULL, 0 }
289 #define BHND_DEVICE_IS_END(_d) \
290 (BHND_MATCH_IS_ANY(&(_d)->core) && (_d)->desc == NULL)
292 const char *bhnd_vendor_name(uint16_t vendor);
293 const char *bhnd_port_type_name(bhnd_port_type port_type);
294 const char *bhnd_nvram_src_name(bhnd_nvram_src nvram_src);
296 const char *bhnd_find_core_name(uint16_t vendor,
298 bhnd_devclass_t bhnd_find_core_class(uint16_t vendor,
301 const char *bhnd_core_name(const struct bhnd_core_info *ci);
302 bhnd_devclass_t bhnd_core_class(const struct bhnd_core_info *ci);
304 int bhnd_format_chip_id(char *buffer, size_t size,
307 device_t bhnd_match_child(device_t dev,
308 const struct bhnd_core_match *desc);
310 device_t bhnd_find_child(device_t dev,
311 bhnd_devclass_t class, int unit);
313 device_t bhnd_find_bridge_root(device_t dev,
314 devclass_t bus_class);
316 const struct bhnd_core_info *bhnd_match_core(
317 const struct bhnd_core_info *cores,
319 const struct bhnd_core_match *desc);
321 const struct bhnd_core_info *bhnd_find_core(
322 const struct bhnd_core_info *cores,
323 u_int num_cores, bhnd_devclass_t class);
325 struct bhnd_core_match bhnd_core_get_match_desc(
326 const struct bhnd_core_info *core);
328 bool bhnd_cores_equal(
329 const struct bhnd_core_info *lhs,
330 const struct bhnd_core_info *rhs);
332 bool bhnd_core_matches(
333 const struct bhnd_core_info *core,
334 const struct bhnd_core_match *desc);
336 bool bhnd_chip_matches(
337 const struct bhnd_chipid *chipid,
338 const struct bhnd_chip_match *desc);
340 bool bhnd_board_matches(
341 const struct bhnd_board_info *info,
342 const struct bhnd_board_match *desc);
344 bool bhnd_hwrev_matches(uint16_t hwrev,
345 const struct bhnd_hwrev_match *desc);
347 bool bhnd_device_matches(device_t dev,
348 const struct bhnd_device_match *desc);
350 const struct bhnd_device *bhnd_device_lookup(device_t dev,
351 const struct bhnd_device *table,
354 uint32_t bhnd_device_quirks(device_t dev,
355 const struct bhnd_device *table,
358 struct bhnd_core_info bhnd_get_core_info(device_t dev);
360 int bhnd_alloc_resources(device_t dev,
361 struct resource_spec *rs,
362 struct bhnd_resource **res);
364 void bhnd_release_resources(device_t dev,
365 const struct resource_spec *rs,
366 struct bhnd_resource **res);
368 struct bhnd_chipid bhnd_parse_chipid(uint32_t idreg,
369 bhnd_addr_t enum_addr);
371 int bhnd_chipid_fixed_ncores(
372 const struct bhnd_chipid *cid,
373 uint16_t chipc_hwrev, uint8_t *ncores);
375 int bhnd_read_chipid(device_t dev,
376 struct resource_spec *rs,
377 bus_size_t chipc_offset,
378 struct bhnd_chipid *result);
380 void bhnd_set_custom_core_desc(device_t dev,
382 void bhnd_set_default_core_desc(device_t dev);
384 void bhnd_set_default_bus_desc(device_t dev,
385 const struct bhnd_chipid *chip_id);
387 int bhnd_nvram_getvar_str(device_t dev,
388 const char *name, char *buf, size_t len,
391 int bhnd_nvram_getvar_uint(device_t dev,
392 const char *name, void *value, int width);
393 int bhnd_nvram_getvar_uint8(device_t dev,
394 const char *name, uint8_t *value);
395 int bhnd_nvram_getvar_uint16(device_t dev,
396 const char *name, uint16_t *value);
397 int bhnd_nvram_getvar_uint32(device_t dev,
398 const char *name, uint32_t *value);
400 int bhnd_nvram_getvar_int(device_t dev,
401 const char *name, void *value, int width);
402 int bhnd_nvram_getvar_int8(device_t dev,
403 const char *name, int8_t *value);
404 int bhnd_nvram_getvar_int16(device_t dev,
405 const char *name, int16_t *value);
406 int bhnd_nvram_getvar_int32(device_t dev,
407 const char *name, int32_t *value);
409 int bhnd_nvram_getvar_array(device_t dev,
410 const char *name, void *buf, size_t count,
411 bhnd_nvram_type type);
413 bool bhnd_bus_generic_is_hw_disabled(device_t dev,
415 bool bhnd_bus_generic_is_region_valid(device_t dev,
416 device_t child, bhnd_port_type type,
417 u_int port, u_int region);
418 int bhnd_bus_generic_get_nvram_var(device_t dev,
419 device_t child, const char *name,
420 void *buf, size_t *size,
421 bhnd_nvram_type type);
422 const struct bhnd_chipid *bhnd_bus_generic_get_chipid(device_t dev,
424 int bhnd_bus_generic_read_board_info(device_t dev,
426 struct bhnd_board_info *info);
427 struct bhnd_resource *bhnd_bus_generic_alloc_resource (device_t dev,
428 device_t child, int type, int *rid,
429 rman_res_t start, rman_res_t end,
430 rman_res_t count, u_int flags);
431 int bhnd_bus_generic_release_resource (device_t dev,
432 device_t child, int type, int rid,
433 struct bhnd_resource *r);
434 int bhnd_bus_generic_activate_resource (device_t dev,
435 device_t child, int type, int rid,
436 struct bhnd_resource *r);
437 int bhnd_bus_generic_deactivate_resource (device_t dev,
438 device_t child, int type, int rid,
439 struct bhnd_resource *r);
440 bhnd_attach_type bhnd_bus_generic_get_attach_type(device_t dev,
444 * Return the bhnd(4) bus driver's device enumeration parser class
446 * @param driver A bhnd bus driver instance.
448 static inline bhnd_erom_class_t *
449 bhnd_driver_get_erom_class(driver_t *driver)
451 return (BHND_BUS_GET_EROM_CLASS(driver));
455 * Return the active host bridge core for the bhnd bus, if any, or NULL if
458 * @param dev A bhnd bus device.
460 static inline device_t
461 bhnd_find_hostb_device(device_t dev) {
462 return (BHND_BUS_FIND_HOSTB_DEVICE(dev));
466 * Return true if the hardware components required by @p dev are known to be
467 * unpopulated or otherwise unusable.
469 * In some cases, enumerated devices may have pins that are left floating, or
470 * the hardware may otherwise be non-functional; this method allows a parent
471 * device to explicitly specify if a successfully enumerated @p dev should
474 * @param dev A bhnd bus child device.
477 bhnd_is_hw_disabled(device_t dev) {
478 return (BHND_BUS_IS_HW_DISABLED(device_get_parent(dev), dev));
482 * Return the BHND chip identification info for the bhnd bus.
484 * @param dev A bhnd bus child device.
486 static inline const struct bhnd_chipid *
487 bhnd_get_chipid(device_t dev) {
488 return (BHND_BUS_GET_CHIPID(device_get_parent(dev), dev));
493 * Read the current value of a bhnd(4) device's per-core I/O control register.
495 * @param dev The bhnd bus child device to be queried.
496 * @param[out] ioctl On success, the I/O control register value.
499 * @retval EINVAL If @p child is not a direct child of @p dev.
500 * @retval ENODEV If agent/config space for @p child is unavailable.
501 * @retval non-zero If reading the IOCTL register otherwise fails, a regular
502 * unix error code will be returned.
505 bhnd_read_ioctl(device_t dev, uint16_t *ioctl)
507 return (BHND_BUS_READ_IOCTL(device_get_parent(dev), dev, ioctl));
511 * Write @p value and @p mask to a bhnd(4) device's per-core I/O control
514 * @param dev The bhnd bus child device for which the IOCTL register will be
516 * @param value The value to be written (see BHND_IOCTL_*).
517 * @param mask Only the bits defined by @p mask will be updated from @p value.
520 * @retval EINVAL If @p child is not a direct child of @p dev.
521 * @retval ENODEV If agent/config space for @p child is unavailable.
522 * @retval non-zero If writing the IOCTL register otherwise fails, a regular
523 * unix error code will be returned.
526 bhnd_write_ioctl(device_t dev, uint16_t value, uint16_t mask)
528 return (BHND_BUS_WRITE_IOCTL(device_get_parent(dev), dev, value, mask));
532 * Read the current value of a bhnd(4) device's per-core I/O status register.
534 * @param dev The bhnd bus child device to be queried.
535 * @param[out] iost On success, the I/O status register value.
538 * @retval EINVAL If @p child is not a direct child of @p dev.
539 * @retval ENODEV If agent/config space for @p child is unavailable.
540 * @retval non-zero If reading the IOST register otherwise fails, a regular
541 * unix error code will be returned.
544 bhnd_read_iost(device_t dev, uint16_t *iost)
546 return (BHND_BUS_READ_IOST(device_get_parent(dev), dev, iost));
550 * Return true if the given bhnd device's hardware is currently held
551 * in a RESET state or otherwise not clocked (BHND_IOCTL_CLK_EN).
553 * @param dev The device to query.
555 * @retval true If @p dev is held in RESET or not clocked (BHND_IOCTL_CLK_EN),
556 * or an error occured determining @p dev's hardware state.
557 * @retval false If @p dev is clocked and is not held in RESET.
560 bhnd_is_hw_suspended(device_t dev)
562 return (BHND_BUS_IS_HW_SUSPENDED(device_get_parent(dev), dev));
566 * Place the bhnd(4) device's hardware into a reset state, and then bring the
567 * hardware out of reset with BHND_IOCTL_CLK_EN and @p ioctl flags set.
569 * Any clock or resource PMU requests previously made by @p dev will be
572 * @param dev The device to be reset.
573 * @param ioctl Device-specific core ioctl flags to be supplied on reset
574 * (see BHND_IOCTL_*).
577 * @retval non-zero error
580 bhnd_reset_hw(device_t dev, uint16_t ioctl)
582 return (BHND_BUS_RESET_HW(device_get_parent(dev), dev, ioctl));
586 * Suspend @p child's hardware in a low-power reset state.
588 * Any clock or resource PMU requests previously made by @p dev will be
591 * The hardware may be brought out of reset via bhnd_reset_hw().
593 * @param dev The device to be suspended.
596 * @retval non-zero error
599 bhnd_suspend_hw(device_t dev)
601 return (BHND_BUS_SUSPEND_HW(device_get_parent(dev), dev));
605 * If supported by the chipset, return the clock source for the given clock.
607 * This function is only supported on early PWRCTL-equipped chipsets
608 * that expose clock management via their host bridge interface. Currently,
609 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9.
611 * @param dev A bhnd bus child device.
612 * @param clock The clock for which a clock source will be returned.
614 * @retval bhnd_clksrc The clock source for @p clock.
615 * @retval BHND_CLKSRC_UNKNOWN If @p clock is unsupported, or its
616 * clock source is not known to the bus.
618 static inline bhnd_clksrc
619 bhnd_pwrctl_get_clksrc(device_t dev, bhnd_clock clock)
621 return (BHND_BUS_PWRCTL_GET_CLKSRC(device_get_parent(dev), dev, clock));
625 * If supported by the chipset, gate @p clock
627 * This function is only supported on early PWRCTL-equipped chipsets
628 * that expose clock management via their host bridge interface. Currently,
629 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9.
631 * @param dev A bhnd bus child device.
632 * @param clock The clock to be disabled.
635 * @retval ENODEV If bus-level clock source management is not supported.
636 * @retval ENXIO If bus-level management of @p clock is not supported.
639 bhnd_pwrctl_gate_clock(device_t dev, bhnd_clock clock)
641 return (BHND_BUS_PWRCTL_GATE_CLOCK(device_get_parent(dev), dev, clock));
645 * If supported by the chipset, ungate @p clock
647 * This function is only supported on early PWRCTL-equipped chipsets
648 * that expose clock management via their host bridge interface. Currently,
649 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9.
651 * @param dev A bhnd bus child device.
652 * @param clock The clock to be enabled.
655 * @retval ENODEV If bus-level clock source management is not supported.
656 * @retval ENXIO If bus-level management of @p clock is not supported.
659 bhnd_pwrctl_ungate_clock(device_t dev, bhnd_clock clock)
661 return (BHND_BUS_PWRCTL_UNGATE_CLOCK(device_get_parent(dev), dev,
666 * Return the BHND attachment type of the parent bhnd bus.
668 * @param dev A bhnd bus child device.
670 * @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter,
671 * such as a WiFi chipset.
672 * @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock,
673 * CPU, etc) to a directly attached native host.
675 static inline bhnd_attach_type
676 bhnd_get_attach_type (device_t dev) {
677 return (BHND_BUS_GET_ATTACH_TYPE(device_get_parent(dev), dev));
681 * Attempt to read the BHND board identification from the bhnd bus.
683 * This relies on NVRAM access, and will fail if a valid NVRAM device cannot
684 * be found, or is not yet attached.
686 * @param dev The parent of @p child.
687 * @param child The bhnd device requesting board info.
688 * @param[out] info On success, will be populated with the bhnd(4) device's
692 * @retval ENODEV No valid NVRAM source could be found.
693 * @retval non-zero If reading @p name otherwise fails, a regular unix
694 * error code will be returned.
697 bhnd_read_board_info(device_t dev, struct bhnd_board_info *info)
699 return (BHND_BUS_READ_BOARD_INFO(device_get_parent(dev), dev, info));
703 * Return the number of interrupts to be assigned to @p child via
704 * BHND_BUS_ASSIGN_INTR().
706 * @param dev A bhnd bus child device.
709 bhnd_get_intr_count(device_t dev)
711 return (BHND_BUS_GET_INTR_COUNT(device_get_parent(dev), dev));
715 * Return the backplane interrupt vector corresponding to @p dev's given
718 * @param dev A bhnd bus child device.
719 * @param intr The interrupt number being queried. This is equivalent to the
720 * bus resource ID for the interrupt.
721 * @param[out] ivec On success, the assigned hardware interrupt vector be
722 * written to this pointer.
724 * On bcma(4) devices, this returns the OOB bus line assigned to the
727 * On siba(4) devices, this returns the target OCP slave flag number assigned
731 * @retval ENXIO If @p intr exceeds the number of interrupts available
735 bhnd_get_core_ivec(device_t dev, u_int intr, uint32_t *ivec)
737 return (BHND_BUS_GET_CORE_IVEC(device_get_parent(dev), dev, intr,
742 * Allocate and enable per-core PMU request handling for @p child.
744 * The region containing the core's PMU register block (if any) must be
745 * allocated via bus_alloc_resource(9) (or bhnd_alloc_resource) before
746 * calling bhnd_alloc_pmu(), and must not be released until after
747 * calling bhnd_release_pmu().
749 * @param dev The parent of @p child.
750 * @param child The requesting bhnd device.
753 * @retval non-zero If allocating PMU request state otherwise fails, a
754 * regular unix error code will be returned.
757 bhnd_alloc_pmu(device_t dev)
759 return (BHND_BUS_ALLOC_PMU(device_get_parent(dev), dev));
763 * Release any per-core PMU resources allocated for @p child. Any outstanding
764 * PMU requests are are discarded.
766 * @param dev The parent of @p child.
767 * @param child The requesting bhnd device.
770 * @retval non-zero If releasing PMU request state otherwise fails, a
771 * regular unix error code will be returned, and
772 * the core state will be left unmodified.
775 bhnd_release_pmu(device_t dev)
777 return (BHND_BUS_RELEASE_PMU(device_get_parent(dev), dev));
781 * Request that @p clock (or faster) be routed to @p dev.
783 * @note A driver must ask the bhnd bus to allocate clock request state
784 * via bhnd_alloc_pmu() before it can request clock resources.
786 * @note Any outstanding PMU clock requests will be discarded upon calling
787 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
789 * @param dev The bhnd(4) device to which @p clock should be routed.
790 * @param clock The requested clock source.
793 * @retval ENODEV If an unsupported clock was requested.
794 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable,
797 bhnd_request_clock(device_t dev, bhnd_clock clock)
799 return (BHND_BUS_REQUEST_CLOCK(device_get_parent(dev), dev, clock));
803 * Request that @p clocks be powered on behalf of @p dev.
805 * This will power any clock sources (e.g. XTAL, PLL, etc) required for
806 * @p clocks and wait until they are ready, discarding any previous
807 * requests by @p dev.
809 * @note A driver must ask the bhnd bus to allocate clock request state
810 * via bhnd_alloc_pmu() before it can request clock resources.
812 * @note Any outstanding PMU clock requests will be discarded upon calling
813 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
815 * @param dev The requesting bhnd(4) device.
816 * @param clocks The clock(s) to be enabled.
819 * @retval ENODEV If an unsupported clock was requested.
820 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable.
823 bhnd_enable_clocks(device_t dev, uint32_t clocks)
825 return (BHND_BUS_ENABLE_CLOCKS(device_get_parent(dev), dev, clocks));
829 * Power up an external PMU-managed resource assigned to @p dev.
831 * @note A driver must ask the bhnd bus to allocate PMU request state
832 * via bhnd_alloc_pmu() before it can request PMU resources.
834 * @note Any outstanding PMU resource requests will be released upon calling
835 * bhnd_reset_hw() or bhnd_suspend_hw().
837 * @param dev The requesting bhnd(4) device.
838 * @param rsrc The core-specific external resource identifier.
841 * @retval ENODEV If the PMU does not support @p rsrc.
842 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable.
845 bhnd_request_ext_rsrc(device_t dev, u_int rsrc)
847 return (BHND_BUS_REQUEST_EXT_RSRC(device_get_parent(dev), dev, rsrc));
851 * Power down an external PMU-managed resource assigned to @p dev.
853 * A driver must ask the bhnd bus to allocate PMU request state
854 * via bhnd_alloc_pmu() before it can request PMU resources.
856 * @param dev The requesting bhnd(4) device.
857 * @param rsrc The core-specific external resource identifier.
860 * @retval ENODEV If the PMU does not support @p rsrc.
861 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable.
864 bhnd_release_ext_rsrc(device_t dev, u_int rsrc)
866 return (BHND_BUS_RELEASE_EXT_RSRC(device_get_parent(dev), dev, rsrc));
870 * Read @p width bytes at @p offset from the bus-specific agent/config
873 * @param dev The bhnd device for which @p offset should be read.
874 * @param offset The offset to be read.
875 * @param[out] value On success, the will be set to the @p width value read
877 * @param width The size of the access. Must be 1, 2 or 4 bytes.
879 * The exact behavior of this method is bus-specific. In the case of
880 * bcma(4), this method provides access to the first agent port of @p child.
882 * @note Device drivers should only use this API for functionality
883 * that is not available via another bhnd(4) function.
886 * @retval EINVAL If @p child is not a direct child of @p dev.
887 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes.
888 * @retval ENODEV If accessing agent/config space for @p child is unsupported.
889 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of
890 * the mapped agent/config space for @p child.
892 static inline uint32_t
893 bhnd_read_config(device_t dev, bus_size_t offset, void *value, u_int width)
895 return (BHND_BUS_READ_CONFIG(device_get_parent(dev), dev, offset,
900 * Write @p width bytes at @p offset to the bus-specific agent/config
903 * @param dev The bhnd device for which @p offset should be read.
904 * @param offset The offset to be written.
905 * @param value A pointer to the value to be written.
906 * @param width The size of @p value. Must be 1, 2 or 4 bytes.
908 * The exact behavior of this method is bus-specific. In the case of
909 * bcma(4), this method provides access to the first agent port of @p child.
911 * @note Device drivers should only use this API for functionality
912 * that is not available via another bhnd(4) function.
915 * @retval EINVAL If @p child is not a direct child of @p dev.
916 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes.
917 * @retval ENODEV If accessing agent/config space for @p child is unsupported.
918 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of
919 * the mapped agent/config space for @p child.
922 bhnd_write_config(device_t dev, bus_size_t offset, const void *value,
925 return (BHND_BUS_WRITE_CONFIG(device_get_parent(dev), dev, offset,
930 * Read an NVRAM variable, coerced to the requested @p type.
932 * @param dev A bhnd bus child device.
933 * @param name The NVRAM variable name.
934 * @param[out] buf A buffer large enough to hold @p len bytes. On
935 * success, the requested value will be written to
936 * this buffer. This argment may be NULL if
937 * the value is not desired.
938 * @param[in,out] len The maximum capacity of @p buf. On success,
939 * will be set to the actual size of the requested
941 * @param type The desired data representation to be written
945 * @retval ENOENT The requested variable was not found.
946 * @retval ENODEV No valid NVRAM source could be found.
947 * @retval ENOMEM If a buffer of @p size is too small to hold the
949 * @retval EOPNOTSUPP If the value cannot be coerced to @p type.
950 * @retval ERANGE If value coercion would overflow @p type.
951 * @retval non-zero If reading @p name otherwise fails, a regular unix
952 * error code will be returned.
955 bhnd_nvram_getvar(device_t dev, const char *name, void *buf, size_t *len,
956 bhnd_nvram_type type)
958 return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), dev, name, buf,
963 * Allocate a resource from a device's parent bhnd(4) bus.
965 * @param dev The device requesting resource ownership.
966 * @param type The type of resource to allocate. This may be any type supported
967 * by the standard bus APIs.
968 * @param rid The bus-specific handle identifying the resource being allocated.
969 * @param start The start address of the resource.
970 * @param end The end address of the resource.
971 * @param count The size of the resource.
972 * @param flags The flags for the resource to be allocated. These may be any
973 * values supported by the standard bus APIs.
975 * To request the resource's default addresses, pass @p start and
976 * @p end values of @c 0 and @c ~0, respectively, and
977 * a @p count of @c 1.
979 * @retval NULL The resource could not be allocated.
980 * @retval resource The allocated resource.
982 static inline struct bhnd_resource *
983 bhnd_alloc_resource(device_t dev, int type, int *rid, rman_res_t start,
984 rman_res_t end, rman_res_t count, u_int flags)
986 return BHND_BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, type, rid,
987 start, end, count, flags);
992 * Allocate a resource from a device's parent bhnd(4) bus, using the
993 * resource's default start, end, and count values.
995 * @param dev The device requesting resource ownership.
996 * @param type The type of resource to allocate. This may be any type supported
997 * by the standard bus APIs.
998 * @param rid The bus-specific handle identifying the resource being allocated.
999 * @param flags The flags for the resource to be allocated. These may be any
1000 * values supported by the standard bus APIs.
1002 * @retval NULL The resource could not be allocated.
1003 * @retval resource The allocated resource.
1005 static inline struct bhnd_resource *
1006 bhnd_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
1008 return bhnd_alloc_resource(dev, type, rid, 0, ~0, 1, flags);
1012 * Activate a previously allocated bhnd resource.
1014 * @param dev The device holding ownership of the allocated resource.
1015 * @param type The type of the resource.
1016 * @param rid The bus-specific handle identifying the resource.
1017 * @param r A pointer to the resource returned by bhnd_alloc_resource or
1018 * BHND_BUS_ALLOC_RESOURCE.
1021 * @retval non-zero an error occurred while activating the resource.
1024 bhnd_activate_resource(device_t dev, int type, int rid,
1025 struct bhnd_resource *r)
1027 return BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev), dev, type,
1032 * Deactivate a previously activated bhnd resource.
1034 * @param dev The device holding ownership of the activated resource.
1035 * @param type The type of the resource.
1036 * @param rid The bus-specific handle identifying the resource.
1037 * @param r A pointer to the resource returned by bhnd_alloc_resource or
1038 * BHND_BUS_ALLOC_RESOURCE.
1041 * @retval non-zero an error occurred while activating the resource.
1044 bhnd_deactivate_resource(device_t dev, int type, int rid,
1045 struct bhnd_resource *r)
1047 return BHND_BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), dev, type,
1052 * Free a resource allocated by bhnd_alloc_resource().
1054 * @param dev The device holding ownership of the resource.
1055 * @param type The type of the resource.
1056 * @param rid The bus-specific handle identifying the resource.
1057 * @param r A pointer to the resource returned by bhnd_alloc_resource or
1058 * BHND_ALLOC_RESOURCE.
1061 * @retval non-zero an error occurred while activating the resource.
1064 bhnd_release_resource(device_t dev, int type, int rid,
1065 struct bhnd_resource *r)
1067 return BHND_BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, type,
1072 * Return true if @p region_num is a valid region on @p port_num of
1073 * @p type attached to @p dev.
1075 * @param dev A bhnd bus child device.
1076 * @param type The port type being queried.
1077 * @param port_num The port number being queried.
1078 * @param region_num The region number being queried.
1081 bhnd_is_region_valid(device_t dev, bhnd_port_type type, u_int port_num,
1084 return (BHND_BUS_IS_REGION_VALID(device_get_parent(dev), dev, type,
1085 port_num, region_num));
1089 * Return the number of ports of type @p type attached to @p def.
1091 * @param dev A bhnd bus child device.
1092 * @param type The port type being queried.
1095 bhnd_get_port_count(device_t dev, bhnd_port_type type) {
1096 return (BHND_BUS_GET_PORT_COUNT(device_get_parent(dev), dev, type));
1100 * Return the number of memory regions mapped to @p child @p port of
1103 * @param dev A bhnd bus child device.
1104 * @param port The port number being queried.
1105 * @param type The port type being queried.
1108 bhnd_get_region_count(device_t dev, bhnd_port_type type, u_int port) {
1109 return (BHND_BUS_GET_REGION_COUNT(device_get_parent(dev), dev, type,
1114 * Return the resource-ID for a memory region on the given device port.
1116 * @param dev A bhnd bus child device.
1117 * @param type The port type.
1118 * @param port The port identifier.
1119 * @param region The identifier of the memory region on @p port.
1121 * @retval int The RID for the given @p port and @p region on @p device.
1122 * @retval -1 No such port/region found.
1125 bhnd_get_port_rid(device_t dev, bhnd_port_type type, u_int port, u_int region)
1127 return BHND_BUS_GET_PORT_RID(device_get_parent(dev), dev, type, port,
1132 * Decode a port / region pair on @p dev defined by @p rid.
1134 * @param dev A bhnd bus child device.
1135 * @param type The resource type.
1136 * @param rid The resource identifier.
1137 * @param[out] port_type The decoded port type.
1138 * @param[out] port The decoded port identifier.
1139 * @param[out] region The decoded region identifier.
1142 * @retval non-zero No matching port/region found.
1145 bhnd_decode_port_rid(device_t dev, int type, int rid, bhnd_port_type *port_type,
1146 u_int *port, u_int *region)
1148 return BHND_BUS_DECODE_PORT_RID(device_get_parent(dev), dev, type, rid,
1149 port_type, port, region);
1153 * Get the address and size of @p region on @p port.
1155 * @param dev A bhnd bus child device.
1156 * @param port_type The port type.
1157 * @param port The port identifier.
1158 * @param region The identifier of the memory region on @p port.
1159 * @param[out] region_addr The region's base address.
1160 * @param[out] region_size The region's size.
1163 * @retval non-zero No matching port/region found.
1166 bhnd_get_region_addr(device_t dev, bhnd_port_type port_type, u_int port,
1167 u_int region, bhnd_addr_t *region_addr, bhnd_size_t *region_size)
1169 return BHND_BUS_GET_REGION_ADDR(device_get_parent(dev), dev, port_type,
1170 port, region, region_addr, region_size);
1174 * bhnd bus-level equivalents of the bus_(read|write|set|barrier|...)
1175 * macros (compatible with bhnd_resource).
1177 * Generated with bhnd/tools/bus_macro.sh
1179 #define bhnd_bus_barrier(r, o, l, f) \
1181 bus_barrier((r)->res, (o), (l), (f)) : \
1183 device_get_parent(rman_get_device((r)->res)), \
1184 rman_get_device((r)->res), (r), (o), (l), (f))
1185 #define bhnd_bus_read_1(r, o) \
1187 bus_read_1((r)->res, (o)) : \
1189 device_get_parent(rman_get_device((r)->res)), \
1190 rman_get_device((r)->res), (r), (o))
1191 #define bhnd_bus_read_multi_1(r, o, d, c) \
1193 bus_read_multi_1((r)->res, (o), (d), (c)) : \
1194 BHND_BUS_READ_MULTI_1( \
1195 device_get_parent(rman_get_device((r)->res)), \
1196 rman_get_device((r)->res), (r), (o), (d), (c))
1197 #define bhnd_bus_read_region_1(r, o, d, c) \
1199 bus_read_region_1((r)->res, (o), (d), (c)) : \
1200 BHND_BUS_READ_REGION_1( \
1201 device_get_parent(rman_get_device((r)->res)), \
1202 rman_get_device((r)->res), (r), (o), (d), (c))
1203 #define bhnd_bus_write_1(r, o, v) \
1205 bus_write_1((r)->res, (o), (v)) : \
1207 device_get_parent(rman_get_device((r)->res)), \
1208 rman_get_device((r)->res), (r), (o), (v))
1209 #define bhnd_bus_write_multi_1(r, o, d, c) \
1211 bus_write_multi_1((r)->res, (o), (d), (c)) : \
1212 BHND_BUS_WRITE_MULTI_1( \
1213 device_get_parent(rman_get_device((r)->res)), \
1214 rman_get_device((r)->res), (r), (o), (d), (c))
1215 #define bhnd_bus_write_region_1(r, o, d, c) \
1217 bus_write_region_1((r)->res, (o), (d), (c)) : \
1218 BHND_BUS_WRITE_REGION_1( \
1219 device_get_parent(rman_get_device((r)->res)), \
1220 rman_get_device((r)->res), (r), (o), (d), (c))
1221 #define bhnd_bus_read_stream_1(r, o) \
1223 bus_read_stream_1((r)->res, (o)) : \
1224 BHND_BUS_READ_STREAM_1( \
1225 device_get_parent(rman_get_device((r)->res)), \
1226 rman_get_device((r)->res), (r), (o))
1227 #define bhnd_bus_read_multi_stream_1(r, o, d, c) \
1229 bus_read_multi_stream_1((r)->res, (o), (d), (c)) : \
1230 BHND_BUS_READ_MULTI_STREAM_1( \
1231 device_get_parent(rman_get_device((r)->res)), \
1232 rman_get_device((r)->res), (r), (o), (d), (c))
1233 #define bhnd_bus_read_region_stream_1(r, o, d, c) \
1235 bus_read_region_stream_1((r)->res, (o), (d), (c)) : \
1236 BHND_BUS_READ_REGION_STREAM_1( \
1237 device_get_parent(rman_get_device((r)->res)), \
1238 rman_get_device((r)->res), (r), (o), (d), (c))
1239 #define bhnd_bus_write_stream_1(r, o, v) \
1241 bus_write_stream_1((r)->res, (o), (v)) : \
1242 BHND_BUS_WRITE_STREAM_1( \
1243 device_get_parent(rman_get_device((r)->res)), \
1244 rman_get_device((r)->res), (r), (o), (v))
1245 #define bhnd_bus_write_multi_stream_1(r, o, d, c) \
1247 bus_write_multi_stream_1((r)->res, (o), (d), (c)) : \
1248 BHND_BUS_WRITE_MULTI_STREAM_1( \
1249 device_get_parent(rman_get_device((r)->res)), \
1250 rman_get_device((r)->res), (r), (o), (d), (c))
1251 #define bhnd_bus_write_region_stream_1(r, o, d, c) \
1253 bus_write_region_stream_1((r)->res, (o), (d), (c)) : \
1254 BHND_BUS_WRITE_REGION_STREAM_1( \
1255 device_get_parent(rman_get_device((r)->res)), \
1256 rman_get_device((r)->res), (r), (o), (d), (c))
1257 #define bhnd_bus_set_multi_1(r, o, v, c) \
1259 bus_set_multi_1((r)->res, (o), (v), (c)) : \
1260 BHND_BUS_SET_MULTI_1( \
1261 device_get_parent(rman_get_device((r)->res)), \
1262 rman_get_device((r)->res), (r), (o), (v), (c))
1263 #define bhnd_bus_set_region_1(r, o, v, c) \
1265 bus_set_region_1((r)->res, (o), (v), (c)) : \
1266 BHND_BUS_SET_REGION_1( \
1267 device_get_parent(rman_get_device((r)->res)), \
1268 rman_get_device((r)->res), (r), (o), (v), (c))
1269 #define bhnd_bus_read_2(r, o) \
1271 bus_read_2((r)->res, (o)) : \
1273 device_get_parent(rman_get_device((r)->res)), \
1274 rman_get_device((r)->res), (r), (o))
1275 #define bhnd_bus_read_multi_2(r, o, d, c) \
1277 bus_read_multi_2((r)->res, (o), (d), (c)) : \
1278 BHND_BUS_READ_MULTI_2( \
1279 device_get_parent(rman_get_device((r)->res)), \
1280 rman_get_device((r)->res), (r), (o), (d), (c))
1281 #define bhnd_bus_read_region_2(r, o, d, c) \
1283 bus_read_region_2((r)->res, (o), (d), (c)) : \
1284 BHND_BUS_READ_REGION_2( \
1285 device_get_parent(rman_get_device((r)->res)), \
1286 rman_get_device((r)->res), (r), (o), (d), (c))
1287 #define bhnd_bus_write_2(r, o, v) \
1289 bus_write_2((r)->res, (o), (v)) : \
1291 device_get_parent(rman_get_device((r)->res)), \
1292 rman_get_device((r)->res), (r), (o), (v))
1293 #define bhnd_bus_write_multi_2(r, o, d, c) \
1295 bus_write_multi_2((r)->res, (o), (d), (c)) : \
1296 BHND_BUS_WRITE_MULTI_2( \
1297 device_get_parent(rman_get_device((r)->res)), \
1298 rman_get_device((r)->res), (r), (o), (d), (c))
1299 #define bhnd_bus_write_region_2(r, o, d, c) \
1301 bus_write_region_2((r)->res, (o), (d), (c)) : \
1302 BHND_BUS_WRITE_REGION_2( \
1303 device_get_parent(rman_get_device((r)->res)), \
1304 rman_get_device((r)->res), (r), (o), (d), (c))
1305 #define bhnd_bus_read_stream_2(r, o) \
1307 bus_read_stream_2((r)->res, (o)) : \
1308 BHND_BUS_READ_STREAM_2( \
1309 device_get_parent(rman_get_device((r)->res)), \
1310 rman_get_device((r)->res), (r), (o))
1311 #define bhnd_bus_read_multi_stream_2(r, o, d, c) \
1313 bus_read_multi_stream_2((r)->res, (o), (d), (c)) : \
1314 BHND_BUS_READ_MULTI_STREAM_2( \
1315 device_get_parent(rman_get_device((r)->res)), \
1316 rman_get_device((r)->res), (r), (o), (d), (c))
1317 #define bhnd_bus_read_region_stream_2(r, o, d, c) \
1319 bus_read_region_stream_2((r)->res, (o), (d), (c)) : \
1320 BHND_BUS_READ_REGION_STREAM_2( \
1321 device_get_parent(rman_get_device((r)->res)), \
1322 rman_get_device((r)->res), (r), (o), (d), (c))
1323 #define bhnd_bus_write_stream_2(r, o, v) \
1325 bus_write_stream_2((r)->res, (o), (v)) : \
1326 BHND_BUS_WRITE_STREAM_2( \
1327 device_get_parent(rman_get_device((r)->res)), \
1328 rman_get_device((r)->res), (r), (o), (v))
1329 #define bhnd_bus_write_multi_stream_2(r, o, d, c) \
1331 bus_write_multi_stream_2((r)->res, (o), (d), (c)) : \
1332 BHND_BUS_WRITE_MULTI_STREAM_2( \
1333 device_get_parent(rman_get_device((r)->res)), \
1334 rman_get_device((r)->res), (r), (o), (d), (c))
1335 #define bhnd_bus_write_region_stream_2(r, o, d, c) \
1337 bus_write_region_stream_2((r)->res, (o), (d), (c)) : \
1338 BHND_BUS_WRITE_REGION_STREAM_2( \
1339 device_get_parent(rman_get_device((r)->res)), \
1340 rman_get_device((r)->res), (r), (o), (d), (c))
1341 #define bhnd_bus_set_multi_2(r, o, v, c) \
1343 bus_set_multi_2((r)->res, (o), (v), (c)) : \
1344 BHND_BUS_SET_MULTI_2( \
1345 device_get_parent(rman_get_device((r)->res)), \
1346 rman_get_device((r)->res), (r), (o), (v), (c))
1347 #define bhnd_bus_set_region_2(r, o, v, c) \
1349 bus_set_region_2((r)->res, (o), (v), (c)) : \
1350 BHND_BUS_SET_REGION_2( \
1351 device_get_parent(rman_get_device((r)->res)), \
1352 rman_get_device((r)->res), (r), (o), (v), (c))
1353 #define bhnd_bus_read_4(r, o) \
1355 bus_read_4((r)->res, (o)) : \
1357 device_get_parent(rman_get_device((r)->res)), \
1358 rman_get_device((r)->res), (r), (o))
1359 #define bhnd_bus_read_multi_4(r, o, d, c) \
1361 bus_read_multi_4((r)->res, (o), (d), (c)) : \
1362 BHND_BUS_READ_MULTI_4( \
1363 device_get_parent(rman_get_device((r)->res)), \
1364 rman_get_device((r)->res), (r), (o), (d), (c))
1365 #define bhnd_bus_read_region_4(r, o, d, c) \
1367 bus_read_region_4((r)->res, (o), (d), (c)) : \
1368 BHND_BUS_READ_REGION_4( \
1369 device_get_parent(rman_get_device((r)->res)), \
1370 rman_get_device((r)->res), (r), (o), (d), (c))
1371 #define bhnd_bus_write_4(r, o, v) \
1373 bus_write_4((r)->res, (o), (v)) : \
1375 device_get_parent(rman_get_device((r)->res)), \
1376 rman_get_device((r)->res), (r), (o), (v))
1377 #define bhnd_bus_write_multi_4(r, o, d, c) \
1379 bus_write_multi_4((r)->res, (o), (d), (c)) : \
1380 BHND_BUS_WRITE_MULTI_4( \
1381 device_get_parent(rman_get_device((r)->res)), \
1382 rman_get_device((r)->res), (r), (o), (d), (c))
1383 #define bhnd_bus_write_region_4(r, o, d, c) \
1385 bus_write_region_4((r)->res, (o), (d), (c)) : \
1386 BHND_BUS_WRITE_REGION_4( \
1387 device_get_parent(rman_get_device((r)->res)), \
1388 rman_get_device((r)->res), (r), (o), (d), (c))
1389 #define bhnd_bus_read_stream_4(r, o) \
1391 bus_read_stream_4((r)->res, (o)) : \
1392 BHND_BUS_READ_STREAM_4( \
1393 device_get_parent(rman_get_device((r)->res)), \
1394 rman_get_device((r)->res), (r), (o))
1395 #define bhnd_bus_read_multi_stream_4(r, o, d, c) \
1397 bus_read_multi_stream_4((r)->res, (o), (d), (c)) : \
1398 BHND_BUS_READ_MULTI_STREAM_4( \
1399 device_get_parent(rman_get_device((r)->res)), \
1400 rman_get_device((r)->res), (r), (o), (d), (c))
1401 #define bhnd_bus_read_region_stream_4(r, o, d, c) \
1403 bus_read_region_stream_4((r)->res, (o), (d), (c)) : \
1404 BHND_BUS_READ_REGION_STREAM_4( \
1405 device_get_parent(rman_get_device((r)->res)), \
1406 rman_get_device((r)->res), (r), (o), (d), (c))
1407 #define bhnd_bus_write_stream_4(r, o, v) \
1409 bus_write_stream_4((r)->res, (o), (v)) : \
1410 BHND_BUS_WRITE_STREAM_4( \
1411 device_get_parent(rman_get_device((r)->res)), \
1412 rman_get_device((r)->res), (r), (o), (v))
1413 #define bhnd_bus_write_multi_stream_4(r, o, d, c) \
1415 bus_write_multi_stream_4((r)->res, (o), (d), (c)) : \
1416 BHND_BUS_WRITE_MULTI_STREAM_4( \
1417 device_get_parent(rman_get_device((r)->res)), \
1418 rman_get_device((r)->res), (r), (o), (d), (c))
1419 #define bhnd_bus_write_region_stream_4(r, o, d, c) \
1421 bus_write_region_stream_4((r)->res, (o), (d), (c)) : \
1422 BHND_BUS_WRITE_REGION_STREAM_4( \
1423 device_get_parent(rman_get_device((r)->res)), \
1424 rman_get_device((r)->res), (r), (o), (d), (c))
1425 #define bhnd_bus_set_multi_4(r, o, v, c) \
1427 bus_set_multi_4((r)->res, (o), (v), (c)) : \
1428 BHND_BUS_SET_MULTI_4( \
1429 device_get_parent(rman_get_device((r)->res)), \
1430 rman_get_device((r)->res), (r), (o), (v), (c))
1431 #define bhnd_bus_set_region_4(r, o, v, c) \
1433 bus_set_region_4((r)->res, (o), (v), (c)) : \
1434 BHND_BUS_SET_REGION_4( \
1435 device_get_parent(rman_get_device((r)->res)), \
1436 rman_get_device((r)->res), (r), (o), (v), (c))
1438 #endif /* _BHND_BHND_H_ */