Ejemplo n.º 1
0
int
mps_pci_setup_interrupts(struct mps_softc *sc)
{
	device_t dev;
	int error;
	u_int irq_flags;

	dev = sc->mps_dev;
#if 0 /* XXX swildner */
	if ((sc->disable_msix == 0) &&
	    ((msgs = pci_msix_count(dev)) >= MPS_MSI_COUNT))
		error = mps_alloc_msix(sc, MPS_MSI_COUNT);
#endif

	sc->mps_irq_rid[0] = 0;
	sc->mps_irq_type[0] = pci_alloc_1intr(dev, sc->enable_msi,
	    &sc->mps_irq_rid[0], &irq_flags);
	sc->mps_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ,
	    &sc->mps_irq_rid[0],  irq_flags);
	if (sc->mps_irq[0] == NULL) {
		device_printf(dev, "Cannot allocate interrupt\n");
		return (ENXIO);
	}
	error = bus_setup_intr(dev, sc->mps_irq[0], INTR_MPSAFE, mps_intr, sc,
	    &sc->mps_intrhand[0], NULL);
	if (error)
		device_printf(dev, "Cannot setup interrupt\n");

	return (error);
}
Ejemplo n.º 2
0
int
mps_pci_setup_interrupts(struct mps_softc *sc)
{
    device_t dev;
    int i, error, msgs;

    dev = sc->mps_dev;
    error = ENXIO;
    if ((sc->disable_msix == 0) &&
            ((msgs = pci_msix_count(dev)) >= MPS_MSI_COUNT))
        error = mps_alloc_msix(sc, MPS_MSI_COUNT);
    if ((error != 0) && (sc->disable_msi == 0) &&
            ((msgs = pci_msi_count(dev)) >= MPS_MSI_COUNT))
        error = mps_alloc_msi(sc, MPS_MSI_COUNT);

    if (error != 0) {
        sc->mps_flags |= MPS_FLAGS_INTX;
        sc->mps_irq_rid[0] = 0;
        sc->mps_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ,
                                                &sc->mps_irq_rid[0],  RF_SHAREABLE | RF_ACTIVE);
        if (sc->mps_irq[0] == NULL) {
            mps_printf(sc, "Cannot allocate INTx interrupt\n");
            return (ENXIO);
        }
        error = bus_setup_intr(dev, sc->mps_irq[0],
                               INTR_TYPE_BIO | INTR_MPSAFE, NULL, mps_intr, sc,
                               &sc->mps_intrhand[0]);
        if (error)
            mps_printf(sc, "Cannot setup INTx interrupt\n");
    } else {
        sc->mps_flags |= MPS_FLAGS_MSI;
        for (i = 0; i < MPS_MSI_COUNT; i++) {
            sc->mps_irq_rid[i] = i + 1;
            sc->mps_irq[i] = bus_alloc_resource_any(dev,
                                                    SYS_RES_IRQ, &sc->mps_irq_rid[i], RF_ACTIVE);
            if (sc->mps_irq[i] == NULL) {
                mps_printf(sc,
                           "Cannot allocate MSI interrupt\n");
                return (ENXIO);
            }
            error = bus_setup_intr(dev, sc->mps_irq[i],
                                   INTR_TYPE_BIO | INTR_MPSAFE, NULL, mps_intr_msi,
                                   sc, &sc->mps_intrhand[i]);
            if (error) {
                mps_printf(sc,
                           "Cannot setup MSI interrupt %d\n", i);
                break;
            }
        }
    }

    return (error);
}