summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2001-05-28 02:53:02 +0000
committerimp <imp@FreeBSD.org>2001-05-28 02:53:02 +0000
commit476e3d24e2f2e209b5a8f8b090f341decf72bcc6 (patch)
tree896bc928d7846a9a7e5c9e26e5a0de8a4d70447e
parent315d04216a024b672d86764ea09a860493672bb5 (diff)
downloadFreeBSD-src-476e3d24e2f2e209b5a8f8b090f341decf72bcc6.zip
FreeBSD-src-476e3d24e2f2e209b5a8f8b090f341decf72bcc6.tar.gz
Turns out that one bit isn't enough. Introduce two new fields
csc_route and func_route to hold the way that each interrupt is routed. csc is Card Status Change in the datasheets and standard, but is called "Management Interrupt" in FreeBSDese. There are three types of interrupt routing: ISA parallel, PCI parallel and ISA serial (some chipsets support other types as well, but I don't plan on supporting them). When we try to allocate an interrupt, and the type for that interrupt is pci_parallel, allow it to be shared by oring in RF_SHAREABLE to the flags argument. Introduce pcic_alloc_resource to allow this to happen.
-rw-r--r--sys/pccard/pcic.c18
-rw-r--r--sys/pccard/pcic_isa.c4
-rw-r--r--sys/pccard/pcicvar.h33
3 files changed, 39 insertions, 16 deletions
diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c
index 8a3598c..43b33d3 100644
--- a/sys/pccard/pcic.c
+++ b/sys/pccard/pcic.c
@@ -324,7 +324,7 @@ pcic_attach(device_t dev)
rid = 0;
r = NULL;
flags = RF_ACTIVE;
- if (sc->flags & PCIC_SHARED_IRQ)
+ if (sc->csc_route == pci_parallel)
flags |= RF_SHAREABLE;
r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, flags);
if (r == NULL) {
@@ -905,3 +905,19 @@ pcic_get_memory_offset(device_t bus, device_t child, int rid, u_int32_t *offset)
return (0);
}
+
+struct resource *
+pcic_alloc_resource(device_t dev, device_t child, int type, int *rid,
+ u_long start, u_long end, u_long count, u_int flags)
+{
+ struct pcic_softc *sc = device_get_softc(dev);
+
+ /*
+ * If we're routing via pci, we can share.
+ */
+ if (sc->func_route == pci_parallel && type == SYS_RES_IRQ)
+ flags |= RF_SHAREABLE;
+
+ return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
+ count, flags));
+}
diff --git a/sys/pccard/pcic_isa.c b/sys/pccard/pcic_isa.c
index 5e18bb2..9856461 100644
--- a/sys/pccard/pcic_isa.c
+++ b/sys/pccard/pcic_isa.c
@@ -284,6 +284,8 @@ pcic_isa_attach(device_t dev)
}
sc->iorid = rid;
sc->iores = r;
+ sc->csc_route = isa_parallel;
+ sc->func_route = isa_parallel;
return (pcic_attach(dev));
}
@@ -298,7 +300,7 @@ static device_method_t pcic_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_alloc_resource, pcic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, pcic_activate_resource),
DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource),
diff --git a/sys/pccard/pcicvar.h b/sys/pccard/pcicvar.h
index 81db1eb..b853a57 100644
--- a/sys/pccard/pcicvar.h
+++ b/sys/pccard/pcicvar.h
@@ -40,6 +40,8 @@ struct pcic_slot {
bus_space_handle_t bsh;
};
+enum pcic_irq_type { isa_parallel, pci_parallel, isa_serial };
+
struct pcic_softc
{
u_int32_t slotmask;/* Mask of valid slots */
@@ -50,7 +52,8 @@ struct pcic_softc
#define PCIC_VG_POWER 0x00000008 /* Uses VG power regs */
#define PCIC_KING_POWER 0x00000010 /* Uses IBM KING regs */
#define PCIC_RICOH_POWER 0x00000020 /* Uses the ricoh power regs */
-#define PCIC_SHARED_IRQ 0x00000040 /* Allow IRQs to be shared */
+ enum pcic_irq_type csc_route; /* How to route csc interrupts */
+ enum pcic_irq_type func_route; /* How to route function ints */
int iorid; /* Rid of I/O region */
struct resource *iores; /* resource for I/O region */
int memrid; /* Memory rid */
@@ -67,25 +70,27 @@ struct pcic_softc
extern devclass_t pcic_devclass;
-int pcic_attach(device_t dev);
int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
struct resource *r);
+struct resource *pcic_alloc_resource(device_t dev, device_t child, int type,
+ int *rid, u_long start, u_long end, u_long count, u_int flags);
+int pcic_attach(device_t dev);
+void pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask);
int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
struct resource *r);
-int pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
- int flags, driver_intr_t *intr, void *arg, void **cookiep);
-int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
- void *cookie);
-int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
- u_long value);
-int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
- u_long *value);
+void pcic_dealloc(device_t dev);
int pcic_get_memory_offset(device_t bus, device_t child, int rid,
u_int32_t *offset);
+int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
+ u_long *value);
+unsigned char pcic_getb_io(struct pcic_slot *sp, int reg);
+void pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val);
int pcic_set_memory_offset(device_t bus, device_t child, int rid,
u_int32_t offset, u_int32_t *deltap);
-void pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask);
+int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
+ u_long value);
void pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask);
-void pcic_dealloc(device_t dev);
-unsigned char pcic_getb_io(struct pcic_slot *sp, int reg);
-void pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val);
+int pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
+ int flags, driver_intr_t *intr, void *arg, void **cookiep);
+int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
+ void *cookie);
OpenPOWER on IntegriCloud