From 145ff35bab0c64320cba09a1c720525e035025c4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 6 Jun 2013 15:37:20 -0700 Subject: [PATCH] staging: comedi: pcl730: add support for the PCM-3730 PC/104 board The PCM-3730 PC/104 board has the same register i/o map as the PCL-730 ISA board. The only difference is the number of isolated digital input and output channels. Add support for the PCM-3770 board to the pcl730 driver and remove the standalone pcm3730 driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 13 +-- drivers/staging/comedi/drivers/Makefile | 1 - drivers/staging/comedi/drivers/pcl730.c | 31 +++++- drivers/staging/comedi/drivers/pcm3730.c | 136 ----------------------- 4 files changed, 28 insertions(+), 153 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/pcm3730.c diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index fe9890afeb5d..a631353e2e5d 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -154,10 +154,11 @@ config COMEDI_PCL726 called pcl726. config COMEDI_PCL730 - tristate "Advantech PCL-730 and ADlink ACL-7130 ISA card support" + tristate "Advantech PCL-730/PCM-3730 and compatible board support" ---help--- Enable support for Advantech PCL-730, ICP ISO-730 and ADlink - ACL-7130 ISA cards + ACL-7130 ISA cards as well as the Advantech PCM-3730 and clone + PC/104 boards. To compile this driver as a module, choose M here: the module will be called pcl730. @@ -201,14 +202,6 @@ config COMEDI_PCM3724 To compile this driver as a module, choose M here: the module will be called pcm3724. -config COMEDI_PCM3730 - tristate "Advantech PCM-3730 and clone PC/104 board support" - ---help--- - Enable support for Advantech PCM-3730 and clone PC/104 boards - - To compile this driver as a module, choose M here: the module will be - called pcm3730. - config COMEDI_AMPLC_DIO200_ISA tristate "Amplicon PC212E/PC214E/PC215E/PC218E/PC272E" select COMEDI_AMPLC_DIO200 diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 5b3c5a24e4e0..30e96269cb61 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -23,7 +23,6 @@ obj-$(CONFIG_COMEDI_PCL812) += pcl812.o obj-$(CONFIG_COMEDI_PCL816) += pcl816.o obj-$(CONFIG_COMEDI_PCL818) += pcl818.o obj-$(CONFIG_COMEDI_PCM3724) += pcm3724.o -obj-$(CONFIG_COMEDI_PCM3730) += pcm3730.o obj-$(CONFIG_COMEDI_RTI800) += rti800.o obj-$(CONFIG_COMEDI_RTI802) += rti802.o obj-$(CONFIG_COMEDI_DAS16M1) += das16m1.o diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index c77e347e7b1e..4b9a4fbd7b72 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -10,6 +10,7 @@ * Devices: (Advantech) PCL-730 [pcl730] * (ICP) ISO-730 [iso730] * (Adlink) ACL-7130 [acl7130] + * (Advantech) PCM-3730 [pcm3730] * Author: José Luis Sánchez (jsanchezv@teleline.es) * Status: untested * @@ -24,26 +25,39 @@ #include +/* + * Register I/O map + * + * The pcm3730 PC/104 board does not have the PCL730_IDIO_HI register. + */ #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) */ struct pcl730_board { - const char *name; /* board name */ - unsigned int io_range; /* len of I/O space */ + const char *name; + unsigned int io_range; + int n_iso_chan; }; static const struct pcl730_board pcl730_boards[] = { { .name = "pcl730", .io_range = 0x04, + .n_iso_chan = 16, }, { .name = "iso730", .io_range = 0x04, + .n_iso_chan = 16, }, { .name = "acl7130", .io_range = 0x08, + .n_iso_chan = 16, + }, { + .name = "pcm3730", + .io_range = 0x04, + .n_iso_chan = 8, }, }; @@ -62,7 +76,7 @@ static int pcl730_do_insn_bits(struct comedi_device *dev, if (mask & 0x00ff) outb(s->state & 0xff, dev->iobase + reg); - if (mask & 0xff00) + if ((mask & 0xff00) && (s->n_chan > 8)) outb((s->state >> 8) & 0xff, dev->iobase + reg + 1); } @@ -77,8 +91,13 @@ static int pcl730_di_insn_bits(struct comedi_device *dev, unsigned int *data) { unsigned long reg = (unsigned long)s->private; + unsigned int val; + + val = inb(dev->iobase + reg); + if (s->n_chan > 8) + val |= (inb(dev->iobase + reg + 1) << 8); - data[1] = inb(dev->iobase + reg) | (inb(dev->iobase + reg + 1) << 8); + data[1] = val; return insn->n; } @@ -102,7 +121,7 @@ static int pcl730_attach(struct comedi_device *dev, s = &dev->subdevices[0]; s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = 16; + s->n_chan = board->n_iso_chan; s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = pcl730_do_insn_bits; @@ -112,7 +131,7 @@ static int pcl730_attach(struct comedi_device *dev, s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; - s->n_chan = 16; + s->n_chan = board->n_iso_chan; s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = pcl730_di_insn_bits; diff --git a/drivers/staging/comedi/drivers/pcm3730.c b/drivers/staging/comedi/drivers/pcm3730.c deleted file mode 100644 index 3a3ce2c769a2..000000000000 --- a/drivers/staging/comedi/drivers/pcm3730.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * comedi/drivers/pcm3730.c - * Driver for PCM3730 and clones - * Blaine Lee - * from pcl725 by David S. - */ -/* -Driver: pcm3730 -Description: PCM3730 -Author: Blaine Lee -Devices: [Advantech] PCM-3730 (pcm3730) -Status: unknown - -Configuration options: - [0] - I/O port base -*/ - -#include "../comedidev.h" - -#include - -#define PCM3730_SIZE 4 /* consecutive io port addresses */ - -#define PCM3730_DOA 0 /* offsets for each port */ -#define PCM3730_DOB 2 -#define PCM3730_DOC 3 -#define PCM3730_DIA 0 -#define PCM3730_DIB 2 -#define PCM3730_DIC 3 - -static int pcm3730_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - if (data[0]) { - s->state &= ~data[0]; - s->state |= (data[0] & data[1]); - outb(s->state, dev->iobase + (unsigned long)(s->private)); - } - data[1] = s->state; - - return insn->n; -} - -static int pcm3730_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - data[1] = inb(dev->iobase + (unsigned long)(s->private)); - return insn->n; -} - -static int pcm3730_attach(struct comedi_device *dev, - struct comedi_devconfig *it) -{ - struct comedi_subdevice *s; - int ret; - - ret = comedi_request_region(dev, it->options[0], PCM3730_SIZE); - if (ret) - return ret; - - ret = comedi_alloc_subdevices(dev, 6); - if (ret) - return ret; - - s = &dev->subdevices[0]; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->maxdata = 1; - s->n_chan = 8; - s->insn_bits = pcm3730_do_insn_bits; - s->range_table = &range_digital; - s->private = (void *)PCM3730_DOA; - - s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->maxdata = 1; - s->n_chan = 8; - s->insn_bits = pcm3730_do_insn_bits; - s->range_table = &range_digital; - s->private = (void *)PCM3730_DOB; - - s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->maxdata = 1; - s->n_chan = 8; - s->insn_bits = pcm3730_do_insn_bits; - s->range_table = &range_digital; - s->private = (void *)PCM3730_DOC; - - s = &dev->subdevices[3]; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->maxdata = 1; - s->n_chan = 8; - s->insn_bits = pcm3730_di_insn_bits; - s->range_table = &range_digital; - s->private = (void *)PCM3730_DIA; - - s = &dev->subdevices[4]; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->maxdata = 1; - s->n_chan = 8; - s->insn_bits = pcm3730_di_insn_bits; - s->range_table = &range_digital; - s->private = (void *)PCM3730_DIB; - - s = &dev->subdevices[5]; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->maxdata = 1; - s->n_chan = 8; - s->insn_bits = pcm3730_di_insn_bits; - s->range_table = &range_digital; - s->private = (void *)PCM3730_DIC; - - printk(KERN_INFO "\n"); - - return 0; -} - -static struct comedi_driver pcm3730_driver = { - .driver_name = "pcm3730", - .module = THIS_MODULE, - .attach = pcm3730_attach, - .detach = comedi_legacy_detach, -}; -module_comedi_driver(pcm3730_driver); - -MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); -MODULE_LICENSE("GPL"); -- 2.39.5