summaryrefslogtreecommitdiffstats
path: root/sys/dev/pcic
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1999-12-08 01:42:44 +0000
committerimp <imp@FreeBSD.org>1999-12-08 01:42:44 +0000
commit08ea43ec86d1c656866bc7dc29e0f8e398c6b8cd (patch)
treeb24e556d572bb05b5d69249c2185655f39686509 /sys/dev/pcic
parented204f848e70fe5cec8c585988ab30e54d850b3b (diff)
downloadFreeBSD-src-08ea43ec86d1c656866bc7dc29e0f8e398c6b8cd.zip
FreeBSD-src-08ea43ec86d1c656866bc7dc29e0f8e398c6b8cd.tar.gz
o Implement IRQ activation. We do this in bus_{setup,teardown}_intr,
per discussions on -arch. This is different than -current's pccard code, but shouldn't have any real difference. o More code cleanup. Next step: convert bus_space_* mapping stuff to newbus.
Diffstat (limited to 'sys/dev/pcic')
-rw-r--r--sys/dev/pcic/i82365.c181
-rw-r--r--sys/dev/pcic/i82365_isa.c4
-rw-r--r--sys/dev/pcic/i82365_isasubr.c72
-rw-r--r--sys/dev/pcic/i82365_isavar.h9
-rw-r--r--sys/dev/pcic/i82365var.h4
5 files changed, 75 insertions, 195 deletions
diff --git a/sys/dev/pcic/i82365.c b/sys/dev/pcic/i82365.c
index 0a1b38a..a6929a2 100644
--- a/sys/dev/pcic/i82365.c
+++ b/sys/dev/pcic/i82365.c
@@ -82,31 +82,27 @@ int pcic_debug = 0;
static void pcic_attach_socket(device_t, struct pcic_handle *);
static void pcic_init_socket(struct pcic_handle *);
-#if XXX
-int pcic_submatch (struct device *, struct cfdata *, void *);
-#endif
-int pcic_intr_socket (struct pcic_handle *);
+int pcic_intr_socket(struct pcic_handle *);
-void pcic_attach_card (struct pcic_handle *);
-void pcic_detach_card (struct pcic_handle *, int);
-void pcic_deactivate_card (struct pcic_handle *);
+void pcic_attach_card(struct pcic_handle *);
+void pcic_detach_card(struct pcic_handle *, int);
+void pcic_deactivate_card(struct pcic_handle *);
-void pcic_chip_do_mem_map (struct pcic_handle *, int);
-void pcic_chip_do_io_map (struct pcic_handle *, int);
+void pcic_chip_do_mem_map(struct pcic_handle *, int);
+void pcic_chip_do_io_map(struct pcic_handle *, int);
-void pcic_create_event_thread (void *);
-void pcic_event_thread (void *);
+void pcic_create_event_thread(void *);
+void pcic_event_thread(void *);
-void pcic_queue_event (struct pcic_handle *, int);
+void pcic_queue_event(struct pcic_handle *, int);
-static void pcic_wait_ready (struct pcic_handle *);
+static void pcic_wait_ready(struct pcic_handle *);
-static u_int8_t st_pcic_read (struct pcic_handle *, int);
-static void st_pcic_write (struct pcic_handle *, int, u_int8_t);
+static u_int8_t st_pcic_read(struct pcic_handle *, int);
+static void st_pcic_write(struct pcic_handle *, int, u_int8_t);
int
-pcic_ident_ok(ident)
- int ident;
+pcic_ident_ok(int ident)
{
/* this is very empirical and heuristic */
@@ -124,8 +120,7 @@ pcic_ident_ok(ident)
}
int
-pcic_vendor(h)
- struct pcic_handle *h;
+pcic_vendor(struct pcic_handle *h)
{
int reg;
@@ -159,8 +154,7 @@ pcic_vendor(h)
}
char *
-pcic_vendor_to_string(vendor)
- int vendor;
+pcic_vendor_to_string(int vendor)
{
switch (vendor) {
case PCIC_VENDOR_I82365SLR0:
@@ -378,8 +372,7 @@ pcic_attach_socket(device_t dev, struct pcic_handle *h)
}
void
-pcic_create_event_thread(arg)
- void *arg;
+pcic_create_event_thread(void *arg)
{
struct pcic_handle *h = arg;
const char *cs;
@@ -410,8 +403,7 @@ pcic_create_event_thread(arg)
}
void
-pcic_event_thread(arg)
- void *arg;
+pcic_event_thread(void *arg)
{
struct pcic_handle *h = arg;
struct pcic_event *pe;
@@ -498,8 +490,7 @@ pcic_event_thread(arg)
}
void
-pcic_init_socket(h)
- struct pcic_handle *h;
+pcic_init_socket(struct pcic_handle *h)
{
int reg;
struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
@@ -545,73 +536,8 @@ pcic_init_socket(h)
}
}
-#if XXX
-int
-pcic_submatch(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
-{
-
- struct pccardbus_attach_args *paa = aux;
- struct pcic_handle *h = (struct pcic_handle *) paa->pch;
-
- switch (h->sock) {
- case C0SA:
- if (cf->cf_loc[PCCARDBUSCF_CONTROLLER] !=
- PCCARDBUSCF_CONTROLLER_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_CONTROLLER] != 0)
- return 0;
- if (cf->cf_loc[PCCARDBUSCF_SOCKET] !=
- PCCARDBUSCF_SOCKET_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_SOCKET] != 0)
- return 0;
-
- break;
- case C0SB:
- if (cf->cf_loc[PCCARDBUSCF_CONTROLLER] !=
- PCCARDBUSCF_CONTROLLER_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_CONTROLLER] != 0)
- return 0;
- if (cf->cf_loc[PCCARDBUSCF_SOCKET] !=
- PCCARDBUSCF_SOCKET_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_SOCKET] != 1)
- return 0;
-
- break;
- case C1SA:
- if (cf->cf_loc[PCCARDBUSCF_CONTROLLER] !=
- PCCARDBUSCF_CONTROLLER_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_CONTROLLER] != 1)
- return 0;
- if (cf->cf_loc[PCCARDBUSCF_SOCKET] !=
- PCCARDBUSCF_SOCKET_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_SOCKET] != 0)
- return 0;
-
- break;
- case C1SB:
- if (cf->cf_loc[PCCARDBUSCF_CONTROLLER] !=
- PCCARDBUSCF_CONTROLLER_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_CONTROLLER] != 1)
- return 0;
- if (cf->cf_loc[PCCARDBUSCF_SOCKET] !=
- PCCARDBUSCF_SOCKET_DEFAULT &&
- cf->cf_loc[PCCARDBUSCF_SOCKET] != 1)
- return 0;
-
- break;
- default:
- panic("unknown pcic socket");
- }
-
- return ((*cf->cf_attach->ca_match)(parent, cf, aux));
-}
-#endif
-
int
-pcic_intr(arg)
- void *arg;
+pcic_intr(void *arg)
{
struct pcic_softc *sc = arg;
int i, ret = 0;
@@ -626,8 +552,7 @@ pcic_intr(arg)
}
int
-pcic_intr_socket(h)
- struct pcic_handle *h;
+pcic_intr_socket(struct pcic_handle *h)
{
int cscreg;
@@ -687,9 +612,7 @@ pcic_intr_socket(h)
}
void
-pcic_queue_event(h, event)
- struct pcic_handle *h;
- int event;
+pcic_queue_event(struct pcic_handle *h, int event)
{
struct pcic_event *pe;
int s;
@@ -706,8 +629,7 @@ pcic_queue_event(h, event)
}
void
-pcic_attach_card(h)
- struct pcic_handle *h;
+pcic_attach_card(struct pcic_handle *h)
{
if (!(h->flags & PCIC_FLAG_CARDP)) {
@@ -721,9 +643,7 @@ pcic_attach_card(h)
}
void
-pcic_detach_card(h, flags)
- struct pcic_handle *h;
- int flags; /* DETACH_* */
+pcic_detach_card(struct pcic_handle *h, int flags)
{
if (h->flags & PCIC_FLAG_CARDP) {
@@ -737,8 +657,7 @@ pcic_detach_card(h, flags)
}
void
-pcic_deactivate_card(h)
- struct pcic_handle *h;
+pcic_deactivate_card(struct pcic_handle *h)
{
/* call the MI deactivate function */
@@ -1374,9 +1293,6 @@ int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
return err;
}
break;
- case SYS_RES_IRQ:
- /* XXX */
- break;
case SYS_RES_MEMORY:
err = pcic_chip_mem_alloc(h, sz, &h->mem[rid]);
if (err)
@@ -1390,7 +1306,8 @@ int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
default:
break;
}
- err = bus_generic_activate_resource(dev, child, type, rid, r);
+ err = bus_generic_activate_resource(device_get_parent(dev), child,
+ type, rid, r);
return (err);
}
@@ -1404,8 +1321,6 @@ int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
case SYS_RES_IOPORT:
pcic_chip_io_unmap(h, rid);
pcic_chip_io_free(h, &h->io[rid]);
- case SYS_RES_IRQ:
- /* XXX */
break;
case SYS_RES_MEMORY:
pcic_chip_mem_unmap(h, rid);
@@ -1413,6 +1328,48 @@ int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
default:
break;
}
- err = bus_generic_deactivate_resource(dev, child, type, rid, r);
+ err = bus_generic_deactivate_resource(device_get_parent(dev), child,
+ type, rid, r);
return (err);
}
+int pcic_setup_intr(device_t dev, device_t child, struct resource *irqres,
+ int flags, driver_intr_t intr, void *arg, void **cookiep)
+{
+ struct pcic_handle *h = (struct pcic_handle *) device_get_ivars(child);
+ int reg;
+ int irq;
+ int err;
+
+ err = bus_generic_setup_intr(device_get_parent(dev), child, irqres,
+ flags, intr, arg, cookiep);
+ if (!err)
+ return (err);
+
+ irq = rman_get_start(irqres);
+ reg = pcic_read(h, PCIC_INTR);
+ reg &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_ENABLE);
+ reg |= irq;
+ pcic_write(h, PCIC_INTR, reg);
+
+ h->ih_irq = irq;
+
+ printf("card irq %d\n",irq);
+
+ return 0;
+}
+
+int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
+ void *cookiep)
+{
+ int reg;
+ struct pcic_handle *h = (struct pcic_handle *) device_get_ivars(child);
+
+ h->ih_irq = 0;
+
+ reg = pcic_read(h, PCIC_INTR);
+ reg &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_ENABLE);
+ pcic_write(h, PCIC_INTR, reg);
+
+ return (bus_generic_teardown_intr(device_get_parent(dev), child, irq,
+ cookiep));
+}
diff --git a/sys/dev/pcic/i82365_isa.c b/sys/dev/pcic/i82365_isa.c
index 2be6a4a7..a85424c 100644
--- a/sys/dev/pcic/i82365_isa.c
+++ b/sys/dev/pcic/i82365_isa.c
@@ -220,8 +220,8 @@ static device_method_t pcic_isa_methods[] = {
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
DEVMETHOD(bus_activate_resource, pcic_activate_resource),
DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+ DEVMETHOD(bus_setup_intr, pcic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, pcic_teardown_intr),
#if 0
/* pccard/cardbus interface */
diff --git a/sys/dev/pcic/i82365_isasubr.c b/sys/dev/pcic/i82365_isasubr.c
index 8c43940..0192eb6 100644
--- a/sys/dev/pcic/i82365_isasubr.c
+++ b/sys/dev/pcic/i82365_isasubr.c
@@ -213,75 +213,3 @@ void pcic_isa_bus_width_probe (device_t dev)
(long) sc->iobase + sc->iosize));
}
}
-
-
-void *
-pcic_isa_chip_intr_establish(pch, pf, ipl, fct, arg)
- pccard_chipset_handle_t pch;
- struct pccard_function *pf;
- int ipl;
- int (*fct) (void *);
- void *arg;
-{
-#define IST_LEVEL 1
-#define IST_PULSE 2
-#define IST_EDGE 3
- struct pcic_handle *h = (struct pcic_handle *) pch;
- struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
-#if XXX
- isa_chipset_tag_t ic = sc->intr_est;
-#endif
- int irq, ist;
- void *ih;
- int reg;
-
- if (pf->cfe->flags & PCCARD_CFE_IRQLEVEL)
- ist = IST_LEVEL;
- else if (pf->cfe->flags & PCCARD_CFE_IRQPULSE)
- ist = IST_PULSE;
- else
- ist = IST_EDGE;
-
-#if XXX
- if (isa_intr_alloc(ic,
- PCIC_INTR_IRQ_VALIDMASK & pcic_isa_intr_alloc_mask, ist, &irq))
- return (NULL);
- if ((ih = isa_intr_establish(ic, irq, ist, ipl,
- fct, arg)) == NULL)
- return (NULL);
-#endif
-
- reg = pcic_read(h, PCIC_INTR);
- reg &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_ENABLE);
- reg |= irq;
- pcic_write(h, PCIC_INTR, reg);
-
- h->ih_irq = irq;
-
- printf("card irq %d\n",irq);
-
- return (ih);
-}
-
-void
-pcic_isa_chip_intr_disestablish(pch, ih)
- pccard_chipset_handle_t pch;
- void *ih;
-{
- struct pcic_handle *h = (struct pcic_handle *) pch;
- struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
-#if XXX
- isa_chipset_tag_t ic = sc->intr_est;
-#endif
- int reg;
-
- h->ih_irq = 0;
-
- reg = pcic_read(h, PCIC_INTR);
- reg &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_ENABLE);
- pcic_write(h, PCIC_INTR, reg);
-
-#if XXX
- isa_intr_disestablish(ic, ih);
-#endif
-}
diff --git a/sys/dev/pcic/i82365_isavar.h b/sys/dev/pcic/i82365_isavar.h
index bc0f2d1..2a58898 100644
--- a/sys/dev/pcic/i82365_isavar.h
+++ b/sys/dev/pcic/i82365_isavar.h
@@ -33,17 +33,8 @@
extern int pcic_isa_intr_alloc_mask;
-/*
- * Establish/disestablish interrupts for PCCARD functions.
- */
-
-void *pcic_isa_chip_intr_establish(pccard_chipset_handle_t,
- struct pccard_function *, int, int (*) (void *), void *);
-void pcic_isa_chip_intr_disestablish(pccard_chipset_handle_t, void *);
-
/*
* Figure out how wide the ISA bus is...
*/
void pcic_isa_bus_width_probe(device_t);
-
diff --git a/sys/dev/pcic/i82365var.h b/sys/dev/pcic/i82365var.h
index 7858f12..5d3391e 100644
--- a/sys/dev/pcic/i82365var.h
+++ b/sys/dev/pcic/i82365var.h
@@ -204,3 +204,7 @@ int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
struct resource *r);
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 *cookiep);
OpenPOWER on IntegriCloud