Allow a shareable interrupts. Note, the bridge must set this flag or

the irq will be unshareable, as things are now.

More work likely is needed, but this is a good checkpoint.

# pcic_pci.c is getting closer :-)
This commit is contained in:
Warner Losh 2001-05-27 05:53:37 +00:00
parent 68c805eb99
commit 92d08a4dcf
2 changed files with 16 additions and 15 deletions

View File

@ -286,7 +286,8 @@ int
pcic_attach(device_t dev) pcic_attach(device_t dev)
{ {
int error; int error;
int irq; u_int flags;
int irq = 0;
int i; int i;
device_t kid; device_t kid;
struct resource *r; struct resource *r;
@ -320,29 +321,30 @@ pcic_attach(device_t dev)
sp->sc = sc; sp->sc = sc;
} }
irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0);
if (irq == 0) {
/* See if the user has requested a specific IRQ */
if (!getenv_int("machdep.pccard.pcic_irq", &irq))
irq = 0;
}
rid = 0; rid = 0;
r = 0; r = NULL;
if (irq > 0) { flags = RF_ACTIVE;
r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq, if (sc->flags & PCIC_SHARED_IRQ)
irq, 1, RF_ACTIVE); flags |= RF_SHAREABLE;
r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, flags);
if (r == NULL) {
/* See if the user has requested a specific IRQ */
if (getenv_int("machdep.pccard.pcic_irq", &irq))
r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
irq, irq, 1, flags);
} }
if (r && ((1 << (rman_get_start(r))) & PCIC_INT_MASK_ALLOWED) == 0) { if (r && ((1 << (rman_get_start(r))) & PCIC_INT_MASK_ALLOWED) == 0) {
device_printf(dev, device_printf(dev,
"Hardware does not support irq %d, trying polling.\n", "Hardware does not support irq %d, trying polling.\n",
irq); irq);
bus_release_resource(dev, SYS_RES_IRQ, rid, r); bus_release_resource(dev, SYS_RES_IRQ, rid, r);
r = 0;
irq = 0; irq = 0;
r = NULL;
} }
sc->irqrid = rid; sc->irqrid = rid;
sc->irqres = r; sc->irqres = r;
if (r) { irq = 0;
if (r != NULL) {
error = bus_setup_intr(dev, r, INTR_TYPE_MISC, error = bus_setup_intr(dev, r, INTR_TYPE_MISC,
pcicintr, (void *) sc, &sc->ih); pcicintr, (void *) sc, &sc->ih);
if (error) { if (error) {
@ -351,8 +353,6 @@ pcic_attach(device_t dev)
} }
irq = rman_get_start(r); irq = rman_get_start(r);
device_printf(dev, "management irq %d\n", irq); device_printf(dev, "management irq %d\n", irq);
} else {
irq = 0;
} }
if (irq == 0) { if (irq == 0) {
sc->timeout_ch = timeout(pcictimeout, (void *) sc, hz/2); sc->timeout_ch = timeout(pcictimeout, (void *) sc, hz/2);

View File

@ -50,6 +50,7 @@ struct pcic_softc
#define PCIC_VG_POWER 0x00000008 /* Uses VG power regs */ #define PCIC_VG_POWER 0x00000008 /* Uses VG power regs */
#define PCIC_KING_POWER 0x00000010 /* Uses IBM KING regs */ #define PCIC_KING_POWER 0x00000010 /* Uses IBM KING regs */
#define PCIC_RICOH_POWER 0x00000020 /* Uses the ricoh power regs */ #define PCIC_RICOH_POWER 0x00000020 /* Uses the ricoh power regs */
#define PCIC_SHARED_IRQ 0x00000040 /* Allow IRQs to be shared */
int iorid; /* Rid of I/O region */ int iorid; /* Rid of I/O region */
struct resource *iores; /* resource for I/O region */ struct resource *iores; /* resource for I/O region */
int memrid; /* Memory rid */ int memrid; /* Memory rid */