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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 The PCI-MIO E series driver was originally written by
26 Tomasz Motylewski <...>, and ported to comedi by ds.
28 References for specifications:
30 321747b.pdf Register Level Programmer Manual (obsolete)
31 321747c.pdf Register Level Programmer Manual (new)
32 DAQ-STC reference manual
34 Other possibly relevant info:
36 320517c.pdf User manual (obsolete)
37 320517f.pdf User manual (new)
39 320906c.pdf maximum signal ratings
41 321791a.pdf discontinuation of at-mio-16e-10 rev. c
42 321808a.pdf about at-mio-16e-10 rev P
43 321837a.pdf discontinuation of at-mio-16de-10 rev d
44 321838a.pdf about at-mio-16de-10 rev N
50 /* #define USE_KMALLOC */
54 #include "comedi_fc.h"
55 #include "../comedidev.h"
58 #define PCI_MITE_SIZE 4096
59 #define PCI_DAQ_SIZE 4096
60 #define PCI_DAQ_SIZE_660X 8192
62 struct mite_struct *mite_devices;
63 EXPORT_SYMBOL(mite_devices);
65 #define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK)))
67 static void mite_init(void)
69 struct pci_dev *pcidev = NULL;
70 struct mite_struct *mite;
72 for_each_pci_dev(pcidev) {
73 if (pcidev->vendor == PCI_VENDOR_ID_NI) {
76 mite = kzalloc(sizeof(*mite), GFP_KERNEL);
78 printk(KERN_ERR "mite: allocation failed\n");
82 spin_lock_init(&mite->lock);
83 mite->pcidev = pci_dev_get(pcidev);
84 for (i = 0; i < MAX_MITE_DMA_CHANNELS; ++i) {
85 mite->channels[i].mite = mite;
86 mite->channels[i].channel = i;
87 mite->channels[i].done = 1;
89 mite->next = mite_devices;
95 static void dump_chip_signature(u32 csigr_bits)
97 printk(KERN_INFO "mite: version = %i, type = %i, mite mode = %i,"
98 "interface mode = %i\n",
99 mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits),
100 mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits));
101 printk(KERN_INFO "mite: num channels = %i, write post fifo depth = %i,"
102 "wins = %i, iowins = %i\n",
103 mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits),
104 mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits));
107 unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel)
109 unsigned fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel));
110 unsigned empty_count = (fcr_bits >> 16) & 0xff;
111 unsigned full_count = fcr_bits & 0xff;
112 return empty_count + full_count;
115 int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
117 unsigned long length;
118 resource_size_t addr;
121 unsigned unknown_dma_burst_bits;
123 if (comedi_pci_enable(mite->pcidev, "mite")) {
124 printk(KERN_ERR "error enabling mite and requesting io regions\n");
127 pci_set_master(mite->pcidev);
129 addr = pci_resource_start(mite->pcidev, 0);
130 mite->mite_phys_addr = addr;
131 mite->mite_io_addr = ioremap(addr, PCI_MITE_SIZE);
132 if (!mite->mite_io_addr) {
133 printk(KERN_ERR "Failed to remap mite io memory address\n");
136 printk(KERN_INFO "MITE:0x%08llx mapped to %p ",
137 (unsigned long long)mite->mite_phys_addr, mite->mite_io_addr);
139 addr = pci_resource_start(mite->pcidev, 1);
140 mite->daq_phys_addr = addr;
141 length = pci_resource_len(mite->pcidev, 1);
143 * In case of a 660x board, DAQ size is 8k instead of 4k
144 * (see as shown by lspci output)
146 mite->daq_io_addr = ioremap(mite->daq_phys_addr, length);
147 if (!mite->daq_io_addr) {
148 printk(KERN_ERR "Failed to remap daq io memory address\n");
151 printk(KERN_INFO "DAQ:0x%08llx mapped to %p\n",
152 (unsigned long long)mite->daq_phys_addr, mite->daq_io_addr);
155 writel(0, mite->mite_io_addr + MITE_IODWBSR);
156 printk(KERN_INFO "mite: using I/O Window Base Size register 1\n");
157 writel(mite->daq_phys_addr | WENAB |
158 MITE_IODWBSR_1_WSIZE_bits(length),
159 mite->mite_io_addr + MITE_IODWBSR_1);
160 writel(0, mite->mite_io_addr + MITE_IODWCR_1);
162 writel(mite->daq_phys_addr | WENAB,
163 mite->mite_io_addr + MITE_IODWBSR);
166 * make sure dma bursts work. I got this from running a bus analyzer
167 * on a pxi-6281 and a pxi-6713. 6713 powered up with register value
168 * of 0x61f and bursts worked. 6281 powered up with register value of
169 * 0x1f and bursts didn't work. The NI windows driver reads the
170 * register, then does a bitwise-or of 0x600 with it and writes it back.
172 unknown_dma_burst_bits =
173 readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
174 unknown_dma_burst_bits |= UNKNOWN_DMA_BURST_ENABLE_BITS;
175 writel(unknown_dma_burst_bits,
176 mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
178 csigr_bits = readl(mite->mite_io_addr + MITE_CSIGR);
179 mite->num_channels = mite_csigr_dmac(csigr_bits);
180 if (mite->num_channels > MAX_MITE_DMA_CHANNELS) {
181 printk(KERN_WARNING "mite: bug? chip claims to have %i dma "
182 "channels. Setting to %i.\n",
183 mite->num_channels, MAX_MITE_DMA_CHANNELS);
184 mite->num_channels = MAX_MITE_DMA_CHANNELS;
186 dump_chip_signature(csigr_bits);
187 for (i = 0; i < mite->num_channels; i++) {
188 writel(CHOR_DMARESET, mite->mite_io_addr + MITE_CHOR(i));
189 /* disable interrupts */
190 writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
191 CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
192 CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
193 mite->mite_io_addr + MITE_CHCR(i));
195 mite->fifo_size = mite_fifo_size(mite, 0);
196 printk(KERN_INFO "mite: fifo size is %i.\n", mite->fifo_size);
201 EXPORT_SYMBOL(mite_setup2);
203 int mite_setup(struct mite_struct *mite)
205 return mite_setup2(mite, 0);
207 EXPORT_SYMBOL(mite_setup);
209 static void mite_cleanup(void)
211 struct mite_struct *mite, *next;
213 for (mite = mite_devices; mite; mite = next) {
214 pci_dev_put(mite->pcidev);
220 void mite_unsetup(struct mite_struct *mite)
222 /* unsigned long offset, start, length; */
227 if (mite->mite_io_addr) {
228 iounmap(mite->mite_io_addr);
229 mite->mite_io_addr = NULL;
231 if (mite->daq_io_addr) {
232 iounmap(mite->daq_io_addr);
233 mite->daq_io_addr = NULL;
235 if (mite->mite_phys_addr) {
236 comedi_pci_disable(mite->pcidev);
237 mite->mite_phys_addr = 0;
242 EXPORT_SYMBOL(mite_unsetup);
244 void mite_list_devices(void)
246 struct mite_struct *mite, *next;
248 printk(KERN_INFO "Available NI device IDs:");
250 for (mite = mite_devices; mite; mite = next) {
252 printk(KERN_INFO " 0x%04x", mite_device_id(mite));
254 printk(KERN_INFO "(used)");
256 printk(KERN_INFO "\n");
258 EXPORT_SYMBOL(mite_list_devices);
260 struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite)
262 struct mite_dma_descriptor_ring *ring =
263 kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL);
267 ring->hw_dev = get_device(&mite->pcidev->dev);
268 if (ring->hw_dev == NULL) {
273 ring->descriptors = NULL;
274 ring->descriptors_dma_addr = 0;
277 EXPORT_SYMBOL(mite_alloc_ring);
279 void mite_free_ring(struct mite_dma_descriptor_ring *ring)
282 if (ring->descriptors) {
283 dma_free_coherent(ring->hw_dev,
285 sizeof(struct mite_dma_descriptor),
287 ring->descriptors_dma_addr);
289 put_device(ring->hw_dev);
293 EXPORT_SYMBOL(mite_free_ring);
295 struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
297 mite_dma_descriptor_ring
298 *ring, unsigned min_channel,
299 unsigned max_channel)
303 struct mite_channel *channel = NULL;
305 /* spin lock so mite_release_channel can be called safely
308 spin_lock_irqsave(&mite->lock, flags);
309 for (i = min_channel; i <= max_channel; ++i) {
310 if (mite->channel_allocated[i] == 0) {
311 mite->channel_allocated[i] = 1;
312 channel = &mite->channels[i];
313 channel->ring = ring;
317 spin_unlock_irqrestore(&mite->lock, flags);
320 EXPORT_SYMBOL(mite_request_channel_in_range);
322 void mite_release_channel(struct mite_channel *mite_chan)
324 struct mite_struct *mite = mite_chan->mite;
327 /* spin lock to prevent races with mite_request_channel */
328 spin_lock_irqsave(&mite->lock, flags);
329 if (mite->channel_allocated[mite_chan->channel]) {
330 mite_dma_disarm(mite_chan);
331 mite_dma_reset(mite_chan);
333 * disable all channel's interrupts (do it after disarm/reset so
334 * MITE_CHCR reg isn't changed while dma is still active!)
336 writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
337 CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
338 CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
339 CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
340 mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
341 mite->channel_allocated[mite_chan->channel] = 0;
342 mite_chan->ring = NULL;
345 spin_unlock_irqrestore(&mite->lock, flags);
347 EXPORT_SYMBOL(mite_release_channel);
349 void mite_dma_arm(struct mite_channel *mite_chan)
351 struct mite_struct *mite = mite_chan->mite;
355 MDPRINTK("mite_dma_arm ch%i\n", channel);
357 * memory barrier is intended to insure any twiddling with the buffer
358 * is done before writing to the mite to arm dma transfer
363 spin_lock_irqsave(&mite->lock, flags);
365 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
367 spin_unlock_irqrestore(&mite->lock, flags);
368 /* mite_dma_tcr(mite, channel); */
370 EXPORT_SYMBOL(mite_dma_arm);
372 /**************************************/
374 int mite_buf_change(struct mite_dma_descriptor_ring *ring,
375 struct comedi_async *async)
377 unsigned int n_links;
380 if (ring->descriptors) {
381 dma_free_coherent(ring->hw_dev,
383 sizeof(struct mite_dma_descriptor),
385 ring->descriptors_dma_addr);
387 ring->descriptors = NULL;
388 ring->descriptors_dma_addr = 0;
391 if (async->prealloc_bufsz == 0)
394 n_links = async->prealloc_bufsz >> PAGE_SHIFT;
396 MDPRINTK("ring->hw_dev=%p, n_links=0x%04x\n", ring->hw_dev, n_links);
399 dma_alloc_coherent(ring->hw_dev,
400 n_links * sizeof(struct mite_dma_descriptor),
401 &ring->descriptors_dma_addr, GFP_KERNEL);
402 if (!ring->descriptors) {
403 printk(KERN_ERR "mite: ring buffer allocation failed\n");
406 ring->n_links = n_links;
408 for (i = 0; i < n_links; i++) {
409 ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE);
410 ring->descriptors[i].addr =
411 cpu_to_le32(async->buf_page_list[i].dma_addr);
412 ring->descriptors[i].next =
413 cpu_to_le32(ring->descriptors_dma_addr + (i +
415 sizeof(struct mite_dma_descriptor));
417 ring->descriptors[n_links - 1].next =
418 cpu_to_le32(ring->descriptors_dma_addr);
420 * barrier is meant to insure that all the writes to the dma descriptors
421 * have completed before the dma controller is commanded to read them
426 EXPORT_SYMBOL(mite_buf_change);
428 void mite_prep_dma(struct mite_channel *mite_chan,
429 unsigned int num_device_bits, unsigned int num_memory_bits)
431 unsigned int chor, chcr, mcr, dcr, lkcr;
432 struct mite_struct *mite = mite_chan->mite;
434 MDPRINTK("mite_prep_dma ch%i\n", mite_chan->channel);
436 /* reset DMA and FIFO */
437 chor = CHOR_DMARESET | CHOR_FRESET;
438 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
440 /* short link chaining mode */
441 chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE |
444 * Link Complete Interrupt: interrupt every time a link
445 * in MITE_RING is completed. This can generate a lot of
446 * extra interrupts, but right now we update the values
447 * of buf_int_ptr and buf_int_count at each interrupt. A
448 * better method is to poll the MITE before each user
449 * "read()" to calculate the number of bytes available.
451 chcr |= CHCR_SET_LC_IE;
452 if (num_memory_bits == 32 && num_device_bits == 16) {
454 * Doing a combined 32 and 16 bit byteswap gets the 16 bit
455 * samples into the fifo in the right order. Tested doing 32 bit
456 * memory to 16 bit device transfers to the analog out of a
457 * pxi-6281, which has mite version = 1, type = 4. This also
458 * works for dma reads from the counters on e-series boards.
460 chcr |= CHCR_BYTE_SWAP_DEVICE | CHCR_BYTE_SWAP_MEMORY;
462 if (mite_chan->dir == COMEDI_INPUT)
463 chcr |= CHCR_DEV_TO_MEM;
465 writel(chcr, mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
468 mcr = CR_RL(64) | CR_ASEQUP;
469 switch (num_memory_bits) {
480 printk(KERN_WARNING "mite: bug! invalid mem bit width for dma "
484 writel(mcr, mite->mite_io_addr + MITE_MCR(mite_chan->channel));
487 dcr = CR_RL(64) | CR_ASEQUP;
488 dcr |= CR_PORTIO | CR_AMDEVICE | CR_REQSDRQ(mite_chan->channel);
489 switch (num_device_bits) {
500 printk(KERN_WARNING "mite: bug! invalid dev bit width for dma "
504 writel(dcr, mite->mite_io_addr + MITE_DCR(mite_chan->channel));
507 writel(0, mite->mite_io_addr + MITE_DAR(mite_chan->channel));
509 /* the link is 32bits */
510 lkcr = CR_RL(64) | CR_ASEQUP | CR_PSIZE32;
511 writel(lkcr, mite->mite_io_addr + MITE_LKCR(mite_chan->channel));
513 /* starting address for link chaining */
514 writel(mite_chan->ring->descriptors_dma_addr,
515 mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
517 MDPRINTK("exit mite_prep_dma\n");
519 EXPORT_SYMBOL(mite_prep_dma);
521 static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan)
523 struct mite_struct *mite = mite_chan->mite;
524 return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel));
527 u32 mite_bytes_in_transit(struct mite_channel *mite_chan)
529 struct mite_struct *mite = mite_chan->mite;
530 return readl(mite->mite_io_addr +
531 MITE_FCR(mite_chan->channel)) & 0x000000FF;
533 EXPORT_SYMBOL(mite_bytes_in_transit);
535 /* returns lower bound for number of bytes transferred from device to memory */
536 u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
538 u32 device_byte_count;
540 device_byte_count = mite_device_bytes_transferred(mite_chan);
541 return device_byte_count - mite_bytes_in_transit(mite_chan);
543 EXPORT_SYMBOL(mite_bytes_written_to_memory_lb);
545 /* returns upper bound for number of bytes transferred from device to memory */
546 u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
548 u32 in_transit_count;
550 in_transit_count = mite_bytes_in_transit(mite_chan);
551 return mite_device_bytes_transferred(mite_chan) - in_transit_count;
553 EXPORT_SYMBOL(mite_bytes_written_to_memory_ub);
555 /* returns lower bound for number of bytes read from memory to device */
556 u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
558 u32 device_byte_count;
560 device_byte_count = mite_device_bytes_transferred(mite_chan);
561 return device_byte_count + mite_bytes_in_transit(mite_chan);
563 EXPORT_SYMBOL(mite_bytes_read_from_memory_lb);
565 /* returns upper bound for number of bytes read from memory to device */
566 u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan)
568 u32 in_transit_count;
570 in_transit_count = mite_bytes_in_transit(mite_chan);
571 return mite_device_bytes_transferred(mite_chan) + in_transit_count;
573 EXPORT_SYMBOL(mite_bytes_read_from_memory_ub);
575 unsigned mite_dma_tcr(struct mite_channel *mite_chan)
577 struct mite_struct *mite = mite_chan->mite;
581 lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
582 tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
583 MDPRINTK("mite_dma_tcr ch%i, lkar=0x%08x tcr=%d\n", mite_chan->channel,
588 EXPORT_SYMBOL(mite_dma_tcr);
590 void mite_dma_disarm(struct mite_channel *mite_chan)
592 struct mite_struct *mite = mite_chan->mite;
597 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
599 EXPORT_SYMBOL(mite_dma_disarm);
601 int mite_sync_input_dma(struct mite_channel *mite_chan,
602 struct comedi_async *async)
605 unsigned int nbytes, old_alloc_count;
606 const unsigned bytes_per_scan = cfc_bytes_per_scan(async->subdevice);
608 old_alloc_count = async->buf_write_alloc_count;
609 /* write alloc as much as we can */
610 comedi_buf_write_alloc(async, async->prealloc_bufsz);
612 nbytes = mite_bytes_written_to_memory_lb(mite_chan);
613 if ((int)(mite_bytes_written_to_memory_ub(mite_chan) -
614 old_alloc_count) > 0) {
615 printk("mite: DMA overwrite of free area\n");
616 async->events |= COMEDI_CB_OVERFLOW;
620 count = nbytes - async->buf_write_count;
621 /* it's possible count will be negative due to
622 * conservative value returned by mite_bytes_written_to_memory_lb */
626 comedi_buf_write_free(async, count);
628 async->scan_progress += count;
629 if (async->scan_progress >= bytes_per_scan) {
630 async->scan_progress %= bytes_per_scan;
631 async->events |= COMEDI_CB_EOS;
633 async->events |= COMEDI_CB_BLOCK;
636 EXPORT_SYMBOL(mite_sync_input_dma);
638 int mite_sync_output_dma(struct mite_channel *mite_chan,
639 struct comedi_async *async)
642 u32 nbytes_ub, nbytes_lb;
643 unsigned int old_alloc_count;
645 async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
647 old_alloc_count = async->buf_read_alloc_count;
648 /* read alloc as much as we can */
649 comedi_buf_read_alloc(async, async->prealloc_bufsz);
650 nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
651 if (async->cmd.stop_src == TRIG_COUNT &&
652 (int)(nbytes_lb - stop_count) > 0)
653 nbytes_lb = stop_count;
654 nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan);
655 if (async->cmd.stop_src == TRIG_COUNT &&
656 (int)(nbytes_ub - stop_count) > 0)
657 nbytes_ub = stop_count;
658 if ((int)(nbytes_ub - old_alloc_count) > 0) {
659 printk(KERN_ERR "mite: DMA underrun\n");
660 async->events |= COMEDI_CB_OVERFLOW;
663 count = nbytes_lb - async->buf_read_count;
668 comedi_buf_read_free(async, count);
669 async->events |= COMEDI_CB_BLOCK;
673 EXPORT_SYMBOL(mite_sync_output_dma);
675 unsigned mite_get_status(struct mite_channel *mite_chan)
677 struct mite_struct *mite = mite_chan->mite;
681 spin_lock_irqsave(&mite->lock, flags);
682 status = readl(mite->mite_io_addr + MITE_CHSR(mite_chan->channel));
683 if (status & CHSR_DONE) {
686 mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
689 spin_unlock_irqrestore(&mite->lock, flags);
692 EXPORT_SYMBOL(mite_get_status);
694 int mite_done(struct mite_channel *mite_chan)
696 struct mite_struct *mite = mite_chan->mite;
700 mite_get_status(mite_chan);
701 spin_lock_irqsave(&mite->lock, flags);
702 done = mite_chan->done;
703 spin_unlock_irqrestore(&mite->lock, flags);
706 EXPORT_SYMBOL(mite_done);
710 static void mite_decode(char **bit_str, unsigned int bits);
712 /* names of bits in mite registers */
714 static const char *const mite_CHOR_strings[] = {
715 "start", "cont", "stop", "abort",
716 "freset", "clrlc", "clrrb", "clrdone",
717 "clr_lpause", "set_lpause", "clr_send_tc",
718 "set_send_tc", "12", "13", "14",
719 "15", "16", "17", "18",
720 "19", "20", "21", "22",
721 "23", "24", "25", "26",
722 "27", "28", "29", "30",
726 static const char *const mite_CHCR_strings[] = {
727 "continue", "ringbuff", "2", "3",
729 "8", "9", "10", "11",
730 "12", "13", "bursten", "fifodis",
731 "clr_cont_rb_ie", "set_cont_rb_ie", "clr_lc_ie", "set_lc_ie",
732 "clr_drdy_ie", "set_drdy_ie", "clr_mrdy_ie", "set_mrdy_ie",
733 "clr_done_ie", "set_done_ie", "clr_sar_ie", "set_sar_ie",
734 "clr_linkp_ie", "set_linkp_ie", "clr_dma_ie", "set_dma_ie",
737 static const char *const mite_MCR_strings[] = {
738 "amdevice", "1", "2", "3",
739 "4", "5", "portio", "portvxi",
740 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "11",
741 "12", "13", "blocken", "berhand",
742 "reqsintlim/reqs0", "reqs1", "reqs2", "rd32",
743 "rd512", "rl1", "rl2", "rl8",
744 "24", "25", "26", "27",
745 "28", "29", "30", "stopen",
748 static const char *const mite_DCR_strings[] = {
749 "amdevice", "1", "2", "3",
750 "4", "5", "portio", "portvxi",
751 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "aseqxp2",
752 "aseqxp8", "13", "blocken", "berhand",
753 "reqsintlim", "reqs1", "reqs2", "rd32",
754 "rd512", "rl1", "rl2", "rl8",
755 "23", "24", "25", "27",
756 "28", "wsdevc", "wsdevs", "rwdevpack",
759 static const char *const mite_LKCR_strings[] = {
760 "amdevice", "1", "2", "3",
761 "4", "5", "portio", "portvxi",
762 "psizebyte", "psizehalf (byte & half = word)", "asequp", "aseqdown",
763 "12", "13", "14", "berhand",
764 "16", "17", "18", "rd32",
765 "rd512", "rl1", "rl2", "rl8",
766 "24", "25", "26", "27",
767 "28", "29", "30", "chngend",
770 static const char *const mite_CHSR_strings[] = {
771 "d.err0", "d.err1", "m.err0", "m.err1",
772 "l.err0", "l.err1", "drq0", "drq1",
773 "end", "xferr", "operr0", "operr1",
774 "stops", "habort", "sabort", "error",
775 "16", "conts_rb", "18", "linkc",
776 "20", "drdy", "22", "mrdy",
777 "24", "done", "26", "sars",
778 "28", "lpauses", "30", "int",
781 void mite_dump_regs(struct mite_channel *mite_chan)
783 unsigned long mite_io_addr =
784 (unsigned long)mite_chan->mite->mite_io_addr;
785 unsigned long addr = 0;
786 unsigned long temp = 0;
788 printk(KERN_DEBUG "mite_dump_regs ch%i\n", mite_chan->channel);
789 printk(KERN_DEBUG "mite address is =0x%08lx\n", mite_io_addr);
791 addr = mite_io_addr + MITE_CHOR(channel);
792 printk(KERN_DEBUG "mite status[CHOR]at 0x%08lx =0x%08lx\n", addr,
794 mite_decode(mite_CHOR_strings, temp);
795 addr = mite_io_addr + MITE_CHCR(channel);
796 printk(KERN_DEBUG "mite status[CHCR]at 0x%08lx =0x%08lx\n", addr,
798 mite_decode(mite_CHCR_strings, temp);
799 addr = mite_io_addr + MITE_TCR(channel);
800 printk(KERN_DEBUG "mite status[TCR] at 0x%08lx =0x%08x\n", addr,
802 addr = mite_io_addr + MITE_MCR(channel);
803 printk(KERN_DEBUG "mite status[MCR] at 0x%08lx =0x%08lx\n", addr,
805 mite_decode(mite_MCR_strings, temp);
807 addr = mite_io_addr + MITE_MAR(channel);
808 printk(KERN_DEBUG "mite status[MAR] at 0x%08lx =0x%08x\n", addr,
810 addr = mite_io_addr + MITE_DCR(channel);
811 printk(KERN_DEBUG "mite status[DCR] at 0x%08lx =0x%08lx\n", addr,
813 mite_decode(mite_DCR_strings, temp);
814 addr = mite_io_addr + MITE_DAR(channel);
815 printk(KERN_DEBUG "mite status[DAR] at 0x%08lx =0x%08x\n", addr,
817 addr = mite_io_addr + MITE_LKCR(channel);
818 printk(KERN_DEBUG "mite status[LKCR]at 0x%08lx =0x%08lx\n", addr,
820 mite_decode(mite_LKCR_strings, temp);
821 addr = mite_io_addr + MITE_LKAR(channel);
822 printk(KERN_DEBUG "mite status[LKAR]at 0x%08lx =0x%08x\n", addr,
824 addr = mite_io_addr + MITE_CHSR(channel);
825 printk(KERN_DEBUG "mite status[CHSR]at 0x%08lx =0x%08lx\n", addr,
827 mite_decode(mite_CHSR_strings, temp);
828 addr = mite_io_addr + MITE_FCR(channel);
829 printk(KERN_DEBUG "mite status[FCR] at 0x%08lx =0x%08x\n\n", addr,
832 EXPORT_SYMBOL(mite_dump_regs);
834 static void mite_decode(char **bit_str, unsigned int bits)
838 for (i = 31; i >= 0; i--) {
840 printk(KERN_DEBUG " %s", bit_str[i]);
842 printk(KERN_DEBUG "\n");
844 EXPORT_SYMBOL(mite_decode);
848 int __init init_module(void)
856 void __exit cleanup_module(void)
862 MODULE_AUTHOR("Comedi http://www.comedi.org");
863 MODULE_DESCRIPTION("Comedi low-level driver");
864 MODULE_LICENSE("GPL");