Adding new driver to drivers/staging/comedi/drivers for contec_fit.c
for CONTEC F&eIT modules
Signed off by dan.naugh...@dtx.com
diff -ruN linux.bak/drivers/staging/comedi/drivers/contec_fit.c
linux/drivers/staging/comedi/drivers/contec_fit.c
--- linux.bak/drivers/staging/comedi/drivers/contec_fit.c
1969-12-31 18:00:00.0 -0600
+++ linux/drivers/staging/comedi/drivers/contec_fit.c2017-05-20
15:02:03.715167366 -0500
@@ -0,0 +1,908 @@
+/*
+comedi/drivers/contec_fit.c
+
+COMEDI - Linux Control and Measurement Device Interface
+Copyright (C) 2000 David A. Schleef
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+/*
+Driver: contec_fit
+Description: Contec F&eIT series modules
+Devices: [Contec] DAI12-4(FIT)GY (contec_fit), ADI16-4(FIT)GY, DIO-8/8(FIT)GY
+Author: Contec Co., Ltd.
+Updated: Thu, 18 May 2017 14:30:00 +0900
+Status: works
+
+Configuration Options:
+ [0] - DeviceID of module (optional)
+ If DeviceID is not specified, DeviceID 0 will be used.
+*/
+
+#include
+#include
+#include "../comedidev.h"
+#include
+
+typedef struct {
+struct task_struct *fit_kthread;
+} contec_fit_private;
+
+#define devpriv ((contec_fit_private *)dev->private)
+
+static int contec_attach(struct comedi_device * dev, struct
comedi_devconfig * it);
+static void contec_detach(struct comedi_device * dev);
+static struct comedi_driver driver_contec = {
+ .driver_name= "contec_fit",
+ .module= THIS_MODULE,
+ .attach= contec_attach,
+ .detach= contec_detach,
+};
+
+/* Classic digital IO */
+static int contec_ai_insn_read(struct comedi_device * dev, struct
comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int contec_ao_insn_write(struct comedi_device * dev, struct
comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int contec_di_insn_bits(struct comedi_device * dev, struct
comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+static int contec_do_insn_bits(struct comedi_device * dev, struct
comedi_subdevice * s, struct comedi_insn * insn, unsigned int * data);
+
+staticint contec_ai_cmdtest(struct comedi_device * dev, struct
comedi_subdevice * s, struct comedi_cmd * cmd);
+static int contec_ai_cmd(struct comedi_device * dev, struct
comedi_subdevice * s);
+static int contec_ai_sampling_thread(void * context_dev);
+static int contec_ai_cancel(struct comedi_device * dev, struct
comedi_subdevice * s);
+
+staticint contec_ao_cmdtest(struct comedi_device * dev, struct
comedi_subdevice * s, struct comedi_cmd * cmd);
+static int contec_ao_cmd(struct comedi_device * dev, struct
comedi_subdevice * s);
+static int contec_ao_sampling_thread(void * context_dev);
+static int contec_ao_cancel(struct comedi_device * dev, struct
comedi_subdevice * s);
+static int contec_ao_cmd_inttrig(struct comedi_device *dev, struct
comedi_subdevice *s, unsigned int trignum);
+
+static void contec_check_sampling_clock(unsigned int *sampling_clock,
unsigned int *channel_num, int flags);
+
+//START ADDRESS
+#define ADDRESS_BASE0x0800
+#define ADDRESS_PER_ID0x1000
+
+//CONTEC FIT SIZE
+#define CONTEC_FIT_SIZE0x20
+
+//COMMON IO
+#define IO_PRODUCT_CATEGORY0x00
+#define IO_PRODUCT_ID_NUMBER0x01
+#define IO_COMMAND_DATA0x18
+#define IO_SETUP_DATA00x1C
+#define IO_SETUP_DATA10x1D
+#define IO_SETUP_DATA20x1E
+#define IO_SETUP_DATA30x1F
+
+//DAI12-4(FIT)GY IO
+#define IO_DAI124_OUTPUTDATA_LOWER0x10
+#define IO_DAI124_OUTPUTDATA_UPPER0x11
+#define IO_DAI124_CHANNELDATA0x12
+#define IO_DAI124_STATUS0x16
+
+//ADI16-4(FIT)GY IO
+#define IO_ADI164_INPUTDATA_LOWER0x10
+#define IO_ADI164_INPUTDATA_UPPER0x11
+#define IO_ADI164_CHANNELDATA0x12
+#define IO_ADI164_STATUS00x16
+#define IO_ADI164_STATUS10x17
+
+//DIO-8/8(FIT)GY IO
+#define IO_DIO88_INPUT00x10
+#define IO_DIO88_OUTPUT00x14
+
+//DAI12-4(FIT)GY COMMAND
+#define COMMAND_DAI124_INIT0x00