1 /*- 2 * Copyright (c) 2015 Landon Fuller <landon@landonf.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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. 15 * 16 * NO WARRANTY 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. 28 * 29 * $FreeBSD$ 30 */ 31 32 #ifndef _BHND_BHND_H_ 33 #define _BHND_BHND_H_ 34 35 #include <sys/types.h> 36 #include <sys/bus.h> 37 38 #include <machine/bus.h> 39 40 #include "bhnd_ids.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" 46 47 #include "nvram/bhnd_nvram.h" 48 49 extern devclass_t bhnd_devclass; 50 extern devclass_t bhnd_hostb_devclass; 51 extern devclass_t bhnd_nvram_devclass; 52 53 #define BHND_CHIPID_MAX_NAMELEN 32 /**< maximum buffer required for a 54 bhnd_format_chip_id() */ 55 56 /** 57 * bhnd child instance variables 58 */ 59 enum bhnd_device_vars { 60 BHND_IVAR_VENDOR, /**< Designer's JEP-106 manufacturer ID. */ 61 BHND_IVAR_DEVICE, /**< Part number */ 62 BHND_IVAR_HWREV, /**< Core revision */ 63 BHND_IVAR_DEVICE_CLASS, /**< Core class (@sa bhnd_devclass_t) */ 64 BHND_IVAR_VENDOR_NAME, /**< Core vendor name */ 65 BHND_IVAR_DEVICE_NAME, /**< Core name */ 66 BHND_IVAR_CORE_INDEX, /**< Bus-assigned core number */ 67 BHND_IVAR_CORE_UNIT, /**< Bus-assigned core unit number, 68 assigned sequentially (starting at 0) for 69 each vendor/device pair. */ 70 }; 71 72 /** 73 * bhnd device probe priority bands. 74 */ 75 enum { 76 BHND_PROBE_ROOT = 0, /**< Nexus or host bridge */ 77 BHND_PROBE_BUS = 1000, /**< Busses and bridges */ 78 BHND_PROBE_CPU = 2000, /**< CPU devices */ 79 BHND_PROBE_INTERRUPT = 3000, /**< Interrupt controllers. */ 80 BHND_PROBE_TIMER = 4000, /**< Timers and clocks. */ 81 BHND_PROBE_RESOURCE = 5000, /**< Resource discovery (including NVRAM/SPROM) */ 82 BHND_PROBE_DEFAULT = 6000, /**< Default device priority */ 83 }; 84 85 /** 86 * Constants defining fine grained ordering within a BHND_PROBE_* priority band. 87 * 88 * Example: 89 * @code 90 * BHND_PROBE_BUS + BHND_PROBE_ORDER_FIRST 91 * @endcode 92 */ 93 enum { 94 BHND_PROBE_ORDER_FIRST = 0, 95 BHND_PROBE_ORDER_EARLY = 25, 96 BHND_PROBE_ORDER_MIDDLE = 50, 97 BHND_PROBE_ORDER_LATE = 75, 98 BHND_PROBE_ORDER_LAST = 100 99 100 }; 101 102 /* 103 * Simplified accessors for bhnd device ivars 104 */ 105 #define BHND_ACCESSOR(var, ivar, type) \ 106 __BUS_ACCESSOR(bhnd, var, BHND, ivar, type) 107 108 BHND_ACCESSOR(vendor, VENDOR, uint16_t); 109 BHND_ACCESSOR(device, DEVICE, uint16_t); 110 BHND_ACCESSOR(hwrev, HWREV, uint8_t); 111 BHND_ACCESSOR(class, DEVICE_CLASS, bhnd_devclass_t); 112 BHND_ACCESSOR(vendor_name, VENDOR_NAME, const char *); 113 BHND_ACCESSOR(device_name, DEVICE_NAME, const char *); 114 BHND_ACCESSOR(core_index, CORE_INDEX, u_int); 115 BHND_ACCESSOR(core_unit, CORE_UNIT, int); 116 117 #undef BHND_ACCESSOR 118 119 /** 120 * A bhnd(4) board descriptor. 121 */ 122 struct bhnd_board_info { 123 uint16_t board_vendor; /**< PCI-SIG vendor ID (even on non-PCI 124 * devices). 125 * 126 * On PCI devices, this will generally 127 * be the subsystem vendor ID, but the 128 * value may be overridden in device 129 * NVRAM. 130 */ 131 uint16_t board_type; /**< Board type (See BHND_BOARD_*) 132 * 133 * On PCI devices, this will generally 134 * be the subsystem device ID, but the 135 * value may be overridden in device 136 * NVRAM. 137 */ 138 uint16_t board_rev; /**< Board revision. */ 139 uint8_t board_srom_rev; /**< Board SROM format revision */ 140 141 uint32_t board_flags; /**< Board flags (see BHND_BFL_*) */ 142 uint32_t board_flags2; /**< Board flags 2 (see BHND_BFL2_*) */ 143 uint32_t board_flags3; /**< Board flags 3 (see BHND_BFL3_*) */ 144 }; 145 146 147 /** 148 * Chip Identification 149 * 150 * This is read from the ChipCommon ID register; on earlier bhnd(4) devices 151 * where ChipCommon is unavailable, known values must be supplied. 152 */ 153 struct bhnd_chipid { 154 uint16_t chip_id; /**< chip id (BHND_CHIPID_*) */ 155 uint8_t chip_rev; /**< chip revision */ 156 uint8_t chip_pkg; /**< chip package (BHND_PKGID_*) */ 157 uint8_t chip_type; /**< chip type (BHND_CHIPTYPE_*) */ 158 159 bhnd_addr_t enum_addr; /**< chip_type-specific enumeration 160 * address; either the siba(4) base 161 * core register block, or the bcma(4) 162 * EROM core address. */ 163 164 uint8_t ncores; /**< number of cores, if known. 0 if 165 * not available. */ 166 }; 167 168 /** 169 * A bhnd(4) core descriptor. 170 */ 171 struct bhnd_core_info { 172 uint16_t vendor; /**< JEP-106 vendor (BHND_MFGID_*) */ 173 uint16_t device; /**< device */ 174 uint16_t hwrev; /**< hardware revision */ 175 u_int core_idx; /**< bus-assigned core index */ 176 int unit; /**< bus-assigned core unit */ 177 }; 178 179 /** 180 * A bhnd(4) bus resource. 181 * 182 * This provides an abstract interface to per-core resources that may require 183 * bus-level remapping of address windows prior to access. 184 */ 185 struct bhnd_resource { 186 struct resource *res; /**< the system resource. */ 187 bool direct; /**< false if the resource requires 188 * bus window remapping before it 189 * is MMIO accessible. */ 190 }; 191 192 /** Wrap the active resource @p _r in a bhnd_resource structure */ 193 #define BHND_DIRECT_RESOURCE(_r) ((struct bhnd_resource) { \ 194 .res = (_r), \ 195 .direct = true, \ 196 }) 197 198 /** 199 * Device quirk table descriptor. 200 */ 201 struct bhnd_device_quirk { 202 struct bhnd_device_match desc; /**< device match descriptor */ 203 uint32_t quirks; /**< quirk flags */ 204 }; 205 206 #define BHND_CORE_QUIRK(_rev, _flags) \ 207 {{ BHND_MATCH_CORE_REV(_rev) }, (_flags) } 208 209 #define BHND_CHIP_QUIRK(_chip, _rev, _flags) \ 210 {{ BHND_CHIP_IR(BCM ## _chip, _rev) }, (_flags) } 211 212 #define BHND_PKG_QUIRK(_chip, _pkg, _flags) \ 213 {{ BHND_CHIP_IP(BCM ## _chip, BCM ## _chip ## _pkg) }, (_flags) } 214 215 #define BHND_BOARD_QUIRK(_board, _flags) \ 216 {{ BHND_MATCH_BOARD_TYPE(_board) }, \ 217 (_flags) } 218 219 #define BHND_DEVICE_QUIRK_END { { BHND_MATCH_ANY }, 0 } 220 #define BHND_DEVICE_QUIRK_IS_END(_q) \ 221 (((_q)->desc.m.match_flags == 0) && (_q)->quirks == 0) 222 223 enum { 224 BHND_DF_ANY = 0, 225 BHND_DF_HOSTB = (1<<0), /**< core is serving as the bus' host 226 * bridge. implies BHND_DF_ADAPTER */ 227 BHND_DF_SOC = (1<<1), /**< core is attached to a native 228 bus (BHND_ATTACH_NATIVE) */ 229 BHND_DF_ADAPTER = (1<<2), /**< core is attached to a bridged 230 * adapter (BHND_ATTACH_ADAPTER) */ 231 }; 232 233 /** Device probe table descriptor */ 234 struct bhnd_device { 235 const struct bhnd_device_match core; /**< core match descriptor */ 236 const char *desc; /**< device description, or NULL. */ 237 const struct bhnd_device_quirk *quirks_table; /**< quirks table for this device, or NULL */ 238 uint32_t device_flags; /**< required BHND_DF_* flags */ 239 }; 240 241 #define _BHND_DEVICE(_vendor, _device, _desc, _quirks, \ 242 _flags, ...) \ 243 { { BHND_MATCH_CORE(BHND_MFGID_ ## _vendor, \ 244 BHND_COREID_ ## _device) }, _desc, _quirks, \ 245 _flags } 246 247 #define BHND_DEVICE(_vendor, _device, _desc, _quirks, ...) \ 248 _BHND_DEVICE(_vendor, _device, _desc, _quirks, \ 249 ## __VA_ARGS__, 0) 250 251 #define BHND_DEVICE_END { { BHND_MATCH_ANY }, NULL, NULL, 0 } 252 #define BHND_DEVICE_IS_END(_d) \ 253 (BHND_MATCH_IS_ANY(&(_d)->core) && (_d)->desc == NULL) 254 255 const char *bhnd_vendor_name(uint16_t vendor); 256 const char *bhnd_port_type_name(bhnd_port_type port_type); 257 const char *bhnd_nvram_src_name(bhnd_nvram_src nvram_src); 258 259 const char *bhnd_find_core_name(uint16_t vendor, 260 uint16_t device); 261 bhnd_devclass_t bhnd_find_core_class(uint16_t vendor, 262 uint16_t device); 263 264 const char *bhnd_core_name(const struct bhnd_core_info *ci); 265 bhnd_devclass_t bhnd_core_class(const struct bhnd_core_info *ci); 266 267 int bhnd_format_chip_id(char *buffer, size_t size, 268 uint16_t chip_id); 269 270 device_t bhnd_match_child(device_t dev, 271 const struct bhnd_core_match *desc); 272 273 device_t bhnd_find_child(device_t dev, 274 bhnd_devclass_t class, int unit); 275 276 device_t bhnd_find_bridge_root(device_t dev, 277 devclass_t bus_class); 278 279 const struct bhnd_core_info *bhnd_match_core( 280 const struct bhnd_core_info *cores, 281 u_int num_cores, 282 const struct bhnd_core_match *desc); 283 284 const struct bhnd_core_info *bhnd_find_core( 285 const struct bhnd_core_info *cores, 286 u_int num_cores, bhnd_devclass_t class); 287 288 struct bhnd_core_match bhnd_core_get_match_desc( 289 const struct bhnd_core_info *core); 290 291 bool bhnd_cores_equal( 292 const struct bhnd_core_info *lhs, 293 const struct bhnd_core_info *rhs); 294 295 bool bhnd_core_matches( 296 const struct bhnd_core_info *core, 297 const struct bhnd_core_match *desc); 298 299 bool bhnd_chip_matches( 300 const struct bhnd_chipid *chipid, 301 const struct bhnd_chip_match *desc); 302 303 bool bhnd_board_matches( 304 const struct bhnd_board_info *info, 305 const struct bhnd_board_match *desc); 306 307 bool bhnd_hwrev_matches(uint16_t hwrev, 308 const struct bhnd_hwrev_match *desc); 309 310 bool bhnd_device_matches(device_t dev, 311 const struct bhnd_device_match *desc); 312 313 const struct bhnd_device *bhnd_device_lookup(device_t dev, 314 const struct bhnd_device *table, 315 size_t entry_size); 316 317 uint32_t bhnd_device_quirks(device_t dev, 318 const struct bhnd_device *table, 319 size_t entry_size); 320 321 struct bhnd_core_info bhnd_get_core_info(device_t dev); 322 323 int bhnd_alloc_resources(device_t dev, 324 struct resource_spec *rs, 325 struct bhnd_resource **res); 326 327 void bhnd_release_resources(device_t dev, 328 const struct resource_spec *rs, 329 struct bhnd_resource **res); 330 331 struct bhnd_chipid bhnd_parse_chipid(uint32_t idreg, 332 bhnd_addr_t enum_addr); 333 334 int bhnd_chipid_fixed_ncores( 335 const struct bhnd_chipid *cid, 336 uint16_t chipc_hwrev, uint8_t *ncores); 337 338 int bhnd_read_chipid(device_t dev, 339 struct resource_spec *rs, 340 bus_size_t chipc_offset, 341 struct bhnd_chipid *result); 342 343 void bhnd_set_custom_core_desc(device_t dev, 344 const char *name); 345 void bhnd_set_default_core_desc(device_t dev); 346 347 void bhnd_set_default_bus_desc(device_t dev, 348 const struct bhnd_chipid *chip_id); 349 350 int bhnd_nvram_getvar_str(device_t dev, 351 const char *name, char *buf, size_t len, 352 size_t *rlen); 353 354 int bhnd_nvram_getvar_uint(device_t dev, 355 const char *name, void *value, int width); 356 int bhnd_nvram_getvar_uint8(device_t dev, 357 const char *name, uint8_t *value); 358 int bhnd_nvram_getvar_uint16(device_t dev, 359 const char *name, uint16_t *value); 360 int bhnd_nvram_getvar_uint32(device_t dev, 361 const char *name, uint32_t *value); 362 363 int bhnd_nvram_getvar_int(device_t dev, 364 const char *name, void *value, int width); 365 int bhnd_nvram_getvar_int8(device_t dev, 366 const char *name, int8_t *value); 367 int bhnd_nvram_getvar_int16(device_t dev, 368 const char *name, int16_t *value); 369 int bhnd_nvram_getvar_int32(device_t dev, 370 const char *name, int32_t *value); 371 372 int bhnd_nvram_getvar_array(device_t dev, 373 const char *name, void *buf, size_t count, 374 bhnd_nvram_type type); 375 376 bool bhnd_bus_generic_is_hw_disabled(device_t dev, 377 device_t child); 378 bool bhnd_bus_generic_is_region_valid(device_t dev, 379 device_t child, bhnd_port_type type, 380 u_int port, u_int region); 381 int bhnd_bus_generic_get_nvram_var(device_t dev, 382 device_t child, const char *name, 383 void *buf, size_t *size, 384 bhnd_nvram_type type); 385 const struct bhnd_chipid *bhnd_bus_generic_get_chipid(device_t dev, 386 device_t child); 387 int bhnd_bus_generic_read_board_info(device_t dev, 388 device_t child, 389 struct bhnd_board_info *info); 390 struct bhnd_resource *bhnd_bus_generic_alloc_resource (device_t dev, 391 device_t child, int type, int *rid, 392 rman_res_t start, rman_res_t end, 393 rman_res_t count, u_int flags); 394 int bhnd_bus_generic_release_resource (device_t dev, 395 device_t child, int type, int rid, 396 struct bhnd_resource *r); 397 int bhnd_bus_generic_activate_resource (device_t dev, 398 device_t child, int type, int rid, 399 struct bhnd_resource *r); 400 int bhnd_bus_generic_deactivate_resource (device_t dev, 401 device_t child, int type, int rid, 402 struct bhnd_resource *r); 403 bhnd_attach_type bhnd_bus_generic_get_attach_type(device_t dev, 404 device_t child); 405 406 /** 407 * Return the bhnd(4) bus driver's device enumeration parser class 408 * 409 * @param driver A bhnd bus driver instance. 410 */ 411 static inline bhnd_erom_class_t * 412 bhnd_driver_get_erom_class(driver_t *driver) 413 { 414 return (BHND_BUS_GET_EROM_CLASS(driver)); 415 } 416 417 /** 418 * Return the active host bridge core for the bhnd bus, if any, or NULL if 419 * not found. 420 * 421 * @param dev A bhnd bus device. 422 */ 423 static inline device_t 424 bhnd_find_hostb_device(device_t dev) { 425 return (BHND_BUS_FIND_HOSTB_DEVICE(dev)); 426 } 427 428 /** 429 * Return true if the hardware components required by @p dev are known to be 430 * unpopulated or otherwise unusable. 431 * 432 * In some cases, enumerated devices may have pins that are left floating, or 433 * the hardware may otherwise be non-functional; this method allows a parent 434 * device to explicitly specify if a successfully enumerated @p dev should 435 * be disabled. 436 * 437 * @param dev A bhnd bus child device. 438 */ 439 static inline bool 440 bhnd_is_hw_disabled(device_t dev) { 441 return (BHND_BUS_IS_HW_DISABLED(device_get_parent(dev), dev)); 442 } 443 444 /** 445 * Return the BHND chip identification info for the bhnd bus. 446 * 447 * @param dev A bhnd bus child device. 448 */ 449 static inline const struct bhnd_chipid * 450 bhnd_get_chipid(device_t dev) { 451 return (BHND_BUS_GET_CHIPID(device_get_parent(dev), dev)); 452 }; 453 454 /** 455 * If supported by the chipset, return the clock source for the given clock. 456 * 457 * This function is only supported on early PWRCTL-equipped chipsets 458 * that expose clock management via their host bridge interface. Currently, 459 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9. 460 * 461 * @param dev A bhnd bus child device. 462 * @param clock The clock for which a clock source will be returned. 463 * 464 * @retval bhnd_clksrc The clock source for @p clock. 465 * @retval BHND_CLKSRC_UNKNOWN If @p clock is unsupported, or its 466 * clock source is not known to the bus. 467 */ 468 static inline bhnd_clksrc 469 bhnd_pwrctl_get_clksrc(device_t dev, bhnd_clock clock) 470 { 471 return (BHND_BUS_PWRCTL_GET_CLKSRC(device_get_parent(dev), dev, clock)); 472 } 473 474 /** 475 * If supported by the chipset, gate @p clock 476 * 477 * This function is only supported on early PWRCTL-equipped chipsets 478 * that expose clock management via their host bridge interface. Currently, 479 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9. 480 * 481 * @param dev A bhnd bus child device. 482 * @param clock The clock to be disabled. 483 * 484 * @retval 0 success 485 * @retval ENODEV If bus-level clock source management is not supported. 486 * @retval ENXIO If bus-level management of @p clock is not supported. 487 */ 488 static inline int 489 bhnd_pwrctl_gate_clock(device_t dev, bhnd_clock clock) 490 { 491 return (BHND_BUS_PWRCTL_GATE_CLOCK(device_get_parent(dev), dev, clock)); 492 } 493 494 /** 495 * If supported by the chipset, ungate @p clock 496 * 497 * This function is only supported on early PWRCTL-equipped chipsets 498 * that expose clock management via their host bridge interface. Currently, 499 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9. 500 * 501 * @param dev A bhnd bus child device. 502 * @param clock The clock to be enabled. 503 * 504 * @retval 0 success 505 * @retval ENODEV If bus-level clock source management is not supported. 506 * @retval ENXIO If bus-level management of @p clock is not supported. 507 */ 508 static inline int 509 bhnd_pwrctl_ungate_clock(device_t dev, bhnd_clock clock) 510 { 511 return (BHND_BUS_PWRCTL_UNGATE_CLOCK(device_get_parent(dev), dev, 512 clock)); 513 } 514 515 /** 516 * Return the BHND attachment type of the parent bhnd bus. 517 * 518 * @param dev A bhnd bus child device. 519 * 520 * @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter, 521 * such as a WiFi chipset. 522 * @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock, 523 * CPU, etc) to a directly attached native host. 524 */ 525 static inline bhnd_attach_type 526 bhnd_get_attach_type (device_t dev) { 527 return (BHND_BUS_GET_ATTACH_TYPE(device_get_parent(dev), dev)); 528 } 529 530 /** 531 * Attempt to read the BHND board identification from the bhnd bus. 532 * 533 * This relies on NVRAM access, and will fail if a valid NVRAM device cannot 534 * be found, or is not yet attached. 535 * 536 * @param dev The parent of @p child. 537 * @param child The bhnd device requesting board info. 538 * @param[out] info On success, will be populated with the bhnd(4) device's 539 * board information. 540 * 541 * @retval 0 success 542 * @retval ENODEV No valid NVRAM source could be found. 543 * @retval non-zero If reading @p name otherwise fails, a regular unix 544 * error code will be returned. 545 */ 546 static inline int 547 bhnd_read_board_info(device_t dev, struct bhnd_board_info *info) 548 { 549 return (BHND_BUS_READ_BOARD_INFO(device_get_parent(dev), dev, info)); 550 } 551 552 /** 553 * Return the number of interrupts to be assigned to @p child via 554 * BHND_BUS_ASSIGN_INTR(). 555 * 556 * @param dev A bhnd bus child device. 557 */ 558 static inline int 559 bhnd_get_intr_count(device_t dev) 560 { 561 return (BHND_BUS_GET_INTR_COUNT(device_get_parent(dev), dev)); 562 } 563 564 /** 565 * Return the backplane interrupt vector corresponding to @p dev's given 566 * @p intr number. 567 * 568 * @param dev A bhnd bus child device. 569 * @param intr The interrupt number being queried. This is equivalent to the 570 * bus resource ID for the interrupt. 571 * @param[out] ivec On success, the assigned hardware interrupt vector be 572 * written to this pointer. 573 * 574 * On bcma(4) devices, this returns the OOB bus line assigned to the 575 * interrupt. 576 * 577 * On siba(4) devices, this returns the target OCP slave flag number assigned 578 * to the interrupt. 579 * 580 * @retval 0 success 581 * @retval ENXIO If @p intr exceeds the number of interrupts available 582 * to @p child. 583 */ 584 static inline int 585 bhnd_get_core_ivec(device_t dev, u_int intr, uint32_t *ivec) 586 { 587 return (BHND_BUS_GET_CORE_IVEC(device_get_parent(dev), dev, intr, 588 ivec)); 589 } 590 591 /** 592 * Allocate and enable per-core PMU request handling for @p child. 593 * 594 * The region containing the core's PMU register block (if any) must be 595 * allocated via bus_alloc_resource(9) (or bhnd_alloc_resource) before 596 * calling bhnd_alloc_pmu(), and must not be released until after 597 * calling bhnd_release_pmu(). 598 * 599 * @param dev The parent of @p child. 600 * @param child The requesting bhnd device. 601 * 602 * @retval 0 success 603 * @retval non-zero If allocating PMU request state otherwise fails, a 604 * regular unix error code will be returned. 605 */ 606 static inline int 607 bhnd_alloc_pmu(device_t dev) 608 { 609 return (BHND_BUS_ALLOC_PMU(device_get_parent(dev), dev)); 610 } 611 612 /** 613 * Release any per-core PMU resources allocated for @p child. Any outstanding 614 * PMU requests are are discarded. 615 * 616 * @param dev The parent of @p child. 617 * @param child The requesting bhnd device. 618 * 619 * @retval 0 success 620 * @retval non-zero If releasing PMU request state otherwise fails, a 621 * regular unix error code will be returned, and 622 * the core state will be left unmodified. 623 */ 624 static inline int 625 bhnd_release_pmu(device_t dev) 626 { 627 return (BHND_BUS_RELEASE_PMU(device_get_parent(dev), dev)); 628 } 629 630 /** 631 * Request that @p clock (or faster) be routed to @p dev. 632 * 633 * A driver must ask the bhnd bus to allocate clock request state 634 * via bhnd_alloc_pmu() before it can request clock resources. 635 * 636 * Request multiplexing is managed by the bus. 637 * 638 * @param dev The bhnd(4) device to which @p clock should be routed. 639 * @param clock The requested clock source. 640 * 641 * @retval 0 success 642 * @retval ENODEV If an unsupported clock was requested. 643 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. 644 */ 645 static inline int 646 bhnd_request_clock(device_t dev, bhnd_clock clock) 647 { 648 return (BHND_BUS_REQUEST_CLOCK(device_get_parent(dev), dev, clock)); 649 } 650 651 /** 652 * Request that @p clocks be powered on behalf of @p dev. 653 * 654 * This will power any clock sources (e.g. XTAL, PLL, etc) required for 655 * @p clocks and wait until they are ready, discarding any previous 656 * requests by @p dev. 657 * 658 * Request multiplexing is managed by the bus. 659 * 660 * A driver must ask the bhnd bus to allocate clock request state 661 * via bhnd_alloc_pmu() before it can request clock resources. 662 * 663 * @param dev The requesting bhnd(4) device. 664 * @param clocks The clock(s) to be enabled. 665 * 666 * @retval 0 success 667 * @retval ENODEV If an unsupported clock was requested. 668 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. 669 */ 670 static inline int 671 bhnd_enable_clocks(device_t dev, uint32_t clocks) 672 { 673 return (BHND_BUS_ENABLE_CLOCKS(device_get_parent(dev), dev, clocks)); 674 } 675 676 /** 677 * Power up an external PMU-managed resource assigned to @p dev. 678 * 679 * A driver must ask the bhnd bus to allocate PMU request state 680 * via bhnd_alloc_pmu() before it can request PMU resources. 681 * 682 * @param dev The requesting bhnd(4) device. 683 * @param rsrc The core-specific external resource identifier. 684 * 685 * @retval 0 success 686 * @retval ENODEV If the PMU does not support @p rsrc. 687 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. 688 */ 689 static inline int 690 bhnd_request_ext_rsrc(device_t dev, u_int rsrc) 691 { 692 return (BHND_BUS_REQUEST_EXT_RSRC(device_get_parent(dev), dev, rsrc)); 693 } 694 695 /** 696 * Power down an external PMU-managed resource assigned to @p dev. 697 * 698 * A driver must ask the bhnd bus to allocate PMU request state 699 * via bhnd_alloc_pmu() before it can request PMU resources. 700 * 701 * @param dev The requesting bhnd(4) device. 702 * @param rsrc The core-specific external resource identifier. 703 * 704 * @retval 0 success 705 * @retval ENODEV If the PMU does not support @p rsrc. 706 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. 707 */ 708 static inline int 709 bhnd_release_ext_rsrc(device_t dev, u_int rsrc) 710 { 711 return (BHND_BUS_RELEASE_EXT_RSRC(device_get_parent(dev), dev, rsrc)); 712 } 713 714 715 /** 716 * Read @p width bytes at @p offset from the bus-specific agent/config 717 * space of @p dev. 718 * 719 * @param dev The bhnd device for which @p offset should be read. 720 * @param offset The offset to be read. 721 * @param width The size of the access. Must be 1, 2 or 4 bytes. 722 * 723 * The exact behavior of this method is bus-specific. In the case of 724 * bcma(4), this method provides access to the first agent port of @p child. 725 * 726 * @note Device drivers should only use this API for functionality 727 * that is not available via another bhnd(4) function. 728 */ 729 static inline uint32_t 730 bhnd_read_config(device_t dev, bus_size_t offset, u_int width) 731 { 732 return (BHND_BUS_READ_CONFIG(device_get_parent(dev), dev, offset, 733 width)); 734 } 735 736 /** 737 * Read @p width bytes at @p offset from the bus-specific agent/config 738 * space of @p dev. 739 * 740 * @param dev The bhnd device for which @p offset should be read. 741 * @param offset The offset to be written. 742 * @param width The size of the access. Must be 1, 2 or 4 bytes. 743 * 744 * The exact behavior of this method is bus-specific. In the case of 745 * bcma(4), this method provides access to the first agent port of @p child. 746 * 747 * @note Device drivers should only use this API for functionality 748 * that is not available via another bhnd(4) function. 749 */ 750 static inline void 751 bhnd_write_config(device_t dev, bus_size_t offset, uint32_t val, u_int width) 752 { 753 BHND_BUS_WRITE_CONFIG(device_get_parent(dev), dev, offset, val, width); 754 } 755 756 /** 757 * Read an NVRAM variable, coerced to the requested @p type. 758 * 759 * @param dev A bhnd bus child device. 760 * @param name The NVRAM variable name. 761 * @param[out] buf A buffer large enough to hold @p len bytes. On 762 * success, the requested value will be written to 763 * this buffer. This argment may be NULL if 764 * the value is not desired. 765 * @param[in,out] len The maximum capacity of @p buf. On success, 766 * will be set to the actual size of the requested 767 * value. 768 * @param type The desired data representation to be written 769 * to @p buf. 770 * 771 * @retval 0 success 772 * @retval ENOENT The requested variable was not found. 773 * @retval ENODEV No valid NVRAM source could be found. 774 * @retval ENOMEM If a buffer of @p size is too small to hold the 775 * requested value. 776 * @retval EOPNOTSUPP If the value cannot be coerced to @p type. 777 * @retval ERANGE If value coercion would overflow @p type. 778 * @retval non-zero If reading @p name otherwise fails, a regular unix 779 * error code will be returned. 780 */ 781 static inline int 782 bhnd_nvram_getvar(device_t dev, const char *name, void *buf, size_t *len, 783 bhnd_nvram_type type) 784 { 785 return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), dev, name, buf, 786 len, type)); 787 } 788 789 /** 790 * Allocate a resource from a device's parent bhnd(4) bus. 791 * 792 * @param dev The device requesting resource ownership. 793 * @param type The type of resource to allocate. This may be any type supported 794 * by the standard bus APIs. 795 * @param rid The bus-specific handle identifying the resource being allocated. 796 * @param start The start address of the resource. 797 * @param end The end address of the resource. 798 * @param count The size of the resource. 799 * @param flags The flags for the resource to be allocated. These may be any 800 * values supported by the standard bus APIs. 801 * 802 * To request the resource's default addresses, pass @p start and 803 * @p end values of @c 0 and @c ~0, respectively, and 804 * a @p count of @c 1. 805 * 806 * @retval NULL The resource could not be allocated. 807 * @retval resource The allocated resource. 808 */ 809 static inline struct bhnd_resource * 810 bhnd_alloc_resource(device_t dev, int type, int *rid, rman_res_t start, 811 rman_res_t end, rman_res_t count, u_int flags) 812 { 813 return BHND_BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, type, rid, 814 start, end, count, flags); 815 } 816 817 818 /** 819 * Allocate a resource from a device's parent bhnd(4) bus, using the 820 * resource's default start, end, and count values. 821 * 822 * @param dev The device requesting resource ownership. 823 * @param type The type of resource to allocate. This may be any type supported 824 * by the standard bus APIs. 825 * @param rid The bus-specific handle identifying the resource being allocated. 826 * @param flags The flags for the resource to be allocated. These may be any 827 * values supported by the standard bus APIs. 828 * 829 * @retval NULL The resource could not be allocated. 830 * @retval resource The allocated resource. 831 */ 832 static inline struct bhnd_resource * 833 bhnd_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) 834 { 835 return bhnd_alloc_resource(dev, type, rid, 0, ~0, 1, flags); 836 } 837 838 /** 839 * Activate a previously allocated bhnd resource. 840 * 841 * @param dev The device holding ownership of the allocated resource. 842 * @param type The type of the resource. 843 * @param rid The bus-specific handle identifying the resource. 844 * @param r A pointer to the resource returned by bhnd_alloc_resource or 845 * BHND_BUS_ALLOC_RESOURCE. 846 * 847 * @retval 0 success 848 * @retval non-zero an error occurred while activating the resource. 849 */ 850 static inline int 851 bhnd_activate_resource(device_t dev, int type, int rid, 852 struct bhnd_resource *r) 853 { 854 return BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev), dev, type, 855 rid, r); 856 } 857 858 /** 859 * Deactivate a previously activated bhnd resource. 860 * 861 * @param dev The device holding ownership of the activated resource. 862 * @param type The type of the resource. 863 * @param rid The bus-specific handle identifying the resource. 864 * @param r A pointer to the resource returned by bhnd_alloc_resource or 865 * BHND_BUS_ALLOC_RESOURCE. 866 * 867 * @retval 0 success 868 * @retval non-zero an error occurred while activating the resource. 869 */ 870 static inline int 871 bhnd_deactivate_resource(device_t dev, int type, int rid, 872 struct bhnd_resource *r) 873 { 874 return BHND_BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), dev, type, 875 rid, r); 876 } 877 878 /** 879 * Free a resource allocated by bhnd_alloc_resource(). 880 * 881 * @param dev The device holding ownership of the resource. 882 * @param type The type of the resource. 883 * @param rid The bus-specific handle identifying the resource. 884 * @param r A pointer to the resource returned by bhnd_alloc_resource or 885 * BHND_ALLOC_RESOURCE. 886 * 887 * @retval 0 success 888 * @retval non-zero an error occurred while activating the resource. 889 */ 890 static inline int 891 bhnd_release_resource(device_t dev, int type, int rid, 892 struct bhnd_resource *r) 893 { 894 return BHND_BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, type, 895 rid, r); 896 } 897 898 /** 899 * Return true if @p region_num is a valid region on @p port_num of 900 * @p type attached to @p dev. 901 * 902 * @param dev A bhnd bus child device. 903 * @param type The port type being queried. 904 * @param port_num The port number being queried. 905 * @param region_num The region number being queried. 906 */ 907 static inline bool 908 bhnd_is_region_valid(device_t dev, bhnd_port_type type, u_int port_num, 909 u_int region_num) 910 { 911 return (BHND_BUS_IS_REGION_VALID(device_get_parent(dev), dev, type, 912 port_num, region_num)); 913 } 914 915 /** 916 * Return the number of ports of type @p type attached to @p def. 917 * 918 * @param dev A bhnd bus child device. 919 * @param type The port type being queried. 920 */ 921 static inline u_int 922 bhnd_get_port_count(device_t dev, bhnd_port_type type) { 923 return (BHND_BUS_GET_PORT_COUNT(device_get_parent(dev), dev, type)); 924 } 925 926 /** 927 * Return the number of memory regions mapped to @p child @p port of 928 * type @p type. 929 * 930 * @param dev A bhnd bus child device. 931 * @param port The port number being queried. 932 * @param type The port type being queried. 933 */ 934 static inline u_int 935 bhnd_get_region_count(device_t dev, bhnd_port_type type, u_int port) { 936 return (BHND_BUS_GET_REGION_COUNT(device_get_parent(dev), dev, type, 937 port)); 938 } 939 940 /** 941 * Return the resource-ID for a memory region on the given device port. 942 * 943 * @param dev A bhnd bus child device. 944 * @param type The port type. 945 * @param port The port identifier. 946 * @param region The identifier of the memory region on @p port. 947 * 948 * @retval int The RID for the given @p port and @p region on @p device. 949 * @retval -1 No such port/region found. 950 */ 951 static inline int 952 bhnd_get_port_rid(device_t dev, bhnd_port_type type, u_int port, u_int region) 953 { 954 return BHND_BUS_GET_PORT_RID(device_get_parent(dev), dev, type, port, 955 region); 956 } 957 958 /** 959 * Decode a port / region pair on @p dev defined by @p rid. 960 * 961 * @param dev A bhnd bus child device. 962 * @param type The resource type. 963 * @param rid The resource identifier. 964 * @param[out] port_type The decoded port type. 965 * @param[out] port The decoded port identifier. 966 * @param[out] region The decoded region identifier. 967 * 968 * @retval 0 success 969 * @retval non-zero No matching port/region found. 970 */ 971 static inline int 972 bhnd_decode_port_rid(device_t dev, int type, int rid, bhnd_port_type *port_type, 973 u_int *port, u_int *region) 974 { 975 return BHND_BUS_DECODE_PORT_RID(device_get_parent(dev), dev, type, rid, 976 port_type, port, region); 977 } 978 979 /** 980 * Get the address and size of @p region on @p port. 981 * 982 * @param dev A bhnd bus child device. 983 * @param port_type The port type. 984 * @param port The port identifier. 985 * @param region The identifier of the memory region on @p port. 986 * @param[out] region_addr The region's base address. 987 * @param[out] region_size The region's size. 988 * 989 * @retval 0 success 990 * @retval non-zero No matching port/region found. 991 */ 992 static inline int 993 bhnd_get_region_addr(device_t dev, bhnd_port_type port_type, u_int port, 994 u_int region, bhnd_addr_t *region_addr, bhnd_size_t *region_size) 995 { 996 return BHND_BUS_GET_REGION_ADDR(device_get_parent(dev), dev, port_type, 997 port, region, region_addr, region_size); 998 } 999 1000 /* 1001 * bhnd bus-level equivalents of the bus_(read|write|set|barrier|...) 1002 * macros (compatible with bhnd_resource). 1003 * 1004 * Generated with bhnd/tools/bus_macro.sh 1005 */ 1006 #define bhnd_bus_barrier(r, o, l, f) \ 1007 ((r)->direct) ? \ 1008 bus_barrier((r)->res, (o), (l), (f)) : \ 1009 BHND_BUS_BARRIER( \ 1010 device_get_parent(rman_get_device((r)->res)), \ 1011 rman_get_device((r)->res), (r), (o), (l), (f)) 1012 #define bhnd_bus_read_1(r, o) \ 1013 ((r)->direct) ? \ 1014 bus_read_1((r)->res, (o)) : \ 1015 BHND_BUS_READ_1( \ 1016 device_get_parent(rman_get_device((r)->res)), \ 1017 rman_get_device((r)->res), (r), (o)) 1018 #define bhnd_bus_read_multi_1(r, o, d, c) \ 1019 ((r)->direct) ? \ 1020 bus_read_multi_1((r)->res, (o), (d), (c)) : \ 1021 BHND_BUS_READ_MULTI_1( \ 1022 device_get_parent(rman_get_device((r)->res)), \ 1023 rman_get_device((r)->res), (r), (o), (d), (c)) 1024 #define bhnd_bus_read_region_1(r, o, d, c) \ 1025 ((r)->direct) ? \ 1026 bus_read_region_1((r)->res, (o), (d), (c)) : \ 1027 BHND_BUS_READ_REGION_1( \ 1028 device_get_parent(rman_get_device((r)->res)), \ 1029 rman_get_device((r)->res), (r), (o), (d), (c)) 1030 #define bhnd_bus_write_1(r, o, v) \ 1031 ((r)->direct) ? \ 1032 bus_write_1((r)->res, (o), (v)) : \ 1033 BHND_BUS_WRITE_1( \ 1034 device_get_parent(rman_get_device((r)->res)), \ 1035 rman_get_device((r)->res), (r), (o), (v)) 1036 #define bhnd_bus_write_multi_1(r, o, d, c) \ 1037 ((r)->direct) ? \ 1038 bus_write_multi_1((r)->res, (o), (d), (c)) : \ 1039 BHND_BUS_WRITE_MULTI_1( \ 1040 device_get_parent(rman_get_device((r)->res)), \ 1041 rman_get_device((r)->res), (r), (o), (d), (c)) 1042 #define bhnd_bus_write_region_1(r, o, d, c) \ 1043 ((r)->direct) ? \ 1044 bus_write_region_1((r)->res, (o), (d), (c)) : \ 1045 BHND_BUS_WRITE_REGION_1( \ 1046 device_get_parent(rman_get_device((r)->res)), \ 1047 rman_get_device((r)->res), (r), (o), (d), (c)) 1048 #define bhnd_bus_read_stream_1(r, o) \ 1049 ((r)->direct) ? \ 1050 bus_read_stream_1((r)->res, (o)) : \ 1051 BHND_BUS_READ_STREAM_1( \ 1052 device_get_parent(rman_get_device((r)->res)), \ 1053 rman_get_device((r)->res), (r), (o)) 1054 #define bhnd_bus_read_multi_stream_1(r, o, d, c) \ 1055 ((r)->direct) ? \ 1056 bus_read_multi_stream_1((r)->res, (o), (d), (c)) : \ 1057 BHND_BUS_READ_MULTI_STREAM_1( \ 1058 device_get_parent(rman_get_device((r)->res)), \ 1059 rman_get_device((r)->res), (r), (o), (d), (c)) 1060 #define bhnd_bus_read_region_stream_1(r, o, d, c) \ 1061 ((r)->direct) ? \ 1062 bus_read_region_stream_1((r)->res, (o), (d), (c)) : \ 1063 BHND_BUS_READ_REGION_STREAM_1( \ 1064 device_get_parent(rman_get_device((r)->res)), \ 1065 rman_get_device((r)->res), (r), (o), (d), (c)) 1066 #define bhnd_bus_write_stream_1(r, o, v) \ 1067 ((r)->direct) ? \ 1068 bus_write_stream_1((r)->res, (o), (v)) : \ 1069 BHND_BUS_WRITE_STREAM_1( \ 1070 device_get_parent(rman_get_device((r)->res)), \ 1071 rman_get_device((r)->res), (r), (o), (v)) 1072 #define bhnd_bus_write_multi_stream_1(r, o, d, c) \ 1073 ((r)->direct) ? \ 1074 bus_write_multi_stream_1((r)->res, (o), (d), (c)) : \ 1075 BHND_BUS_WRITE_MULTI_STREAM_1( \ 1076 device_get_parent(rman_get_device((r)->res)), \ 1077 rman_get_device((r)->res), (r), (o), (d), (c)) 1078 #define bhnd_bus_write_region_stream_1(r, o, d, c) \ 1079 ((r)->direct) ? \ 1080 bus_write_region_stream_1((r)->res, (o), (d), (c)) : \ 1081 BHND_BUS_WRITE_REGION_STREAM_1( \ 1082 device_get_parent(rman_get_device((r)->res)), \ 1083 rman_get_device((r)->res), (r), (o), (d), (c)) 1084 #define bhnd_bus_set_multi_1(r, o, v, c) \ 1085 ((r)->direct) ? \ 1086 bus_set_multi_1((r)->res, (o), (v), (c)) : \ 1087 BHND_BUS_SET_MULTI_1( \ 1088 device_get_parent(rman_get_device((r)->res)), \ 1089 rman_get_device((r)->res), (r), (o), (v), (c)) 1090 #define bhnd_bus_set_region_1(r, o, v, c) \ 1091 ((r)->direct) ? \ 1092 bus_set_region_1((r)->res, (o), (v), (c)) : \ 1093 BHND_BUS_SET_REGION_1( \ 1094 device_get_parent(rman_get_device((r)->res)), \ 1095 rman_get_device((r)->res), (r), (o), (v), (c)) 1096 #define bhnd_bus_read_2(r, o) \ 1097 ((r)->direct) ? \ 1098 bus_read_2((r)->res, (o)) : \ 1099 BHND_BUS_READ_2( \ 1100 device_get_parent(rman_get_device((r)->res)), \ 1101 rman_get_device((r)->res), (r), (o)) 1102 #define bhnd_bus_read_multi_2(r, o, d, c) \ 1103 ((r)->direct) ? \ 1104 bus_read_multi_2((r)->res, (o), (d), (c)) : \ 1105 BHND_BUS_READ_MULTI_2( \ 1106 device_get_parent(rman_get_device((r)->res)), \ 1107 rman_get_device((r)->res), (r), (o), (d), (c)) 1108 #define bhnd_bus_read_region_2(r, o, d, c) \ 1109 ((r)->direct) ? \ 1110 bus_read_region_2((r)->res, (o), (d), (c)) : \ 1111 BHND_BUS_READ_REGION_2( \ 1112 device_get_parent(rman_get_device((r)->res)), \ 1113 rman_get_device((r)->res), (r), (o), (d), (c)) 1114 #define bhnd_bus_write_2(r, o, v) \ 1115 ((r)->direct) ? \ 1116 bus_write_2((r)->res, (o), (v)) : \ 1117 BHND_BUS_WRITE_2( \ 1118 device_get_parent(rman_get_device((r)->res)), \ 1119 rman_get_device((r)->res), (r), (o), (v)) 1120 #define bhnd_bus_write_multi_2(r, o, d, c) \ 1121 ((r)->direct) ? \ 1122 bus_write_multi_2((r)->res, (o), (d), (c)) : \ 1123 BHND_BUS_WRITE_MULTI_2( \ 1124 device_get_parent(rman_get_device((r)->res)), \ 1125 rman_get_device((r)->res), (r), (o), (d), (c)) 1126 #define bhnd_bus_write_region_2(r, o, d, c) \ 1127 ((r)->direct) ? \ 1128 bus_write_region_2((r)->res, (o), (d), (c)) : \ 1129 BHND_BUS_WRITE_REGION_2( \ 1130 device_get_parent(rman_get_device((r)->res)), \ 1131 rman_get_device((r)->res), (r), (o), (d), (c)) 1132 #define bhnd_bus_read_stream_2(r, o) \ 1133 ((r)->direct) ? \ 1134 bus_read_stream_2((r)->res, (o)) : \ 1135 BHND_BUS_READ_STREAM_2( \ 1136 device_get_parent(rman_get_device((r)->res)), \ 1137 rman_get_device((r)->res), (r), (o)) 1138 #define bhnd_bus_read_multi_stream_2(r, o, d, c) \ 1139 ((r)->direct) ? \ 1140 bus_read_multi_stream_2((r)->res, (o), (d), (c)) : \ 1141 BHND_BUS_READ_MULTI_STREAM_2( \ 1142 device_get_parent(rman_get_device((r)->res)), \ 1143 rman_get_device((r)->res), (r), (o), (d), (c)) 1144 #define bhnd_bus_read_region_stream_2(r, o, d, c) \ 1145 ((r)->direct) ? \ 1146 bus_read_region_stream_2((r)->res, (o), (d), (c)) : \ 1147 BHND_BUS_READ_REGION_STREAM_2( \ 1148 device_get_parent(rman_get_device((r)->res)), \ 1149 rman_get_device((r)->res), (r), (o), (d), (c)) 1150 #define bhnd_bus_write_stream_2(r, o, v) \ 1151 ((r)->direct) ? \ 1152 bus_write_stream_2((r)->res, (o), (v)) : \ 1153 BHND_BUS_WRITE_STREAM_2( \ 1154 device_get_parent(rman_get_device((r)->res)), \ 1155 rman_get_device((r)->res), (r), (o), (v)) 1156 #define bhnd_bus_write_multi_stream_2(r, o, d, c) \ 1157 ((r)->direct) ? \ 1158 bus_write_multi_stream_2((r)->res, (o), (d), (c)) : \ 1159 BHND_BUS_WRITE_MULTI_STREAM_2( \ 1160 device_get_parent(rman_get_device((r)->res)), \ 1161 rman_get_device((r)->res), (r), (o), (d), (c)) 1162 #define bhnd_bus_write_region_stream_2(r, o, d, c) \ 1163 ((r)->direct) ? \ 1164 bus_write_region_stream_2((r)->res, (o), (d), (c)) : \ 1165 BHND_BUS_WRITE_REGION_STREAM_2( \ 1166 device_get_parent(rman_get_device((r)->res)), \ 1167 rman_get_device((r)->res), (r), (o), (d), (c)) 1168 #define bhnd_bus_set_multi_2(r, o, v, c) \ 1169 ((r)->direct) ? \ 1170 bus_set_multi_2((r)->res, (o), (v), (c)) : \ 1171 BHND_BUS_SET_MULTI_2( \ 1172 device_get_parent(rman_get_device((r)->res)), \ 1173 rman_get_device((r)->res), (r), (o), (v), (c)) 1174 #define bhnd_bus_set_region_2(r, o, v, c) \ 1175 ((r)->direct) ? \ 1176 bus_set_region_2((r)->res, (o), (v), (c)) : \ 1177 BHND_BUS_SET_REGION_2( \ 1178 device_get_parent(rman_get_device((r)->res)), \ 1179 rman_get_device((r)->res), (r), (o), (v), (c)) 1180 #define bhnd_bus_read_4(r, o) \ 1181 ((r)->direct) ? \ 1182 bus_read_4((r)->res, (o)) : \ 1183 BHND_BUS_READ_4( \ 1184 device_get_parent(rman_get_device((r)->res)), \ 1185 rman_get_device((r)->res), (r), (o)) 1186 #define bhnd_bus_read_multi_4(r, o, d, c) \ 1187 ((r)->direct) ? \ 1188 bus_read_multi_4((r)->res, (o), (d), (c)) : \ 1189 BHND_BUS_READ_MULTI_4( \ 1190 device_get_parent(rman_get_device((r)->res)), \ 1191 rman_get_device((r)->res), (r), (o), (d), (c)) 1192 #define bhnd_bus_read_region_4(r, o, d, c) \ 1193 ((r)->direct) ? \ 1194 bus_read_region_4((r)->res, (o), (d), (c)) : \ 1195 BHND_BUS_READ_REGION_4( \ 1196 device_get_parent(rman_get_device((r)->res)), \ 1197 rman_get_device((r)->res), (r), (o), (d), (c)) 1198 #define bhnd_bus_write_4(r, o, v) \ 1199 ((r)->direct) ? \ 1200 bus_write_4((r)->res, (o), (v)) : \ 1201 BHND_BUS_WRITE_4( \ 1202 device_get_parent(rman_get_device((r)->res)), \ 1203 rman_get_device((r)->res), (r), (o), (v)) 1204 #define bhnd_bus_write_multi_4(r, o, d, c) \ 1205 ((r)->direct) ? \ 1206 bus_write_multi_4((r)->res, (o), (d), (c)) : \ 1207 BHND_BUS_WRITE_MULTI_4( \ 1208 device_get_parent(rman_get_device((r)->res)), \ 1209 rman_get_device((r)->res), (r), (o), (d), (c)) 1210 #define bhnd_bus_write_region_4(r, o, d, c) \ 1211 ((r)->direct) ? \ 1212 bus_write_region_4((r)->res, (o), (d), (c)) : \ 1213 BHND_BUS_WRITE_REGION_4( \ 1214 device_get_parent(rman_get_device((r)->res)), \ 1215 rman_get_device((r)->res), (r), (o), (d), (c)) 1216 #define bhnd_bus_read_stream_4(r, o) \ 1217 ((r)->direct) ? \ 1218 bus_read_stream_4((r)->res, (o)) : \ 1219 BHND_BUS_READ_STREAM_4( \ 1220 device_get_parent(rman_get_device((r)->res)), \ 1221 rman_get_device((r)->res), (r), (o)) 1222 #define bhnd_bus_read_multi_stream_4(r, o, d, c) \ 1223 ((r)->direct) ? \ 1224 bus_read_multi_stream_4((r)->res, (o), (d), (c)) : \ 1225 BHND_BUS_READ_MULTI_STREAM_4( \ 1226 device_get_parent(rman_get_device((r)->res)), \ 1227 rman_get_device((r)->res), (r), (o), (d), (c)) 1228 #define bhnd_bus_read_region_stream_4(r, o, d, c) \ 1229 ((r)->direct) ? \ 1230 bus_read_region_stream_4((r)->res, (o), (d), (c)) : \ 1231 BHND_BUS_READ_REGION_STREAM_4( \ 1232 device_get_parent(rman_get_device((r)->res)), \ 1233 rman_get_device((r)->res), (r), (o), (d), (c)) 1234 #define bhnd_bus_write_stream_4(r, o, v) \ 1235 ((r)->direct) ? \ 1236 bus_write_stream_4((r)->res, (o), (v)) : \ 1237 BHND_BUS_WRITE_STREAM_4( \ 1238 device_get_parent(rman_get_device((r)->res)), \ 1239 rman_get_device((r)->res), (r), (o), (v)) 1240 #define bhnd_bus_write_multi_stream_4(r, o, d, c) \ 1241 ((r)->direct) ? \ 1242 bus_write_multi_stream_4((r)->res, (o), (d), (c)) : \ 1243 BHND_BUS_WRITE_MULTI_STREAM_4( \ 1244 device_get_parent(rman_get_device((r)->res)), \ 1245 rman_get_device((r)->res), (r), (o), (d), (c)) 1246 #define bhnd_bus_write_region_stream_4(r, o, d, c) \ 1247 ((r)->direct) ? \ 1248 bus_write_region_stream_4((r)->res, (o), (d), (c)) : \ 1249 BHND_BUS_WRITE_REGION_STREAM_4( \ 1250 device_get_parent(rman_get_device((r)->res)), \ 1251 rman_get_device((r)->res), (r), (o), (d), (c)) 1252 #define bhnd_bus_set_multi_4(r, o, v, c) \ 1253 ((r)->direct) ? \ 1254 bus_set_multi_4((r)->res, (o), (v), (c)) : \ 1255 BHND_BUS_SET_MULTI_4( \ 1256 device_get_parent(rman_get_device((r)->res)), \ 1257 rman_get_device((r)->res), (r), (o), (v), (c)) 1258 #define bhnd_bus_set_region_4(r, o, v, c) \ 1259 ((r)->direct) ? \ 1260 bus_set_region_4((r)->res, (o), (v), (c)) : \ 1261 BHND_BUS_SET_REGION_4( \ 1262 device_get_parent(rman_get_device((r)->res)), \ 1263 rman_get_device((r)->res), (r), (o), (v), (c)) 1264 1265 #endif /* _BHND_BHND_H_ */ 1266