summaryrefslogtreecommitdiffstats
path: root/sys/dev/dpt/dpt_eisa.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/dpt/dpt_eisa.c')
-rw-r--r--sys/dev/dpt/dpt_eisa.c192
1 files changed, 93 insertions, 99 deletions
diff --git a/sys/dev/dpt/dpt_eisa.c b/sys/dev/dpt/dpt_eisa.c
index 65eefc9..a8b2448 100644
--- a/sys/dev/dpt/dpt_eisa.c
+++ b/sys/dev/dpt/dpt_eisa.c
@@ -33,7 +33,7 @@
*/
/*
- * $Id: dpt_eisa.c,v 1.3 1998/08/09 02:22:34 jkh Exp $
+ * $Id: dpt_eisa.c,v 1.4 1998/09/15 08:33:35 gibbs Exp $
*/
#include "eisa.h"
@@ -46,9 +46,13 @@
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
#include <machine/bus_pio.h>
#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
#include <cam/scsi/scsi_all.h>
@@ -65,100 +69,80 @@
/* Function Prototypes */
-static int dpt_eisa_probe(void);
-static int dpt_eisa_attach(struct eisa_device*);
-
static const char *dpt_eisa_match(eisa_id_t);
-static struct eisa_driver dpt_eisa_driver =
-{
- "dpt",
- dpt_eisa_probe,
- dpt_eisa_attach,
- NULL,
- &dpt_unit
-};
-
-DATA_SET (eisadriver_set, dpt_eisa_driver);
-
static int
-dpt_eisa_probe(void)
+dpt_eisa_probe(device_t dev)
{
- struct eisa_device *e_dev = NULL;
- int count;
+ const char *desc;
u_int32_t io_base;
u_int intdef;
u_int irq;
- e_dev = NULL;
- count = 0;
- while ((e_dev = eisa_match_dev(e_dev, dpt_eisa_match))) {
- io_base = (e_dev->ioconf.slot * EISA_SLOT_SIZE)
- + DPT_EISA_SLOT_OFFSET;
+ desc = dpt_eisa_match(eisa_get_id(dev));
+ if (!desc)
+ return (ENXIO);
+ device_set_desc(dev, desc);
- eisa_add_iospace(e_dev, io_base,
- DPT_EISA_IOSIZE, RESVADDR_NONE);
+ io_base = (eisa_get_slot(dev) * EISA_SLOT_SIZE)
+ + DPT_EISA_SLOT_OFFSET;
+
+ eisa_add_iospace(dev, io_base, DPT_EISA_IOSIZE, RESVADDR_NONE);
- intdef = inb(DPT_EISA_INTDEF + io_base);
+ intdef = inb(DPT_EISA_INTDEF + io_base);
+
+ irq = intdef & DPT_EISA_INT_NUM_MASK;
+ switch (irq) {
+ case DPT_EISA_INT_NUM_11:
+ irq = 11;
+ break;
+ case DPT_EISA_INT_NUM_15:
+ irq = 15;
+ break;
+ case DPT_EISA_INT_NUM_14:
+ irq = 14;
+ break;
+ default:
+ printf("dpt at slot %d: illegal irq setting %d\n",
+ eisa_get_slot(dev), irq);
+ irq = 0;
+ break;
+ }
+ if (irq == 0)
+ return ENXIO;
- irq = intdef & DPT_EISA_INT_NUM_MASK;
- switch (irq) {
- case DPT_EISA_INT_NUM_11:
- irq = 11;
- break;
- case DPT_EISA_INT_NUM_15:
- irq = 15;
- break;
- case DPT_EISA_INT_NUM_14:
- irq = 14;
- break;
- default:
- printf("dpt at slot %d: illegal irq setting %d\n",
- e_dev->ioconf.slot, irq);
- irq = 0;
- break;
- }
- if (irq == 0)
- continue;
+ eisa_add_intr(dev, irq);
- eisa_add_intr(e_dev, irq);
- eisa_registerdev(e_dev, &dpt_eisa_driver);
- count++;
- }
- return count;
+ return 0;
}
-int
-dpt_eisa_attach(e_dev)
- struct eisa_device *e_dev;
+static int
+dpt_eisa_attach(device_t dev)
{
dpt_softc_t *dpt;
- resvaddr_t *io_space;
- int unit = e_dev->unit;
- int irq;
+ struct resource *io = 0;
+ struct resource *irq = 0;
+ int unit = device_get_unit(dev);
int shared;
int s;
-
- if (TAILQ_FIRST(&e_dev->ioconf.irqs) == NULL) {
- printf("dpt%d: Can't retrieve irq from EISA config struct.\n",
- unit);
- return -1;
- }
-
- irq = TAILQ_FIRST(&e_dev->ioconf.irqs)->irq_no;
- io_space = e_dev->ioconf.ioaddrs.lh_first;
-
- if (!io_space) {
- printf("dpt%d: No I/O space?!\n", unit);
- return -1;
+ int rid;
+ void *ih;
+
+ rid = 0;
+ io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!io) {
+ device_printf(dev, "No I/O space?!\n");
+ return ENOMEM;
}
- shared = inb(DPT_EISA_INTDEF + io_space->addr) & DPT_EISA_INT_LEVEL;
+ shared = (inb(DPT_EISA_INTDEF + rman_get_start(io))
+ & DPT_EISA_INT_LEVEL) ? RF_SHAREABLE : 0;
- dpt = dpt_alloc(unit, I386_BUS_SPACE_IO,
- io_space->addr + DPT_EISA_EATA_REG_OFFSET);
+ dpt = dpt_alloc(unit, rman_get_bustag(io),
+ rman_get_bushandle(io) + DPT_EISA_EATA_REG_OFFSET);
if (dpt == NULL)
- return -1;
+ goto bad;
/* Allocate a dmatag representing the capabilities of this attachment */
/* XXX Should be a child of the EISA bus dma tag */
@@ -171,46 +155,37 @@ dpt_eisa_attach(e_dev)
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &dpt->parent_dmat) != 0) {
dpt_free(dpt);
- return -1;
+ goto bad;
}
- if (eisa_reg_intr(e_dev, irq, dpt_intr, (void *)dpt, &cam_imask,
- shared)) {
- printf("dpt%d: eisa_reg_intr() failed.\n", unit);
- dpt_free(dpt);
- return -1;
- }
- eisa_reg_end(e_dev);
-
- /* Enable our interrupt handler. */
- if (eisa_enable_intr(e_dev, irq)) {
-#ifdef DPT_DEBUG_ERROR
- printf("dpt%d: eisa_enable_intr() failed.\n", unit);
-#endif
- free(dpt, M_DEVBUF);
- eisa_release_intr(e_dev, irq, dpt_intr);
- return -1;
- }
- /*
- * Enable our interrupt handler.
- */
- if (eisa_enable_intr(e_dev, irq)) {
- dpt_free(dpt);
- eisa_release_intr(e_dev, irq, dpt_intr);
- return -1;
+ rid = 0;
+ irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
+ 0, ~0, 1, shared | RF_ACTIVE);
+ if (!irq) {
+ device_printf(dev, "No irq?!\n");
+ goto bad;
}
s = splcam();
if (dpt_init(dpt) != 0) {
dpt_free(dpt);
- return -1;
+ goto bad;
}
/* Register with the XPT */
dpt_attach(dpt);
+ bus_setup_intr(dev, irq, dpt_intr, dpt, &ih);
+
splx(s);
return 0;
+
+ bad:
+ if (io)
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
+ if (irq)
+ bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
+ return -1;
}
static const char *
@@ -264,4 +239,23 @@ dpt_eisa_match(type)
return (NULL);
}
+static device_method_t dpt_eisa_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, dpt_eisa_probe),
+ DEVMETHOD(device_attach, dpt_eisa_attach),
+
+ { 0, 0 }
+};
+
+static driver_t dpt_eisa_driver = {
+ "dpt",
+ dpt_eisa_methods,
+ DRIVER_TYPE_CAM,
+ 1, /* unused */
+};
+
+static devclass_t dpt_devclass;
+
+DRIVER_MODULE(dpt, eisa, dpt_eisa_driver, dpt_devclass, 0, 0);
+
#endif /* NEISA > 0 */
OpenPOWER on IntegriCloud