50 #include "../comedidev.h"
65 struct pcmcia_device *
link;
85 #define DAQP_FIFO_SIZE 4096
88 #define DAQP_SCANLIST 1
89 #define DAQP_CONTROL 2
91 #define DAQP_DIGITAL_IO 3
92 #define DAQP_PACER_LOW 4
93 #define DAQP_PACER_MID 5
94 #define DAQP_PACER_HIGH 6
95 #define DAQP_COMMAND 7
100 #define DAQP_SCANLIST_DIFFERENTIAL 0x4000
101 #define DAQP_SCANLIST_GAIN(x) ((x)<<12)
102 #define DAQP_SCANLIST_CHANNEL(x) ((x)<<8)
103 #define DAQP_SCANLIST_START 0x0080
104 #define DAQP_SCANLIST_EXT_GAIN(x) ((x)<<4)
105 #define DAQP_SCANLIST_EXT_CHANNEL(x) (x)
107 #define DAQP_CONTROL_PACER_100kHz 0xc0
108 #define DAQP_CONTROL_PACER_1MHz 0x80
109 #define DAQP_CONTROL_PACER_5MHz 0x40
110 #define DAQP_CONTROL_PACER_EXTERNAL 0x00
111 #define DAQP_CONTORL_EXPANSION 0x20
112 #define DAQP_CONTROL_EOS_INT_ENABLE 0x10
113 #define DAQP_CONTROL_FIFO_INT_ENABLE 0x08
114 #define DAQP_CONTROL_TRIGGER_ONESHOT 0x00
115 #define DAQP_CONTROL_TRIGGER_CONTINUOUS 0x04
116 #define DAQP_CONTROL_TRIGGER_INTERNAL 0x00
117 #define DAQP_CONTROL_TRIGGER_EXTERNAL 0x02
118 #define DAQP_CONTROL_TRIGGER_RISING 0x00
119 #define DAQP_CONTROL_TRIGGER_FALLING 0x01
121 #define DAQP_STATUS_IDLE 0x80
122 #define DAQP_STATUS_RUNNING 0x40
123 #define DAQP_STATUS_EVENTS 0x38
124 #define DAQP_STATUS_DATA_LOST 0x20
125 #define DAQP_STATUS_END_OF_SCAN 0x10
126 #define DAQP_STATUS_FIFO_THRESHOLD 0x08
127 #define DAQP_STATUS_FIFO_FULL 0x04
128 #define DAQP_STATUS_FIFO_NEARFULL 0x02
129 #define DAQP_STATUS_FIFO_EMPTY 0x01
131 #define DAQP_COMMAND_ARM 0x80
132 #define DAQP_COMMAND_RSTF 0x40
133 #define DAQP_COMMAND_RSTQ 0x20
134 #define DAQP_COMMAND_STOP 0x10
135 #define DAQP_COMMAND_LATCH 0x08
136 #define DAQP_COMMAND_100kHz 0x00
137 #define DAQP_COMMAND_50kHz 0x02
138 #define DAQP_COMMAND_25kHz 0x04
139 #define DAQP_COMMAND_FIFO_DATA 0x01
140 #define DAQP_COMMAND_FIFO_PROGRAM 0x00
142 #define DAQP_AUX_TRIGGER_TTL 0x00
143 #define DAQP_AUX_TRIGGER_ANALOG 0x80
144 #define DAQP_AUX_TRIGGER_PRETRIGGER 0x40
145 #define DAQP_AUX_TIMER_INT_ENABLE 0x20
146 #define DAQP_AUX_TIMER_RELOAD 0x00
147 #define DAQP_AUX_TIMER_PAUSE 0x08
148 #define DAQP_AUX_TIMER_GO 0x10
149 #define DAQP_AUX_TIMER_GO_EXTERNAL 0x18
150 #define DAQP_AUX_TIMER_EXTERNAL_SRC 0x04
151 #define DAQP_AUX_TIMER_INTERNAL_SRC 0x00
152 #define DAQP_AUX_DA_DIRECT 0x00
153 #define DAQP_AUX_DA_OVERFLOW 0x01
154 #define DAQP_AUX_DA_EXTERNAL 0x02
155 #define DAQP_AUX_DA_PACER 0x03
157 #define DAQP_AUX_RUNNING 0x80
158 #define DAQP_AUX_TRIGGERED 0x40
159 #define DAQP_AUX_DA_BUFFER 0x20
160 #define DAQP_AUX_TIMER_OVERFLOW 0x10
161 #define DAQP_AUX_CONVERSION 0x08
162 #define DAQP_AUX_DATA_LOST 0x04
163 #define DAQP_AUX_FIFO_NEARFULL 0x02
164 #define DAQP_AUX_FIFO_EMPTY 0x01
188 .driver_name =
"quatech_daqp_cs",
190 .attach = daqp_attach,
191 .detach = daqp_detach,
202 static void hex_dump(
char *
str,
void *
ptr,
int len)
204 unsigned char *cptr =
ptr;
209 for (i = 0; i < len; i++) {
213 printk(
" %02x", *(cptr++));
254 int loop_limit = 10000;
259 "daqp_interrupt(): irq %d for unknown device.\n", irq);
271 "daqp_interrupt(): struct comedi_device not yet attached.\n");
278 "daqp_interrupt(): NULL comedi_subdevice.\n");
284 "daqp_interrupt(): invalid comedi_subdevice.\n");
305 printk(
"daqp: data lost\n");
306 daqp_ai_cancel(dev, s);
320 if (local->
count > 0) {
322 if (local->
count == 0) {
323 daqp_ai_cancel(dev, s);
329 if ((loop_limit--) <= 0)
333 if (loop_limit <= 0) {
335 "loop_limit reached in daqp_interrupt()\n");
336 daqp_ai_cancel(dev, s);
363 daqp_ai_cancel(dev, s);
402 printk(
"daqp: couldn't clear interrupts in status register\n");
406 init_completion(&local->
eos);
411 for (i = 0; i < insn->
n; i++) {
437 static int daqp_ns_to_timer(
unsigned int *
ns,
int round)
477 err |= cfc_check_trigger_is_unique(cmd->
convert_src);
478 err |= cfc_check_trigger_is_unique(cmd->
stop_src);
491 #define MAX_SPEED 10000
563 int scanlist_start_on_every_entry;
574 daqp_ai_cancel(dev, s);
600 scanlist_start_on_every_entry = 1;
607 scanlist_start_on_every_entry = 0;
624 if (i == 0 || scanlist_start_on_every_entry)
740 "daqp: couldn't clear interrupts in status register\n");
827 printk(
"comedi%d: No such daqp device %d\n",
842 if (local->
link->prod_id[2]) {
843 if (
strncmp(local->
link->prod_id[2],
"DAQP", 4) == 0) {
849 dev->
iobase = local->
link->resource[0]->start;
870 s->
cancel = daqp_ai_cancel;
942 static void daqp_cs_config(
struct pcmcia_device *
link);
943 static void daqp_cs_release(
struct pcmcia_device *
link);
944 static int daqp_cs_suspend(
struct pcmcia_device *p_dev);
945 static int daqp_cs_resume(
struct pcmcia_device *p_dev);
947 static int daqp_cs_attach(
struct pcmcia_device *);
948 static void daqp_cs_detach(
struct pcmcia_device *);
950 static int daqp_cs_attach(
struct pcmcia_device *
link)
955 dev_dbg(&link->dev,
"daqp_cs_attach()\n");
958 if (dev_table[i] ==
NULL)
971 dev_table[
i] = local;
975 daqp_cs_config(link);
980 static void daqp_cs_detach(
struct pcmcia_device *link)
985 daqp_cs_release(link);
993 static int daqp_pcmcia_config_loop(
struct pcmcia_device *
p_dev,
void *priv_data)
995 if (p_dev->config_index == 0)
1001 static void daqp_cs_config(
struct pcmcia_device *link)
1005 dev_dbg(&link->dev,
"daqp_cs_config\n");
1007 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
1009 ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop,
NULL);
1011 dev_warn(&link->dev,
"no configuration found\n");
1026 daqp_cs_release(link);
1030 static void daqp_cs_release(
struct pcmcia_device *link)
1032 dev_dbg(&link->dev,
"daqp_cs_release\n");
1037 static int daqp_cs_suspend(
struct pcmcia_device *link)
1046 static int daqp_cs_resume(
struct pcmcia_device *link)
1060 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0027),
1069 static struct pcmcia_driver daqp_cs_driver = {
1070 .probe = daqp_cs_attach,
1071 .remove = daqp_cs_detach,
1072 .suspend = daqp_cs_suspend,
1073 .resume = daqp_cs_resume,
1074 .id_table = daqp_cs_id_table,
1076 .name =
"quatech_daqp_cs",