From a54b447c98879c191a8a58298f9eb47c5b2b7bbf Mon Sep 17 00:00:00 2001 From: David Schleef Date: Mon, 24 Jul 2000 19:43:29 +0000 Subject: [PATCH] patch from dobes --- Documentation/comedi/drivers.txt | 23 +++- comedi/Config.in | 4 + comedi/drivers/8255.h | 7 + comedi/drivers/Makefile | 1 + comedi/drivers/pcl724.c | 222 +++++++++++++++++++++++++++++++ scripts/Configure.help | 6 + 6 files changed, 258 insertions(+), 5 deletions(-) create mode 100644 comedi/drivers/pcl724.c diff --git a/Documentation/comedi/drivers.txt b/Documentation/comedi/drivers.txt index 3c3de3ba..b4da8f09 100644 --- a/Documentation/comedi/drivers.txt +++ b/Documentation/comedi/drivers.txt @@ -385,23 +385,36 @@ DMA is halfway completed, but not yet operational. -pcl711.o: PC-LabCard PCL-711 and 711b, AdSys ACL-8112 +pcl711.o: Advantech PCL-711 and 711b, ADLink ACL-8112 Authors: ds, Janne Jalkanen , Eric Bunn Status: mostly complete This driver recognizes the following board names: - pcl711 PCL-711 - pcl711b PCL-711B - acl8112dg ACL-8112DG - acl8112hg ACL-8112HG + pcl711 Advantech PCL-711 + pcl711b Advantech PCL-711B + acl8112dg ADLink ACL-8112DG + acl8112hg ADLink ACL-8112HG Since these boards do not have DMA or FIFOs, only immediate mode is supported. +pcl724.o: Advantech PCL-724, PCL-722, PCL-731 + ADLink ACL-7122, ACL-7124, PET-48DIO + +Author: Michal Dobes +Status: untested + +This is driver for digital I/O boards PCL-722/724/731 with 144/24/48 DIO +and for digital I/O boards ACL-7122/7124/PET-48DIO with 144/24/48 DIO. +It need 8255.o for operations and only immediate mode is supported. +See the source for configuration details. + + + pcl725.o: PC-LabCard PCL-725 (& compatibles) Author: ds diff --git a/comedi/Config.in b/comedi/Config.in index 8f85eb92..a7565554 100644 --- a/comedi/Config.in +++ b/comedi/Config.in @@ -71,6 +71,10 @@ dep_tristate 'Generic 8255 support' CONFIG_COMEDI_8255 $CONFIG_COMEDI dep_tristate 'Quanser Consulting MultiQ-3' CONFIG_COMEDI_MULTIQ3 $CONFIG_COMEDI dep_tristate 'Generic parallel port support' CONFIG_COMEDI_PARPORT $CONFIG_COMEDI dep_tristate 'PCL-711, PCL-711b, ACL-8112, and compatibles' CONFIG_COMEDI_PCL711 $CONFIG_COMEDI +dep_tristate 'PCL-722/724/731, ACL-7122/7124, PET-48DIO' CONFIG_COMEDI_PCL724 $CONFIG_COMEDI +if [ "$CONFIG_COMEDI_PCL724" = "m" ];then + define_bool CONFIG_COMEDI_8255 m +fi dep_tristate 'PCL-725' CONFIG_COMEDI_PCL725 $CONFIG_COMEDI dep_tristate 'PCL-726' CONFIG_COMEDI_PCL726 $CONFIG_COMEDI dep_tristate 'Advantech PCL-812PG, PCL-813B' CONFIG_COMEDI_PCL812 $CONFIG_COMEDI diff --git a/comedi/drivers/8255.h b/comedi/drivers/8255.h index 32b9ed06..d45283e3 100644 --- a/comedi/drivers/8255.h +++ b/comedi/drivers/8255.h @@ -32,6 +32,12 @@ int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,in #else +#ifdef CONFIG_COMEDI_8255_MODULE + +int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,int,void *),void *arg); + +#else + static inline int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,void *x,void *y) { printk("8255 support not configured -- disabling subdevice\n"); @@ -41,6 +47,7 @@ static inline int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,void * return 0; } +#endif #endif diff --git a/comedi/drivers/Makefile b/comedi/drivers/Makefile index a6de973b..146347ca 100644 --- a/comedi/drivers/Makefile +++ b/comedi/drivers/Makefile @@ -49,6 +49,7 @@ obj-$(CONFIG_COMEDI_MITE) += mite.o obj-$(CONFIG_COMEDI_NI_ATMIO16D) += ni_atmio16d.o obj-$(CONFIG_COMEDI_PCL711) += pcl711.o +obj-$(CONFIG_COMEDI_PCL724) += pcl724.o obj-$(CONFIG_COMEDI_PCL725) += pcl725.o obj-$(CONFIG_COMEDI_PCL726) += pcl726.o obj-$(CONFIG_COMEDI_PCL812) += pcl812.o diff --git a/comedi/drivers/pcl724.c b/comedi/drivers/pcl724.c new file mode 100644 index 00000000..0cc079d7 --- /dev/null +++ b/comedi/drivers/pcl724.c @@ -0,0 +1,222 @@ +/* + module/pcl724.c + + Michal Dobes + + hardware driver for Advantech cards: + card: PCL-724, PCL-722, PCL-731 + driver: pcl724, pcl722, pcl731 + and ADLink cards: + card: ACL-7122, ACL-7124, PET-48DIO + driver: acl7122, acl7124, pet48dio + + Options for PCL-724, PCL-731, ACL-7124 and PET-48DIO: + [0] - IO Base + + Options for PCL-722 and ACL-7122: + [0] - IO Base + [1] - IRQ (0=disable IRQ) IRQ isn't supported at this time! + [2] -number of DIO: + 0, 144: 144 DIO configuration + 1, 96: 96 DIO configuration +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include <8255.h> + +#define PCL722_SIZE 32 +#define PCL722_96_SIZE 16 +#define PCL724_SIZE 4 +#define PCL731_SIZE 8 +#define PET48_SIZE 2 + +#define SIZE_8255 4 + +// #define PCL724_IRQ 1 /* no IRQ support now */ + +static int pcl724_attach(comedi_device *dev,comedi_devconfig *it); +static int pcl724_detach(comedi_device *dev); +static int pcl724_recognize(char *name); + +comedi_driver driver_pcl724={ + driver_name: "pcl724", + module: THIS_MODULE, + attach: pcl724_attach, + detach: pcl724_detach, + recognize: pcl724_recognize, +}; + +typedef struct { + char *name; // driver name + int dio; // num of DIO + int numofports; // num of 8255 subdevices + unsigned int IRQbits; // allowed interrupts + int io_range; // len of IO space + char can_have96; + char is_pet48; +} boardtype; + +static boardtype boardtypes[] = +{ + {"pcl724", 24, 1, 0x00fc, PCL724_SIZE, 0, 0, }, + {"pcl722", 144, 6, 0x00fc, PCL722_SIZE, 1, 0, }, + {"pcl731", 48, 2, 0x9cfc, PCL731_SIZE, 0, 0, }, + {"acl7122", 144, 6, 0x9ee8, PCL722_SIZE, 1, 0, }, + {"acl7124", 24, 1, 0x00fc, PCL724_SIZE, 0, 0, }, + {"pet48dio", 48, 2, 0x9eb8, PET48_SIZE, 0, 1, }, +}; + +#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype)) + +static int subdev_8255_cb(int dir,int port,int data,void *arg) +{ + int iobase=(int)arg; + + if(dir){ + outb(data,iobase+port); + return 0; + }else{ + return inb(iobase+port); + } +} + +static int subdev_8255mapped_cb(int dir,int port,int data,void *arg) +{ + int iobase=(int)arg; + int movport=SIZE_8255*(iobase>>12); + + iobase&=0x0fff; + + if(dir){ + outb(port+movport,iobase); + outb(data,iobase+1); + return 0; + }else{ + outb(port+movport,iobase); + return inb(iobase+1); + } +} + +static int pcl724_attach(comedi_device *dev,comedi_devconfig *it) +{ + int board,iobase,iorange; + int ret,i; + + board=dev->board; + + iobase=it->options[0]; + iorange=boardtypes[board].io_range; + if ((boardtypes[board].can_have96)&&((it->options[1]==1)||(it->options[1]==96))) + iorange=PCL722_96_SIZE; // PCL-724 in 96 DIO configuration + printk("comedi%d: pcl724: board=%s, 0x%03x ",dev->minor,boardtypes[board].name,iobase); + if(check_region(iobase,iorange)<0){ + printk("I/O port conflict\n"); + return -EIO; + } + + request_region(iobase, iorange, "pcl724"); + dev->iobase=iobase; + dev->iosize=iorange; + + dev->board_name = boardtypes[board].name; + +#ifdef PCL724_IRQ + irq=0; + if (boardtypes[board].IRQbits!=0) { /* board support IRQ */ + irq=it->options[1]; + if (irq>0) {/* we want to use IRQ */ + if (((1<irq = irq; +#endif + + printk("\n"); + + dev->n_subdevices=boardtypes[board].numofports; + if ((boardtypes[board].can_have96)&&((it->options[1]==1)||(it->options[1]==96))) + dev->n_subdevices=4; // PCL-724 in 96 DIO configuration + + + if((ret=alloc_subdevices(dev))<0) + return ret; + + for(i=0;in_subdevices;i++){ + if (boardtypes[board].is_pet48) { + subdev_8255_init(dev,dev->subdevices+i, + subdev_8255mapped_cb,(void *)(dev->iobase+i*0x1000)); + } else + subdev_8255_init(dev,dev->subdevices+i, + subdev_8255_cb,(void *)(dev->iobase+SIZE_8255*i)); + }; + + return 0; +} + + +static int pcl724_detach(comedi_device *dev) +{ +// printk("comedi%d: pcl724: remove\n",dev->minor); + +#ifdef PCL724_IRQ + if(dev->irq){ + free_irq(dev->irq,dev); + } +#endif + + release_region(dev->iobase,dev->iosize); + + return 0; +} + +static int pcl724_recognize(char *name) +{ + int i; + + for (i = 0; i < n_boardtypes; i++) { + if (!strcmp(boardtypes[i].name, name)) { + return i; + } + } + + return -1; +} + + + +#ifdef MODULE +int init_module(void) +{ + comedi_driver_register(&driver_pcl724); + + return 0; +} + +void cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl724); +} +#endif diff --git a/scripts/Configure.help b/scripts/Configure.help index bebf73c0..a12fa125 100644 --- a/scripts/Configure.help +++ b/scripts/Configure.help @@ -156,6 +156,12 @@ PCL 711 driver CONFIG_COMEDI_PCL711 Includes support for PCL 711, 711b and ACL 8112. +Advantech PCL-722/724/731 and ADLink ACL-7122/7124/PET-48DIO driver +CONFIG_COMEDI_PCL724 + Includes support for Advantech DIO boards PCL-722, PCL-724 and PCL-731. + Includes support for ADLink DIO boards ACL-7122, ACL-7124 and PET-48DIO. + This driver need 8255 chip support for correct work. + PCL 725 driver CONFIG_COMEDI_PCL725 Includes support for PCL 725. -- 2.26.2