obj-$(CONFIG_COMEDI_USB_MODULES) += dt9812.o
obj-m += 8255.o
-obj-m += amcc_s5933.o
obj-m += comedi_fc.o
obj-m += das08.o
obj-m += mite.o
LINK = $(top_builddir)/modtool --link -o $@ \
-i ../.mods/comedi.o.symvers \
-i .mods/8255.o.symvers \
- -i .mods/amcc_s5933.o.symvers \
-i .mods/comedi_fc.o.symvers \
-i .mods/das08.o.symvers \
-i .mods/mite.o.symvers \
8255_ko_LINK = $(top_builddir)/modtool --link -o $@ \
-i ../.mods/comedi.o.symvers
-amcc_s5933_ko_LINK = $(top_builddir)/modtool --link -o $@ \
- -i ../.mods/comedi.o.symvers
comedi_fc_ko_LINK = $(top_builddir)/modtool --link -o $@ \
-i ../.mods/comedi.o.symvers
das08_ko_LINK = $(top_builddir)/modtool --link -o $@ \
-i ../.mods/comedi.o.symvers
8255_ko_CFLAGS = $(AM_CFLAGS) -DEXPORT_SYMTAB
-amcc_s5933_ko_CFLAGS = $(AM_CFLAGS) -DEXPORT_SYMTAB
comedi_fc_ko_CFLAGS = $(AM_CFLAGS) -DEXPORT_SYMTAB
das08_ko_CFLAGS = $(AM_CFLAGS) -DEXPORT_SYMTAB
mite_ko_CFLAGS = $(AM_CFLAGS) -DEXPORT_SYMTAB
else !CONFIG_KBUILD
module_PROGRAMS = \
8255.ko \
- amcc_s5933.ko \
comedi_fc.ko \
das08.ko \
mite.ko \
adl_pci9111_ko_SOURCES = adl_pci9111.c
adl_pci9118_ko_SOURCES = adl_pci9118.c
adv_pci1710_ko_SOURCES = adv_pci1710.c
-amcc_s5933_ko_SOURCES = amcc_s5933.c
adv_pci_dio_ko_SOURCES = adv_pci_dio.c
amplc_pci224_ko_SOURCES = amplc_pci224.c
amplc_pci230_ko_SOURCES = amplc_pci230.c
*/
#include <linux/comedidev.h>
+#include <linux/pci.h>
#include <linux/delay.h>
static int pci9118_attach(comedi_device *dev,comedi_devconfig *it);
static int pci9118_detach(comedi_device *dev);
-static unsigned short pci_list_builded=0; /*>0 list of cards is known */
-
typedef struct {
char *name; // driver name
int vendor_id; // PCI vendor a device ID of card
typedef struct{
int iobase_a; // base+size for AMCC chip
- struct pcilst_struct *amcc; // ptr too AMCC data
unsigned int master; // master capable
struct pci_dev *pcidev; // ptr to actual pcidev
unsigned int usemux; // we want to use external multiplexor!
{
comedi_subdevice *s;
int ret,pages,i;
- unsigned short io_addr[5],master,irq,m;
+ unsigned short master,irq;
unsigned int iobase_a,iobase_9;
- struct pcilst_struct *card=NULL;
+ struct pci_dev *pcidev;
+ int opt_bus, opt_slot;
+ const char *errstr;
unsigned char pci_bus,pci_slot,pci_func;
u16 u16w;
- if (pci_list_builded++ == 0) {
- pci_card_list_init(PCI_VENDOR_ID_AMCC,0);
- }
-
rt_printk("comedi%d: adl_pci9118: board=%s",dev->minor,this_board->name);
+ opt_bus = it->options[0];
+ opt_slot = it->options[1];
if (it->options[3]&1) {
master=0; // user don't want use bus master
} else {
master=1;
}
- /* this call pci_enable_device(), pci_request_regions(),
- * and pci_set_master() */
- if ((card=select_and_alloc_pci_card(PCI_VENDOR_ID_AMCC, this_board->device_id, it->options[0], it->options[1], master))==NULL)
- return -EIO;
-
- if ((pci_card_data(card,&pci_bus,&pci_slot,&pci_func,
- &io_addr[0],&irq,&m))<0) {
- pci_card_free(card);
- rt_printk(" - Can't get AMCC data!\n");
+ if((ret=alloc_private(dev,sizeof(pci9118_private)))<0) {
+ rt_printk(" - Allocation failed!\n");
+ return -ENOMEM;
+ }
+
+ /* Look for matching PCI device */
+ errstr = "not found!";
+ pcidev = NULL;
+ while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_AMCC,
+ this_board->device_id, pcidev))) {
+ /* Found matching vendor/device. */
+ if (opt_bus || opt_slot) {
+ /* Check bus/slot. */
+ if (opt_bus != pcidev->bus->number
+ || opt_slot != PCI_SLOT(pcidev->devfn))
+ continue; /* no match */
+ }
+ /*
+ * Look for device that isn't in use.
+ * Enable PCI device and request regions.
+ */
+ if (pci_enable_device(pcidev)) {
+ errstr = "failed to enable PCI device!";
+ continue;
+ }
+ if (pci_request_regions(pcidev, "adl_pci9118")) {
+ errstr = "in use or I/O port conflict!";
+ continue;
+ }
+ break;
+ }
+
+ if (!pcidev) {
+ if (opt_bus || opt_slot) {
+ rt_printk(" - Card at b:s %d:%d %s\n",
+ opt_bus, opt_slot, errstr);
+ } else {
+ rt_printk(" - Card %s\n", errstr);
+ }
return -EIO;
}
- iobase_a=io_addr[0];
- iobase_9=io_addr[2];
+ if (master) {
+ pci_set_master(pcidev);
+ }
+
+ pci_bus = pcidev->bus->number;
+ pci_slot = PCI_SLOT(pcidev->devfn);
+ pci_func = PCI_FUNC(pcidev->devfn);
+ irq = pcidev->irq;
+ iobase_a = pci_resource_start(pcidev, 0);
+ iobase_9 = pci_resource_start(pcidev, 2);
rt_printk(", b:s:f=%d:%d:%d, io=0x%4x, 0x%4x",pci_bus,pci_slot,pci_func,iobase_9,iobase_a);
dev->iobase=iobase_9;
dev->board_name = this_board->name;
-
- if((ret=alloc_private(dev,sizeof(pci9118_private)))<0) {
- pci_card_free(card);
- rt_printk(" - Allocation failed!\n");
- return -ENOMEM;
- }
- devpriv->amcc=card;
- devpriv->pcidev=card->pcidev;
+ devpriv->pcidev=pcidev;
devpriv->iobase_a=iobase_a;
if (it->options[3]&2) irq=0; // user don't want use IRQ
if (dev->private) {
if (devpriv->valid) pci9118_reset(dev);
if(dev->irq) comedi_free_irq(dev->irq,dev);
- if (devpriv->amcc) pci_card_free(devpriv->amcc);
+ if (devpriv->pcidev) {
+ if (dev->iobase) {
+ pci_release_regions(devpriv->pcidev);
+ pci_disable_device(devpriv->pcidev);
+ }
+ pci_dev_put(devpriv->pcidev);
+ }
if (devpriv->dmabuf_virt[0]) free_pages((unsigned long)devpriv->dmabuf_virt[0],devpriv->dmabuf_pages[0]);
if (devpriv->dmabuf_virt[1]) free_pages((unsigned long)devpriv->dmabuf_virt[1],devpriv->dmabuf_pages[1]);
}
- if (--pci_list_builded == 0) {
- pci_card_list_cleanup(PCI_VENDOR_ID_AMCC);
- }
-
return 0;
}
static int pci1710_attach(comedi_device *dev,comedi_devconfig *it);
static int pci1710_detach(comedi_device *dev);
-static unsigned short pci_list_builded=0; /*>0 list of card is known */
-
typedef struct {
char *name; // driver name
int device_id;
};
typedef struct{
- struct pcilst_struct *amcc; // ptr to AMCC data
+ struct pci_dev *pcidev; // ptr to PCI device
char valid; // card is usable
char neverending_ai; // we do unlimited AI
unsigned int CntrlReg; // Control register
{
comedi_subdevice *s;
int ret,subdev,n_subdevices;
- unsigned short io_addr[5],master,irq;
- struct pcilst_struct *card=NULL;
+ unsigned short irq;
unsigned int iobase;
+ struct pci_dev *pcidev;
+ int opt_bus, opt_slot;
+ const char *errstr;
unsigned char pci_bus,pci_slot,pci_func;
- if (pci_list_builded++ == 0) {
- pci_card_list_init(PCI_VENDOR_ID_ADVANTECH,
-#ifdef PCI171X_EXTDEBUG
- 1
-#else
- 0
-#endif
- );
- }
-
rt_printk("comedi%d: adv_pci1710: board=%s",dev->minor,this_board->name);
- /* this call pci_enable_device() and pci_request_regions() */
- if ((card=select_and_alloc_pci_card(PCI_VENDOR_ID_ADVANTECH, this_board->device_id, it->options[0], it->options[1], 0))==NULL)
- return -EIO;
+ opt_bus = it->options[0];
+ opt_slot = it->options[1];
+
+ if((ret=alloc_private(dev,sizeof(pci1710_private)))<0) {
+ rt_printk(" - Allocation failed!\n");
+ return -ENOMEM;
+ }
+
+ /* Look for matching PCI device */
+ errstr = "not found!";
+ pcidev = NULL;
+ while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
+ this_board->device_id, pcidev))) {
+ /* Found matching vendor/device. */
+ if (opt_bus || opt_slot) {
+ /* Check bus/slot. */
+ if (opt_bus != pcidev->bus->number
+ || opt_slot != PCI_SLOT(pcidev->devfn))
+ continue; /* no match */
+ }
+ /*
+ * Look for device that isn't in use.
+ * Enable PCI device and request regions.
+ */
+ if (pci_enable_device(pcidev)) {
+ errstr = "failed to enable PCI device!";
+ continue;
+ }
+ if (pci_request_regions(pcidev, "adl_pci9118")) {
+ errstr = "in use or I/O port conflict!";
+ continue;
+ }
+ break;
+ }
- if ((pci_card_data(card,&pci_bus,&pci_slot,&pci_func,
- &io_addr[0],&irq,&master))<0) {
- pci_card_free(card);
- rt_printk(" - Can't get configuration data!\n");
+ if (!pcidev) {
+ if (opt_bus || opt_slot) {
+ rt_printk(" - Card at b:s %d:%d %s\n",
+ opt_bus, opt_slot, errstr);
+ } else {
+ rt_printk(" - Card %s\n", errstr);
+ }
return -EIO;
}
- iobase=io_addr[2];
+ pci_bus = pcidev->bus->number;
+ pci_slot = PCI_SLOT(pcidev->devfn);
+ pci_func = PCI_FUNC(pcidev->devfn);
+ irq = pcidev->irq;
+ iobase = pci_resource_start(pcidev, 2);
rt_printk(", b:s:f=%d:%d:%d, io=0x%4x",pci_bus,pci_slot,pci_func,iobase);
dev->iobase=iobase;
dev->board_name = this_board->name;
-
- if((ret=alloc_private(dev,sizeof(pci1710_private)))<0) {
- pci_card_free(card);
- rt_printk(" - Allocation failed!\n");
- return -ENOMEM;
- }
-
- devpriv->amcc = card;
+ devpriv->pcidev = pcidev;
n_subdevices = 0;
if (this_board->n_aichan) n_subdevices++;
if (dev->private) {
if (devpriv->valid) pci1710_reset(dev);
if (dev->irq) comedi_free_irq(dev->irq,dev);
- if (devpriv->amcc) pci_card_free(devpriv->amcc);
- }
-
- if (--pci_list_builded == 0) {
- pci_card_list_cleanup(PCI_VENDOR_ID_ADVANTECH);
+ if (devpriv->pcidev) {
+ if (dev->iobase) {
+ pci_release_regions(devpriv->pcidev);
+ pci_disable_device(devpriv->pcidev);
+ }
+ pci_dev_put(devpriv->pcidev);
+ }
}
#ifndef _AMCC_S5933_H_
#define _AMCC_S5933_H_
-#include <linux/comedidev.h>
-#include <linux/pci.h>
-
/****************************************************************************/
/* AMCC Operation Register Offsets - PCI */
#define TARGET_ABORT_INT 0x00200000L
#define BUS_MASTER_INT 0x00200000L
-/****************************************************************************/
-
-struct pcilst_struct{
- struct pcilst_struct *next;
- int used;
- struct pci_dev *pcidev;
- unsigned short vendor;
- unsigned short device;
- unsigned int master;
- unsigned char pci_bus;
- unsigned char pci_slot;
- unsigned char pci_func;
- unsigned int io_addr[5];
- unsigned int irq;
-};
-
-struct pcilst_struct *amcc_devices; // ptr to root list of all amcc devices
-
-/****************************************************************************/
-
-void pci_card_list_init(unsigned short pci_vendor, char display);
-void pci_card_list_cleanup(unsigned short pci_vendor);
-struct pcilst_struct *find_free_pci_card_by_device(unsigned short vendor_id, unsigned short device_id);
-int find_free_pci_card_by_position(unsigned short vendor_id, unsigned short device_id, unsigned short pci_bus, unsigned short pci_slot, struct pcilst_struct **card);
-struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id, unsigned short device_id, unsigned short pci_bus, unsigned short pci_slot, char master);
-
-//int pci_card_alloc(struct pcilst_struct *amcc);
-int pci_card_free(struct pcilst_struct *amcc);
-void pci_card_list_display(void);
-int pci_card_data(struct pcilst_struct *amcc,
- unsigned char *pci_bus, unsigned char *pci_slot, unsigned char *pci_func,
- unsigned short *io_addr, unsigned short *irq, unsigned short *master);
-
-/****************************************************************************/
-
#endif