1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * das08_pci.c 4 * comedi driver for DAS08 PCI boards 5 * 6 * COMEDI - Linux Control and Measurement Device Interface 7 * Copyright (C) 2000 David A. Schleef <ds@schleef.org> 8 * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> 9 * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> 10 */ 11 12 /* 13 * Driver: das08_pci 14 * Description: DAS-08 PCI compatible boards 15 * Devices: [ComputerBoards] PCI-DAS08 (pci-das08) 16 * Author: Warren Jasper, ds, Frank Hess 17 * Updated: Fri, 31 Aug 2012 19:19:06 +0100 18 * Status: works 19 * 20 * This is the PCI-specific support split off from the das08 driver. 21 * 22 * Configuration Options: not applicable, uses PCI auto config 23 */ 24 25 #include <linux/module.h> 26 27 #include "../comedi_pci.h" 28 29 #include "das08.h" 30 31 static const struct das08_board_struct das08_pci_boards[] = { 32 { 33 .name = "pci-das08", 34 .ai_nbits = 12, 35 .ai_pg = das08_bipolar5, 36 .ai_encoding = das08_encode12, 37 .di_nchan = 3, 38 .do_nchan = 4, 39 .i8254_offset = 4, 40 .iosize = 8, 41 }, 42 }; 43 44 static int das08_pci_auto_attach(struct comedi_device *dev, 45 unsigned long context_unused) 46 { 47 struct pci_dev *pdev = comedi_to_pci_dev(dev); 48 struct das08_private_struct *devpriv; 49 int ret; 50 51 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); 52 if (!devpriv) 53 return -ENOMEM; 54 55 /* The das08 driver needs the board_ptr */ 56 dev->board_ptr = &das08_pci_boards[0]; 57 58 ret = comedi_pci_enable(dev); 59 if (ret) 60 return ret; 61 dev->iobase = pci_resource_start(pdev, 2); 62 63 return das08_common_attach(dev, dev->iobase); 64 } 65 66 static struct comedi_driver das08_pci_comedi_driver = { 67 .driver_name = "pci-das08", 68 .module = THIS_MODULE, 69 .auto_attach = das08_pci_auto_attach, 70 .detach = comedi_pci_detach, 71 }; 72 73 static int das08_pci_probe(struct pci_dev *dev, 74 const struct pci_device_id *id) 75 { 76 return comedi_pci_auto_config(dev, &das08_pci_comedi_driver, 77 id->driver_data); 78 } 79 80 static const struct pci_device_id das08_pci_table[] = { 81 { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0029) }, 82 { 0 } 83 }; 84 MODULE_DEVICE_TABLE(pci, das08_pci_table); 85 86 static struct pci_driver das08_pci_driver = { 87 .name = "pci-das08", 88 .id_table = das08_pci_table, 89 .probe = das08_pci_probe, 90 .remove = comedi_pci_auto_unconfig, 91 }; 92 module_comedi_pci_driver(das08_pci_comedi_driver, das08_pci_driver); 93 94 MODULE_AUTHOR("Comedi https://www.comedi.org"); 95 MODULE_DESCRIPTION("Comedi low-level driver"); 96 MODULE_LICENSE("GPL"); 97