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