* Retain @p isrc and assign a MIPS CPU interrupt on behalf of @p res; if * the @p isrc already has a MIPS CPU interrupt assigned, the existing * reference will be left unmodified. * * @param sc BHND MIPS driver state. * @param isrc The interrupt source corresponding to @p res. * @param res The interrupt resource for which a MIPS CPU IRQ will be * assigned. */
| 526 | * assigned. |
| 527 | */ |
| 528 | static int |
| 529 | bcm_mips_retain_cpu_intr(struct bcm_mips_softc *sc, |
| 530 | struct bcm_mips_irqsrc *isrc, struct resource *res) |
| 531 | { |
| 532 | struct bcm_mips_cpuirq *cpuirq; |
| 533 | bhnd_devclass_t devclass; |
| 534 | device_t core; |
| 535 | |
| 536 | BCM_MIPS_LOCK_ASSERT(sc, MA_OWNED); |
| 537 | |
| 538 | /* Prefer existing assignment */ |
| 539 | if (isrc->cpuirq != NULL) { |
| 540 | KASSERT(isrc->cpuirq->refs > 0, ("assigned IRQ has no " |
| 541 | "references")); |
| 542 | |
| 543 | /* Increment our reference count */ |
| 544 | if (isrc->refs == UINT_MAX) |
| 545 | return (ENOMEM); /* would overflow */ |
| 546 | |
| 547 | isrc->refs++; |
| 548 | return (0); |
| 549 | } |
| 550 | |
| 551 | /* Use the device class of the bhnd core to which the interrupt |
| 552 | * vector is routed to determine whether a shared interrupt should |
| 553 | * be preferred. */ |
| 554 | devclass = BHND_DEVCLASS_OTHER; |
| 555 | core = bcm_mips_find_bhnd_parent(rman_get_device(res)); |
| 556 | if (core != NULL) |
| 557 | devclass = bhnd_get_class(core); |
| 558 | |
| 559 | switch (devclass) { |
| 560 | case BHND_DEVCLASS_CC: |
| 561 | case BHND_DEVCLASS_CC_B: |
| 562 | case BHND_DEVCLASS_PMU: |
| 563 | case BHND_DEVCLASS_RAM: |
| 564 | case BHND_DEVCLASS_MEMC: |
| 565 | case BHND_DEVCLASS_CPU: |
| 566 | case BHND_DEVCLASS_SOC_ROUTER: |
| 567 | case BHND_DEVCLASS_SOC_BRIDGE: |
| 568 | case BHND_DEVCLASS_EROM: |
| 569 | case BHND_DEVCLASS_NVRAM: |
| 570 | /* Always use a shared interrupt for these devices */ |
| 571 | cpuirq = &sc->cpuirqs[BCM_MIPS_IRQ_SHARED]; |
| 572 | break; |
| 573 | |
| 574 | case BHND_DEVCLASS_PCI: |
| 575 | case BHND_DEVCLASS_PCIE: |
| 576 | case BHND_DEVCLASS_PCCARD: |
| 577 | case BHND_DEVCLASS_ENET: |
| 578 | case BHND_DEVCLASS_ENET_MAC: |
| 579 | case BHND_DEVCLASS_ENET_PHY: |
| 580 | case BHND_DEVCLASS_WLAN: |
| 581 | case BHND_DEVCLASS_WLAN_MAC: |
| 582 | case BHND_DEVCLASS_WLAN_PHY: |
| 583 | case BHND_DEVCLASS_USB_HOST: |
| 584 | case BHND_DEVCLASS_USB_DEV: |
| 585 | case BHND_DEVCLASS_USB_DUAL: |
no test coverage detected