68 #include <linux/slab.h>
69 #include "../comedidev.h"
79 #define A2150_DMA_BUFFER_SIZE 0xff00
85 #define CONFIG_REG 0x0
86 #define CHANNEL_BITS(x) ((x) & 0x7)
87 #define CHANNEL_MASK 0x7
88 #define CLOCK_SELECT_BITS(x) (((x) & 0x3) << 3)
89 #define CLOCK_DIVISOR_BITS(x) (((x) & 0x3) << 5)
90 #define CLOCK_MASK (0xf << 3)
91 #define ENABLE0_BIT 0x80
92 #define ENABLE1_BIT 0x100
96 #define DPD_BIT 0x1000
97 #define TRIGGER_REG 0x2
98 #define POST_TRIGGER_BITS 0x2
99 #define DELAY_TRIGGER_BITS 0x3
100 #define HW_TRIG_EN 0x10
101 #define FIFO_START_REG 0x6
102 #define FIFO_RESET_REG 0x8
103 #define FIFO_DATA_REG 0xa
104 #define DMA_TC_CLEAR_REG 0xe
105 #define STATUS_REG 0x12
108 #define EDAQ_BIT 0x10
109 #define DCAL_BIT 0x20
110 #define INTR_BIT 0x40
111 #define DMA_TC_BIT 0x80
112 #define ID_BITS(x) (((x) >> 8) & 0x3)
113 #define IRQ_DMA_CNTRL_REG 0x12
114 #define DMA_CHAN_BITS(x) ((x) & 0x7)
115 #define DMA_EN_BIT 0x8
116 #define IRQ_LVL_BITS(x) (((x) & 0xf) << 4)
117 #define FIFO_INTR_EN_BIT 0x100
118 #define FIFO_INTR_FHF_BIT 0x200
119 #define DMA_INTR_EN_BIT 0x800
120 #define DMA_DEM_EN_BIT 0x1000
121 #define I8253_BASE_REG 0x14
122 #define I8253_MODE_REG 0x17
123 #define HW_COUNT_DISABLE 0x30
136 RANGE(-2.828, 2.828),
145 .clock = {31250, 22676, 20833, 19531},
151 .clock = {62500, 50000, 41667, 0},
160 #define thisboard ((const struct a2150_board *)dev->board_ptr)
172 #define devpriv ((struct a2150_private *)dev->private)
179 unsigned int start_channel,
202 unsigned int max_points, num_points, residue, leftover;
224 a2150_cancel(dev, s);
229 comedi_error(dev,
"caught non-dma interrupt? Aborting.");
230 a2150_cancel(dev, s);
249 num_points = max_points - residue;
257 }
else if (
devpriv->count > max_points) {
258 leftover =
devpriv->count - max_points;
259 if (leftover > max_points)
260 leftover = max_points;
269 for (i = 0; i < num_points; i++) {
274 cfc_write_to_buffer(s, dpnt);
277 a2150_cancel(dev, s);
337 err |= cfc_check_trigger_is_unique(cmd->
start_src);
338 err |= cfc_check_trigger_is_unique(cmd->
stop_src);
398 "entries in chanlist must be consecutive channels, counting upwards\n");
404 "length 2 chanlist must be channels 0,1 or channels 2,3");
409 "chanlist must have 1,2 or 4 channels");
415 "channels 0/1 and 2/3 must have the same analog reference");
431 unsigned int old_config_bits =
devpriv->config_bits;
432 unsigned int trigger_bits;
436 " irq and dma required, cannot do hardware conversions");
441 " dma incompatible with hard real-time interrupt (TRIG_RT), aborting");
479 #define ONE_THIRD_SECOND 333333333
509 (
devpriv->config_bits & CLOCK_MASK)) {
540 static const int timeout = 100000;
541 static const int filter_delay = 36;
571 for (n = 0; n < filter_delay; n++) {
572 for (i = 0; i < timeout; i++) {
585 for (n = 0; n < insn->
n; n++) {
586 for (i = 0; i < timeout; i++) {
600 printk(
" data is %i\n", data[n]);
619 int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
623 lub_divisor_shift = 3;
625 lub =
thisboard->clock[lub_index] * (1 << lub_divisor_shift);
626 glb_divisor_shift = 0;
628 glb =
thisboard->clock[glb_index] * (1 << glb_divisor_shift);
637 for (i = 0; i < 4; i++) {
639 for (j = 0; j <
thisboard->num_clocks; j++) {
643 if (temp < lub && temp >= *period) {
644 lub_divisor_shift =
i;
648 if (temp > glb && temp <= *period) {
649 glb_divisor_shift =
i;
660 if (lub - *period < *period - glb)
674 devpriv->config_bits &= ~CLOCK_MASK;
675 if (*period == lub) {
689 unsigned int start_channel,
692 if (start_channel + num_channels > 4)
697 switch (num_channels) {
702 if (start_channel == 0) {
704 }
else if (start_channel == 2) {
732 unsigned int irq = it->
options[1];
734 static const int timeout = 2000;
757 printk(
" io base address required\n");
763 printk(
" I/O port conflict\n");
771 if (irq < 3 || irq == 8 || irq == 13 || irq > 15) {
772 printk(
" invalid irq line %u\n", irq);
776 dev->
driver->driver_name, dev)) {
777 printk(
"unable to allocate irq %u\n", irq);
785 if (dma == 4 || dma > 7) {
786 printk(
" invalid dma channel %u\n", dma);
790 printk(
" failed to allocate dma channel %u\n", dma);
805 dev->
board_ptr = a2150_boards + a2150_probe(dev);
840 for (i = 0; i < timeout; i++) {
847 (
" timed out waiting for offset calibration to complete\n");
872 .driver_name =
"ni_at_a2150",
874 .attach = a2150_attach,
875 .detach = a2150_detach,