3 Hardware driver for NI Mite PCI interface chip
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1997-2002 David A. Schleef <ds@schleef.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 The PCI-MIO E series driver was originally written by
21 Tomasz Motylewski <...>, and ported to comedi by ds.
23 References for specifications:
25 321747b.pdf Register Level Programmer Manual (obsolete)
26 321747c.pdf Register Level Programmer Manual (new)
27 DAQ-STC reference manual
29 Other possibly relevant info:
31 320517c.pdf User manual (obsolete)
32 320517f.pdf User manual (new)
34 320906c.pdf maximum signal ratings
36 321791a.pdf discontinuation of at-mio-16e-10 rev. c
37 321808a.pdf about at-mio-16e-10 rev P
38 321837a.pdf discontinuation of at-mio-16de-10 rev d
39 321838a.pdf about at-mio-16de-10 rev N
45 /* #define USE_KMALLOC */
47 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
49 #include <linux/pci.h>
51 #include "../comedidev.h"
53 #include "comedi_fc.h"
56 #define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK)))
58 struct mite_struct
*mite_alloc(struct pci_dev
*pcidev
)
60 struct mite_struct
*mite
;
63 mite
= kzalloc(sizeof(*mite
), GFP_KERNEL
);
65 spin_lock_init(&mite
->lock
);
66 mite
->pcidev
= pcidev
;
67 for (i
= 0; i
< MAX_MITE_DMA_CHANNELS
; ++i
) {
68 mite
->channels
[i
].mite
= mite
;
69 mite
->channels
[i
].channel
= i
;
70 mite
->channels
[i
].done
= 1;
75 EXPORT_SYMBOL_GPL(mite_alloc
);
77 static void dump_chip_signature(u32 csigr_bits
)
79 pr_info("version = %i, type = %i, mite mode = %i, interface mode = %i\n",
80 mite_csigr_version(csigr_bits
), mite_csigr_type(csigr_bits
),
81 mite_csigr_mmode(csigr_bits
), mite_csigr_imode(csigr_bits
));
82 pr_info("num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n",
83 mite_csigr_dmac(csigr_bits
), mite_csigr_wpdep(csigr_bits
),
84 mite_csigr_wins(csigr_bits
), mite_csigr_iowins(csigr_bits
));
87 static unsigned mite_fifo_size(struct mite_struct
*mite
, unsigned channel
)
89 unsigned fcr_bits
= readl(mite
->mite_io_addr
+ MITE_FCR(channel
));
90 unsigned empty_count
= (fcr_bits
>> 16) & 0xff;
91 unsigned full_count
= fcr_bits
& 0xff;
92 return empty_count
+ full_count
;
95 int mite_setup2(struct mite_struct
*mite
, unsigned use_iodwbsr_1
)
100 unsigned unknown_dma_burst_bits
;
102 pci_set_master(mite
->pcidev
);
104 mite
->mite_io_addr
= pci_ioremap_bar(mite
->pcidev
, 0);
105 if (!mite
->mite_io_addr
) {
106 dev_err(&mite
->pcidev
->dev
,
107 "Failed to remap mite io memory address\n");
110 mite
->mite_phys_addr
= pci_resource_start(mite
->pcidev
, 0);
112 mite
->daq_io_addr
= pci_ioremap_bar(mite
->pcidev
, 1);
113 if (!mite
->daq_io_addr
) {
114 dev_err(&mite
->pcidev
->dev
,
115 "Failed to remap daq io memory address\n");
118 mite
->daq_phys_addr
= pci_resource_start(mite
->pcidev
, 1);
119 length
= pci_resource_len(mite
->pcidev
, 1);
122 writel(0, mite
->mite_io_addr
+ MITE_IODWBSR
);
123 dev_info(&mite
->pcidev
->dev
,
124 "using I/O Window Base Size register 1\n");
125 writel(mite
->daq_phys_addr
| WENAB
|
126 MITE_IODWBSR_1_WSIZE_bits(length
),
127 mite
->mite_io_addr
+ MITE_IODWBSR_1
);
128 writel(0, mite
->mite_io_addr
+ MITE_IODWCR_1
);
130 writel(mite
->daq_phys_addr
| WENAB
,
131 mite
->mite_io_addr
+ MITE_IODWBSR
);
134 * make sure dma bursts work. I got this from running a bus analyzer
135 * on a pxi-6281 and a pxi-6713. 6713 powered up with register value
136 * of 0x61f and bursts worked. 6281 powered up with register value of
137 * 0x1f and bursts didn't work. The NI windows driver reads the
138 * register, then does a bitwise-or of 0x600 with it and writes it back.
140 unknown_dma_burst_bits
=
141 readl(mite
->mite_io_addr
+ MITE_UNKNOWN_DMA_BURST_REG
);
142 unknown_dma_burst_bits
|= UNKNOWN_DMA_BURST_ENABLE_BITS
;
143 writel(unknown_dma_burst_bits
,
144 mite
->mite_io_addr
+ MITE_UNKNOWN_DMA_BURST_REG
);
146 csigr_bits
= readl(mite
->mite_io_addr
+ MITE_CSIGR
);
147 mite
->num_channels
= mite_csigr_dmac(csigr_bits
);
148 if (mite
->num_channels
> MAX_MITE_DMA_CHANNELS
) {
149 dev_warn(&mite
->pcidev
->dev
,
150 "mite: bug? chip claims to have %i dma channels. Setting to %i.\n",
151 mite
->num_channels
, MAX_MITE_DMA_CHANNELS
);
152 mite
->num_channels
= MAX_MITE_DMA_CHANNELS
;
154 dump_chip_signature(csigr_bits
);
155 for (i
= 0; i
< mite
->num_channels
; i
++) {
156 writel(CHOR_DMARESET
, mite
->mite_io_addr
+ MITE_CHOR(i
));
157 /* disable interrupts */
158 writel(CHCR_CLR_DMA_IE
| CHCR_CLR_LINKP_IE
| CHCR_CLR_SAR_IE
|
159 CHCR_CLR_DONE_IE
| CHCR_CLR_MRDY_IE
| CHCR_CLR_DRDY_IE
|
160 CHCR_CLR_LC_IE
| CHCR_CLR_CONT_RB_IE
,
161 mite
->mite_io_addr
+ MITE_CHCR(i
));
163 mite
->fifo_size
= mite_fifo_size(mite
, 0);
164 dev_info(&mite
->pcidev
->dev
, "fifo size is %i.\n", mite
->fifo_size
);
167 EXPORT_SYMBOL_GPL(mite_setup2
);
169 int mite_setup(struct mite_struct
*mite
)
171 return mite_setup2(mite
, 0);
173 EXPORT_SYMBOL_GPL(mite_setup
);
175 void mite_unsetup(struct mite_struct
*mite
)
177 /* unsigned long offset, start, length; */
182 if (mite
->mite_io_addr
) {
183 iounmap(mite
->mite_io_addr
);
184 mite
->mite_io_addr
= NULL
;
186 if (mite
->daq_io_addr
) {
187 iounmap(mite
->daq_io_addr
);
188 mite
->daq_io_addr
= NULL
;
190 if (mite
->mite_phys_addr
)
191 mite
->mite_phys_addr
= 0;
193 EXPORT_SYMBOL_GPL(mite_unsetup
);
195 struct mite_dma_descriptor_ring
*mite_alloc_ring(struct mite_struct
*mite
)
197 struct mite_dma_descriptor_ring
*ring
=
198 kmalloc(sizeof(struct mite_dma_descriptor_ring
), GFP_KERNEL
);
202 ring
->hw_dev
= get_device(&mite
->pcidev
->dev
);
203 if (ring
->hw_dev
== NULL
) {
208 ring
->descriptors
= NULL
;
209 ring
->descriptors_dma_addr
= 0;
212 EXPORT_SYMBOL_GPL(mite_alloc_ring
);
214 void mite_free_ring(struct mite_dma_descriptor_ring
*ring
)
217 if (ring
->descriptors
) {
218 dma_free_coherent(ring
->hw_dev
,
220 sizeof(struct mite_dma_descriptor
),
222 ring
->descriptors_dma_addr
);
224 put_device(ring
->hw_dev
);
228 EXPORT_SYMBOL_GPL(mite_free_ring
);
230 struct mite_channel
*mite_request_channel_in_range(struct mite_struct
*mite
,
232 mite_dma_descriptor_ring
233 *ring
, unsigned min_channel
,
234 unsigned max_channel
)
238 struct mite_channel
*channel
= NULL
;
240 /* spin lock so mite_release_channel can be called safely
243 spin_lock_irqsave(&mite
->lock
, flags
);
244 for (i
= min_channel
; i
<= max_channel
; ++i
) {
245 if (mite
->channel_allocated
[i
] == 0) {
246 mite
->channel_allocated
[i
] = 1;
247 channel
= &mite
->channels
[i
];
248 channel
->ring
= ring
;
252 spin_unlock_irqrestore(&mite
->lock
, flags
);
255 EXPORT_SYMBOL_GPL(mite_request_channel_in_range
);
257 void mite_release_channel(struct mite_channel
*mite_chan
)
259 struct mite_struct
*mite
= mite_chan
->mite
;
262 /* spin lock to prevent races with mite_request_channel */
263 spin_lock_irqsave(&mite
->lock
, flags
);
264 if (mite
->channel_allocated
[mite_chan
->channel
]) {
265 mite_dma_disarm(mite_chan
);
266 mite_dma_reset(mite_chan
);
268 * disable all channel's interrupts (do it after disarm/reset so
269 * MITE_CHCR reg isn't changed while dma is still active!)
271 writel(CHCR_CLR_DMA_IE
| CHCR_CLR_LINKP_IE
|
272 CHCR_CLR_SAR_IE
| CHCR_CLR_DONE_IE
|
273 CHCR_CLR_MRDY_IE
| CHCR_CLR_DRDY_IE
|
274 CHCR_CLR_LC_IE
| CHCR_CLR_CONT_RB_IE
,
275 mite
->mite_io_addr
+ MITE_CHCR(mite_chan
->channel
));
276 mite
->channel_allocated
[mite_chan
->channel
] = 0;
277 mite_chan
->ring
= NULL
;
280 spin_unlock_irqrestore(&mite
->lock
, flags
);
282 EXPORT_SYMBOL_GPL(mite_release_channel
);
284 void mite_dma_arm(struct mite_channel
*mite_chan
)
286 struct mite_struct
*mite
= mite_chan
->mite
;
290 MDPRINTK("mite_dma_arm ch%i\n", mite_chan
->channel
);
292 * memory barrier is intended to insure any twiddling with the buffer
293 * is done before writing to the mite to arm dma transfer
298 spin_lock_irqsave(&mite
->lock
, flags
);
300 writel(chor
, mite
->mite_io_addr
+ MITE_CHOR(mite_chan
->channel
));
302 spin_unlock_irqrestore(&mite
->lock
, flags
);
303 /* mite_dma_tcr(mite, channel); */
305 EXPORT_SYMBOL_GPL(mite_dma_arm
);
307 /**************************************/
309 int mite_buf_change(struct mite_dma_descriptor_ring
*ring
,
310 struct comedi_async
*async
)
312 unsigned int n_links
;
315 if (ring
->descriptors
) {
316 dma_free_coherent(ring
->hw_dev
,
318 sizeof(struct mite_dma_descriptor
),
320 ring
->descriptors_dma_addr
);
322 ring
->descriptors
= NULL
;
323 ring
->descriptors_dma_addr
= 0;
326 if (async
->prealloc_bufsz
== 0)
329 n_links
= async
->prealloc_bufsz
>> PAGE_SHIFT
;
331 MDPRINTK("ring->hw_dev=%p, n_links=0x%04x\n", ring
->hw_dev
, n_links
);
334 dma_alloc_coherent(ring
->hw_dev
,
335 n_links
* sizeof(struct mite_dma_descriptor
),
336 &ring
->descriptors_dma_addr
, GFP_KERNEL
);
337 if (!ring
->descriptors
) {
338 dev_err(async
->subdevice
->device
->class_dev
,
339 "mite: ring buffer allocation failed\n");
342 ring
->n_links
= n_links
;
344 for (i
= 0; i
< n_links
; i
++) {
345 ring
->descriptors
[i
].count
= cpu_to_le32(PAGE_SIZE
);
346 ring
->descriptors
[i
].addr
=
347 cpu_to_le32(async
->buf_page_list
[i
].dma_addr
);
348 ring
->descriptors
[i
].next
=
349 cpu_to_le32(ring
->descriptors_dma_addr
+ (i
+
351 sizeof(struct mite_dma_descriptor
));
353 ring
->descriptors
[n_links
- 1].next
=
354 cpu_to_le32(ring
->descriptors_dma_addr
);
356 * barrier is meant to insure that all the writes to the dma descriptors
357 * have completed before the dma controller is commanded to read them
362 EXPORT_SYMBOL_GPL(mite_buf_change
);
364 void mite_prep_dma(struct mite_channel
*mite_chan
,
365 unsigned int num_device_bits
, unsigned int num_memory_bits
)
367 unsigned int chor
, chcr
, mcr
, dcr
, lkcr
;
368 struct mite_struct
*mite
= mite_chan
->mite
;
370 MDPRINTK("mite_prep_dma ch%i\n", mite_chan
->channel
);
372 /* reset DMA and FIFO */
373 chor
= CHOR_DMARESET
| CHOR_FRESET
;
374 writel(chor
, mite
->mite_io_addr
+ MITE_CHOR(mite_chan
->channel
));
376 /* short link chaining mode */
377 chcr
= CHCR_SET_DMA_IE
| CHCR_LINKSHORT
| CHCR_SET_DONE_IE
|
380 * Link Complete Interrupt: interrupt every time a link
381 * in MITE_RING is completed. This can generate a lot of
382 * extra interrupts, but right now we update the values
383 * of buf_int_ptr and buf_int_count at each interrupt. A
384 * better method is to poll the MITE before each user
385 * "read()" to calculate the number of bytes available.
387 chcr
|= CHCR_SET_LC_IE
;
388 if (num_memory_bits
== 32 && num_device_bits
== 16) {
390 * Doing a combined 32 and 16 bit byteswap gets the 16 bit
391 * samples into the fifo in the right order. Tested doing 32 bit
392 * memory to 16 bit device transfers to the analog out of a
393 * pxi-6281, which has mite version = 1, type = 4. This also
394 * works for dma reads from the counters on e-series boards.
396 chcr
|= CHCR_BYTE_SWAP_DEVICE
| CHCR_BYTE_SWAP_MEMORY
;
398 if (mite_chan
->dir
== COMEDI_INPUT
)
399 chcr
|= CHCR_DEV_TO_MEM
;
401 writel(chcr
, mite
->mite_io_addr
+ MITE_CHCR(mite_chan
->channel
));
404 mcr
= CR_RL(64) | CR_ASEQUP
;
405 switch (num_memory_bits
) {
416 pr_warn("bug! invalid mem bit width for dma transfer\n");
419 writel(mcr
, mite
->mite_io_addr
+ MITE_MCR(mite_chan
->channel
));
422 dcr
= CR_RL(64) | CR_ASEQUP
;
423 dcr
|= CR_PORTIO
| CR_AMDEVICE
| CR_REQSDRQ(mite_chan
->channel
);
424 switch (num_device_bits
) {
435 pr_warn("bug! invalid dev bit width for dma transfer\n");
438 writel(dcr
, mite
->mite_io_addr
+ MITE_DCR(mite_chan
->channel
));
441 writel(0, mite
->mite_io_addr
+ MITE_DAR(mite_chan
->channel
));
443 /* the link is 32bits */
444 lkcr
= CR_RL(64) | CR_ASEQUP
| CR_PSIZE32
;
445 writel(lkcr
, mite
->mite_io_addr
+ MITE_LKCR(mite_chan
->channel
));
447 /* starting address for link chaining */
448 writel(mite_chan
->ring
->descriptors_dma_addr
,
449 mite
->mite_io_addr
+ MITE_LKAR(mite_chan
->channel
));
451 MDPRINTK("exit mite_prep_dma\n");
453 EXPORT_SYMBOL_GPL(mite_prep_dma
);
455 static u32
mite_device_bytes_transferred(struct mite_channel
*mite_chan
)
457 struct mite_struct
*mite
= mite_chan
->mite
;
458 return readl(mite
->mite_io_addr
+ MITE_DAR(mite_chan
->channel
));
461 u32
mite_bytes_in_transit(struct mite_channel
*mite_chan
)
463 struct mite_struct
*mite
= mite_chan
->mite
;
464 return readl(mite
->mite_io_addr
+
465 MITE_FCR(mite_chan
->channel
)) & 0x000000FF;
467 EXPORT_SYMBOL_GPL(mite_bytes_in_transit
);
469 /* returns lower bound for number of bytes transferred from device to memory */
470 u32
mite_bytes_written_to_memory_lb(struct mite_channel
*mite_chan
)
472 u32 device_byte_count
;
474 device_byte_count
= mite_device_bytes_transferred(mite_chan
);
475 return device_byte_count
- mite_bytes_in_transit(mite_chan
);
477 EXPORT_SYMBOL_GPL(mite_bytes_written_to_memory_lb
);
479 /* returns upper bound for number of bytes transferred from device to memory */
480 u32
mite_bytes_written_to_memory_ub(struct mite_channel
*mite_chan
)
482 u32 in_transit_count
;
484 in_transit_count
= mite_bytes_in_transit(mite_chan
);
485 return mite_device_bytes_transferred(mite_chan
) - in_transit_count
;
487 EXPORT_SYMBOL_GPL(mite_bytes_written_to_memory_ub
);
489 /* returns lower bound for number of bytes read from memory to device */
490 u32
mite_bytes_read_from_memory_lb(struct mite_channel
*mite_chan
)
492 u32 device_byte_count
;
494 device_byte_count
= mite_device_bytes_transferred(mite_chan
);
495 return device_byte_count
+ mite_bytes_in_transit(mite_chan
);
497 EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_lb
);
499 /* returns upper bound for number of bytes read from memory to device */
500 u32
mite_bytes_read_from_memory_ub(struct mite_channel
*mite_chan
)
502 u32 in_transit_count
;
504 in_transit_count
= mite_bytes_in_transit(mite_chan
);
505 return mite_device_bytes_transferred(mite_chan
) + in_transit_count
;
507 EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_ub
);
509 unsigned mite_dma_tcr(struct mite_channel
*mite_chan
)
511 struct mite_struct
*mite
= mite_chan
->mite
;
515 lkar
= readl(mite
->mite_io_addr
+ MITE_LKAR(mite_chan
->channel
));
516 tcr
= readl(mite
->mite_io_addr
+ MITE_TCR(mite_chan
->channel
));
517 MDPRINTK("mite_dma_tcr ch%i, lkar=0x%08x tcr=%d\n", mite_chan
->channel
,
522 EXPORT_SYMBOL_GPL(mite_dma_tcr
);
524 void mite_dma_disarm(struct mite_channel
*mite_chan
)
526 struct mite_struct
*mite
= mite_chan
->mite
;
531 writel(chor
, mite
->mite_io_addr
+ MITE_CHOR(mite_chan
->channel
));
533 EXPORT_SYMBOL_GPL(mite_dma_disarm
);
535 int mite_sync_input_dma(struct mite_channel
*mite_chan
,
536 struct comedi_async
*async
)
539 unsigned int nbytes
, old_alloc_count
;
540 const unsigned bytes_per_scan
= cfc_bytes_per_scan(async
->subdevice
);
542 old_alloc_count
= async
->buf_write_alloc_count
;
543 /* write alloc as much as we can */
544 comedi_buf_write_alloc(async
, async
->prealloc_bufsz
);
546 nbytes
= mite_bytes_written_to_memory_lb(mite_chan
);
547 if ((int)(mite_bytes_written_to_memory_ub(mite_chan
) -
548 old_alloc_count
) > 0) {
549 dev_warn(async
->subdevice
->device
->class_dev
,
550 "mite: DMA overwrite of free area\n");
551 async
->events
|= COMEDI_CB_OVERFLOW
;
555 count
= nbytes
- async
->buf_write_count
;
556 /* it's possible count will be negative due to
557 * conservative value returned by mite_bytes_written_to_memory_lb */
561 comedi_buf_write_free(async
, count
);
563 async
->scan_progress
+= count
;
564 if (async
->scan_progress
>= bytes_per_scan
) {
565 async
->scan_progress
%= bytes_per_scan
;
566 async
->events
|= COMEDI_CB_EOS
;
568 async
->events
|= COMEDI_CB_BLOCK
;
571 EXPORT_SYMBOL_GPL(mite_sync_input_dma
);
573 int mite_sync_output_dma(struct mite_channel
*mite_chan
,
574 struct comedi_async
*async
)
577 u32 nbytes_ub
, nbytes_lb
;
578 unsigned int old_alloc_count
;
580 async
->cmd
.stop_arg
* cfc_bytes_per_scan(async
->subdevice
);
582 old_alloc_count
= async
->buf_read_alloc_count
;
583 /* read alloc as much as we can */
584 comedi_buf_read_alloc(async
, async
->prealloc_bufsz
);
585 nbytes_lb
= mite_bytes_read_from_memory_lb(mite_chan
);
586 if (async
->cmd
.stop_src
== TRIG_COUNT
&&
587 (int)(nbytes_lb
- stop_count
) > 0)
588 nbytes_lb
= stop_count
;
589 nbytes_ub
= mite_bytes_read_from_memory_ub(mite_chan
);
590 if (async
->cmd
.stop_src
== TRIG_COUNT
&&
591 (int)(nbytes_ub
- stop_count
) > 0)
592 nbytes_ub
= stop_count
;
593 if ((int)(nbytes_ub
- old_alloc_count
) > 0) {
594 dev_warn(async
->subdevice
->device
->class_dev
,
595 "mite: DMA underrun\n");
596 async
->events
|= COMEDI_CB_OVERFLOW
;
599 count
= nbytes_lb
- async
->buf_read_count
;
604 comedi_buf_read_free(async
, count
);
605 async
->events
|= COMEDI_CB_BLOCK
;
609 EXPORT_SYMBOL_GPL(mite_sync_output_dma
);
611 unsigned mite_get_status(struct mite_channel
*mite_chan
)
613 struct mite_struct
*mite
= mite_chan
->mite
;
617 spin_lock_irqsave(&mite
->lock
, flags
);
618 status
= readl(mite
->mite_io_addr
+ MITE_CHSR(mite_chan
->channel
));
619 if (status
& CHSR_DONE
) {
622 mite
->mite_io_addr
+ MITE_CHOR(mite_chan
->channel
));
625 spin_unlock_irqrestore(&mite
->lock
, flags
);
628 EXPORT_SYMBOL_GPL(mite_get_status
);
630 int mite_done(struct mite_channel
*mite_chan
)
632 struct mite_struct
*mite
= mite_chan
->mite
;
636 mite_get_status(mite_chan
);
637 spin_lock_irqsave(&mite
->lock
, flags
);
638 done
= mite_chan
->done
;
639 spin_unlock_irqrestore(&mite
->lock
, flags
);
642 EXPORT_SYMBOL_GPL(mite_done
);
646 /* names of bits in mite registers */
648 static const char *const mite_CHOR_strings
[] = {
649 "start", "cont", "stop", "abort",
650 "freset", "clrlc", "clrrb", "clrdone",
651 "clr_lpause", "set_lpause", "clr_send_tc",
652 "set_send_tc", "12", "13", "14",
653 "15", "16", "17", "18",
654 "19", "20", "21", "22",
655 "23", "24", "25", "26",
656 "27", "28", "29", "30",
660 static const char *const mite_CHCR_strings
[] = {
661 "continue", "ringbuff", "2", "3",
663 "8", "9", "10", "11",
664 "12", "13", "bursten", "fifodis",
665 "clr_cont_rb_ie", "set_cont_rb_ie", "clr_lc_ie", "set_lc_ie",
666 "clr_drdy_ie", "set_drdy_ie", "clr_mrdy_ie", "set_mrdy_ie",
667 "clr_done_ie", "set_done_ie", "clr_sar_ie", "set_sar_ie",
668 "clr_linkp_ie", "set_linkp_ie", "clr_dma_ie", "set_dma_ie",
671 static const char *const mite_MCR_strings
[] = {
672 "amdevice", "1", "2", "3",
673 "4", "5", "portio", "portvxi",
674 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "11",
675 "12", "13", "blocken", "berhand",
676 "reqsintlim/reqs0", "reqs1", "reqs2", "rd32",
677 "rd512", "rl1", "rl2", "rl8",
678 "24", "25", "26", "27",
679 "28", "29", "30", "stopen",
682 static const char *const mite_DCR_strings
[] = {
683 "amdevice", "1", "2", "3",
684 "4", "5", "portio", "portvxi",
685 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "aseqxp2",
686 "aseqxp8", "13", "blocken", "berhand",
687 "reqsintlim", "reqs1", "reqs2", "rd32",
688 "rd512", "rl1", "rl2", "rl8",
689 "23", "24", "25", "27",
690 "28", "wsdevc", "wsdevs", "rwdevpack",
693 static const char *const mite_LKCR_strings
[] = {
694 "amdevice", "1", "2", "3",
695 "4", "5", "portio", "portvxi",
696 "psizebyte", "psizehalf (byte & half = word)", "asequp", "aseqdown",
697 "12", "13", "14", "berhand",
698 "16", "17", "18", "rd32",
699 "rd512", "rl1", "rl2", "rl8",
700 "24", "25", "26", "27",
701 "28", "29", "30", "chngend",
704 static const char *const mite_CHSR_strings
[] = {
705 "d.err0", "d.err1", "m.err0", "m.err1",
706 "l.err0", "l.err1", "drq0", "drq1",
707 "end", "xferr", "operr0", "operr1",
708 "stops", "habort", "sabort", "error",
709 "16", "conts_rb", "18", "linkc",
710 "20", "drdy", "22", "mrdy",
711 "24", "done", "26", "sars",
712 "28", "lpauses", "30", "int",
715 static void mite_decode(const char *const *bit_str
, unsigned int bits
)
719 for (i
= 31; i
>= 0; i
--) {
721 pr_debug(" %s\n", bit_str
[i
]);
725 void mite_dump_regs(struct mite_channel
*mite_chan
)
727 void __iomem
*mite_io_addr
= mite_chan
->mite
->mite_io_addr
;
730 int channel
= mite_chan
->channel
;
732 pr_debug("mite_dump_regs ch%i\n", channel
);
733 pr_debug("mite address is =%p\n", mite_io_addr
);
735 offset
= MITE_CHOR(channel
);
736 value
= readl(mite_io_addr
+ offset
);
737 pr_debug("mite status[CHOR] at 0x%08x =0x%08x\n", offset
, value
);
738 mite_decode(mite_CHOR_strings
, value
);
739 offset
= MITE_CHCR(channel
);
740 value
= readl(mite_io_addr
+ offset
);
741 pr_debug("mite status[CHCR] at 0x%08x =0x%08x\n", offset
, value
);
742 mite_decode(mite_CHCR_strings
, value
);
743 offset
= MITE_TCR(channel
);
744 value
= readl(mite_io_addr
+ offset
);
745 pr_debug("mite status[TCR] at 0x%08x =0x%08x\n", offset
, value
);
746 offset
= MITE_MCR(channel
);
747 value
= readl(mite_io_addr
+ offset
);
748 pr_debug("mite status[MCR] at 0x%08x =0x%08x\n", offset
, value
);
749 mite_decode(mite_MCR_strings
, value
);
750 offset
= MITE_MAR(channel
);
751 value
= readl(mite_io_addr
+ offset
);
752 pr_debug("mite status[MAR] at 0x%08x =0x%08x\n", offset
, value
);
753 offset
= MITE_DCR(channel
);
754 value
= readl(mite_io_addr
+ offset
);
755 pr_debug("mite status[DCR] at 0x%08x =0x%08x\n", offset
, value
);
756 mite_decode(mite_DCR_strings
, value
);
757 offset
= MITE_DAR(channel
);
758 value
= readl(mite_io_addr
+ offset
);
759 pr_debug("mite status[DAR] at 0x%08x =0x%08x\n", offset
, value
);
760 offset
= MITE_LKCR(channel
);
761 value
= readl(mite_io_addr
+ offset
);
762 pr_debug("mite status[LKCR] at 0x%08x =0x%08x\n", offset
, value
);
763 mite_decode(mite_LKCR_strings
, value
);
764 offset
= MITE_LKAR(channel
);
765 value
= readl(mite_io_addr
+ offset
);
766 pr_debug("mite status[LKAR] at 0x%08x =0x%08x\n", offset
, value
);
767 offset
= MITE_CHSR(channel
);
768 value
= readl(mite_io_addr
+ offset
);
769 pr_debug("mite status[CHSR] at 0x%08x =0x%08x\n", offset
, value
);
770 mite_decode(mite_CHSR_strings
, value
);
771 offset
= MITE_FCR(channel
);
772 value
= readl(mite_io_addr
+ offset
);
773 pr_debug("mite status[FCR] at 0x%08x =0x%08x\n", offset
, value
);
775 EXPORT_SYMBOL_GPL(mite_dump_regs
);
778 static int __init
mite_module_init(void)
783 static void __exit
mite_module_exit(void)
787 module_init(mite_module_init
);
788 module_exit(mite_module_exit
);
790 MODULE_AUTHOR("Comedi http://www.comedi.org");
791 MODULE_DESCRIPTION("Comedi low-level driver");
792 MODULE_LICENSE("GPL");