summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-04-05 08:16:23 +0000
committerbde <bde@FreeBSD.org>2004-04-05 08:16:23 +0000
commit8ff01ad78588c2228109302e270b64639208cdee (patch)
treeadbcc6b808103d4af4980c216d34b82d4cc207bb /sys
parentad426d20c2816920c3f7fb41565bedfb2d9f34dc (diff)
downloadFreeBSD-src-8ff01ad78588c2228109302e270b64639208cdee.zip
FreeBSD-src-8ff01ad78588c2228109302e270b64639208cdee.tar.gz
Converted the isa probe and attach to new-bus so that this driver works
without the (defunct) isa compatibility shims. The new-bus-specific parts are very similar to the ones for the pci probe and attach. This was held up too long waiting for a repo copy to src/sys/dev/cy, so I decided to fix the files in their old place. This gives easier to read and merge diffs anyway. The "count" line in src/sys/conf/files won't be changed until after the repo copy, so old kernel configs that specify a count need not be (and must not be) changed until then. The count is just ignored in the driver. One unfinished detail is dynamic allocation of arrays with <count> and (<count> * 32) entries, and iteration over the arrays. This is now kludged with a fixed count of 10 (up to 10 cards with up to 32 ports each). Prodded by: imp Submitted by: mostly by imp Approved by: imp
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/cy/cy.c126
-rw-r--r--sys/dev/cy/cy_isa.c126
-rw-r--r--sys/dev/cy/cy_pci.c4
-rw-r--r--sys/i386/isa/cy.c126
-rw-r--r--sys/pci/cy_pci.c4
5 files changed, 247 insertions, 139 deletions
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c
index 218f57f..1c7d8ff 100644
--- a/sys/dev/cy/cy.c
+++ b/sys/dev/cy/cy.c
@@ -32,7 +32,6 @@
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
-#include "cy.h"
/*
* TODO:
@@ -81,15 +80,17 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/tty.h>
+#include <machine/bus.h>
#include <machine/psl.h>
+#include <sys/rman.h>
+#include <machine/resource.h>
+
+#include <isa/isavar.h>
-#include <i386/isa/isa_device.h>
#include <i386/isa/cyreg.h>
#include <i386/isa/ic/cd1400.h>
-#ifndef COMPAT_OLDISA
-#error "The cy device requires the old isa compatibility shims"
-#endif
+#define NCY 10 /* KLUDGE */
/*
* Dictionary so that I can name everything *sio* or *com* to compare with
@@ -117,7 +118,6 @@ __FBSDID("$FreeBSD$");
#define comstart cystart
#define comwakeup cywakeup
#define p_com_addr p_cy_addr
-#define sioattach cyattach
#define sioclose cyclose
#define siodriver cydriver
#define siodtrwakeup cydtrwakeup
@@ -126,7 +126,6 @@ __FBSDID("$FreeBSD$");
#define sioioctl cyioctl
#define sioopen cyopen
#define siopoll cypoll
-#define sioprobe cyprobe
#define siosettimeout cysettimeout
#define siosetwater cysetwater
#define comstop cystop
@@ -332,25 +331,26 @@ struct com_s {
u_char obuf2[256];
};
+devclass_t cy_devclass;
+
/* PCI driver entry points. */
void *cyattach_common(cy_addr cy_iobase, int cy_align);
driver_intr_t siointr1;
-static ointhand2_t cyointr;
static int cy_units(cy_addr cy_iobase, int cy_align);
-static int sioattach(struct isa_device *dev);
static void cd1400_channel_cmd(struct com_s *com, int cmd);
static void cd1400_channel_cmd_wait(struct com_s *com);
static void cd_etc(struct com_s *com, int etc);
static int cd_getreg(struct com_s *com, int reg);
static void cd_setreg(struct com_s *com, int reg, int val);
+static int cy_isa_attach(device_t dev);
+static int cy_isa_probe(device_t dev);
static timeout_t siodtrwakeup;
static void comhardclose(struct com_s *com);
static void sioinput(struct com_s *com);
static int commctl(struct com_s *com, int bits, int how);
static int comparam(struct tty *tp, struct termios *t);
static void siopoll(void *arg);
-static int sioprobe(struct isa_device *dev);
static void siosettimeout(void);
static int siosetwater(struct com_s *com, speed_t speed);
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
@@ -372,13 +372,21 @@ static int sio_inited;
static struct com_s *p_com_addr[NSIO];
#define com_addr(unit) (p_com_addr[unit])
-struct isa_driver siodriver = {
- INTR_TYPE_TTY | INTR_FAST,
- sioprobe,
- sioattach,
- driver_name
+static device_method_t cy_isa_methods[] = {
+ /* Device interface. */
+ DEVMETHOD(device_probe, cy_isa_probe),
+ DEVMETHOD(device_attach, cy_isa_attach),
+
+ { 0, 0 }
};
-COMPAT_ISA_DRIVER(cy, cydriver); /* XXX */
+
+static driver_t cy_isa_driver = {
+ driver_name,
+ cy_isa_methods,
+ 0,
+};
+
+DRIVER_MODULE(cy, isa, cy_isa_driver, cy_devclass, 0, 0);
static d_open_t sioopen;
static d_close_t sioclose;
@@ -423,12 +431,23 @@ static int cy_total_devices;
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
static int
-sioprobe(dev)
- struct isa_device *dev;
+cy_isa_probe(device_t dev)
{
- cy_addr iobase;
+ struct resource *mem_res;
+ cy_addr iobase;
+ int mem_rid;
+
+ if (isa_get_logicalid(dev) != 0) /* skip PnP probes */
+ return (ENXIO);
- iobase = (cy_addr)dev->id_maddr;
+ mem_rid = 0;
+ mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
+ 0ul, ~0ul, 0ul, RF_ACTIVE);
+ if (mem_res == NULL) {
+ device_printf(dev, "ioport resource allocation failed\n");
+ return (ENXIO);
+ }
+ iobase = rman_get_virtual(mem_res);
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
@@ -438,7 +457,8 @@ sioprobe(dev)
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
DELAY(500);
- return (cy_units(iobase, 0) == 0 ? 0 : -1);
+ bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
+ return (cy_units(iobase, 0) == 0 ? ENXIO : 0);
}
static int
@@ -494,29 +514,51 @@ cy_units(cy_iobase, cy_align)
}
static int
-sioattach(isdp)
- struct isa_device *isdp;
+cy_isa_attach(device_t dev)
{
- int adapter;
- struct com_s *com;
+ struct resource *irq_res, *mem_res;
+ void *irq_cookie, *vaddr, *vsc;
+ int irq_rid, mem_rid;
+
+ irq_res = NULL;
+ mem_res = NULL;
+
+ mem_rid = 0;
+ mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
+ 0ul, ~0ul, 0ul, RF_ACTIVE);
+ if (mem_res == NULL) {
+ device_printf(dev, "memory resource allocation failed\n");
+ goto fail;
+ }
+ vaddr = rman_get_virtual(mem_res);
- com = cyattach_common((cy_addr) isdp->id_maddr, 0);
- if (com == NULL)
- return (0);
- adapter = com->unit / CY_MAX_PORTS;
+ vsc = cyattach_common(vaddr, 0);
+ if (vsc == NULL) {
+ device_printf(dev, "no ports found!\n");
+ goto fail;
+ }
- /*
- * XXX
- * This kludge is to allow ISA/PCI device specifications in the
- * kernel config file to be in any order.
- */
- if (isdp->id_unit != adapter) {
- printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
- isdp->id_unit = adapter; /* XXX */
+ irq_rid = 0;
+ irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
+ RF_SHAREABLE | RF_ACTIVE);
+ if (irq_res == NULL) {
+ device_printf(dev, "interrupt resource allocation failed\n");
+ goto fail;
+ }
+ if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, cyintr,
+ vsc, &irq_cookie) != 0) {
+ device_printf(dev, "interrupt setup failed\n");
+ goto fail;
}
- isdp->id_ointr = cyointr;
- return (1);
+ return (0);
+
+fail:
+ if (irq_res != NULL)
+ bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
+ if (mem_res != NULL)
+ bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
+ return (ENXIO);
}
void *
@@ -1106,12 +1148,6 @@ sioinput(com)
#endif
}
-static void
-cyointr(int unit)
-{
- siointr1(com_addr(unit * CY_MAX_PORTS));
-}
-
void
siointr1(vcom)
void *vcom;
diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c
index 218f57f..1c7d8ff 100644
--- a/sys/dev/cy/cy_isa.c
+++ b/sys/dev/cy/cy_isa.c
@@ -32,7 +32,6 @@
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
-#include "cy.h"
/*
* TODO:
@@ -81,15 +80,17 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/tty.h>
+#include <machine/bus.h>
#include <machine/psl.h>
+#include <sys/rman.h>
+#include <machine/resource.h>
+
+#include <isa/isavar.h>
-#include <i386/isa/isa_device.h>
#include <i386/isa/cyreg.h>
#include <i386/isa/ic/cd1400.h>
-#ifndef COMPAT_OLDISA
-#error "The cy device requires the old isa compatibility shims"
-#endif
+#define NCY 10 /* KLUDGE */
/*
* Dictionary so that I can name everything *sio* or *com* to compare with
@@ -117,7 +118,6 @@ __FBSDID("$FreeBSD$");
#define comstart cystart
#define comwakeup cywakeup
#define p_com_addr p_cy_addr
-#define sioattach cyattach
#define sioclose cyclose
#define siodriver cydriver
#define siodtrwakeup cydtrwakeup
@@ -126,7 +126,6 @@ __FBSDID("$FreeBSD$");
#define sioioctl cyioctl
#define sioopen cyopen
#define siopoll cypoll
-#define sioprobe cyprobe
#define siosettimeout cysettimeout
#define siosetwater cysetwater
#define comstop cystop
@@ -332,25 +331,26 @@ struct com_s {
u_char obuf2[256];
};
+devclass_t cy_devclass;
+
/* PCI driver entry points. */
void *cyattach_common(cy_addr cy_iobase, int cy_align);
driver_intr_t siointr1;
-static ointhand2_t cyointr;
static int cy_units(cy_addr cy_iobase, int cy_align);
-static int sioattach(struct isa_device *dev);
static void cd1400_channel_cmd(struct com_s *com, int cmd);
static void cd1400_channel_cmd_wait(struct com_s *com);
static void cd_etc(struct com_s *com, int etc);
static int cd_getreg(struct com_s *com, int reg);
static void cd_setreg(struct com_s *com, int reg, int val);
+static int cy_isa_attach(device_t dev);
+static int cy_isa_probe(device_t dev);
static timeout_t siodtrwakeup;
static void comhardclose(struct com_s *com);
static void sioinput(struct com_s *com);
static int commctl(struct com_s *com, int bits, int how);
static int comparam(struct tty *tp, struct termios *t);
static void siopoll(void *arg);
-static int sioprobe(struct isa_device *dev);
static void siosettimeout(void);
static int siosetwater(struct com_s *com, speed_t speed);
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
@@ -372,13 +372,21 @@ static int sio_inited;
static struct com_s *p_com_addr[NSIO];
#define com_addr(unit) (p_com_addr[unit])
-struct isa_driver siodriver = {
- INTR_TYPE_TTY | INTR_FAST,
- sioprobe,
- sioattach,
- driver_name
+static device_method_t cy_isa_methods[] = {
+ /* Device interface. */
+ DEVMETHOD(device_probe, cy_isa_probe),
+ DEVMETHOD(device_attach, cy_isa_attach),
+
+ { 0, 0 }
};
-COMPAT_ISA_DRIVER(cy, cydriver); /* XXX */
+
+static driver_t cy_isa_driver = {
+ driver_name,
+ cy_isa_methods,
+ 0,
+};
+
+DRIVER_MODULE(cy, isa, cy_isa_driver, cy_devclass, 0, 0);
static d_open_t sioopen;
static d_close_t sioclose;
@@ -423,12 +431,23 @@ static int cy_total_devices;
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
static int
-sioprobe(dev)
- struct isa_device *dev;
+cy_isa_probe(device_t dev)
{
- cy_addr iobase;
+ struct resource *mem_res;
+ cy_addr iobase;
+ int mem_rid;
+
+ if (isa_get_logicalid(dev) != 0) /* skip PnP probes */
+ return (ENXIO);
- iobase = (cy_addr)dev->id_maddr;
+ mem_rid = 0;
+ mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
+ 0ul, ~0ul, 0ul, RF_ACTIVE);
+ if (mem_res == NULL) {
+ device_printf(dev, "ioport resource allocation failed\n");
+ return (ENXIO);
+ }
+ iobase = rman_get_virtual(mem_res);
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
@@ -438,7 +457,8 @@ sioprobe(dev)
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
DELAY(500);
- return (cy_units(iobase, 0) == 0 ? 0 : -1);
+ bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
+ return (cy_units(iobase, 0) == 0 ? ENXIO : 0);
}
static int
@@ -494,29 +514,51 @@ cy_units(cy_iobase, cy_align)
}
static int
-sioattach(isdp)
- struct isa_device *isdp;
+cy_isa_attach(device_t dev)
{
- int adapter;
- struct com_s *com;
+ struct resource *irq_res, *mem_res;
+ void *irq_cookie, *vaddr, *vsc;
+ int irq_rid, mem_rid;
+
+ irq_res = NULL;
+ mem_res = NULL;
+
+ mem_rid = 0;
+ mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
+ 0ul, ~0ul, 0ul, RF_ACTIVE);
+ if (mem_res == NULL) {
+ device_printf(dev, "memory resource allocation failed\n");
+ goto fail;
+ }
+ vaddr = rman_get_virtual(mem_res);
- com = cyattach_common((cy_addr) isdp->id_maddr, 0);
- if (com == NULL)
- return (0);
- adapter = com->unit / CY_MAX_PORTS;
+ vsc = cyattach_common(vaddr, 0);
+ if (vsc == NULL) {
+ device_printf(dev, "no ports found!\n");
+ goto fail;
+ }
- /*
- * XXX
- * This kludge is to allow ISA/PCI device specifications in the
- * kernel config file to be in any order.
- */
- if (isdp->id_unit != adapter) {
- printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
- isdp->id_unit = adapter; /* XXX */
+ irq_rid = 0;
+ irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
+ RF_SHAREABLE | RF_ACTIVE);
+ if (irq_res == NULL) {
+ device_printf(dev, "interrupt resource allocation failed\n");
+ goto fail;
+ }
+ if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, cyintr,
+ vsc, &irq_cookie) != 0) {
+ device_printf(dev, "interrupt setup failed\n");
+ goto fail;
}
- isdp->id_ointr = cyointr;
- return (1);
+ return (0);
+
+fail:
+ if (irq_res != NULL)
+ bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
+ if (mem_res != NULL)
+ bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
+ return (ENXIO);
}
void *
@@ -1106,12 +1148,6 @@ sioinput(com)
#endif
}
-static void
-cyointr(int unit)
-{
- siointr1(com_addr(unit * CY_MAX_PORTS));
-}
-
void
siointr1(vcom)
void *vcom;
diff --git a/sys/dev/cy/cy_pci.c b/sys/dev/cy/cy_pci.c
index 9664651..c08c419 100644
--- a/sys/dev/cy/cy_pci.c
+++ b/sys/dev/cy/cy_pci.c
@@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$");
#define PLX_9060 0x0c
#define PLX_9080 0x0d
+extern devclass_t cy_devclass;
+
void *cyattach_common(u_char volatile *iobase, int cy_align);
driver_intr_t cyintr;
@@ -86,8 +88,6 @@ static driver_t cy_pci_driver = {
0,
};
-static devclass_t cy_devclass;
-
DRIVER_MODULE(cy, pci, cy_pci_driver, cy_devclass, 0, 0);
MODULE_DEPEND(cy, pci, 1, 1, 1);
diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c
index 218f57f..1c7d8ff 100644
--- a/sys/i386/isa/cy.c
+++ b/sys/i386/isa/cy.c
@@ -32,7 +32,6 @@
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
-#include "cy.h"
/*
* TODO:
@@ -81,15 +80,17 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/tty.h>
+#include <machine/bus.h>
#include <machine/psl.h>
+#include <sys/rman.h>
+#include <machine/resource.h>
+
+#include <isa/isavar.h>
-#include <i386/isa/isa_device.h>
#include <i386/isa/cyreg.h>
#include <i386/isa/ic/cd1400.h>
-#ifndef COMPAT_OLDISA
-#error "The cy device requires the old isa compatibility shims"
-#endif
+#define NCY 10 /* KLUDGE */
/*
* Dictionary so that I can name everything *sio* or *com* to compare with
@@ -117,7 +118,6 @@ __FBSDID("$FreeBSD$");
#define comstart cystart
#define comwakeup cywakeup
#define p_com_addr p_cy_addr
-#define sioattach cyattach
#define sioclose cyclose
#define siodriver cydriver
#define siodtrwakeup cydtrwakeup
@@ -126,7 +126,6 @@ __FBSDID("$FreeBSD$");
#define sioioctl cyioctl
#define sioopen cyopen
#define siopoll cypoll
-#define sioprobe cyprobe
#define siosettimeout cysettimeout
#define siosetwater cysetwater
#define comstop cystop
@@ -332,25 +331,26 @@ struct com_s {
u_char obuf2[256];
};
+devclass_t cy_devclass;
+
/* PCI driver entry points. */
void *cyattach_common(cy_addr cy_iobase, int cy_align);
driver_intr_t siointr1;
-static ointhand2_t cyointr;
static int cy_units(cy_addr cy_iobase, int cy_align);
-static int sioattach(struct isa_device *dev);
static void cd1400_channel_cmd(struct com_s *com, int cmd);
static void cd1400_channel_cmd_wait(struct com_s *com);
static void cd_etc(struct com_s *com, int etc);
static int cd_getreg(struct com_s *com, int reg);
static void cd_setreg(struct com_s *com, int reg, int val);
+static int cy_isa_attach(device_t dev);
+static int cy_isa_probe(device_t dev);
static timeout_t siodtrwakeup;
static void comhardclose(struct com_s *com);
static void sioinput(struct com_s *com);
static int commctl(struct com_s *com, int bits, int how);
static int comparam(struct tty *tp, struct termios *t);
static void siopoll(void *arg);
-static int sioprobe(struct isa_device *dev);
static void siosettimeout(void);
static int siosetwater(struct com_s *com, speed_t speed);
static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io);
@@ -372,13 +372,21 @@ static int sio_inited;
static struct com_s *p_com_addr[NSIO];
#define com_addr(unit) (p_com_addr[unit])
-struct isa_driver siodriver = {
- INTR_TYPE_TTY | INTR_FAST,
- sioprobe,
- sioattach,
- driver_name
+static device_method_t cy_isa_methods[] = {
+ /* Device interface. */
+ DEVMETHOD(device_probe, cy_isa_probe),
+ DEVMETHOD(device_attach, cy_isa_attach),
+
+ { 0, 0 }
};
-COMPAT_ISA_DRIVER(cy, cydriver); /* XXX */
+
+static driver_t cy_isa_driver = {
+ driver_name,
+ cy_isa_methods,
+ 0,
+};
+
+DRIVER_MODULE(cy, isa, cy_isa_driver, cy_devclass, 0, 0);
static d_open_t sioopen;
static d_close_t sioclose;
@@ -423,12 +431,23 @@ static int cy_total_devices;
static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
static int
-sioprobe(dev)
- struct isa_device *dev;
+cy_isa_probe(device_t dev)
{
- cy_addr iobase;
+ struct resource *mem_res;
+ cy_addr iobase;
+ int mem_rid;
+
+ if (isa_get_logicalid(dev) != 0) /* skip PnP probes */
+ return (ENXIO);
- iobase = (cy_addr)dev->id_maddr;
+ mem_rid = 0;
+ mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
+ 0ul, ~0ul, 0ul, RF_ACTIVE);
+ if (mem_res == NULL) {
+ device_printf(dev, "ioport resource allocation failed\n");
+ return (ENXIO);
+ }
+ iobase = rman_get_virtual(mem_res);
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
cy_inb(iobase, CY16_RESET, 0); /* XXX? */
@@ -438,7 +457,8 @@ sioprobe(dev)
cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
DELAY(500);
- return (cy_units(iobase, 0) == 0 ? 0 : -1);
+ bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
+ return (cy_units(iobase, 0) == 0 ? ENXIO : 0);
}
static int
@@ -494,29 +514,51 @@ cy_units(cy_iobase, cy_align)
}
static int
-sioattach(isdp)
- struct isa_device *isdp;
+cy_isa_attach(device_t dev)
{
- int adapter;
- struct com_s *com;
+ struct resource *irq_res, *mem_res;
+ void *irq_cookie, *vaddr, *vsc;
+ int irq_rid, mem_rid;
+
+ irq_res = NULL;
+ mem_res = NULL;
+
+ mem_rid = 0;
+ mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
+ 0ul, ~0ul, 0ul, RF_ACTIVE);
+ if (mem_res == NULL) {
+ device_printf(dev, "memory resource allocation failed\n");
+ goto fail;
+ }
+ vaddr = rman_get_virtual(mem_res);
- com = cyattach_common((cy_addr) isdp->id_maddr, 0);
- if (com == NULL)
- return (0);
- adapter = com->unit / CY_MAX_PORTS;
+ vsc = cyattach_common(vaddr, 0);
+ if (vsc == NULL) {
+ device_printf(dev, "no ports found!\n");
+ goto fail;
+ }
- /*
- * XXX
- * This kludge is to allow ISA/PCI device specifications in the
- * kernel config file to be in any order.
- */
- if (isdp->id_unit != adapter) {
- printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
- isdp->id_unit = adapter; /* XXX */
+ irq_rid = 0;
+ irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
+ RF_SHAREABLE | RF_ACTIVE);
+ if (irq_res == NULL) {
+ device_printf(dev, "interrupt resource allocation failed\n");
+ goto fail;
+ }
+ if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, cyintr,
+ vsc, &irq_cookie) != 0) {
+ device_printf(dev, "interrupt setup failed\n");
+ goto fail;
}
- isdp->id_ointr = cyointr;
- return (1);
+ return (0);
+
+fail:
+ if (irq_res != NULL)
+ bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
+ if (mem_res != NULL)
+ bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
+ return (ENXIO);
}
void *
@@ -1106,12 +1148,6 @@ sioinput(com)
#endif
}
-static void
-cyointr(int unit)
-{
- siointr1(com_addr(unit * CY_MAX_PORTS));
-}
-
void
siointr1(vcom)
void *vcom;
diff --git a/sys/pci/cy_pci.c b/sys/pci/cy_pci.c
index 9664651..c08c419 100644
--- a/sys/pci/cy_pci.c
+++ b/sys/pci/cy_pci.c
@@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$");
#define PLX_9060 0x0c
#define PLX_9080 0x0d
+extern devclass_t cy_devclass;
+
void *cyattach_common(u_char volatile *iobase, int cy_align);
driver_intr_t cyintr;
@@ -86,8 +88,6 @@ static driver_t cy_pci_driver = {
0,
};
-static devclass_t cy_devclass;
-
DRIVER_MODULE(cy, pci, cy_pci_driver, cy_devclass, 0, 0);
MODULE_DEPEND(cy, pci, 1, 1, 1);
OpenPOWER on IntegriCloud