1 /*- 2 * Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.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 30 #include <sys/cdefs.h> 31 __FBSDID("$FreeBSD$"); 32 33 /* 34 * Broadcom Home Networking Division (HND) Bus Driver. 35 * 36 * The Broadcom HND family of devices consists of both SoCs and host-connected 37 * networking chipsets containing a common family of Broadcom IP cores, 38 * including an integrated MIPS and/or ARM cores. 39 * 40 * HND devices expose a nearly identical interface whether accessible over a 41 * native SoC interconnect, or when connected via a host interface such as 42 * PCIe. As a result, the majority of hardware support code should be re-usable 43 * across host drivers for HND networking chipsets, as well as FreeBSD support 44 * for Broadcom MIPS/ARM HND SoCs. 45 * 46 * Earlier HND models used the siba(4) on-chip interconnect, while later models 47 * use bcma(4); the programming model is almost entirely independent 48 * of the actual underlying interconect. 49 */ 50 51 #include <sys/param.h> 52 #include <sys/kernel.h> 53 #include <sys/bus.h> 54 #include <sys/module.h> 55 #include <sys/systm.h> 56 57 #include <machine/bus.h> 58 #include <sys/rman.h> 59 #include <machine/resource.h> 60 61 #include <dev/bhnd/cores/chipc/chipcvar.h> 62 63 #include <dev/bhnd/cores/pmu/bhnd_pmu.h> 64 #include <dev/bhnd/cores/pmu/bhnd_pmureg.h> 65 66 #include "bhnd_chipc_if.h" 67 #include "bhnd_nvram_if.h" 68 69 #include "bhnd.h" 70 #include "bhndvar.h" 71 72 MALLOC_DEFINE(M_BHND, "bhnd", "bhnd bus data structures"); 73 74 /* Bus pass at which all bus-required children must be available, and 75 * attachment may be finalized. */ 76 #define BHND_FINISH_ATTACH_PASS BUS_PASS_DEFAULT 77 78 /** 79 * bhnd_generic_probe_nomatch() reporting configuration. 80 */ 81 static const struct bhnd_nomatch { 82 uint16_t vendor; /**< core designer */ 83 uint16_t device; /**< core id */ 84 bool if_verbose; /**< print when bootverbose is set. */ 85 } bhnd_nomatch_table[] = { 86 { BHND_MFGID_ARM, BHND_COREID_OOB_ROUTER, true }, 87 { BHND_MFGID_ARM, BHND_COREID_EROM, true }, 88 { BHND_MFGID_ARM, BHND_COREID_PL301, true }, 89 { BHND_MFGID_ARM, BHND_COREID_APB_BRIDGE, true }, 90 { BHND_MFGID_ARM, BHND_COREID_AXI_UNMAPPED, false }, 91 92 { BHND_MFGID_INVALID, BHND_COREID_INVALID, false } 93 }; 94 95 96 static int bhnd_delete_children(struct bhnd_softc *sc); 97 98 static int bhnd_finish_attach(struct bhnd_softc *sc); 99 100 static device_t bhnd_find_chipc(struct bhnd_softc *sc); 101 static struct chipc_caps *bhnd_find_chipc_caps(struct bhnd_softc *sc); 102 static device_t bhnd_find_platform_dev(struct bhnd_softc *sc, 103 const char *classname); 104 static device_t bhnd_find_pmu(struct bhnd_softc *sc); 105 static device_t bhnd_find_nvram(struct bhnd_softc *sc); 106 107 static int compare_ascending_probe_order(const void *lhs, 108 const void *rhs); 109 static int compare_descending_probe_order(const void *lhs, 110 const void *rhs); 111 112 /** 113 * Default bhnd(4) bus driver implementation of DEVICE_ATTACH(). 114 * 115 * This implementation calls device_probe_and_attach() for each of the device's 116 * children, in bhnd probe order. 117 */ 118 int 119 bhnd_generic_attach(device_t dev) 120 { 121 struct bhnd_softc *sc; 122 device_t *devs; 123 int ndevs; 124 int error; 125 126 if (device_is_attached(dev)) 127 return (EBUSY); 128 129 sc = device_get_softc(dev); 130 sc->dev = dev; 131 132 if ((error = device_get_children(dev, &devs, &ndevs))) 133 return (error); 134 135 /* Probe and attach all children */ 136 qsort(devs, ndevs, sizeof(*devs), compare_ascending_probe_order); 137 for (int i = 0; i < ndevs; i++) { 138 device_t child = devs[i]; 139 device_probe_and_attach(child); 140 } 141 142 /* Try to finalize attachment */ 143 if (bus_current_pass >= BHND_FINISH_ATTACH_PASS) { 144 if ((error = bhnd_finish_attach(sc))) 145 goto cleanup; 146 } 147 148 cleanup: 149 free(devs, M_TEMP); 150 151 if (error) 152 bhnd_delete_children(sc); 153 154 return (error); 155 } 156 157 /** 158 * Detach and delete all children, in reverse of their attach order. 159 */ 160 static int 161 bhnd_delete_children(struct bhnd_softc *sc) 162 { 163 device_t *devs; 164 int ndevs; 165 int error; 166 167 if ((error = device_get_children(sc->dev, &devs, &ndevs))) 168 return (error); 169 170 /* Detach in the reverse of attach order */ 171 qsort(devs, ndevs, sizeof(*devs), compare_descending_probe_order); 172 for (int i = 0; i < ndevs; i++) { 173 device_t child = devs[i]; 174 175 /* Terminate on first error */ 176 if ((error = device_delete_child(sc->dev, child))) 177 goto cleanup; 178 } 179 180 cleanup: 181 free(devs, M_TEMP); 182 return (error); 183 } 184 185 /** 186 * Default bhnd(4) bus driver implementation of DEVICE_DETACH(). 187 * 188 * This implementation calls device_detach() for each of the device's 189 * children, in reverse bhnd probe order, terminating if any call to 190 * device_detach() fails. 191 */ 192 int 193 bhnd_generic_detach(device_t dev) 194 { 195 struct bhnd_softc *sc; 196 197 if (!device_is_attached(dev)) 198 return (EBUSY); 199 200 sc = device_get_softc(dev); 201 return (bhnd_delete_children(sc)); 202 } 203 204 /** 205 * Default bhnd(4) bus driver implementation of DEVICE_SHUTDOWN(). 206 * 207 * This implementation calls device_shutdown() for each of the device's 208 * children, in reverse bhnd probe order, terminating if any call to 209 * device_shutdown() fails. 210 */ 211 int 212 bhnd_generic_shutdown(device_t dev) 213 { 214 device_t *devs; 215 int ndevs; 216 int error; 217 218 if (!device_is_attached(dev)) 219 return (EBUSY); 220 221 if ((error = device_get_children(dev, &devs, &ndevs))) 222 return (error); 223 224 /* Shutdown in the reverse of attach order */ 225 qsort(devs, ndevs, sizeof(*devs), compare_descending_probe_order); 226 for (int i = 0; i < ndevs; i++) { 227 device_t child = devs[i]; 228 229 /* Terminate on first error */ 230 if ((error = device_shutdown(child))) 231 goto cleanup; 232 } 233 234 cleanup: 235 free(devs, M_TEMP); 236 return (error); 237 } 238 239 /** 240 * Default bhnd(4) bus driver implementation of DEVICE_RESUME(). 241 * 242 * This implementation calls BUS_RESUME_CHILD() for each of the device's 243 * children in bhnd probe order, terminating if any call to BUS_RESUME_CHILD() 244 * fails. 245 */ 246 int 247 bhnd_generic_resume(device_t dev) 248 { 249 device_t *devs; 250 int ndevs; 251 int error; 252 253 if (!device_is_attached(dev)) 254 return (EBUSY); 255 256 if ((error = device_get_children(dev, &devs, &ndevs))) 257 return (error); 258 259 qsort(devs, ndevs, sizeof(*devs), compare_ascending_probe_order); 260 for (int i = 0; i < ndevs; i++) { 261 device_t child = devs[i]; 262 263 /* Terminate on first error */ 264 if ((error = BUS_RESUME_CHILD(device_get_parent(child), child))) 265 goto cleanup; 266 } 267 268 cleanup: 269 free(devs, M_TEMP); 270 return (error); 271 } 272 273 /** 274 * Default bhnd(4) bus driver implementation of DEVICE_SUSPEND(). 275 * 276 * This implementation calls BUS_SUSPEND_CHILD() for each of the device's 277 * children in reverse bhnd probe order. If any call to BUS_SUSPEND_CHILD() 278 * fails, the suspend operation is terminated and any devices that were 279 * suspended are resumed immediately by calling their BUS_RESUME_CHILD() 280 * methods. 281 */ 282 int 283 bhnd_generic_suspend(device_t dev) 284 { 285 device_t *devs; 286 int ndevs; 287 int error; 288 289 if (!device_is_attached(dev)) 290 return (EBUSY); 291 292 if ((error = device_get_children(dev, &devs, &ndevs))) 293 return (error); 294 295 /* Suspend in the reverse of attach order */ 296 qsort(devs, ndevs, sizeof(*devs), compare_descending_probe_order); 297 for (int i = 0; i < ndevs; i++) { 298 device_t child = devs[i]; 299 error = BUS_SUSPEND_CHILD(device_get_parent(child), child); 300 301 /* On error, resume suspended devices and then terminate */ 302 if (error) { 303 for (int j = 0; j < i; j++) { 304 BUS_RESUME_CHILD(device_get_parent(devs[j]), 305 devs[j]); 306 } 307 308 goto cleanup; 309 } 310 } 311 312 cleanup: 313 free(devs, M_TEMP); 314 return (error); 315 } 316 317 static void 318 bhnd_new_pass(device_t dev) 319 { 320 struct bhnd_softc *sc; 321 int error; 322 323 sc = device_get_softc(dev); 324 325 /* Attach any permissible children */ 326 bus_generic_new_pass(dev); 327 328 /* Finalize attachment */ 329 if (!sc->attach_done && bus_current_pass >= BHND_FINISH_ATTACH_PASS) { 330 if ((error = bhnd_finish_attach(sc))) { 331 panic("bhnd_finish_attach() failed: %d", error); 332 } 333 } 334 } 335 336 /* 337 * Finish any pending bus attachment operations. 338 * 339 * When attached as a SoC bus (as opposed to a bridged WiFi device), our 340 * platform devices may not be attached until later bus passes, necessitating 341 * delayed initialization on our part. 342 */ 343 static int 344 bhnd_finish_attach(struct bhnd_softc *sc) 345 { 346 struct chipc_caps *ccaps; 347 348 GIANT_REQUIRED; /* for newbus */ 349 350 KASSERT(bus_current_pass >= BHND_FINISH_ATTACH_PASS, 351 ("bhnd_finish_attach() called in pass %d", bus_current_pass)); 352 353 KASSERT(!sc->attach_done, ("duplicate call to bhnd_finish_attach()")); 354 355 /* Locate chipc device */ 356 if ((sc->chipc_dev = bhnd_find_chipc(sc)) == NULL) { 357 device_printf(sc->dev, "error: ChipCommon device not found\n"); 358 return (ENXIO); 359 } 360 361 ccaps = BHND_CHIPC_GET_CAPS(sc->chipc_dev); 362 363 /* Look for NVRAM device */ 364 if (ccaps->nvram_src != BHND_NVRAM_SRC_UNKNOWN) { 365 if ((sc->nvram_dev = bhnd_find_nvram(sc)) == NULL) { 366 device_printf(sc->dev, 367 "warning: NVRAM %s device not found\n", 368 bhnd_nvram_src_name(ccaps->nvram_src)); 369 } 370 } 371 372 /* Look for a PMU */ 373 if (ccaps->pmu || ccaps->pwr_ctrl) { 374 if ((sc->pmu_dev = bhnd_find_pmu(sc)) == NULL) { 375 device_printf(sc->dev, 376 "attach failed: supported PMU not found\n"); 377 return (ENXIO); 378 } 379 } 380 381 /* Mark attach as completed */ 382 sc->attach_done = true; 383 384 return (0); 385 } 386 387 /* Locate the ChipCommon core. */ 388 static device_t 389 bhnd_find_chipc(struct bhnd_softc *sc) 390 { 391 device_t chipc; 392 393 /* Make sure we're holding Giant for newbus */ 394 GIANT_REQUIRED; 395 396 /* chipc_dev is initialized during attachment */ 397 if (sc->attach_done) { 398 if ((chipc = sc->chipc_dev) == NULL) 399 return (NULL); 400 401 goto found; 402 } 403 404 /* Locate chipc core with a core unit of 0 */ 405 chipc = bhnd_find_child(sc->dev, BHND_DEVCLASS_CC, 0); 406 if (chipc == NULL) 407 return (NULL); 408 409 found: 410 if (device_get_state(chipc) < DS_ATTACHING) { 411 device_printf(sc->dev, "chipc found, but did not attach\n"); 412 return (NULL); 413 } 414 415 return (chipc); 416 } 417 418 /* Locate the ChipCommon core and return the device capabilities */ 419 static struct chipc_caps * 420 bhnd_find_chipc_caps(struct bhnd_softc *sc) 421 { 422 device_t chipc; 423 424 if ((chipc = bhnd_find_chipc(sc)) == NULL) { 425 device_printf(sc->dev, 426 "chipc unavailable; cannot fetch capabilities\n"); 427 return (NULL); 428 } 429 430 return (BHND_CHIPC_GET_CAPS(chipc)); 431 } 432 433 /** 434 * Find an attached platform device on @p dev, searching first for cores 435 * matching @p classname, and if not found, searching the children of the first 436 * bhnd_chipc device on the bus. 437 * 438 * @param sc Driver state. 439 * @param chipc Attached ChipCommon device. 440 * @param classname Device class to search for. 441 * 442 * @retval device_t A matching device. 443 * @retval NULL If no matching device is found. 444 */ 445 static device_t 446 bhnd_find_platform_dev(struct bhnd_softc *sc, const char *classname) 447 { 448 device_t chipc, child; 449 450 /* Make sure we're holding Giant for newbus */ 451 GIANT_REQUIRED; 452 453 /* Look for a directly-attached child */ 454 child = device_find_child(sc->dev, classname, -1); 455 if (child != NULL) 456 goto found; 457 458 /* Look for the first matching ChipCommon child */ 459 if ((chipc = bhnd_find_chipc(sc)) == NULL) { 460 device_printf(sc->dev, 461 "chipc unavailable; cannot locate %s\n", classname); 462 return (NULL); 463 } 464 465 child = device_find_child(chipc, classname, -1); 466 if (child != NULL) 467 goto found; 468 469 /* Look for a parent-attached device (e.g. nexus0 -> bhnd_nvram) */ 470 child = device_find_child(device_get_parent(sc->dev), classname, -1); 471 if (child == NULL) 472 return (NULL); 473 474 found: 475 if (device_get_state(child) < DS_ATTACHING) 476 return (NULL); 477 478 return (child); 479 } 480 481 /* Locate the PMU device, if any */ 482 static device_t 483 bhnd_find_pmu(struct bhnd_softc *sc) 484 { 485 /* Make sure we're holding Giant for newbus */ 486 GIANT_REQUIRED; 487 488 /* pmu_dev is initialized during attachment */ 489 if (sc->attach_done) { 490 if (sc->pmu_dev == NULL) 491 return (NULL); 492 493 if (device_get_state(sc->pmu_dev) < DS_ATTACHING) 494 return (NULL); 495 496 return (sc->pmu_dev); 497 } 498 499 500 return (bhnd_find_platform_dev(sc, "bhnd_pmu")); 501 } 502 503 /* Locate the NVRAM device, if any */ 504 static device_t 505 bhnd_find_nvram(struct bhnd_softc *sc) 506 { 507 struct chipc_caps *ccaps; 508 509 /* Make sure we're holding Giant for newbus */ 510 GIANT_REQUIRED; 511 512 513 /* nvram_dev is initialized during attachment */ 514 if (sc->attach_done) { 515 if (sc->nvram_dev == NULL) 516 return (NULL); 517 518 if (device_get_state(sc->nvram_dev) < DS_ATTACHING) 519 return (NULL); 520 521 return (sc->nvram_dev); 522 } 523 524 if ((ccaps = bhnd_find_chipc_caps(sc)) == NULL) 525 return (NULL); 526 527 if (ccaps->nvram_src == BHND_NVRAM_SRC_UNKNOWN) 528 return (NULL); 529 530 return (bhnd_find_platform_dev(sc, "bhnd_nvram")); 531 } 532 533 /* 534 * Ascending comparison of bhnd device's probe order. 535 */ 536 static int 537 compare_ascending_probe_order(const void *lhs, const void *rhs) 538 { 539 device_t ldev, rdev; 540 int lorder, rorder; 541 542 ldev = (*(const device_t *) lhs); 543 rdev = (*(const device_t *) rhs); 544 545 lorder = BHND_BUS_GET_PROBE_ORDER(device_get_parent(ldev), ldev); 546 rorder = BHND_BUS_GET_PROBE_ORDER(device_get_parent(rdev), rdev); 547 548 if (lorder < rorder) { 549 return (-1); 550 } else if (lorder > rorder) { 551 return (1); 552 } else { 553 return (0); 554 } 555 } 556 557 /* 558 * Descending comparison of bhnd device's probe order. 559 */ 560 static int 561 compare_descending_probe_order(const void *lhs, const void *rhs) 562 { 563 return (compare_ascending_probe_order(rhs, lhs)); 564 } 565 566 /** 567 * Default bhnd(4) bus driver implementation of BHND_BUS_GET_PROBE_ORDER(). 568 * 569 * This implementation determines probe ordering based on the device's class 570 * and other properties, including whether the device is serving as a host 571 * bridge. 572 */ 573 int 574 bhnd_generic_get_probe_order(device_t dev, device_t child) 575 { 576 switch (bhnd_get_class(child)) { 577 case BHND_DEVCLASS_CC: 578 /* Must be early enough to provide NVRAM access to the 579 * host bridge */ 580 return (BHND_PROBE_ROOT + BHND_PROBE_ORDER_FIRST); 581 582 case BHND_DEVCLASS_CC_B: 583 /* fall through */ 584 case BHND_DEVCLASS_PMU: 585 return (BHND_PROBE_BUS + BHND_PROBE_ORDER_EARLY); 586 587 case BHND_DEVCLASS_SOC_ROUTER: 588 return (BHND_PROBE_BUS + BHND_PROBE_ORDER_LATE); 589 590 case BHND_DEVCLASS_SOC_BRIDGE: 591 return (BHND_PROBE_BUS + BHND_PROBE_ORDER_LAST); 592 593 case BHND_DEVCLASS_CPU: 594 return (BHND_PROBE_CPU + BHND_PROBE_ORDER_FIRST); 595 596 case BHND_DEVCLASS_RAM: 597 /* fall through */ 598 case BHND_DEVCLASS_MEMC: 599 return (BHND_PROBE_CPU + BHND_PROBE_ORDER_EARLY); 600 601 case BHND_DEVCLASS_NVRAM: 602 return (BHND_PROBE_RESOURCE + BHND_PROBE_ORDER_EARLY); 603 604 case BHND_DEVCLASS_PCI: 605 case BHND_DEVCLASS_PCIE: 606 case BHND_DEVCLASS_PCCARD: 607 case BHND_DEVCLASS_ENET: 608 case BHND_DEVCLASS_ENET_MAC: 609 case BHND_DEVCLASS_ENET_PHY: 610 case BHND_DEVCLASS_WLAN: 611 case BHND_DEVCLASS_WLAN_MAC: 612 case BHND_DEVCLASS_WLAN_PHY: 613 case BHND_DEVCLASS_EROM: 614 case BHND_DEVCLASS_OTHER: 615 case BHND_DEVCLASS_INVALID: 616 if (bhnd_find_hostb_device(dev) == child) 617 return (BHND_PROBE_ROOT + BHND_PROBE_ORDER_EARLY); 618 619 return (BHND_PROBE_DEFAULT); 620 default: 621 return (BHND_PROBE_DEFAULT); 622 } 623 } 624 625 /** 626 * Default bhnd(4) bus driver implementation of BHND_BUS_ALLOC_PMU(). 627 */ 628 int 629 bhnd_generic_alloc_pmu(device_t dev, device_t child) 630 { 631 struct bhnd_softc *sc; 632 struct bhnd_resource *br; 633 struct chipc_caps *ccaps; 634 struct bhnd_core_pmu_info *pm; 635 struct resource_list *rl; 636 struct resource_list_entry *rle; 637 device_t pmu_dev; 638 bhnd_addr_t r_addr; 639 bhnd_size_t r_size; 640 bus_size_t pmu_regs; 641 int error; 642 643 GIANT_REQUIRED; /* for newbus */ 644 645 sc = device_get_softc(dev); 646 pm = bhnd_get_pmu_info(child); 647 pmu_regs = BHND_CLK_CTL_ST; 648 649 if ((ccaps = bhnd_find_chipc_caps(sc)) == NULL) { 650 device_printf(sc->dev, "alloc_pmu failed: chipc " 651 "capabilities unavailable\n"); 652 return (ENXIO); 653 } 654 655 if ((pmu_dev = bhnd_find_pmu(sc)) == NULL) { 656 device_printf(sc->dev, 657 "pmu unavailable; cannot allocate request state\n"); 658 return (ENXIO); 659 } 660 661 /* already allocated? */ 662 if (pm != NULL) { 663 panic("duplicate PMU allocation for %s", 664 device_get_nameunit(child)); 665 } 666 667 /* Determine address+size of the core's PMU register block */ 668 error = bhnd_get_region_addr(child, BHND_PORT_DEVICE, 0, 0, &r_addr, 669 &r_size); 670 if (error) { 671 device_printf(sc->dev, "error fetching register block info for " 672 "%s: %d\n", device_get_nameunit(child), error); 673 return (error); 674 } 675 676 if (r_size < (pmu_regs + sizeof(uint32_t))) { 677 device_printf(sc->dev, "pmu offset %#jx would overrun %s " 678 "register block\n", (uintmax_t)pmu_regs, 679 device_get_nameunit(child)); 680 return (ENODEV); 681 } 682 683 /* Locate actual resource containing the core's register block */ 684 if ((rl = BUS_GET_RESOURCE_LIST(dev, child)) == NULL) { 685 device_printf(dev, "NULL resource list returned for %s\n", 686 device_get_nameunit(child)); 687 return (ENXIO); 688 } 689 690 if ((rle = resource_list_find(rl, SYS_RES_MEMORY, 0)) == NULL) { 691 device_printf(dev, "cannot locate core register resource " 692 "for %s\n", device_get_nameunit(child)); 693 return (ENXIO); 694 } 695 696 if (rle->res == NULL) { 697 device_printf(dev, "core register resource unallocated for " 698 "%s\n", device_get_nameunit(child)); 699 return (ENXIO); 700 } 701 702 if (r_addr+pmu_regs < rman_get_start(rle->res) || 703 r_addr+pmu_regs >= rman_get_end(rle->res)) 704 { 705 device_printf(dev, "core register resource does not map PMU " 706 "registers at %#jx\n for %s\n", r_addr+pmu_regs, 707 device_get_nameunit(child)); 708 return (ENXIO); 709 } 710 711 /* Adjust PMU register offset relative to the actual start address 712 * of the core's register block allocation. 713 * 714 * XXX: The saved offset will be invalid if bus_adjust_resource is 715 * used to modify the resource's start address. 716 */ 717 if (rman_get_start(rle->res) > r_addr) 718 pmu_regs -= rman_get_start(rle->res) - r_addr; 719 else 720 pmu_regs -= r_addr - rman_get_start(rle->res); 721 722 /* Allocate and initialize PMU info */ 723 br = malloc(sizeof(struct bhnd_resource), M_BHND, M_NOWAIT); 724 if (br == NULL) 725 return (ENOMEM); 726 727 br->res = rle->res; 728 br->direct = ((rman_get_flags(rle->res) & RF_ACTIVE) != 0); 729 730 pm = malloc(sizeof(*pm), M_BHND, M_NOWAIT); 731 if (pm == NULL) { 732 free(br, M_BHND); 733 return (ENOMEM); 734 } 735 pm->pm_dev = child; 736 pm->pm_pmu = pmu_dev; 737 pm->pm_res = br; 738 pm->pm_regs = pmu_regs; 739 740 bhnd_set_pmu_info(child, pm); 741 return (0); 742 } 743 744 /** 745 * Default bhnd(4) bus driver implementation of BHND_BUS_RELEASE_PMU(). 746 */ 747 int 748 bhnd_generic_release_pmu(device_t dev, device_t child) 749 { 750 struct bhnd_softc *sc; 751 struct bhnd_core_pmu_info *pm; 752 device_t pmu; 753 int error; 754 755 GIANT_REQUIRED; /* for newbus */ 756 757 sc = device_get_softc(dev); 758 759 if ((pmu = bhnd_find_pmu(sc)) == NULL) { 760 device_printf(sc->dev, 761 "pmu unavailable; cannot release request state\n"); 762 return (ENXIO); 763 } 764 765 /* dispatch release request */ 766 pm = bhnd_get_pmu_info(child); 767 if (pm == NULL) 768 panic("pmu over-release for %s", device_get_nameunit(child)); 769 770 if ((error = BHND_PMU_CORE_RELEASE(pmu, pm))) 771 return (error); 772 773 /* free PMU info */ 774 bhnd_set_pmu_info(child, NULL); 775 free(pm->pm_res, M_BHND); 776 free(pm, M_BHND); 777 778 return (0); 779 } 780 781 /** 782 * Default bhnd(4) bus driver implementation of BHND_BUS_REQUEST_CLOCK(). 783 */ 784 int 785 bhnd_generic_request_clock(device_t dev, device_t child, bhnd_clock clock) 786 { 787 struct bhnd_softc *sc; 788 struct bhnd_core_pmu_info *pm; 789 790 sc = device_get_softc(dev); 791 792 if ((pm = bhnd_get_pmu_info(child)) == NULL) 793 panic("no active PMU request state"); 794 795 /* dispatch request to PMU */ 796 return (BHND_PMU_CORE_REQ_CLOCK(pm->pm_pmu, pm, clock)); 797 } 798 799 /** 800 * Default bhnd(4) bus driver implementation of BHND_BUS_ENABLE_CLOCKS(). 801 */ 802 int 803 bhnd_generic_enable_clocks(device_t dev, device_t child, uint32_t clocks) 804 { 805 struct bhnd_softc *sc; 806 struct bhnd_core_pmu_info *pm; 807 808 sc = device_get_softc(dev); 809 810 if ((pm = bhnd_get_pmu_info(child)) == NULL) 811 panic("no active PMU request state"); 812 813 /* dispatch request to PMU */ 814 return (BHND_PMU_CORE_EN_CLOCKS(pm->pm_pmu, pm, clocks)); 815 } 816 817 /** 818 * Default bhnd(4) bus driver implementation of BHND_BUS_REQUEST_EXT_RSRC(). 819 */ 820 int 821 bhnd_generic_request_ext_rsrc(device_t dev, device_t child, u_int rsrc) 822 { 823 struct bhnd_softc *sc; 824 struct bhnd_core_pmu_info *pm; 825 826 sc = device_get_softc(dev); 827 828 if ((pm = bhnd_get_pmu_info(child)) == NULL) 829 panic("no active PMU request state"); 830 831 /* dispatch request to PMU */ 832 return (BHND_PMU_CORE_REQ_EXT_RSRC(pm->pm_pmu, pm, rsrc)); 833 } 834 835 /** 836 * Default bhnd(4) bus driver implementation of BHND_BUS_RELEASE_EXT_RSRC(). 837 */ 838 int 839 bhnd_generic_release_ext_rsrc(device_t dev, device_t child, u_int rsrc) 840 { 841 struct bhnd_softc *sc; 842 struct bhnd_core_pmu_info *pm; 843 844 sc = device_get_softc(dev); 845 846 if ((pm = bhnd_get_pmu_info(child)) == NULL) 847 panic("no active PMU request state"); 848 849 /* dispatch request to PMU */ 850 return (BHND_PMU_CORE_RELEASE_EXT_RSRC(pm->pm_pmu, pm, rsrc)); 851 } 852 853 854 /** 855 * Default bhnd(4) bus driver implementation of BHND_BUS_IS_REGION_VALID(). 856 * 857 * This implementation assumes that port and region numbers are 0-indexed and 858 * are allocated non-sparsely, using BHND_BUS_GET_PORT_COUNT() and 859 * BHND_BUS_GET_REGION_COUNT() to determine if @p port and @p region fall 860 * within the defined range. 861 */ 862 static bool 863 bhnd_generic_is_region_valid(device_t dev, device_t child, 864 bhnd_port_type type, u_int port, u_int region) 865 { 866 if (port >= bhnd_get_port_count(child, type)) 867 return (false); 868 869 if (region >= bhnd_get_region_count(child, type, port)) 870 return (false); 871 872 return (true); 873 } 874 875 /** 876 * Default bhnd(4) bus driver implementation of BHND_BUS_GET_NVRAM_VAR(). 877 * 878 * This implementation searches @p dev for a usable NVRAM child device. 879 * 880 * If no usable child device is found on @p dev, the request is delegated to 881 * the BHND_BUS_GET_NVRAM_VAR() method on the parent of @p dev. 882 */ 883 int 884 bhnd_generic_get_nvram_var(device_t dev, device_t child, const char *name, 885 void *buf, size_t *size, bhnd_nvram_type type) 886 { 887 struct bhnd_softc *sc; 888 device_t nvram, parent; 889 890 sc = device_get_softc(dev); 891 892 /* If a NVRAM device is available, consult it first */ 893 if ((nvram = bhnd_find_nvram(sc)) != NULL) 894 return BHND_NVRAM_GETVAR(nvram, name, buf, size, type); 895 896 /* Otherwise, try to delegate to parent */ 897 if ((parent = device_get_parent(dev)) == NULL) 898 return (ENODEV); 899 900 return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), child, 901 name, buf, size, type)); 902 } 903 904 /** 905 * Default bhnd(4) bus driver implementation of BUS_PRINT_CHILD(). 906 * 907 * This implementation requests the device's struct resource_list via 908 * BUS_GET_RESOURCE_LIST. 909 */ 910 int 911 bhnd_generic_print_child(device_t dev, device_t child) 912 { 913 struct resource_list *rl; 914 int retval = 0; 915 916 retval += bus_print_child_header(dev, child); 917 918 rl = BUS_GET_RESOURCE_LIST(dev, child); 919 920 921 if (rl != NULL) { 922 retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, 923 "%#jx"); 924 925 retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, 926 "%#jd"); 927 } 928 929 retval += printf(" at core %u", bhnd_get_core_index(child)); 930 931 retval += bus_print_child_domain(dev, child); 932 retval += bus_print_child_footer(dev, child); 933 934 return (retval); 935 } 936 937 /** 938 * Default bhnd(4) bus driver implementation of BUS_PROBE_NOMATCH(). 939 * 940 * This implementation requests the device's struct resource_list via 941 * BUS_GET_RESOURCE_LIST. 942 */ 943 void 944 bhnd_generic_probe_nomatch(device_t dev, device_t child) 945 { 946 struct resource_list *rl; 947 const struct bhnd_nomatch *nm; 948 bool report; 949 950 /* Fetch reporting configuration for this device */ 951 report = true; 952 for (nm = bhnd_nomatch_table; nm->device != BHND_COREID_INVALID; nm++) { 953 if (nm->vendor != bhnd_get_vendor(child)) 954 continue; 955 956 if (nm->device != bhnd_get_device(child)) 957 continue; 958 959 report = false; 960 if (bootverbose && nm->if_verbose) 961 report = true; 962 break; 963 } 964 965 if (!report) 966 return; 967 968 /* Print the non-matched device info */ 969 device_printf(dev, "<%s %s>", bhnd_get_vendor_name(child), 970 bhnd_get_device_name(child)); 971 972 rl = BUS_GET_RESOURCE_LIST(dev, child); 973 if (rl != NULL) { 974 resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#jx"); 975 resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%#jd"); 976 } 977 978 printf(" at core %u (no driver attached)\n", 979 bhnd_get_core_index(child)); 980 } 981 982 /** 983 * Default implementation of BUS_CHILD_PNPINFO_STR(). 984 */ 985 static int 986 bhnd_child_pnpinfo_str(device_t dev, device_t child, char *buf, 987 size_t buflen) 988 { 989 if (device_get_parent(child) != dev) { 990 return (BUS_CHILD_PNPINFO_STR(device_get_parent(dev), child, 991 buf, buflen)); 992 } 993 994 snprintf(buf, buflen, "vendor=0x%hx device=0x%hx rev=0x%hhx", 995 bhnd_get_vendor(child), bhnd_get_device(child), 996 bhnd_get_hwrev(child)); 997 998 return (0); 999 } 1000 1001 /** 1002 * Default implementation of BUS_CHILD_LOCATION_STR(). 1003 */ 1004 static int 1005 bhnd_child_location_str(device_t dev, device_t child, char *buf, 1006 size_t buflen) 1007 { 1008 bhnd_addr_t addr; 1009 bhnd_size_t size; 1010 1011 if (device_get_parent(child) != dev) { 1012 return (BUS_CHILD_LOCATION_STR(device_get_parent(dev), child, 1013 buf, buflen)); 1014 } 1015 1016 1017 if (bhnd_get_region_addr(child, BHND_PORT_DEVICE, 0, 0, &addr, &size)) { 1018 /* No device default port/region */ 1019 if (buflen > 0) 1020 *buf = '\0'; 1021 return (0); 1022 } 1023 1024 snprintf(buf, buflen, "port0.0=0x%llx", (unsigned long long) addr); 1025 return (0); 1026 } 1027 1028 /** 1029 * Default bhnd(4) bus driver implementation of BUS_CHILD_DELETED(). 1030 * 1031 * This implementation manages internal bhnd(4) state, and must be called 1032 * by subclassing drivers. 1033 */ 1034 void 1035 bhnd_generic_child_deleted(device_t dev, device_t child) 1036 { 1037 struct bhnd_softc *sc; 1038 1039 sc = device_get_softc(dev); 1040 1041 /* Free device info */ 1042 if (bhnd_get_pmu_info(child) != NULL) { 1043 /* Releasing PMU requests automatically would be nice, 1044 * but we can't reference per-core PMU register 1045 * resource after driver detach */ 1046 panic("%s leaked device pmu state\n", 1047 device_get_nameunit(child)); 1048 } 1049 1050 /* Clean up platform device references */ 1051 if (sc->chipc_dev == child) { 1052 sc->chipc_dev = NULL; 1053 } else if (sc->nvram_dev == child) { 1054 sc->nvram_dev = NULL; 1055 } else if (sc->pmu_dev == child) { 1056 sc->pmu_dev = NULL; 1057 } 1058 } 1059 1060 /** 1061 * Helper function for implementing BUS_SUSPEND_CHILD(). 1062 * 1063 * TODO: Power management 1064 * 1065 * If @p child is not a direct child of @p dev, suspension is delegated to 1066 * the @p dev parent. 1067 */ 1068 int 1069 bhnd_generic_suspend_child(device_t dev, device_t child) 1070 { 1071 if (device_get_parent(child) != dev) 1072 BUS_SUSPEND_CHILD(device_get_parent(dev), child); 1073 1074 return bus_generic_suspend_child(dev, child); 1075 } 1076 1077 /** 1078 * Helper function for implementing BUS_RESUME_CHILD(). 1079 * 1080 * TODO: Power management 1081 * 1082 * If @p child is not a direct child of @p dev, suspension is delegated to 1083 * the @p dev parent. 1084 */ 1085 int 1086 bhnd_generic_resume_child(device_t dev, device_t child) 1087 { 1088 if (device_get_parent(child) != dev) 1089 BUS_RESUME_CHILD(device_get_parent(dev), child); 1090 1091 return bus_generic_resume_child(dev, child); 1092 } 1093 1094 /* 1095 * Delegate all indirect I/O to the parent device. When inherited by 1096 * non-bridged bus implementations, resources will never be marked as 1097 * indirect, and these methods will never be called. 1098 */ 1099 #define BHND_IO_READ(_type, _name, _method) \ 1100 static _type \ 1101 bhnd_read_ ## _name (device_t dev, device_t child, \ 1102 struct bhnd_resource *r, bus_size_t offset) \ 1103 { \ 1104 return (BHND_BUS_READ_ ## _method( \ 1105 device_get_parent(dev), child, r, offset)); \ 1106 } 1107 1108 #define BHND_IO_WRITE(_type, _name, _method) \ 1109 static void \ 1110 bhnd_write_ ## _name (device_t dev, device_t child, \ 1111 struct bhnd_resource *r, bus_size_t offset, _type value) \ 1112 { \ 1113 return (BHND_BUS_WRITE_ ## _method( \ 1114 device_get_parent(dev), child, r, offset, \ 1115 value)); \ 1116 } 1117 1118 #define BHND_IO_MISC(_type, _op, _method) \ 1119 static void \ 1120 bhnd_ ## _op (device_t dev, device_t child, \ 1121 struct bhnd_resource *r, bus_size_t offset, _type datap, \ 1122 bus_size_t count) \ 1123 { \ 1124 BHND_BUS_ ## _method(device_get_parent(dev), child, r, \ 1125 offset, datap, count); \ 1126 } 1127 1128 #define BHND_IO_METHODS(_type, _size) \ 1129 BHND_IO_READ(_type, _size, _size) \ 1130 BHND_IO_WRITE(_type, _size, _size) \ 1131 \ 1132 BHND_IO_READ(_type, stream_ ## _size, STREAM_ ## _size) \ 1133 BHND_IO_WRITE(_type, stream_ ## _size, STREAM_ ## _size) \ 1134 \ 1135 BHND_IO_MISC(_type*, read_multi_ ## _size, \ 1136 READ_MULTI_ ## _size) \ 1137 BHND_IO_MISC(_type*, write_multi_ ## _size, \ 1138 WRITE_MULTI_ ## _size) \ 1139 \ 1140 BHND_IO_MISC(_type*, read_multi_stream_ ## _size, \ 1141 READ_MULTI_STREAM_ ## _size) \ 1142 BHND_IO_MISC(_type*, write_multi_stream_ ## _size, \ 1143 WRITE_MULTI_STREAM_ ## _size) \ 1144 \ 1145 BHND_IO_MISC(_type, set_multi_ ## _size, SET_MULTI_ ## _size) \ 1146 BHND_IO_MISC(_type, set_region_ ## _size, SET_REGION_ ## _size) \ 1147 \ 1148 BHND_IO_MISC(_type*, read_region_ ## _size, \ 1149 READ_REGION_ ## _size) \ 1150 BHND_IO_MISC(_type*, write_region_ ## _size, \ 1151 WRITE_REGION_ ## _size) \ 1152 \ 1153 BHND_IO_MISC(_type*, read_region_stream_ ## _size, \ 1154 READ_REGION_STREAM_ ## _size) \ 1155 BHND_IO_MISC(_type*, write_region_stream_ ## _size, \ 1156 WRITE_REGION_STREAM_ ## _size) \ 1157 1158 BHND_IO_METHODS(uint8_t, 1); 1159 BHND_IO_METHODS(uint16_t, 2); 1160 BHND_IO_METHODS(uint32_t, 4); 1161 1162 static void 1163 bhnd_barrier(device_t dev, device_t child, struct bhnd_resource *r, 1164 bus_size_t offset, bus_size_t length, int flags) 1165 { 1166 BHND_BUS_BARRIER(device_get_parent(dev), child, r, offset, length, 1167 flags); 1168 } 1169 1170 static device_method_t bhnd_methods[] = { 1171 /* Device interface */ \ 1172 DEVMETHOD(device_attach, bhnd_generic_attach), 1173 DEVMETHOD(device_detach, bhnd_generic_detach), 1174 DEVMETHOD(device_shutdown, bhnd_generic_shutdown), 1175 DEVMETHOD(device_suspend, bhnd_generic_suspend), 1176 DEVMETHOD(device_resume, bhnd_generic_resume), 1177 1178 /* Bus interface */ 1179 DEVMETHOD(bus_new_pass, bhnd_new_pass), 1180 DEVMETHOD(bus_child_deleted, bhnd_generic_child_deleted), 1181 DEVMETHOD(bus_probe_nomatch, bhnd_generic_probe_nomatch), 1182 DEVMETHOD(bus_print_child, bhnd_generic_print_child), 1183 DEVMETHOD(bus_child_pnpinfo_str, bhnd_child_pnpinfo_str), 1184 DEVMETHOD(bus_child_location_str, bhnd_child_location_str), 1185 1186 DEVMETHOD(bus_suspend_child, bhnd_generic_suspend_child), 1187 DEVMETHOD(bus_resume_child, bhnd_generic_resume_child), 1188 1189 DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), 1190 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), 1191 DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource), 1192 DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), 1193 DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), 1194 DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), 1195 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 1196 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 1197 1198 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 1199 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 1200 DEVMETHOD(bus_config_intr, bus_generic_config_intr), 1201 DEVMETHOD(bus_bind_intr, bus_generic_bind_intr), 1202 DEVMETHOD(bus_describe_intr, bus_generic_describe_intr), 1203 1204 DEVMETHOD(bus_get_dma_tag, bus_generic_get_dma_tag), 1205 1206 /* BHND interface */ 1207 DEVMETHOD(bhnd_bus_get_chipid, bhnd_bus_generic_get_chipid), 1208 DEVMETHOD(bhnd_bus_is_hw_disabled, bhnd_bus_generic_is_hw_disabled), 1209 DEVMETHOD(bhnd_bus_read_board_info, bhnd_bus_generic_read_board_info), 1210 1211 DEVMETHOD(bhnd_bus_get_probe_order, bhnd_generic_get_probe_order), 1212 1213 DEVMETHOD(bhnd_bus_alloc_pmu, bhnd_generic_alloc_pmu), 1214 DEVMETHOD(bhnd_bus_release_pmu, bhnd_generic_release_pmu), 1215 DEVMETHOD(bhnd_bus_request_clock, bhnd_generic_request_clock), 1216 DEVMETHOD(bhnd_bus_enable_clocks, bhnd_generic_enable_clocks), 1217 DEVMETHOD(bhnd_bus_request_ext_rsrc, bhnd_generic_request_ext_rsrc), 1218 DEVMETHOD(bhnd_bus_release_ext_rsrc, bhnd_generic_release_ext_rsrc), 1219 1220 DEVMETHOD(bhnd_bus_is_region_valid, bhnd_generic_is_region_valid), 1221 DEVMETHOD(bhnd_bus_get_nvram_var, bhnd_generic_get_nvram_var), 1222 1223 /* BHND interface (bus I/O) */ 1224 DEVMETHOD(bhnd_bus_read_1, bhnd_read_1), 1225 DEVMETHOD(bhnd_bus_read_2, bhnd_read_2), 1226 DEVMETHOD(bhnd_bus_read_4, bhnd_read_4), 1227 DEVMETHOD(bhnd_bus_write_1, bhnd_write_1), 1228 DEVMETHOD(bhnd_bus_write_2, bhnd_write_2), 1229 DEVMETHOD(bhnd_bus_write_4, bhnd_write_4), 1230 1231 DEVMETHOD(bhnd_bus_read_stream_1, bhnd_read_stream_1), 1232 DEVMETHOD(bhnd_bus_read_stream_2, bhnd_read_stream_2), 1233 DEVMETHOD(bhnd_bus_read_stream_4, bhnd_read_stream_4), 1234 DEVMETHOD(bhnd_bus_write_stream_1, bhnd_write_stream_1), 1235 DEVMETHOD(bhnd_bus_write_stream_2, bhnd_write_stream_2), 1236 DEVMETHOD(bhnd_bus_write_stream_4, bhnd_write_stream_4), 1237 1238 DEVMETHOD(bhnd_bus_read_multi_1, bhnd_read_multi_1), 1239 DEVMETHOD(bhnd_bus_read_multi_2, bhnd_read_multi_2), 1240 DEVMETHOD(bhnd_bus_read_multi_4, bhnd_read_multi_4), 1241 DEVMETHOD(bhnd_bus_write_multi_1, bhnd_write_multi_1), 1242 DEVMETHOD(bhnd_bus_write_multi_2, bhnd_write_multi_2), 1243 DEVMETHOD(bhnd_bus_write_multi_4, bhnd_write_multi_4), 1244 1245 DEVMETHOD(bhnd_bus_read_multi_stream_1, bhnd_read_multi_stream_1), 1246 DEVMETHOD(bhnd_bus_read_multi_stream_2, bhnd_read_multi_stream_2), 1247 DEVMETHOD(bhnd_bus_read_multi_stream_4, bhnd_read_multi_stream_4), 1248 DEVMETHOD(bhnd_bus_write_multi_stream_1,bhnd_write_multi_stream_1), 1249 DEVMETHOD(bhnd_bus_write_multi_stream_2,bhnd_write_multi_stream_2), 1250 DEVMETHOD(bhnd_bus_write_multi_stream_4,bhnd_write_multi_stream_4), 1251 1252 DEVMETHOD(bhnd_bus_set_multi_1, bhnd_set_multi_1), 1253 DEVMETHOD(bhnd_bus_set_multi_2, bhnd_set_multi_2), 1254 DEVMETHOD(bhnd_bus_set_multi_4, bhnd_set_multi_4), 1255 1256 DEVMETHOD(bhnd_bus_set_region_1, bhnd_set_region_1), 1257 DEVMETHOD(bhnd_bus_set_region_2, bhnd_set_region_2), 1258 DEVMETHOD(bhnd_bus_set_region_4, bhnd_set_region_4), 1259 1260 DEVMETHOD(bhnd_bus_read_region_1, bhnd_read_region_1), 1261 DEVMETHOD(bhnd_bus_read_region_2, bhnd_read_region_2), 1262 DEVMETHOD(bhnd_bus_read_region_4, bhnd_read_region_4), 1263 DEVMETHOD(bhnd_bus_write_region_1, bhnd_write_region_1), 1264 DEVMETHOD(bhnd_bus_write_region_2, bhnd_write_region_2), 1265 DEVMETHOD(bhnd_bus_write_region_4, bhnd_write_region_4), 1266 1267 DEVMETHOD(bhnd_bus_read_region_stream_1,bhnd_read_region_stream_1), 1268 DEVMETHOD(bhnd_bus_read_region_stream_2,bhnd_read_region_stream_2), 1269 DEVMETHOD(bhnd_bus_read_region_stream_4,bhnd_read_region_stream_4), 1270 DEVMETHOD(bhnd_bus_write_region_stream_1, bhnd_write_region_stream_1), 1271 DEVMETHOD(bhnd_bus_write_region_stream_2, bhnd_write_region_stream_2), 1272 DEVMETHOD(bhnd_bus_write_region_stream_4, bhnd_write_region_stream_4), 1273 1274 DEVMETHOD(bhnd_bus_barrier, bhnd_barrier), 1275 1276 DEVMETHOD_END 1277 }; 1278 1279 devclass_t bhnd_devclass; /**< bhnd bus. */ 1280 devclass_t bhnd_hostb_devclass; /**< bhnd bus host bridge. */ 1281 devclass_t bhnd_nvram_devclass; /**< bhnd NVRAM device */ 1282 1283 DEFINE_CLASS_0(bhnd, bhnd_driver, bhnd_methods, sizeof(struct bhnd_softc)); 1284 MODULE_VERSION(bhnd, 1); 1285