1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org> 5 * Copyright (c) 2017 The FreeBSD Foundation 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Landon Fuller 9 * under sponsorship from the FreeBSD Foundation. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 19 * redistribution must be conditioned upon including a substantially 20 * similar Disclaimer requirement for further binary redistribution. 21 * 22 * NO WARRANTY 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 26 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 27 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 28 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 31 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 33 * THE POSSIBILITY OF SUCH DAMAGES. 34 * 35 */ 36 37#ifndef _BHND_BHND_H_ 38#define _BHND_BHND_H_ 39 40#include <sys/param.h> 41#include <sys/bus.h> 42#include <sys/lock.h> 43#include <sys/mutex.h> 44 45#include <machine/bus.h> 46 47#include "bhnd_ids.h" 48#include "bhnd_types.h" 49#include "bhnd_erom_types.h" 50#include "bhnd_debug.h" 51#include "bhnd_bus_if.h" 52#include "bhnd_match.h" 53 54#include "nvram/bhnd_nvram.h" 55 56#define BHND_CHIPID_MAX_NAMELEN 32 /**< maximum buffer required for a 57 bhnd_format_chip_id() */ 58 59/** 60 * bhnd child instance variables 61 */ 62enum bhnd_device_vars { 63 BHND_IVAR_VENDOR, /**< Designer's JEP-106 manufacturer ID. */ 64 BHND_IVAR_DEVICE, /**< Part number */ 65 BHND_IVAR_HWREV, /**< Core revision */ 66 BHND_IVAR_DEVICE_CLASS, /**< Core class (@sa bhnd_devclass_t) */ 67 BHND_IVAR_VENDOR_NAME, /**< Core vendor name */ 68 BHND_IVAR_DEVICE_NAME, /**< Core name */ 69 BHND_IVAR_CORE_INDEX, /**< Bus-assigned core number */ 70 BHND_IVAR_CORE_UNIT, /**< Bus-assigned core unit number, 71 assigned sequentially (starting at 0) for 72 each vendor/device pair. */ 73 BHND_IVAR_PMU_INFO, /**< Internal bus-managed PMU state */ 74}; 75 76/** 77 * bhnd device probe priority bands. 78 */ 79enum { 80 BHND_PROBE_ROOT = 0, /**< Nexus or host bridge */ 81 BHND_PROBE_BUS = 1000, /**< Buses and bridges */ 82 BHND_PROBE_CPU = 2000, /**< CPU devices */ 83 BHND_PROBE_INTERRUPT = 3000, /**< Interrupt controllers. */ 84 BHND_PROBE_TIMER = 4000, /**< Timers and clocks. */ 85 BHND_PROBE_RESOURCE = 5000, /**< Resource discovery (including NVRAM/SPROM) */ 86 BHND_PROBE_DEFAULT = 6000, /**< Default device priority */ 87}; 88 89/** 90 * Constants defining fine grained ordering within a BHND_PROBE_* priority band. 91 * 92 * Example: 93 * @code 94 * BHND_PROBE_BUS + BHND_PROBE_ORDER_FIRST 95 * @endcode 96 */ 97enum { 98 BHND_PROBE_ORDER_FIRST = 0, 99 BHND_PROBE_ORDER_EARLY = 25, 100 BHND_PROBE_ORDER_MIDDLE = 50, 101 BHND_PROBE_ORDER_LATE = 75, 102 BHND_PROBE_ORDER_LAST = 100 103 104}; 105 106/** 107 * Per-core IOCTL flags common to all bhnd(4) cores. 108 */ 109enum { 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 120 held in reset. */ 121}; 122 123/** 124 * Per-core IOST flags common to all bhnd(4) cores. 125 */ 126enum { 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. */ 136}; 137 138/* 139 * Simplified accessors for bhnd device ivars 140 */ 141#define BHND_ACCESSOR(var, ivar, type) \ 142 __BUS_ACCESSOR(bhnd, var, BHND, ivar, type) 143 144BHND_ACCESSOR(vendor, VENDOR, uint16_t); 145BHND_ACCESSOR(device, DEVICE, uint16_t); 146BHND_ACCESSOR(hwrev, HWREV, uint8_t); 147BHND_ACCESSOR(class, DEVICE_CLASS, bhnd_devclass_t); 148BHND_ACCESSOR(vendor_name, VENDOR_NAME, const char *); 149BHND_ACCESSOR(device_name, DEVICE_NAME, const char *); 150BHND_ACCESSOR(core_index, CORE_INDEX, u_int); 151BHND_ACCESSOR(core_unit, CORE_UNIT, int); 152BHND_ACCESSOR(pmu_info, PMU_INFO, void *); 153 154#undef BHND_ACCESSOR 155 156/** 157 * A bhnd(4) board descriptor. 158 */ 159struct bhnd_board_info { 160 uint16_t board_vendor; /**< Board vendor (PCI-SIG vendor ID). 161 * 162 * On PCI devices, this will default to 163 * the PCI subsystem vendor ID, but may 164 * be overridden by the 'boardtype' 165 * NVRAM variable. 166 * 167 * On SoCs, this will default to 168 * PCI_VENDOR_BROADCOM, but may be 169 * overridden by the 'boardvendor' 170 * NVRAM variable. 171 */ 172 uint16_t board_type; /**< Board type (See BHND_BOARD_*) 173 * 174 * This value is usually a 175 * Broadcom-assigned reference board 176 * identifier (see BHND_BOARD_*), but 177 * may be set to an arbitrary value 178 * assigned by the board vendor. 179 * 180 * On PCI devices, this will default 181 * to the PCI subsystem ID, but may be 182 * overridden by the 'boardtype' 183 * NVRAM variable. 184 * 185 * On SoCs, this will always be 186 * populated with the value of the 187 * 'boardtype' NVRAM variable. 188 */ 189 uint16_t board_devid; /**< Board device ID. 190 * 191 * On PCI devices, this will default 192 * to the PCI device ID, but may 193 * be overridden by the 'devid' 194 * NVRAM variable. 195 */ 196 uint16_t board_rev; /**< Board revision. */ 197 uint8_t board_srom_rev; /**< Board SROM format revision */ 198 199 uint32_t board_flags; /**< Board flags (see BHND_BFL_*) */ 200 uint32_t board_flags2; /**< Board flags 2 (see BHND_BFL2_*) */ 201 uint32_t board_flags3; /**< Board flags 3 (see BHND_BFL3_*) */ 202}; 203 204/** 205 * Chip Identification 206 * 207 * This is read from the ChipCommon ID register; on earlier bhnd(4) devices 208 * where ChipCommon is unavailable, known values must be supplied. 209 */ 210struct bhnd_chipid { 211 uint16_t chip_id; /**< chip id (BHND_CHIPID_*) */ 212 uint8_t chip_rev; /**< chip revision */ 213 uint8_t chip_pkg; /**< chip package (BHND_PKGID_*) */ 214 uint8_t chip_type; /**< chip type (BHND_CHIPTYPE_*) */ 215 uint32_t chip_caps; /**< chip capabilities (BHND_CAP_*) */ 216 217 bhnd_addr_t enum_addr; /**< chip_type-specific enumeration 218 * address; either the siba(4) base 219 * core register block, or the bcma(4) 220 * EROM core address. */ 221 222 uint8_t ncores; /**< number of cores, if known. 0 if 223 * not available. */ 224}; 225 226/** 227 * Chip capabilities 228 */ 229enum bhnd_cap { 230 BHND_CAP_BP64 = (1<<0), /**< Backplane supports 64-bit 231 * addressing */ 232 BHND_CAP_PMU = (1<<1), /**< PMU is present */ 233}; 234 235/** 236 * A bhnd(4) core descriptor. 237 */ 238struct bhnd_core_info { 239 uint16_t vendor; /**< JEP-106 vendor (BHND_MFGID_*) */ 240 uint16_t device; /**< device */ 241 uint16_t hwrev; /**< hardware revision */ 242 u_int core_idx; /**< bus-assigned core index */ 243 int unit; /**< bus-assigned core unit */ 244}; 245 246/** 247 * bhnd(4) DMA address widths. 248 */ 249typedef enum { 250 BHND_DMA_ADDR_30BIT = 30, /**< 30-bit DMA */ 251 BHND_DMA_ADDR_32BIT = 32, /**< 32-bit DMA */ 252 BHND_DMA_ADDR_64BIT = 64, /**< 64-bit DMA */ 253} bhnd_dma_addrwidth; 254 255/** 256 * Convert an address width (in bits) to its corresponding mask. 257 */ 258#define BHND_DMA_ADDR_BITMASK(_width) \ 259 ((_width >= 64) ? ~0ULL : \ 260 (_width == 0) ? 0x0 : \ 261 ((1ULL << (_width)) - 1)) \ 262 263/** 264 * bhnd(4) DMA address translation descriptor. 265 */ 266struct bhnd_dma_translation { 267 /** 268 * Host-to-device physical address translation. 269 * 270 * This may be added to the host physical address to produce a device 271 * DMA address. 272 */ 273 bhnd_addr_t base_addr; 274 275 /** 276 * Device-addressable address mask. 277 * 278 * This defines the device's DMA address range, excluding any bits 279 * reserved for mapping the address to the base_addr. 280 */ 281 bhnd_addr_t addr_mask; 282 283 /** 284 * Device-addressable extended address mask. 285 * 286 * If a per-core bhnd(4) DMA engine supports the 'addrext' control 287 * field, it can be used to provide address bits excluded by addr_mask. 288 * 289 * Support for DMA extended address changes ��� including coordination 290 * with the core providing DMA translation ��� is handled transparently by 291 * the DMA engine. For example, on PCI(e) Wi-Fi chipsets, the Wi-Fi 292 * core DMA engine will (in effect) update the PCI core's DMA 293 * sbtopcitranslation base address to map the full address prior to 294 * performing a DMA transaction. 295 */ 296 bhnd_addr_t addrext_mask; 297 298 /** 299 * Translation flags (see bhnd_dma_translation_flags). 300 */ 301 uint32_t flags; 302}; 303#define BHND_DMA_TRANSLATION_TABLE_END { 0, 0, 0, 0 } 304 305#define BHND_DMA_IS_TRANSLATION_TABLE_END(_dt) \ 306 ((_dt)->base_addr == 0 && (_dt)->addr_mask == 0 && \ 307 (_dt)->addrext_mask == 0 && (_dt)->flags == 0) 308 309/** 310 * bhnd(4) DMA address translation flags. 311 */ 312enum bhnd_dma_translation_flags { 313 /** 314 * The translation remaps the device's physical address space. 315 * 316 * This is used in conjunction with BHND_DMA_TRANSLATION_BYTESWAPPED to 317 * define a DMA translation that provides byteswapped access to 318 * physical memory on big-endian MIPS SoCs. 319 */ 320 BHND_DMA_TRANSLATION_PHYSMAP = (1<<0), 321 322 /** 323 * Provides a byte-swapped mapping; write requests will be byte-swapped 324 * before being written to memory, and read requests will be 325 * byte-swapped before being returned. 326 * 327 * This is primarily used to perform efficient byte swapping of DMA 328 * data on embedded MIPS SoCs executing in big-endian mode. 329 */ 330 BHND_DMA_TRANSLATION_BYTESWAPPED = (1<<1), 331}; 332 333/** 334* A bhnd(4) bus resource. 335* 336* This provides an abstract interface to per-core resources that may require 337* bus-level remapping of address windows prior to access. 338*/ 339struct bhnd_resource { 340 struct resource *res; /**< the system resource. */ 341 bool direct; /**< false if the resource requires 342 * bus window remapping before it 343 * is MMIO accessible. */ 344}; 345 346/** Wrap the active resource @p _r in a bhnd_resource structure */ 347#define BHND_DIRECT_RESOURCE(_r) ((struct bhnd_resource) { \ 348 .res = (_r), \ 349 .direct = true, \ 350}) 351 352/** 353 * Device quirk table descriptor. 354 */ 355struct bhnd_device_quirk { 356 struct bhnd_device_match desc; /**< device match descriptor */ 357 uint32_t quirks; /**< quirk flags */ 358}; 359 360#define BHND_CORE_QUIRK(_rev, _flags) \ 361 {{ BHND_MATCH_CORE_REV(_rev) }, (_flags) } 362 363#define BHND_CHIP_QUIRK(_chip, _rev, _flags) \ 364 {{ BHND_MATCH_CHIP_IR(BCM ## _chip, _rev) }, (_flags) } 365 366#define BHND_PKG_QUIRK(_chip, _pkg, _flags) \ 367 {{ BHND_MATCH_CHIP_IP(BCM ## _chip, BCM ## _chip ## _pkg) }, (_flags) } 368 369#define BHND_BOARD_QUIRK(_board, _flags) \ 370 {{ BHND_MATCH_BOARD_TYPE(_board) }, \ 371 (_flags) } 372#define BHND_DEVICE_QUIRK_END { { BHND_MATCH_ANY }, 0 } 373#define BHND_DEVICE_QUIRK_IS_END(_q) \ 374 (((_q)->desc.m.match_flags == 0) && (_q)->quirks == 0) 375 376enum { 377 BHND_DF_ANY = 0, 378 BHND_DF_HOSTB = (1<<0), /**< core is serving as the bus' host 379 * bridge. implies BHND_DF_ADAPTER */ 380 BHND_DF_SOC = (1<<1), /**< core is attached to a native 381 bus (BHND_ATTACH_NATIVE) */ 382 BHND_DF_ADAPTER = (1<<2), /**< core is attached to a bridged 383 * adapter (BHND_ATTACH_ADAPTER) */ 384}; 385 386/** Device probe table descriptor */ 387struct bhnd_device { 388 const struct bhnd_device_match core; /**< core match descriptor */ 389 const char *desc; /**< device description, or NULL. */ 390 const struct bhnd_device_quirk *quirks_table; /**< quirks table for this device, or NULL */ 391 uint32_t device_flags; /**< required BHND_DF_* flags */ 392}; 393 394#define _BHND_DEVICE(_vendor, _device, _desc, _quirks, \ 395 _flags, ...) \ 396 { { BHND_MATCH_CORE(BHND_MFGID_ ## _vendor, \ 397 BHND_COREID_ ## _device) }, _desc, _quirks, \ 398 _flags } 399 400#define BHND_DEVICE(_vendor, _device, _desc, _quirks, ...) \ 401 _BHND_DEVICE(_vendor, _device, _desc, _quirks, \ 402 ## __VA_ARGS__, 0) 403#define BHND_DEVICE_END { { BHND_MATCH_ANY }, NULL, NULL, 0 } 404#define BHND_DEVICE_IS_END(_d) \ 405 (BHND_MATCH_IS_ANY(&(_d)->core) && (_d)->desc == NULL) 406 407/** 408 * bhnd device sort order. 409 */ 410typedef enum { 411 BHND_DEVICE_ORDER_ATTACH, /**< sort by bhnd(4) device attach order; 412 child devices should be probed/attached 413 in this order */ 414 BHND_DEVICE_ORDER_DETACH, /**< sort by bhnd(4) device detach order; 415 child devices should be detached, suspended, 416 and shutdown in this order */ 417} bhnd_device_order; 418 419/** 420 * A registry of bhnd service providers. 421 */ 422struct bhnd_service_registry { 423 STAILQ_HEAD(,bhnd_service_entry) entries; /**< registered services */ 424 struct mtx lock; /**< state lock */ 425}; 426 427/** 428 * bhnd service provider flags. 429 */ 430enum { 431 BHND_SPF_INHERITED = (1<<0), /**< service provider reference was inherited from 432 a parent bus, and should be deregistered when the 433 last active reference is released */ 434}; 435 436const char *bhnd_vendor_name(uint16_t vendor); 437const char *bhnd_port_type_name(bhnd_port_type port_type); 438const char *bhnd_nvram_src_name(bhnd_nvram_src nvram_src); 439 440const char *bhnd_find_core_name(uint16_t vendor, 441 uint16_t device); 442bhnd_devclass_t bhnd_find_core_class(uint16_t vendor, 443 uint16_t device); 444 445const char *bhnd_core_name(const struct bhnd_core_info *ci); 446bhnd_devclass_t bhnd_core_class(const struct bhnd_core_info *ci); 447 448int bhnd_format_chip_id(char *buffer, size_t size, 449 uint16_t chip_id); 450 451device_t bhnd_bus_match_child(device_t bus, 452 const struct bhnd_core_match *desc); 453 454device_t bhnd_bus_find_child(device_t bus, 455 bhnd_devclass_t class, int unit); 456 457int bhnd_bus_get_children(device_t bus, 458 device_t **devlistp, int *devcountp, 459 bhnd_device_order order); 460 461void bhnd_bus_free_children(device_t *devlist); 462 463int bhnd_bus_probe_children(device_t bus); 464 465int bhnd_sort_devices(device_t *devlist, 466 size_t devcount, bhnd_device_order order); 467 468device_t bhnd_find_bridge_root(device_t dev, 469 devclass_t bus_class); 470 471const struct bhnd_core_info *bhnd_match_core( 472 const struct bhnd_core_info *cores, 473 u_int num_cores, 474 const struct bhnd_core_match *desc); 475 476const struct bhnd_core_info *bhnd_find_core( 477 const struct bhnd_core_info *cores, 478 u_int num_cores, bhnd_devclass_t class); 479 480struct bhnd_core_match bhnd_core_get_match_desc( 481 const struct bhnd_core_info *core); 482 483bool bhnd_cores_equal( 484 const struct bhnd_core_info *lhs, 485 const struct bhnd_core_info *rhs); 486 487bool bhnd_core_matches( 488 const struct bhnd_core_info *core, 489 const struct bhnd_core_match *desc); 490 491bool bhnd_chip_matches( 492 const struct bhnd_chipid *chipid, 493 const struct bhnd_chip_match *desc); 494 495bool bhnd_board_matches( 496 const struct bhnd_board_info *info, 497 const struct bhnd_board_match *desc); 498 499bool bhnd_hwrev_matches(uint16_t hwrev, 500 const struct bhnd_hwrev_match *desc); 501 502bool bhnd_device_matches(device_t dev, 503 const struct bhnd_device_match *desc); 504 505const struct bhnd_device *bhnd_device_lookup(device_t dev, 506 const struct bhnd_device *table, 507 size_t entry_size); 508 509uint32_t bhnd_device_quirks(device_t dev, 510 const struct bhnd_device *table, 511 size_t entry_size); 512 513struct bhnd_core_info bhnd_get_core_info(device_t dev); 514 515int bhnd_alloc_resources(device_t dev, 516 struct resource_spec *rs, 517 struct bhnd_resource **res); 518 519void bhnd_release_resources(device_t dev, 520 const struct resource_spec *rs, 521 struct bhnd_resource **res); 522 523void bhnd_set_custom_core_desc(device_t dev, 524 const char *name); 525void bhnd_set_default_core_desc(device_t dev); 526 527void bhnd_set_default_bus_desc(device_t dev, 528 const struct bhnd_chipid *chip_id); 529 530int bhnd_nvram_getvar_str(device_t dev, 531 const char *name, char *buf, size_t len, 532 size_t *rlen); 533 534int bhnd_nvram_getvar_uint(device_t dev, 535 const char *name, void *value, int width); 536int bhnd_nvram_getvar_uint8(device_t dev, 537 const char *name, uint8_t *value); 538int bhnd_nvram_getvar_uint16(device_t dev, 539 const char *name, uint16_t *value); 540int bhnd_nvram_getvar_uint32(device_t dev, 541 const char *name, uint32_t *value); 542 543int bhnd_nvram_getvar_int(device_t dev, 544 const char *name, void *value, int width); 545int bhnd_nvram_getvar_int8(device_t dev, 546 const char *name, int8_t *value); 547int bhnd_nvram_getvar_int16(device_t dev, 548 const char *name, int16_t *value); 549int bhnd_nvram_getvar_int32(device_t dev, 550 const char *name, int32_t *value); 551 552int bhnd_nvram_getvar_array(device_t dev, 553 const char *name, void *buf, size_t count, 554 bhnd_nvram_type type); 555 556int bhnd_service_registry_init( 557 struct bhnd_service_registry *bsr); 558int bhnd_service_registry_fini( 559 struct bhnd_service_registry *bsr); 560int bhnd_service_registry_add( 561 struct bhnd_service_registry *bsr, 562 device_t provider, 563 bhnd_service_t service, 564 uint32_t flags); 565int bhnd_service_registry_remove( 566 struct bhnd_service_registry *bsr, 567 device_t provider, 568 bhnd_service_t service); 569device_t bhnd_service_registry_retain( 570 struct bhnd_service_registry *bsr, 571 bhnd_service_t service); 572bool bhnd_service_registry_release( 573 struct bhnd_service_registry *bsr, 574 device_t provider, 575 bhnd_service_t service); 576 577int bhnd_bus_generic_register_provider( 578 device_t dev, device_t child, 579 device_t provider, bhnd_service_t service); 580int bhnd_bus_generic_deregister_provider( 581 device_t dev, device_t child, 582 device_t provider, bhnd_service_t service); 583device_t bhnd_bus_generic_retain_provider(device_t dev, 584 device_t child, bhnd_service_t service); 585void bhnd_bus_generic_release_provider(device_t dev, 586 device_t child, device_t provider, 587 bhnd_service_t service); 588 589int bhnd_bus_generic_sr_register_provider( 590 device_t dev, device_t child, 591 device_t provider, bhnd_service_t service); 592int bhnd_bus_generic_sr_deregister_provider( 593 device_t dev, device_t child, 594 device_t provider, bhnd_service_t service); 595device_t bhnd_bus_generic_sr_retain_provider(device_t dev, 596 device_t child, bhnd_service_t service); 597void bhnd_bus_generic_sr_release_provider(device_t dev, 598 device_t child, device_t provider, 599 bhnd_service_t service); 600 601bool bhnd_bus_generic_is_hw_disabled(device_t dev, 602 device_t child); 603bool bhnd_bus_generic_is_region_valid(device_t dev, 604 device_t child, bhnd_port_type type, 605 u_int port, u_int region); 606int bhnd_bus_generic_get_nvram_var(device_t dev, 607 device_t child, const char *name, 608 void *buf, size_t *size, 609 bhnd_nvram_type type); 610const struct bhnd_chipid *bhnd_bus_generic_get_chipid(device_t dev, 611 device_t child); 612int bhnd_bus_generic_get_dma_translation( 613 device_t dev, device_t child, u_int width, 614 uint32_t flags, bus_dma_tag_t *dmat, 615 struct bhnd_dma_translation *translation); 616int bhnd_bus_generic_read_board_info(device_t dev, 617 device_t child, 618 struct bhnd_board_info *info); 619struct bhnd_resource *bhnd_bus_generic_alloc_resource (device_t dev, 620 device_t child, int type, int *rid, 621 rman_res_t start, rman_res_t end, 622 rman_res_t count, u_int flags); 623int bhnd_bus_generic_release_resource (device_t dev, 624 device_t child, int type, int rid, 625 struct bhnd_resource *r); 626int bhnd_bus_generic_activate_resource (device_t dev, 627 device_t child, int type, int rid, 628 struct bhnd_resource *r); 629int bhnd_bus_generic_deactivate_resource (device_t dev, 630 device_t child, int type, int rid, 631 struct bhnd_resource *r); 632uintptr_t bhnd_bus_generic_get_intr_domain(device_t dev, 633 device_t child, bool self); 634 635/** 636 * Return the bhnd(4) bus driver's device enumeration parser class 637 * 638 * @param driver A bhnd bus driver instance. 639 */ 640static inline bhnd_erom_class_t * 641bhnd_driver_get_erom_class(driver_t *driver) 642{ 643 return (BHND_BUS_GET_EROM_CLASS(driver)); 644} 645 646/** 647 * Return the active host bridge core for the bhnd bus, if any, or NULL if 648 * not found. 649 * 650 * @param dev A bhnd bus device. 651 */ 652static inline device_t 653bhnd_bus_find_hostb_device(device_t dev) { 654 return (BHND_BUS_FIND_HOSTB_DEVICE(dev)); 655} 656 657/** 658 * Register a provider for a given @p service. 659 * 660 * @param dev The device to register as a service provider 661 * with its parent bus. 662 * @param service The service for which @p dev will be registered. 663 * 664 * @retval 0 success 665 * @retval EEXIST if an entry for @p service already exists. 666 * @retval non-zero if registering @p dev otherwise fails, a regular 667 * unix error code will be returned. 668 */ 669static inline int 670bhnd_register_provider(device_t dev, bhnd_service_t service) 671{ 672 return (BHND_BUS_REGISTER_PROVIDER(device_get_parent(dev), dev, dev, 673 service)); 674} 675 676 /** 677 * Attempt to remove a service provider registration for @p dev. 678 * 679 * @param dev The device to be deregistered as a service provider. 680 * @param service The service for which @p dev will be deregistered, or 681 * BHND_SERVICE_INVALID to remove all service registrations 682 * for @p dev. 683 * 684 * @retval 0 success 685 * @retval EBUSY if active references to @p dev exist; @see 686 * bhnd_retain_provider() and bhnd_release_provider(). 687 */ 688static inline int 689bhnd_deregister_provider(device_t dev, bhnd_service_t service) 690{ 691 return (BHND_BUS_DEREGISTER_PROVIDER(device_get_parent(dev), dev, dev, 692 service)); 693} 694 695/** 696 * Retain and return a reference to the registered @p service provider, if any. 697 * 698 * @param dev The requesting device. 699 * @param service The service for which a provider should be returned. 700 * 701 * On success, the caller assumes ownership the returned provider, and 702 * is responsible for releasing this reference via 703 * BHND_BUS_RELEASE_PROVIDER(). 704 * 705 * @retval device_t success 706 * @retval NULL if no provider is registered for @p service. 707 */ 708static inline device_t 709bhnd_retain_provider(device_t dev, bhnd_service_t service) 710{ 711 return (BHND_BUS_RETAIN_PROVIDER(device_get_parent(dev), dev, 712 service)); 713} 714 715/** 716 * Release a reference to a provider device previously returned by 717 * bhnd_retain_provider(). 718 * 719 * @param dev The requesting device. 720 * @param provider The provider to be released. 721 * @param service The service for which @p provider was previously retained. 722 */ 723static inline void 724bhnd_release_provider(device_t dev, device_t provider, 725 bhnd_service_t service) 726{ 727 return (BHND_BUS_RELEASE_PROVIDER(device_get_parent(dev), dev, 728 provider, service)); 729} 730 731/** 732 * Return true if the hardware components required by @p dev are known to be 733 * unpopulated or otherwise unusable. 734 * 735 * In some cases, enumerated devices may have pins that are left floating, or 736 * the hardware may otherwise be non-functional; this method allows a parent 737 * device to explicitly specify if a successfully enumerated @p dev should 738 * be disabled. 739 * 740 * @param dev A bhnd bus child device. 741 */ 742static inline bool 743bhnd_is_hw_disabled(device_t dev) { 744 return (BHND_BUS_IS_HW_DISABLED(device_get_parent(dev), dev)); 745} 746 747/** 748 * Return the BHND chip identification info for the bhnd bus. 749 * 750 * @param dev A bhnd bus child device. 751 */ 752static inline const struct bhnd_chipid * 753bhnd_get_chipid(device_t dev) { 754 return (BHND_BUS_GET_CHIPID(device_get_parent(dev), dev)); 755}; 756 757/** 758 * Read the current value of a bhnd(4) device's per-core I/O control register. 759 * 760 * @param dev The bhnd bus child device to be queried. 761 * @param[out] ioctl On success, the I/O control register value. 762 * 763 * @retval 0 success 764 * @retval EINVAL If @p child is not a direct child of @p dev. 765 * @retval ENODEV If agent/config space for @p child is unavailable. 766 * @retval non-zero If reading the IOCTL register otherwise fails, a regular 767 * unix error code will be returned. 768 */ 769static inline int 770bhnd_read_ioctl(device_t dev, uint16_t *ioctl) 771{ 772 return (BHND_BUS_READ_IOCTL(device_get_parent(dev), dev, ioctl)); 773} 774 775/** 776 * Write @p value and @p mask to a bhnd(4) device's per-core I/O control 777 * register. 778 * 779 * @param dev The bhnd bus child device for which the IOCTL register will be 780 * written. 781 * @param value The value to be written (see BHND_IOCTL_*). 782 * @param mask Only the bits defined by @p mask will be updated from @p value. 783 * 784 * @retval 0 success 785 * @retval EINVAL If @p child is not a direct child of @p dev. 786 * @retval ENODEV If agent/config space for @p child is unavailable. 787 * @retval non-zero If writing the IOCTL register otherwise fails, a regular 788 * unix error code will be returned. 789 */ 790static inline int 791bhnd_write_ioctl(device_t dev, uint16_t value, uint16_t mask) 792{ 793 return (BHND_BUS_WRITE_IOCTL(device_get_parent(dev), dev, value, mask)); 794} 795 796/** 797 * Read the current value of a bhnd(4) device's per-core I/O status register. 798 * 799 * @param dev The bhnd bus child device to be queried. 800 * @param[out] iost On success, the I/O status register value. 801 * 802 * @retval 0 success 803 * @retval EINVAL If @p child is not a direct child of @p dev. 804 * @retval ENODEV If agent/config space for @p child is unavailable. 805 * @retval non-zero If reading the IOST register otherwise fails, a regular 806 * unix error code will be returned. 807 */ 808static inline int 809bhnd_read_iost(device_t dev, uint16_t *iost) 810{ 811 return (BHND_BUS_READ_IOST(device_get_parent(dev), dev, iost)); 812} 813 814/** 815 * Return true if the given bhnd device's hardware is currently held 816 * in a RESET state or otherwise not clocked (BHND_IOCTL_CLK_EN). 817 * 818 * @param dev The device to query. 819 * 820 * @retval true If @p dev is held in RESET or not clocked (BHND_IOCTL_CLK_EN), 821 * or an error occurred determining @p dev's hardware state. 822 * @retval false If @p dev is clocked and is not held in RESET. 823 */ 824static inline bool 825bhnd_is_hw_suspended(device_t dev) 826{ 827 return (BHND_BUS_IS_HW_SUSPENDED(device_get_parent(dev), dev)); 828} 829 830/** 831 * Place the bhnd(4) device's hardware into a low-power RESET state with 832 * the @p reset_ioctl I/O control flags set, and then bring the hardware out of 833 * RESET with the @p ioctl I/O control flags set. 834 * 835 * Any clock or resource PMU requests previously made by @p child will be 836 * invalidated. 837 * 838 * @param dev The device to be reset. 839 * @param ioctl Device-specific I/O control flags to be set when bringing 840 * the core out of its RESET state (see BHND_IOCTL_*). 841 * @param reset_ioctl Device-specific I/O control flags to be set when placing 842 * the core into its RESET state. 843 * 844 * @retval 0 success 845 * @retval non-zero error 846 */ 847static inline int 848bhnd_reset_hw(device_t dev, uint16_t ioctl, uint16_t reset_ioctl) 849{ 850 return (BHND_BUS_RESET_HW(device_get_parent(dev), dev, ioctl, 851 reset_ioctl)); 852} 853 854/** 855 * Suspend @p child's hardware in a low-power reset state. 856 * 857 * Any clock or resource PMU requests previously made by @p dev will be 858 * invalidated. 859 * 860 * The hardware may be brought out of reset via bhnd_reset_hw(). 861 * 862 * @param dev The device to be suspended. 863 * 864 * @retval 0 success 865 * @retval non-zero error 866 */ 867static inline int 868bhnd_suspend_hw(device_t dev, uint16_t ioctl) 869{ 870 return (BHND_BUS_SUSPEND_HW(device_get_parent(dev), dev, ioctl)); 871} 872 873/** 874 * Return the BHND attachment type of the parent bhnd bus. 875 * 876 * @param dev A bhnd bus child device. 877 * 878 * @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter, 879 * such as a WiFi chipset. 880 * @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock, 881 * CPU, etc) to a directly attached native host. 882 */ 883static inline bhnd_attach_type 884bhnd_get_attach_type (device_t dev) { 885 return (BHND_BUS_GET_ATTACH_TYPE(device_get_parent(dev), dev)); 886} 887 888/** 889 * Find the best available DMA address translation capable of mapping a 890 * physical host address to a BHND DMA device address of @p width with 891 * @p flags. 892 * 893 * @param dev A bhnd bus child device. 894 * @param width The address width within which the translation window must 895 * reside (see BHND_DMA_ADDR_*). 896 * @param flags Required translation flags (see BHND_DMA_TRANSLATION_*). 897 * @param[out] dmat On success, will be populated with a DMA tag specifying the 898 * @p translation DMA address restrictions. This argment may be NULL if the DMA 899 * tag is not desired. 900 * the set of valid host DMA addresses reachable via @p translation. 901 * @param[out] translation On success, will be populated with a DMA address 902 * translation descriptor for @p child. This argment may be NULL if the 903 * descriptor is not desired. 904 * 905 * @retval 0 success 906 * @retval ENODEV If DMA is not supported. 907 * @retval ENOENT If no DMA translation matching @p width and @p flags is 908 * available. 909 * @retval non-zero If determining the DMA address translation for @p child 910 * otherwise fails, a regular unix error code will be returned. 911 */ 912static inline int 913bhnd_get_dma_translation(device_t dev, u_int width, uint32_t flags, 914 bus_dma_tag_t *dmat, struct bhnd_dma_translation *translation) 915{ 916 return (BHND_BUS_GET_DMA_TRANSLATION(device_get_parent(dev), dev, width, 917 flags, dmat, translation)); 918} 919 920/** 921 * Attempt to read the BHND board identification from the bhnd bus. 922 * 923 * This relies on NVRAM access, and will fail if a valid NVRAM device cannot 924 * be found, or is not yet attached. 925 * 926 * @param dev The bhnd device requesting board info. 927 * @param[out] info On success, will be populated with the bhnd(4) device's 928 * board information. 929 * 930 * @retval 0 success 931 * @retval ENODEV No valid NVRAM source could be found. 932 * @retval non-zero If reading @p name otherwise fails, a regular unix 933 * error code will be returned. 934 */ 935static inline int 936bhnd_read_board_info(device_t dev, struct bhnd_board_info *info) 937{ 938 return (BHND_BUS_READ_BOARD_INFO(device_get_parent(dev), dev, info)); 939} 940 941/** 942 * Return the number of interrupt lines assigned to @p dev. 943 * 944 * @param dev A bhnd bus child device. 945 */ 946static inline u_int 947bhnd_get_intr_count(device_t dev) 948{ 949 return (BHND_BUS_GET_INTR_COUNT(device_get_parent(dev), dev)); 950} 951 952/** 953 * Get the backplane interrupt vector of the @p intr line attached to @p dev. 954 * 955 * @param dev A bhnd bus child device. 956 * @param intr The index of the interrupt line being queried. 957 * @param[out] ivec On success, the assigned hardware interrupt vector will be 958 * written to this pointer. 959 * 960 * On bcma(4) devices, this returns the OOB bus line assigned to the 961 * interrupt. 962 * 963 * On siba(4) devices, this returns the target OCP slave flag number assigned 964 * to the interrupt. 965 * 966 * @retval 0 success 967 * @retval ENXIO If @p intr exceeds the number of interrupt lines 968 * assigned to @p child. 969 */ 970static inline int 971bhnd_get_intr_ivec(device_t dev, u_int intr, u_int *ivec) 972{ 973 return (BHND_BUS_GET_INTR_IVEC(device_get_parent(dev), dev, intr, 974 ivec)); 975} 976 977/** 978 * Map the given @p intr to an IRQ number; until unmapped, this IRQ may be used 979 * to allocate a resource of type SYS_RES_IRQ. 980 * 981 * On success, the caller assumes ownership of the interrupt mapping, and 982 * is responsible for releasing the mapping via bhnd_unmap_intr(). 983 * 984 * @param dev The requesting device. 985 * @param intr The interrupt being mapped. 986 * @param[out] irq On success, the bus interrupt value mapped for @p intr. 987 * 988 * @retval 0 If an interrupt was assigned. 989 * @retval non-zero If mapping an interrupt otherwise fails, a regular 990 * unix error code will be returned. 991 */ 992static inline int 993bhnd_map_intr(device_t dev, u_int intr, rman_res_t *irq) 994{ 995 return (BHND_BUS_MAP_INTR(device_get_parent(dev), dev, intr, irq)); 996} 997 998/** 999 * Unmap an bus interrupt previously mapped via bhnd_map_intr(). 1000 * 1001 * @param dev The requesting device. 1002 * @param irq The interrupt value being unmapped. 1003 */ 1004static inline void 1005bhnd_unmap_intr(device_t dev, rman_res_t irq) 1006{ 1007 return (BHND_BUS_UNMAP_INTR(device_get_parent(dev), dev, irq)); 1008} 1009 1010/** 1011 * Allocate and enable per-core PMU request handling for @p child. 1012 * 1013 * The region containing the core's PMU register block (if any) must be 1014 * allocated via bus_alloc_resource(9) (or bhnd_alloc_resource) before 1015 * calling bhnd_alloc_pmu(), and must not be released until after 1016 * calling bhnd_release_pmu(). 1017 * 1018 * @param dev The requesting bhnd device. 1019 * 1020 * @retval 0 success 1021 * @retval non-zero If allocating PMU request state otherwise fails, a 1022 * regular unix error code will be returned. 1023 */ 1024static inline int 1025bhnd_alloc_pmu(device_t dev) 1026{ 1027 return (BHND_BUS_ALLOC_PMU(device_get_parent(dev), dev)); 1028} 1029 1030/** 1031 * Release any per-core PMU resources allocated for @p child. Any outstanding 1032 * PMU requests are are discarded. 1033 * 1034 * @param dev The requesting bhnd device. 1035 * 1036 * @retval 0 success 1037 * @retval non-zero If releasing PMU request state otherwise fails, a 1038 * regular unix error code will be returned, and 1039 * the core state will be left unmodified. 1040 */ 1041static inline int 1042bhnd_release_pmu(device_t dev) 1043{ 1044 return (BHND_BUS_RELEASE_PMU(device_get_parent(dev), dev)); 1045} 1046 1047/** 1048 * Return the transition latency required for @p clock in microseconds, if 1049 * known. 1050 * 1051 * The BHND_CLOCK_HT latency value is suitable for use as the D11 core's 1052 * 'fastpwrup_dly' value. 1053 * 1054 * @note A driver must ask the bhnd bus to allocate PMU request state 1055 * via BHND_BUS_ALLOC_PMU() before querying PMU clocks. 1056 * 1057 * @param dev The requesting bhnd device. 1058 * @param clock The clock to be queried for transition latency. 1059 * @param[out] latency On success, the transition latency of @p clock in 1060 * microseconds. 1061 * 1062 * @retval 0 success 1063 * @retval ENODEV If the transition latency for @p clock is not available. 1064 */ 1065static inline int 1066bhnd_get_clock_latency(device_t dev, bhnd_clock clock, u_int *latency) 1067{ 1068 return (BHND_BUS_GET_CLOCK_LATENCY(device_get_parent(dev), dev, clock, 1069 latency)); 1070} 1071 1072/** 1073 * Return the frequency for @p clock in Hz, if known. 1074 * 1075 * @param dev The requesting bhnd device. 1076 * @param clock The clock to be queried. 1077 * @param[out] freq On success, the frequency of @p clock in Hz. 1078 * 1079 * @note A driver must ask the bhnd bus to allocate PMU request state 1080 * via BHND_BUS_ALLOC_PMU() before querying PMU clocks. 1081 * 1082 * @retval 0 success 1083 * @retval ENODEV If the frequency for @p clock is not available. 1084 */ 1085static inline int 1086bhnd_get_clock_freq(device_t dev, bhnd_clock clock, u_int *freq) 1087{ 1088 return (BHND_BUS_GET_CLOCK_FREQ(device_get_parent(dev), dev, clock, 1089 freq)); 1090} 1091 1092/** 1093 * Request that @p clock (or faster) be routed to @p dev. 1094 * 1095 * @note A driver must ask the bhnd bus to allocate clock request state 1096 * via bhnd_alloc_pmu() before it can request clock resources. 1097 * 1098 * @note Any outstanding PMU clock requests will be discarded upon calling 1099 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW(). 1100 * 1101 * @param dev The bhnd(4) device to which @p clock should be routed. 1102 * @param clock The requested clock source. 1103 * 1104 * @retval 0 success 1105 * @retval ENODEV If an unsupported clock was requested. 1106 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable, 1107 */ 1108static inline int 1109bhnd_request_clock(device_t dev, bhnd_clock clock) 1110{ 1111 return (BHND_BUS_REQUEST_CLOCK(device_get_parent(dev), dev, clock)); 1112} 1113 1114/** 1115 * Request that @p clocks be powered on behalf of @p dev. 1116 * 1117 * This will power any clock sources (e.g. XTAL, PLL, etc) required for 1118 * @p clocks and wait until they are ready, discarding any previous 1119 * requests by @p dev. 1120 * 1121 * @note A driver must ask the bhnd bus to allocate clock request state 1122 * via bhnd_alloc_pmu() before it can request clock resources. 1123 * 1124 * @note Any outstanding PMU clock requests will be discarded upon calling 1125 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW(). 1126 * 1127 * @param dev The requesting bhnd(4) device. 1128 * @param clocks The clock(s) to be enabled. 1129 * 1130 * @retval 0 success 1131 * @retval ENODEV If an unsupported clock was requested. 1132 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. 1133 */ 1134static inline int 1135bhnd_enable_clocks(device_t dev, uint32_t clocks) 1136{ 1137 return (BHND_BUS_ENABLE_CLOCKS(device_get_parent(dev), dev, clocks)); 1138} 1139 1140/** 1141 * Power up an external PMU-managed resource assigned to @p dev. 1142 * 1143 * @note A driver must ask the bhnd bus to allocate PMU request state 1144 * via bhnd_alloc_pmu() before it can request PMU resources. 1145 * 1146 * @note Any outstanding PMU resource requests will be released upon calling 1147 * bhnd_reset_hw() or bhnd_suspend_hw(). 1148 * 1149 * @param dev The requesting bhnd(4) device. 1150 * @param rsrc The core-specific external resource identifier. 1151 * 1152 * @retval 0 success 1153 * @retval ENODEV If the PMU does not support @p rsrc. 1154 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. 1155 */ 1156static inline int 1157bhnd_request_ext_rsrc(device_t dev, u_int rsrc) 1158{ 1159 return (BHND_BUS_REQUEST_EXT_RSRC(device_get_parent(dev), dev, rsrc)); 1160} 1161 1162/** 1163 * Power down an external PMU-managed resource assigned to @p dev. 1164 * 1165 * A driver must ask the bhnd bus to allocate PMU request state 1166 * via bhnd_alloc_pmu() before it can request PMU resources. 1167 * 1168 * @param dev The requesting bhnd(4) device. 1169 * @param rsrc The core-specific external resource identifier. 1170 * 1171 * @retval 0 success 1172 * @retval ENODEV If the PMU does not support @p rsrc. 1173 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. 1174 */ 1175static inline int 1176bhnd_release_ext_rsrc(device_t dev, u_int rsrc) 1177{ 1178 return (BHND_BUS_RELEASE_EXT_RSRC(device_get_parent(dev), dev, rsrc)); 1179} 1180 1181/** 1182 * Read @p width bytes at @p offset from the bus-specific agent/config 1183 * space of @p dev. 1184 * 1185 * @param dev The bhnd device for which @p offset should be read. 1186 * @param offset The offset to be read. 1187 * @param[out] value On success, the will be set to the @p width value read 1188 * at @p offset. 1189 * @param width The size of the access. Must be 1, 2 or 4 bytes. 1190 * 1191 * The exact behavior of this method is bus-specific. In the case of 1192 * bcma(4), this method provides access to the first agent port of @p child. 1193 * 1194 * @note Device drivers should only use this API for functionality 1195 * that is not available via another bhnd(4) function. 1196 * 1197 * @retval 0 success 1198 * @retval EINVAL If @p child is not a direct child of @p dev. 1199 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes. 1200 * @retval ENODEV If accessing agent/config space for @p child is unsupported. 1201 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of 1202 * the mapped agent/config space for @p child. 1203 */ 1204static inline uint32_t 1205bhnd_read_config(device_t dev, bus_size_t offset, void *value, u_int width) 1206{ 1207 return (BHND_BUS_READ_CONFIG(device_get_parent(dev), dev, offset, 1208 value, width)); 1209} 1210 1211/** 1212 * Write @p width bytes at @p offset to the bus-specific agent/config 1213 * space of @p dev. 1214 * 1215 * @param dev The bhnd device for which @p offset should be read. 1216 * @param offset The offset to be written. 1217 * @param value A pointer to the value to be written. 1218 * @param width The size of @p value. Must be 1, 2 or 4 bytes. 1219 * 1220 * The exact behavior of this method is bus-specific. In the case of 1221 * bcma(4), this method provides access to the first agent port of @p child. 1222 * 1223 * @note Device drivers should only use this API for functionality 1224 * that is not available via another bhnd(4) function. 1225 * 1226 * @retval 0 success 1227 * @retval EINVAL If @p child is not a direct child of @p dev. 1228 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes. 1229 * @retval ENODEV If accessing agent/config space for @p child is unsupported. 1230 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of 1231 * the mapped agent/config space for @p child. 1232 */ 1233static inline int 1234bhnd_write_config(device_t dev, bus_size_t offset, const void *value, 1235 u_int width) 1236{ 1237 return (BHND_BUS_WRITE_CONFIG(device_get_parent(dev), dev, offset, 1238 value, width)); 1239} 1240 1241/** 1242 * Read an NVRAM variable, coerced to the requested @p type. 1243 * 1244 * @param dev A bhnd bus child device. 1245 * @param name The NVRAM variable name. 1246 * @param[out] buf A buffer large enough to hold @p len bytes. On 1247 * success, the requested value will be written to 1248 * this buffer. This argment may be NULL if 1249 * the value is not desired. 1250 * @param[in,out] len The maximum capacity of @p buf. On success, 1251 * will be set to the actual size of the requested 1252 * value. 1253 * @param type The desired data representation to be written 1254 * to @p buf. 1255 * 1256 * @retval 0 success 1257 * @retval ENOENT The requested variable was not found. 1258 * @retval ENODEV No valid NVRAM source could be found. 1259 * @retval ENOMEM If a buffer of @p size is too small to hold the 1260 * requested value. 1261 * @retval EOPNOTSUPP If the value cannot be coerced to @p type. 1262 * @retval ERANGE If value coercion would overflow @p type. 1263 * @retval non-zero If reading @p name otherwise fails, a regular unix 1264 * error code will be returned. 1265 */ 1266static inline int 1267bhnd_nvram_getvar(device_t dev, const char *name, void *buf, size_t *len, 1268 bhnd_nvram_type type) 1269{ 1270 return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), dev, name, buf, 1271 len, type)); 1272} 1273 1274/** 1275 * Allocate a resource from a device's parent bhnd(4) bus. 1276 * 1277 * @param dev The device requesting resource ownership. 1278 * @param type The type of resource to allocate. This may be any type supported 1279 * by the standard bus APIs. 1280 * @param rid The bus-specific handle identifying the resource being allocated. 1281 * @param start The start address of the resource. 1282 * @param end The end address of the resource. 1283 * @param count The size of the resource. 1284 * @param flags The flags for the resource to be allocated. These may be any 1285 * values supported by the standard bus APIs. 1286 * 1287 * To request the resource's default addresses, pass @p start and 1288 * @p end values of @c 0 and @c ~0, respectively, and 1289 * a @p count of @c 1. 1290 * 1291 * @retval NULL The resource could not be allocated. 1292 * @retval resource The allocated resource. 1293 */ 1294static inline struct bhnd_resource * 1295bhnd_alloc_resource(device_t dev, int type, int *rid, rman_res_t start, 1296 rman_res_t end, rman_res_t count, u_int flags) 1297{ 1298 return BHND_BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, type, rid, 1299 start, end, count, flags); 1300} 1301 1302/** 1303 * Allocate a resource from a device's parent bhnd(4) bus, using the 1304 * resource's default start, end, and count values. 1305 * 1306 * @param dev The device requesting resource ownership. 1307 * @param type The type of resource to allocate. This may be any type supported 1308 * by the standard bus APIs. 1309 * @param rid The bus-specific handle identifying the resource being allocated. 1310 * @param flags The flags for the resource to be allocated. These may be any 1311 * values supported by the standard bus APIs. 1312 * 1313 * @retval NULL The resource could not be allocated. 1314 * @retval resource The allocated resource. 1315 */ 1316static inline struct bhnd_resource * 1317bhnd_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) 1318{ 1319 return bhnd_alloc_resource(dev, type, rid, 0, ~0, 1, flags); 1320} 1321 1322/** 1323 * Activate a previously allocated bhnd resource. 1324 * 1325 * @param dev The device holding ownership of the allocated resource. 1326 * @param type The type of the resource. 1327 * @param rid The bus-specific handle identifying the resource. 1328 * @param r A pointer to the resource returned by bhnd_alloc_resource or 1329 * BHND_BUS_ALLOC_RESOURCE. 1330 * 1331 * @retval 0 success 1332 * @retval non-zero an error occurred while activating the resource. 1333 */ 1334static inline int 1335bhnd_activate_resource(device_t dev, int type, int rid, 1336 struct bhnd_resource *r) 1337{ 1338 return BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev), dev, type, 1339 rid, r); 1340} 1341 1342/** 1343 * Deactivate a previously activated bhnd resource. 1344 * 1345 * @param dev The device holding ownership of the activated resource. 1346 * @param type The type of the resource. 1347 * @param rid The bus-specific handle identifying the resource. 1348 * @param r A pointer to the resource returned by bhnd_alloc_resource or 1349 * BHND_BUS_ALLOC_RESOURCE. 1350 * 1351 * @retval 0 success 1352 * @retval non-zero an error occurred while activating the resource. 1353 */ 1354static inline int 1355bhnd_deactivate_resource(device_t dev, int type, int rid, 1356 struct bhnd_resource *r) 1357{ 1358 return BHND_BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), dev, type, 1359 rid, r); 1360} 1361 1362/** 1363 * Free a resource allocated by bhnd_alloc_resource(). 1364 * 1365 * @param dev The device holding ownership of the resource. 1366 * @param type The type of the resource. 1367 * @param rid The bus-specific handle identifying the resource. 1368 * @param r A pointer to the resource returned by bhnd_alloc_resource or 1369 * BHND_ALLOC_RESOURCE. 1370 * 1371 * @retval 0 success 1372 * @retval non-zero an error occurred while activating the resource. 1373 */ 1374static inline int 1375bhnd_release_resource(device_t dev, int type, int rid, 1376 struct bhnd_resource *r) 1377{ 1378 return BHND_BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, type, 1379 rid, r); 1380} 1381 1382/** 1383 * Return true if @p region_num is a valid region on @p port_num of 1384 * @p type attached to @p dev. 1385 * 1386 * @param dev A bhnd bus child device. 1387 * @param type The port type being queried. 1388 * @param port The port number being queried. 1389 * @param region The region number being queried. 1390 */ 1391static inline bool 1392bhnd_is_region_valid(device_t dev, bhnd_port_type type, u_int port, 1393 u_int region) 1394{ 1395 return (BHND_BUS_IS_REGION_VALID(device_get_parent(dev), dev, type, 1396 port, region)); 1397} 1398 1399/** 1400 * Return the number of ports of type @p type attached to @p def. 1401 * 1402 * @param dev A bhnd bus child device. 1403 * @param type The port type being queried. 1404 */ 1405static inline u_int 1406bhnd_get_port_count(device_t dev, bhnd_port_type type) { 1407 return (BHND_BUS_GET_PORT_COUNT(device_get_parent(dev), dev, type)); 1408} 1409 1410/** 1411 * Return the number of memory regions mapped to @p child @p port of 1412 * type @p type. 1413 * 1414 * @param dev A bhnd bus child device. 1415 * @param port The port number being queried. 1416 * @param type The port type being queried. 1417 */ 1418static inline u_int 1419bhnd_get_region_count(device_t dev, bhnd_port_type type, u_int port) { 1420 return (BHND_BUS_GET_REGION_COUNT(device_get_parent(dev), dev, type, 1421 port)); 1422} 1423 1424/** 1425 * Return the resource-ID for a memory region on the given device port. 1426 * 1427 * @param dev A bhnd bus child device. 1428 * @param type The port type. 1429 * @param port The port identifier. 1430 * @param region The identifier of the memory region on @p port. 1431 * 1432 * @retval int The RID for the given @p port and @p region on @p device. 1433 * @retval -1 No such port/region found. 1434 */ 1435static inline int 1436bhnd_get_port_rid(device_t dev, bhnd_port_type type, u_int port, u_int region) 1437{ 1438 return BHND_BUS_GET_PORT_RID(device_get_parent(dev), dev, type, port, 1439 region); 1440} 1441 1442/** 1443 * Decode a port / region pair on @p dev defined by @p rid. 1444 * 1445 * @param dev A bhnd bus child device. 1446 * @param type The resource type. 1447 * @param rid The resource identifier. 1448 * @param[out] port_type The decoded port type. 1449 * @param[out] port The decoded port identifier. 1450 * @param[out] region The decoded region identifier. 1451 * 1452 * @retval 0 success 1453 * @retval non-zero No matching port/region found. 1454 */ 1455static inline int 1456bhnd_decode_port_rid(device_t dev, int type, int rid, bhnd_port_type *port_type, 1457 u_int *port, u_int *region) 1458{ 1459 return BHND_BUS_DECODE_PORT_RID(device_get_parent(dev), dev, type, rid, 1460 port_type, port, region); 1461} 1462 1463/** 1464 * Get the address and size of @p region on @p port. 1465 * 1466 * @param dev A bhnd bus child device. 1467 * @param port_type The port type. 1468 * @param port The port identifier. 1469 * @param region The identifier of the memory region on @p port. 1470 * @param[out] region_addr The region's base address. 1471 * @param[out] region_size The region's size. 1472 * 1473 * @retval 0 success 1474 * @retval non-zero No matching port/region found. 1475 */ 1476static inline int 1477bhnd_get_region_addr(device_t dev, bhnd_port_type port_type, u_int port, 1478 u_int region, bhnd_addr_t *region_addr, bhnd_size_t *region_size) 1479{ 1480 return BHND_BUS_GET_REGION_ADDR(device_get_parent(dev), dev, port_type, 1481 port, region, region_addr, region_size); 1482} 1483 1484/* 1485 * bhnd bus-level equivalents of the bus_(read|write|set|barrier|...) 1486 * macros (compatible with bhnd_resource). 1487 * 1488 * Generated with bhnd/tools/bus_macro.sh 1489 */ 1490#define bhnd_bus_barrier(r, o, l, f) \ 1491 (((r)->direct) ? \ 1492 bus_barrier((r)->res, (o), (l), (f)) : \ 1493 BHND_BUS_BARRIER( \ 1494 device_get_parent(rman_get_device((r)->res)), \ 1495 rman_get_device((r)->res), (r), (o), (l), (f))) 1496#define bhnd_bus_read_1(r, o) \ 1497 (((r)->direct) ? \ 1498 bus_read_1((r)->res, (o)) : \ 1499 BHND_BUS_READ_1( \ 1500 device_get_parent(rman_get_device((r)->res)), \ 1501 rman_get_device((r)->res), (r), (o))) 1502#define bhnd_bus_read_multi_1(r, o, d, c) \ 1503 (((r)->direct) ? \ 1504 bus_read_multi_1((r)->res, (o), (d), (c)) : \ 1505 BHND_BUS_READ_MULTI_1( \ 1506 device_get_parent(rman_get_device((r)->res)), \ 1507 rman_get_device((r)->res), (r), (o), (d), (c))) 1508#define bhnd_bus_read_region_1(r, o, d, c) \ 1509 (((r)->direct) ? \ 1510 bus_read_region_1((r)->res, (o), (d), (c)) : \ 1511 BHND_BUS_READ_REGION_1( \ 1512 device_get_parent(rman_get_device((r)->res)), \ 1513 rman_get_device((r)->res), (r), (o), (d), (c))) 1514#define bhnd_bus_write_1(r, o, v) \ 1515 (((r)->direct) ? \ 1516 bus_write_1((r)->res, (o), (v)) : \ 1517 BHND_BUS_WRITE_1( \ 1518 device_get_parent(rman_get_device((r)->res)), \ 1519 rman_get_device((r)->res), (r), (o), (v))) 1520#define bhnd_bus_write_multi_1(r, o, d, c) \ 1521 (((r)->direct) ? \ 1522 bus_write_multi_1((r)->res, (o), (d), (c)) : \ 1523 BHND_BUS_WRITE_MULTI_1( \ 1524 device_get_parent(rman_get_device((r)->res)), \ 1525 rman_get_device((r)->res), (r), (o), (d), (c))) 1526#define bhnd_bus_write_region_1(r, o, d, c) \ 1527 (((r)->direct) ? \ 1528 bus_write_region_1((r)->res, (o), (d), (c)) : \ 1529 BHND_BUS_WRITE_REGION_1( \ 1530 device_get_parent(rman_get_device((r)->res)), \ 1531 rman_get_device((r)->res), (r), (o), (d), (c))) 1532#define bhnd_bus_read_stream_1(r, o) \ 1533 (((r)->direct) ? \ 1534 bus_read_stream_1((r)->res, (o)) : \ 1535 BHND_BUS_READ_STREAM_1( \ 1536 device_get_parent(rman_get_device((r)->res)), \ 1537 rman_get_device((r)->res), (r), (o))) 1538#define bhnd_bus_read_multi_stream_1(r, o, d, c) \ 1539 (((r)->direct) ? \ 1540 bus_read_multi_stream_1((r)->res, (o), (d), (c)) : \ 1541 BHND_BUS_READ_MULTI_STREAM_1( \ 1542 device_get_parent(rman_get_device((r)->res)), \ 1543 rman_get_device((r)->res), (r), (o), (d), (c))) 1544#define bhnd_bus_read_region_stream_1(r, o, d, c) \ 1545 (((r)->direct) ? \ 1546 bus_read_region_stream_1((r)->res, (o), (d), (c)) : \ 1547 BHND_BUS_READ_REGION_STREAM_1( \ 1548 device_get_parent(rman_get_device((r)->res)), \ 1549 rman_get_device((r)->res), (r), (o), (d), (c))) 1550#define bhnd_bus_write_stream_1(r, o, v) \ 1551 (((r)->direct) ? \ 1552 bus_write_stream_1((r)->res, (o), (v)) : \ 1553 BHND_BUS_WRITE_STREAM_1( \ 1554 device_get_parent(rman_get_device((r)->res)), \ 1555 rman_get_device((r)->res), (r), (o), (v))) 1556#define bhnd_bus_write_multi_stream_1(r, o, d, c) \ 1557 (((r)->direct) ? \ 1558 bus_write_multi_stream_1((r)->res, (o), (d), (c)) : \ 1559 BHND_BUS_WRITE_MULTI_STREAM_1( \ 1560 device_get_parent(rman_get_device((r)->res)), \ 1561 rman_get_device((r)->res), (r), (o), (d), (c))) 1562#define bhnd_bus_write_region_stream_1(r, o, d, c) \ 1563 (((r)->direct) ? \ 1564 bus_write_region_stream_1((r)->res, (o), (d), (c)) : \ 1565 BHND_BUS_WRITE_REGION_STREAM_1( \ 1566 device_get_parent(rman_get_device((r)->res)), \ 1567 rman_get_device((r)->res), (r), (o), (d), (c))) 1568#define bhnd_bus_set_multi_1(r, o, v, c) \ 1569 (((r)->direct) ? \ 1570 bus_set_multi_1((r)->res, (o), (v), (c)) : \ 1571 BHND_BUS_SET_MULTI_1( \ 1572 device_get_parent(rman_get_device((r)->res)), \ 1573 rman_get_device((r)->res), (r), (o), (v), (c))) 1574#define bhnd_bus_set_region_1(r, o, v, c) \ 1575 (((r)->direct) ? \ 1576 bus_set_region_1((r)->res, (o), (v), (c)) : \ 1577 BHND_BUS_SET_REGION_1( \ 1578 device_get_parent(rman_get_device((r)->res)), \ 1579 rman_get_device((r)->res), (r), (o), (v), (c))) 1580#define bhnd_bus_read_2(r, o) \ 1581 (((r)->direct) ? \ 1582 bus_read_2((r)->res, (o)) : \ 1583 BHND_BUS_READ_2( \ 1584 device_get_parent(rman_get_device((r)->res)), \ 1585 rman_get_device((r)->res), (r), (o))) 1586#define bhnd_bus_read_multi_2(r, o, d, c) \ 1587 (((r)->direct) ? \ 1588 bus_read_multi_2((r)->res, (o), (d), (c)) : \ 1589 BHND_BUS_READ_MULTI_2( \ 1590 device_get_parent(rman_get_device((r)->res)), \ 1591 rman_get_device((r)->res), (r), (o), (d), (c))) 1592#define bhnd_bus_read_region_2(r, o, d, c) \ 1593 (((r)->direct) ? \ 1594 bus_read_region_2((r)->res, (o), (d), (c)) : \ 1595 BHND_BUS_READ_REGION_2( \ 1596 device_get_parent(rman_get_device((r)->res)), \ 1597 rman_get_device((r)->res), (r), (o), (d), (c))) 1598#define bhnd_bus_write_2(r, o, v) \ 1599 (((r)->direct) ? \ 1600 bus_write_2((r)->res, (o), (v)) : \ 1601 BHND_BUS_WRITE_2( \ 1602 device_get_parent(rman_get_device((r)->res)), \ 1603 rman_get_device((r)->res), (r), (o), (v))) 1604#define bhnd_bus_write_multi_2(r, o, d, c) \ 1605 (((r)->direct) ? \ 1606 bus_write_multi_2((r)->res, (o), (d), (c)) : \ 1607 BHND_BUS_WRITE_MULTI_2( \ 1608 device_get_parent(rman_get_device((r)->res)), \ 1609 rman_get_device((r)->res), (r), (o), (d), (c))) 1610#define bhnd_bus_write_region_2(r, o, d, c) \ 1611 (((r)->direct) ? \ 1612 bus_write_region_2((r)->res, (o), (d), (c)) : \ 1613 BHND_BUS_WRITE_REGION_2( \ 1614 device_get_parent(rman_get_device((r)->res)), \ 1615 rman_get_device((r)->res), (r), (o), (d), (c))) 1616#define bhnd_bus_read_stream_2(r, o) \ 1617 (((r)->direct) ? \ 1618 bus_read_stream_2((r)->res, (o)) : \ 1619 BHND_BUS_READ_STREAM_2( \ 1620 device_get_parent(rman_get_device((r)->res)), \ 1621 rman_get_device((r)->res), (r), (o))) 1622#define bhnd_bus_read_multi_stream_2(r, o, d, c) \ 1623 (((r)->direct) ? \ 1624 bus_read_multi_stream_2((r)->res, (o), (d), (c)) : \ 1625 BHND_BUS_READ_MULTI_STREAM_2( \ 1626 device_get_parent(rman_get_device((r)->res)), \ 1627 rman_get_device((r)->res), (r), (o), (d), (c))) 1628#define bhnd_bus_read_region_stream_2(r, o, d, c) \ 1629 (((r)->direct) ? \ 1630 bus_read_region_stream_2((r)->res, (o), (d), (c)) : \ 1631 BHND_BUS_READ_REGION_STREAM_2( \ 1632 device_get_parent(rman_get_device((r)->res)), \ 1633 rman_get_device((r)->res), (r), (o), (d), (c))) 1634#define bhnd_bus_write_stream_2(r, o, v) \ 1635 (((r)->direct) ? \ 1636 bus_write_stream_2((r)->res, (o), (v)) : \ 1637 BHND_BUS_WRITE_STREAM_2( \ 1638 device_get_parent(rman_get_device((r)->res)), \ 1639 rman_get_device((r)->res), (r), (o), (v))) 1640#define bhnd_bus_write_multi_stream_2(r, o, d, c) \ 1641 (((r)->direct) ? \ 1642 bus_write_multi_stream_2((r)->res, (o), (d), (c)) : \ 1643 BHND_BUS_WRITE_MULTI_STREAM_2( \ 1644 device_get_parent(rman_get_device((r)->res)), \ 1645 rman_get_device((r)->res), (r), (o), (d), (c))) 1646#define bhnd_bus_write_region_stream_2(r, o, d, c) \ 1647 (((r)->direct) ? \ 1648 bus_write_region_stream_2((r)->res, (o), (d), (c)) : \ 1649 BHND_BUS_WRITE_REGION_STREAM_2( \ 1650 device_get_parent(rman_get_device((r)->res)), \ 1651 rman_get_device((r)->res), (r), (o), (d), (c))) 1652#define bhnd_bus_set_multi_2(r, o, v, c) \ 1653 (((r)->direct) ? \ 1654 bus_set_multi_2((r)->res, (o), (v), (c)) : \ 1655 BHND_BUS_SET_MULTI_2( \ 1656 device_get_parent(rman_get_device((r)->res)), \ 1657 rman_get_device((r)->res), (r), (o), (v), (c))) 1658#define bhnd_bus_set_region_2(r, o, v, c) \ 1659 (((r)->direct) ? \ 1660 bus_set_region_2((r)->res, (o), (v), (c)) : \ 1661 BHND_BUS_SET_REGION_2( \ 1662 device_get_parent(rman_get_device((r)->res)), \ 1663 rman_get_device((r)->res), (r), (o), (v), (c))) 1664#define bhnd_bus_read_4(r, o) \ 1665 (((r)->direct) ? \ 1666 bus_read_4((r)->res, (o)) : \ 1667 BHND_BUS_READ_4( \ 1668 device_get_parent(rman_get_device((r)->res)), \ 1669 rman_get_device((r)->res), (r), (o))) 1670#define bhnd_bus_read_multi_4(r, o, d, c) \ 1671 (((r)->direct) ? \ 1672 bus_read_multi_4((r)->res, (o), (d), (c)) : \ 1673 BHND_BUS_READ_MULTI_4( \ 1674 device_get_parent(rman_get_device((r)->res)), \ 1675 rman_get_device((r)->res), (r), (o), (d), (c))) 1676#define bhnd_bus_read_region_4(r, o, d, c) \ 1677 (((r)->direct) ? \ 1678 bus_read_region_4((r)->res, (o), (d), (c)) : \ 1679 BHND_BUS_READ_REGION_4( \ 1680 device_get_parent(rman_get_device((r)->res)), \ 1681 rman_get_device((r)->res), (r), (o), (d), (c))) 1682#define bhnd_bus_write_4(r, o, v) \ 1683 (((r)->direct) ? \ 1684 bus_write_4((r)->res, (o), (v)) : \ 1685 BHND_BUS_WRITE_4( \ 1686 device_get_parent(rman_get_device((r)->res)), \ 1687 rman_get_device((r)->res), (r), (o), (v))) 1688#define bhnd_bus_write_multi_4(r, o, d, c) \ 1689 (((r)->direct) ? \ 1690 bus_write_multi_4((r)->res, (o), (d), (c)) : \ 1691 BHND_BUS_WRITE_MULTI_4( \ 1692 device_get_parent(rman_get_device((r)->res)), \ 1693 rman_get_device((r)->res), (r), (o), (d), (c))) 1694#define bhnd_bus_write_region_4(r, o, d, c) \ 1695 (((r)->direct) ? \ 1696 bus_write_region_4((r)->res, (o), (d), (c)) : \ 1697 BHND_BUS_WRITE_REGION_4( \ 1698 device_get_parent(rman_get_device((r)->res)), \ 1699 rman_get_device((r)->res), (r), (o), (d), (c))) 1700#define bhnd_bus_read_stream_4(r, o) \ 1701 (((r)->direct) ? \ 1702 bus_read_stream_4((r)->res, (o)) : \ 1703 BHND_BUS_READ_STREAM_4( \ 1704 device_get_parent(rman_get_device((r)->res)), \ 1705 rman_get_device((r)->res), (r), (o))) 1706#define bhnd_bus_read_multi_stream_4(r, o, d, c) \ 1707 (((r)->direct) ? \ 1708 bus_read_multi_stream_4((r)->res, (o), (d), (c)) : \ 1709 BHND_BUS_READ_MULTI_STREAM_4( \ 1710 device_get_parent(rman_get_device((r)->res)), \ 1711 rman_get_device((r)->res), (r), (o), (d), (c))) 1712#define bhnd_bus_read_region_stream_4(r, o, d, c) \ 1713 (((r)->direct) ? \ 1714 bus_read_region_stream_4((r)->res, (o), (d), (c)) : \ 1715 BHND_BUS_READ_REGION_STREAM_4( \ 1716 device_get_parent(rman_get_device((r)->res)), \ 1717 rman_get_device((r)->res), (r), (o), (d), (c))) 1718#define bhnd_bus_write_stream_4(r, o, v) \ 1719 (((r)->direct) ? \ 1720 bus_write_stream_4((r)->res, (o), (v)) : \ 1721 BHND_BUS_WRITE_STREAM_4( \ 1722 device_get_parent(rman_get_device((r)->res)), \ 1723 rman_get_device((r)->res), (r), (o), (v))) 1724#define bhnd_bus_write_multi_stream_4(r, o, d, c) \ 1725 (((r)->direct) ? \ 1726 bus_write_multi_stream_4((r)->res, (o), (d), (c)) : \ 1727 BHND_BUS_WRITE_MULTI_STREAM_4( \ 1728 device_get_parent(rman_get_device((r)->res)), \ 1729 rman_get_device((r)->res), (r), (o), (d), (c))) 1730#define bhnd_bus_write_region_stream_4(r, o, d, c) \ 1731 (((r)->direct) ? \ 1732 bus_write_region_stream_4((r)->res, (o), (d), (c)) : \ 1733 BHND_BUS_WRITE_REGION_STREAM_4( \ 1734 device_get_parent(rman_get_device((r)->res)), \ 1735 rman_get_device((r)->res), (r), (o), (d), (c))) 1736#define bhnd_bus_set_multi_4(r, o, v, c) \ 1737 (((r)->direct) ? \ 1738 bus_set_multi_4((r)->res, (o), (v), (c)) : \ 1739 BHND_BUS_SET_MULTI_4( \ 1740 device_get_parent(rman_get_device((r)->res)), \ 1741 rman_get_device((r)->res), (r), (o), (v), (c))) 1742#define bhnd_bus_set_region_4(r, o, v, c) \ 1743 (((r)->direct) ? \ 1744 bus_set_region_4((r)->res, (o), (v), (c)) : \ 1745 BHND_BUS_SET_REGION_4( \ 1746 device_get_parent(rman_get_device((r)->res)), \ 1747 rman_get_device((r)->res), (r), (o), (v), (c))) 1748 1749#endif /* _BHND_BHND_H_ */ 1750