diff options
Diffstat (limited to 'drivers/staging/comedi/drivers/amplc_dio200_pci.c')
-rw-r--r-- | drivers/staging/comedi/drivers/amplc_dio200_pci.c | 167 |
1 files changed, 68 insertions, 99 deletions
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c index fbf05687347f..b83d1f5a8fb9 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c @@ -242,80 +242,70 @@ enum dio200_pci_model { static const struct dio200_board dio200_pci_boards[] = { [pci215_model] = { - .name = "pci215", - .bustype = pci_bustype, - .mainbar = 2, - .mainsize = DIO200_IO_SIZE, - .layout = { - .n_subdevs = 5, - .sdtype = {sd_8255, sd_8255, sd_8254, sd_8254, sd_intr}, - .sdinfo = {0x00, 0x08, 0x10, 0x14, 0x3F}, - .has_int_sce = true, - .has_clk_gat_sce = true, + .name = "pci215", + .mainbar = 2, + .n_subdevs = 5, + .sdtype = { + sd_8255, sd_8255, sd_8254, sd_8254, sd_intr }, + .sdinfo = { 0x00, 0x08, 0x10, 0x14, 0x3f }, + .has_int_sce = true, + .has_clk_gat_sce = true, }, [pci272_model] = { - .name = "pci272", - .bustype = pci_bustype, - .mainbar = 2, - .mainsize = DIO200_IO_SIZE, - .layout = { - .n_subdevs = 4, - .sdtype = {sd_8255, sd_8255, sd_8255, sd_intr}, - .sdinfo = {0x00, 0x08, 0x10, 0x3F}, - .has_int_sce = true, + .name = "pci272", + .mainbar = 2, + .n_subdevs = 4, + .sdtype = { + sd_8255, sd_8255, sd_8255, sd_intr }, + .sdinfo = { 0x00, 0x08, 0x10, 0x3f }, + .has_int_sce = true, }, [pcie215_model] = { - .name = "pcie215", - .bustype = pci_bustype, - .mainbar = 1, - .mainshift = 3, - .mainsize = DIO200_PCIE_IO_SIZE, - .layout = { - .n_subdevs = 8, - .sdtype = {sd_8255, sd_none, sd_8255, sd_none, - sd_8254, sd_8254, sd_timer, sd_intr}, - .sdinfo = {0x00, 0x00, 0x08, 0x00, - 0x10, 0x14, 0x00, 0x3F}, - .has_int_sce = true, - .has_clk_gat_sce = true, - .has_enhancements = true, + .name = "pcie215", + .mainbar = 1, + .n_subdevs = 8, + .sdtype = { + sd_8255, sd_none, sd_8255, sd_none, + sd_8254, sd_8254, sd_timer, sd_intr }, + .sdinfo = { + 0x00, 0x00, 0x08, 0x00, 0x10, 0x14, 0x00, 0x3f + }, + .has_int_sce = true, + .has_clk_gat_sce = true, + .is_pcie = true, }, [pcie236_model] = { - .name = "pcie236", - .bustype = pci_bustype, - .mainbar = 1, - .mainshift = 3, - .mainsize = DIO200_PCIE_IO_SIZE, - .layout = { - .n_subdevs = 8, - .sdtype = {sd_8255, sd_none, sd_none, sd_none, - sd_8254, sd_8254, sd_timer, sd_intr}, - .sdinfo = {0x00, 0x00, 0x00, 0x00, - 0x10, 0x14, 0x00, 0x3F}, - .has_int_sce = true, - .has_clk_gat_sce = true, - .has_enhancements = true, + .name = "pcie236", + .mainbar = 1, + .n_subdevs = 8, + .sdtype = { + sd_8255, sd_none, sd_none, sd_none, + sd_8254, sd_8254, sd_timer, sd_intr + }, + .sdinfo = { + 0x00, 0x00, 0x00, 0x00, 0x10, 0x14, 0x00, 0x3f }, + .has_int_sce = true, + .has_clk_gat_sce = true, + .is_pcie = true, }, [pcie296_model] = { - .name = "pcie296", - .bustype = pci_bustype, - .mainbar = 1, - .mainshift = 3, - .mainsize = DIO200_PCIE_IO_SIZE, - .layout = { - .n_subdevs = 8, - .sdtype = {sd_8255, sd_8255, sd_8255, sd_8255, - sd_8254, sd_8254, sd_timer, sd_intr}, - .sdinfo = {0x00, 0x04, 0x08, 0x0C, - 0x10, 0x14, 0x00, 0x3F}, - .has_int_sce = true, - .has_clk_gat_sce = true, - .has_enhancements = true, + .name = "pcie296", + .mainbar = 1, + .n_subdevs = 8, + .sdtype = { + sd_8255, sd_8255, sd_8255, sd_8255, + sd_8254, sd_8254, sd_timer, sd_intr + }, + .sdinfo = { + 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x00, 0x3f }, + .has_int_sce = true, + .has_clk_gat_sce = true, + .is_pcie = true, }, }; @@ -358,34 +348,25 @@ static int dio200_pci_auto_attach(struct comedi_device *dev, unsigned long context_model) { struct pci_dev *pci_dev = comedi_to_pci_dev(dev); - const struct dio200_board *thisboard = NULL; - struct dio200_private *devpriv; + const struct dio200_board *board = NULL; unsigned int bar; int ret; if (context_model < ARRAY_SIZE(dio200_pci_boards)) - thisboard = &dio200_pci_boards[context_model]; - if (!thisboard) + board = &dio200_pci_boards[context_model]; + if (!board) return -EINVAL; - dev->board_ptr = thisboard; - dev->board_name = thisboard->name; + dev->board_ptr = board; + dev->board_name = board->name; dev_info(dev->class_dev, "%s: attach pci %s (%s)\n", dev->driver->driver_name, pci_name(pci_dev), dev->board_name); - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - ret = comedi_pci_enable(dev); if (ret) return ret; - bar = thisboard->mainbar; - if (pci_resource_len(pci_dev, bar) < thisboard->mainsize) { - dev_err(dev->class_dev, "error! PCI region size too small!\n"); - return -EINVAL; - } + bar = board->mainbar; if (pci_resource_flags(pci_dev, bar) & IORESOURCE_MEM) { dev->mmio = pci_ioremap_bar(pci_dev, bar); if (!dev->mmio) { @@ -396,33 +377,21 @@ static int dio200_pci_auto_attach(struct comedi_device *dev, } else { dev->iobase = pci_resource_start(pci_dev, bar); } - switch (context_model) { - case pcie215_model: - case pcie236_model: - case pcie296_model: + + if (board->is_pcie) { ret = dio200_pcie_board_setup(dev); if (ret < 0) return ret; - break; - default: - break; } - return amplc_dio200_common_attach(dev, pci_dev->irq, IRQF_SHARED); -} -static void dio200_pci_detach(struct comedi_device *dev) -{ - amplc_dio200_common_detach(dev); - if (dev->mmio) - iounmap(dev->mmio); - comedi_pci_disable(dev); + return amplc_dio200_common_attach(dev, pci_dev->irq, IRQF_SHARED); } static struct comedi_driver dio200_pci_comedi_driver = { - .driver_name = "amplc_dio200_pci", - .module = THIS_MODULE, - .auto_attach = dio200_pci_auto_attach, - .detach = dio200_pci_detach, + .driver_name = "amplc_dio200_pci", + .module = THIS_MODULE, + .auto_attach = dio200_pci_auto_attach, + .detach = comedi_pci_detach, }; static const struct pci_device_id dio200_pci_table[] = { @@ -443,10 +412,10 @@ static int dio200_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) } static struct pci_driver dio200_pci_pci_driver = { - .name = "amplc_dio200_pci", - .id_table = dio200_pci_table, - .probe = dio200_pci_probe, - .remove = comedi_pci_auto_unconfig, + .name = "amplc_dio200_pci", + .id_table = dio200_pci_table, + .probe = dio200_pci_probe, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(dio200_pci_comedi_driver, dio200_pci_pci_driver); |