added new drivers from José Luis Sánchez (jsanchezv@teleline.es)
authorFrank Mori Hess <fmhess@speakeasy.net>
Tue, 30 Nov 2004 01:01:06 +0000 (01:01 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Tue, 30 Nov 2004 01:01:06 +0000 (01:01 +0000)
comedi/drivers/Makefile.am
comedi/drivers/acl7225b.c [new file with mode: 0644]
comedi/drivers/pcl730.c [new file with mode: 0644]

index eb4baebfb3ea38ba5620b1681f0dfb266cfdeef7..42aa4af3295c44ef000394098c4650b3e9494eb7 100644 (file)
@@ -83,6 +83,7 @@ module_PROGRAMS = \
  das08.ko \
  mite.ko \
  ni_labpc.ko \
+ acl7225b.ko \
  adl_pci9111.ko \
  adl_pci9118.ko \
  adv_pci1710.ko \
@@ -133,6 +134,7 @@ module_PROGRAMS = \
  pcl724.ko \
  pcl725.ko \
  pcl726.ko \
+ pcl730.ko \
  pcl812.ko \
  pcl816.ko \
  pcl818.ko \
diff --git a/comedi/drivers/acl7225b.c b/comedi/drivers/acl7225b.c
new file mode 100644 (file)
index 0000000..127fe39
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Driver for Adlink NuDAQ ACL-7225b and clones
+ * José Luis Sánchez
+ */
+/*
+Driver: acl7225b.o
+Description: Adlink NuDAQ ACL-7225b (& compatibles as ICP P16R16DIO)
+Author: José Luis Sánchez (jsanchezv@teleline.es)
+Status: testing
+Devices: [Adlink] ACL-7225b (acl7225b), [ICP] P16R16DIO (p16r16dio)
+*/
+
+#include <linux/comedidev.h>
+
+#include <linux/ioport.h>
+
+#define ACL7225_SIZE   8  /* Requires 8 ioports, but only 4 are used */
+#define P16R16DIO_SIZE 4
+#define ACL7225_RIO_LO 0  /* Relays input/output low byte (R0-R7) */
+#define ACL7225_RIO_HI 1  /* Relays input/output high byte (R8-R15) */
+#define ACL7225_DI_LO  2  /* Digital input low byte (DI0-DI7) */
+#define ACL7225_DI_HI  3  /* Digital input high byte (DI8-DI15) */
+
+static int acl7225b_attach(comedi_device *dev,comedi_devconfig *it);
+static int acl7225b_detach(comedi_device *dev);
+
+typedef struct {
+       char    *name;          // driver name
+       int             io_range;       // len of I/O space
+} boardtype;
+
+static boardtype boardtypes[] =
+{
+       { "acl7225b",  ACL7225_SIZE, },
+       { "p16r16dio", P16R16DIO_SIZE, },
+};
+#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define this_board ((boardtype *)dev->board_ptr)
+
+static comedi_driver driver_acl7225b = {
+       driver_name:    "acl7225b",
+       module:         THIS_MODULE,
+       attach:         acl7225b_attach,
+       detach:         acl7225b_detach,
+       board_name: boardtypes,
+       num_names:      n_boardtypes,
+       offset:         sizeof(boardtype),
+};
+COMEDI_INITCLEANUP(driver_acl7225b);
+
+static int acl7225b_do_insn(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+{
+       if( insn->n != 2 )
+        return -EINVAL;
+
+       if(data[0])
+    {
+               s->state &= ~data[0];
+               s->state |= (data[0] & data[1]);
+       }
+    if( data[0] & 0x00ff )
+        outb(s->state & 0xff, dev->iobase+(unsigned long)s->private);
+    if( data[0] & 0xff00 )
+        outb((s->state >> 8), dev->iobase+(unsigned long)s->private+1);
+       
+       data[1]=s->state;
+
+       return 2;
+}
+
+static int acl7225b_di_insn(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+{
+       if( insn->n != 2 )
+        return -EINVAL;
+
+       data[1]=inb(dev->iobase + (unsigned long)s->private) |
+        (inb(dev->iobase + (unsigned long)s->private+1) << 8);
+
+       return 2;
+}
+
+static int acl7225b_attach(comedi_device *dev,comedi_devconfig *it)
+{
+       comedi_subdevice *s;
+       int iobase, iorange;
+
+       iobase=it->options[0];
+       iorange=this_board->io_range;
+       printk("comedi%d: acl7225b: board=%s 0x%04x ", dev->minor,
+           this_board->name, iobase);
+       if( check_region(iobase, iorange) < 0 )
+    {
+               printk("I/O port conflict\n");
+               return -EIO;
+       }
+       request_region(iobase, iorange, "acl7225b");
+    dev->board_name=this_board->name;
+       dev->iobase=iobase;
+       dev->irq=0;
+
+       if( alloc_subdevices(dev, 3) < 0 )
+               return -ENOMEM;
+
+       s=dev->subdevices+0;
+       /* Relays outputs */
+       s->type=COMEDI_SUBD_DO;
+       s->subdev_flags=SDF_WRITABLE;
+       s->maxdata=1;
+       s->n_chan=16;
+       s->insn_bits = acl7225b_do_insn;
+       s->range_table=&range_digital;
+    s->private=(void *)ACL7225_RIO_LO;
+
+       s=dev->subdevices+1;
+       /* Relays status */
+       s->type=COMEDI_SUBD_DI;
+       s->subdev_flags=SDF_READABLE;
+       s->maxdata=1;
+       s->n_chan=16;
+       s->insn_bits = acl7225b_di_insn;
+       s->range_table=&range_digital;
+    s->private=(void *)ACL7225_RIO_LO;
+
+       s=dev->subdevices+2;
+       /* Isolated digital inputs */
+       s->type=COMEDI_SUBD_DI;
+       s->subdev_flags=SDF_READABLE;
+       s->maxdata=1;
+       s->n_chan=16;
+       s->insn_bits = acl7225b_di_insn;
+       s->range_table=&range_digital;
+    s->private=(void *)ACL7225_DI_LO;
+
+       printk("\n");
+
+       return 0;
+}
+
+static int acl7225b_detach(comedi_device *dev)
+{
+       printk("comedi%d: acl7225b: remove\n",dev->minor);
+
+       if(dev->iobase)
+        release_region(dev->iobase, this_board->io_range);
+       
+       return 0;
+}
diff --git a/comedi/drivers/pcl730.c b/comedi/drivers/pcl730.c
new file mode 100644 (file)
index 0000000..70c3f5e
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Driver for Advantech PCL-730 and clones
+ * José Luis Sánchez
+ */
+/*
+Driver: pcl730.o
+Description: Advantech PCL-730 (& compatibles)
+Author: José Luis Sánchez (jsanchezv@teleline.es)
+Status: untested
+Devices: [Advantech] PCL-730 (pcl730), [ICP] ISO-730 (iso730),
+                [Adlink] ACL-7130 (acl7130)
+
+Interrupts are not supported.
+The ACL-7130 card have an 8254 timer/counter not supported by this driver.
+*/
+
+#include <linux/comedidev.h>
+
+#include <linux/ioport.h>
+
+#define PCL730_SIZE            4
+#define ACL7130_SIZE   8
+#define PCL730_IDIO_LO 0  /* Isolated Digital I/O low byte (ID0-ID7) */
+#define PCL730_IDIO_HI 1  /* Isolated Digital I/O high byte (ID8-ID15) */
+#define PCL730_DIO_LO  2  /* TTL Digital I/O low byte (D0-D7) */
+#define PCL730_DIO_HI  3  /* TTL Digital I/O high byte (D8-D15) */
+
+static int pcl730_attach(comedi_device *dev,comedi_devconfig *it);
+static int pcl730_detach(comedi_device *dev);
+
+typedef struct {
+       char    *name;          // driver name
+       int             io_range;       // len of I/O space
+} boardtype;
+
+static boardtype boardtypes[] =
+{
+       { "pcl730",  PCL730_SIZE, },
+       { "iso730",  PCL730_SIZE, },
+       { "acl7130", ACL7130_SIZE, },
+};
+#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define this_board ((boardtype *)dev->board_ptr)
+
+static comedi_driver driver_pcl730 = {
+       driver_name:    "pcl730",
+       module:         THIS_MODULE,
+       attach:         pcl730_attach,
+       detach:         pcl730_detach,
+       board_name: boardtypes,
+       num_names:      n_boardtypes,
+       offset:         sizeof(boardtype),
+};
+COMEDI_INITCLEANUP(driver_pcl730);
+
+static int pcl730_do_insn(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+{
+       if( insn->n != 2 )
+        return -EINVAL;
+
+       if(data[0])
+    {
+               s->state &= ~data[0];
+               s->state |= (data[0] & data[1]);
+       }
+    if( data[0] & 0x00ff )
+        outb(s->state & 0xff, dev->iobase+((unsigned long)s->private));
+    if( data[0] & 0xff00 )
+        outb((s->state >> 8), dev->iobase+((unsigned long)s->private)+1);
+       
+       data[1]=s->state;
+
+       return 2;
+}
+
+static int pcl730_di_insn(comedi_device *dev,comedi_subdevice *s,
+       comedi_insn *insn,lsampl_t *data)
+{
+       if( insn->n != 2 )
+        return -EINVAL;
+
+       data[1]=inb(dev->iobase+((unsigned long)s->private)) | 
+                       (inb(dev->iobase+((unsigned long)s->private)+1)<<8);
+
+       return 2;
+}
+
+static int pcl730_attach(comedi_device *dev,comedi_devconfig *it)
+{
+       comedi_subdevice *s;
+       int iobase, iorange;
+
+       iobase=it->options[0];
+       iorange=this_board->io_range;
+       printk("comedi%d: pcl730: board=%s 0x%04x ", dev->minor,
+                       this_board->name, iobase);
+       if( check_region(iobase, iorange) < 0 )
+    {
+               printk("I/O port conflict\n");
+               return -EIO;
+       }
+       request_region(iobase, iorange, "pcl730");
+    dev->board_name=this_board->name;
+       dev->iobase=iobase;
+       dev->irq=0;
+
+       if( alloc_subdevices(dev, 4) < 0 )
+               return -ENOMEM;
+
+       s=dev->subdevices+0;
+       /* Isolated do */
+       s->type=COMEDI_SUBD_DO;
+       s->subdev_flags=SDF_WRITABLE;
+       s->maxdata=1;
+       s->n_chan=16;
+       s->insn_bits = pcl730_do_insn;
+       s->range_table=&range_digital;
+       s->private = (void *)PCL730_IDIO_LO;    
+
+       s=dev->subdevices+1;
+       /* Isolated di */
+       s->type=COMEDI_SUBD_DI;
+       s->subdev_flags=SDF_READABLE;
+       s->maxdata=1;
+       s->n_chan=16;
+       s->insn_bits = pcl730_di_insn;
+       s->range_table=&range_digital;
+       s->private = (void *)PCL730_IDIO_LO;    
+
+       s=dev->subdevices+2;
+       /* TTL do */
+       s->type=COMEDI_SUBD_DO;
+       s->subdev_flags=SDF_WRITABLE;
+       s->maxdata=1;
+       s->n_chan=16;
+       s->insn_bits = pcl730_do_insn;
+       s->range_table=&range_digital;
+       s->private = (void *)PCL730_DIO_LO;     
+
+       s=dev->subdevices+3;
+       /* TTL di */
+       s->type=COMEDI_SUBD_DI;
+       s->subdev_flags=SDF_READABLE;
+       s->maxdata=1;
+       s->n_chan=16;
+       s->insn_bits = pcl730_di_insn;
+       s->range_table=&range_digital;
+       s->private = (void *)PCL730_DIO_LO;     
+
+       printk("\n");
+
+       return 0;
+}
+
+static int pcl730_detach(comedi_device *dev)
+{
+       printk("comedi%d: pcl730: remove\n",dev->minor);
+
+       if(dev->iobase)
+        release_region(dev->iobase, this_board->io_range);
+       
+       return 0;
+}