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/module.h>
50 #include <linux/pci.h>
52 #include "../comedidev.h"
54 #include "comedi_fc.h"
57 #define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK)))
59 struct mite_struct *mite_alloc(struct pci_dev *pcidev)
61 struct mite_struct *mite;
64 mite = kzalloc(sizeof(*mite), GFP_KERNEL);
66 spin_lock_init(&mite->lock);
67 mite->pcidev = pcidev;
68 for (i = 0; i < MAX_MITE_DMA_CHANNELS; ++i) {
69 mite->channels[i].mite = mite;
70 mite->channels[i].channel = i;
71 mite->channels[i].done = 1;
76 EXPORT_SYMBOL_GPL(mite_alloc);
78 static void dump_chip_signature(u32 csigr_bits)
80 pr_info("version = %i, type = %i, mite mode = %i, interface mode = %i\n",
81 mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits),
82 mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits));
83 pr_info("num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n",
84 mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits),
85 mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits));
88 static unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel)
90 unsigned fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel));
91 unsigned empty_count = (fcr_bits >> 16) & 0xff;
92 unsigned full_count = fcr_bits & 0xff;
93 return empty_count + full_count;
96 int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
101 unsigned unknown_dma_burst_bits;
103 pci_set_master(mite->pcidev);
105 mite->mite_io_addr = pci_ioremap_bar(mite->pcidev, 0);
106 if (!mite->mite_io_addr) {
107 dev_err(&mite->pcidev->dev,
108 "Failed to remap mite io memory address\n");
111 mite->mite_phys_addr = pci_resource_start(mite->pcidev, 0);
113 mite->daq_io_addr = pci_ioremap_bar(mite->pcidev, 1);
114 if (!mite->daq_io_addr) {
115 dev_err(&mite->pcidev->dev,
116 "Failed to remap daq io memory address\n");
119 mite->daq_phys_addr = pci_resource_start(mite->pcidev, 1);
120 length = pci_resource_len(mite->pcidev, 1);
123 writel(0, mite->mite_io_addr + MITE_IODWBSR);
124 dev_info(&mite->pcidev->dev,
125 "using I/O Window Base Size register 1\n");
126 writel(mite->daq_phys_addr | WENAB |
127 MITE_IODWBSR_1_WSIZE_bits(length),
128 mite->mite_io_addr + MITE_IODWBSR_1);
129 writel(0, mite->mite_io_addr + MITE_IODWCR_1);
131 writel(mite->daq_phys_addr | WENAB,
132 mite->mite_io_addr + MITE_IODWBSR);
135 * make sure dma bursts work. I got this from running a bus analyzer
136 * on a pxi-6281 and a pxi-6713. 6713 powered up with register value
137 * of 0x61f and bursts worked. 6281 powered up with register value of
138 * 0x1f and bursts didn't work. The NI windows driver reads the
139 * register, then does a bitwise-or of 0x600 with it and writes it back.
141 unknown_dma_burst_bits =
142 readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
143 unknown_dma_burst_bits |= UNKNOWN_DMA_BURST_ENABLE_BITS;
144 writel(unknown_dma_burst_bits,
145 mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
147 csigr_bits = readl(mite->mite_io_addr + MITE_CSIGR);
148 mite->num_channels = mite_csigr_dmac(csigr_bits);
149 if (mite->num_channels > MAX_MITE_DMA_CHANNELS) {
150 dev_warn(&mite->pcidev->dev,
151 "mite: bug? chip claims to have %i dma channels. Setting to %i.\n",
152 mite->num_channels, MAX_MITE_DMA_CHANNELS);
153 mite->num_channels = MAX_MITE_DMA_CHANNELS;
155 dump_chip_signature(csigr_bits);
156 for (i = 0; i < mite->num_channels; i++) {
157 writel(CHOR_DMARESET, mite->mite_io_addr + MITE_CHOR(i));
158 /* disable interrupts */
159 writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
160 CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
161 CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
162 mite->mite_io_addr + MITE_CHCR(i));
164 mite->fifo_size = mite_fifo_size(mite, 0);
165 dev_info(&mite->pcidev->dev, "fifo size is %i.\n", mite->fifo_size);
168 EXPORT_SYMBOL_GPL(mite_setup2);
170 int mite_setup(struct mite_struct *mite)
172 return mite_setup2(mite, 0);
174 EXPORT_SYMBOL_GPL(mite_setup);
176 void mite_unsetup(struct mite_struct *mite)
178 /* unsigned long offset, start, length; */
183 if (mite->mite_io_addr) {
184 iounmap(mite->mite_io_addr);
185 mite->mite_io_addr = NULL;
187 if (mite->daq_io_addr) {
188 iounmap(mite->daq_io_addr);
189 mite->daq_io_addr = NULL;
191 if (mite->mite_phys_addr)
192 mite->mite_phys_addr = 0;
194 EXPORT_SYMBOL_GPL(mite_unsetup);
196 struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite)
198 struct mite_dma_descriptor_ring *ring =
199 kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL);
203 ring->hw_dev = get_device(&mite->pcidev->dev);
204 if (ring->hw_dev == NULL) {
209 ring->descriptors = NULL;
210 ring->descriptors_dma_addr = 0;
213 EXPORT_SYMBOL_GPL(mite_alloc_ring);
215 void mite_free_ring(struct mite_dma_descriptor_ring *ring)
218 if (ring->descriptors) {
219 dma_free_coherent(ring->hw_dev,
221 sizeof(struct mite_dma_descriptor),
223 ring->descriptors_dma_addr);
225 put_device(ring->hw_dev);
229 EXPORT_SYMBOL_GPL(mite_free_ring);
231 struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
233 mite_dma_descriptor_ring
234 *ring, unsigned min_channel,
235 unsigned max_channel)
239 struct mite_channel *channel = NULL;
241 /* spin lock so mite_release_channel can be called safely
244 spin_lock_irqsave(&mite->lock, flags);
245 for (i = min_channel; i <= max_channel; ++i) {
246 if (mite->channel_allocated[i] == 0) {
247 mite->channel_allocated[i] = 1;
248 channel = &mite->channels[i];
249 channel->ring = ring;
253 spin_unlock_irqrestore(&mite->lock, flags);
256 EXPORT_SYMBOL_GPL(mite_request_channel_in_range);
258 void mite_release_channel(struct mite_channel *mite_chan)
260 struct mite_struct *mite = mite_chan->mite;
263 /* spin lock to prevent races with mite_request_channel */
264 spin_lock_irqsave(&mite->lock, flags);
265 if (mite->channel_allocated[mite_chan->channel]) {
266 mite_dma_disarm(mite_chan);
267 mite_dma_reset(mite_chan);
269 * disable all channel's interrupts (do it after disarm/reset so
270 * MITE_CHCR reg isn't changed while dma is still active!)
272 writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
273 CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
274 CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
275 CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
276 mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
277 mite->channel_allocated[mite_chan->channel] = 0;
278 mite_chan->ring = NULL;
281 spin_unlock_irqrestore(&mite->lock, flags);
283 EXPORT_SYMBOL_GPL(mite_release_channel);
285 void mite_dma_arm(struct mite_channel *mite_chan)
287 struct mite_struct *mite = mite_chan->mite;
291 MDPRINTK("mite_dma_arm ch%i\n", mite_chan->channel);
293 * memory barrier is intended to insure any twiddling with the buffer
294 * is done before writing to the mite to arm dma transfer
299 spin_lock_irqsave(&mite->lock, flags);
301 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
303 spin_unlock_irqrestore(&mite->lock, flags);
304 /* mite_dma_tcr(mite, channel); */
306 EXPORT_SYMBOL_GPL(mite_dma_arm);
308 /**************************************/
310 int mite_buf_change(struct mite_dma_descriptor_ring *ring,
311 struct comedi_async *async)
313 unsigned int n_links;
316 if (ring->descriptors) {
317 dma_free_coherent(ring->hw_dev,
319 sizeof(struct mite_dma_descriptor),
321 ring->descriptors_dma_addr);
323 ring->descriptors = NULL;
324 ring->descriptors_dma_addr = 0;
327 if (async->prealloc_bufsz == 0)
330 n_links = async->prealloc_bufsz >> PAGE_SHIFT;
332 MDPRINTK("ring->hw_dev=%p, n_links=0x%04x\n", ring->hw_dev, n_links);
335 dma_alloc_coherent(ring->hw_dev,
336 n_links * sizeof(struct mite_dma_descriptor),
337 &ring->descriptors_dma_addr, GFP_KERNEL);
338 if (!ring->descriptors) {
339 dev_err(async->subdevice->device->class_dev,
340 "mite: ring buffer allocation failed\n");
343 ring->n_links = n_links;
345 for (i = 0; i < n_links; i++) {
346 ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE);
347 ring->descriptors[i].addr =
348 cpu_to_le32(async->buf_page_list[i].dma_addr);
349 ring->descriptors[i].next =
350 cpu_to_le32(ring->descriptors_dma_addr + (i +
352 sizeof(struct mite_dma_descriptor));
354 ring->descriptors[n_links - 1].next =
355 cpu_to_le32(ring->descriptors_dma_addr);
357 * barrier is meant to insure that all the writes to the dma descriptors
358 * have completed before the dma controller is commanded to read them
363 EXPORT_SYMBOL_GPL(mite_buf_change);
365 void mite_prep_dma(struct mite_channel *mite_chan,
366 unsigned int num_device_bits, unsigned int num_memory_bits)
368 unsigned int chor, chcr, mcr, dcr, lkcr;
369 struct mite_struct *mite = mite_chan->mite;
371 MDPRINTK("mite_prep_dma ch%i\n", mite_chan->channel);
373 /* reset DMA and FIFO */
374 chor = CHOR_DMARESET | CHOR_FRESET;
375 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
377 /* short link chaining mode */
378 chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE |
381 * Link Complete Interrupt: interrupt every time a link
382 * in MITE_RING is completed. This can generate a lot of
383 * extra interrupts, but right now we update the values
384 * of buf_int_ptr and buf_int_count at each interrupt. A
385 * better method is to poll the MITE before each user
386 * "read()" to calculate the number of bytes available.
388 chcr |= CHCR_SET_LC_IE;
389 if (num_memory_bits == 32 && num_device_bits == 16) {
391 * Doing a combined 32 and 16 bit byteswap gets the 16 bit
392 * samples into the fifo in the right order. Tested doing 32 bit
393 * memory to 16 bit device transfers to the analog out of a
394 * pxi-6281, which has mite version = 1, type = 4. This also
395 * works for dma reads from the counters on e-series boards.
397 chcr |= CHCR_BYTE_SWAP_DEVICE | CHCR_BYTE_SWAP_MEMORY;
399 if (mite_chan->dir == COMEDI_INPUT)
400 chcr |= CHCR_DEV_TO_MEM;
402 writel(chcr, mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
405 mcr = CR_RL(64) | CR_ASEQUP;
406 switch (num_memory_bits) {
417 pr_warn("bug! invalid mem bit width for dma transfer\n");
420 writel(mcr, mite->mite_io_addr + MITE_MCR(mite_chan->channel));
423 dcr = CR_RL(64) | CR_ASEQUP;
424 dcr |= CR_PORTIO | CR_AMDEVICE | CR_REQSDRQ(mite_chan->channel);
425 switch (num_device_bits) {
436 pr_warn("bug! invalid dev bit width for dma transfer\n");
439 writel(dcr, mite->mite_io_addr + MITE_DCR(mite_chan->channel));
442 writel(0, mite->mite_io_addr + MITE_DAR(mite_chan->channel));
444 /* the link is 32bits */
445 lkcr = CR_RL(64) | CR_ASEQUP | CR_PSIZE32;
446 writel(lkcr, mite->mite_io_addr + MITE_LKCR(mite_chan->channel));
448 /* starting address for link chaining */
449 writel(mite_chan->ring->descriptors_dma_addr,
450 mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
452 MDPRINTK("exit mite_prep_dma\n");
454 EXPORT_SYMBOL_GPL(mite_prep_dma);
456 static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan)
458 struct mite_struct *mite = mite_chan->mite;
459 return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel));
462 u32 mite_bytes_in_transit(struct mite_channel *mite_chan)
464 struct mite_struct *mite = mite_chan->mite;
465 return readl(mite->mite_io_addr +
466 MITE_FCR(mite_chan->channel)) & 0x000000FF;
468 EXPORT_SYMBOL_GPL(mite_bytes_in_transit);
470 /* returns lower bound for number of bytes transferred from device to memory */
471 u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
473 u32 device_byte_count;
475 device_byte_count = mite_device_bytes_transferred(mite_chan);
476 return device_byte_count - mite_bytes_in_transit(mite_chan);
478 EXPORT_SYMBOL_GPL(mite_bytes_written_to_memory_lb);
480 /* returns upper bound for number of bytes transferred from device to memory */
481 u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
483 u32 in_transit_count;
485 in_transit_count = mite_bytes_in_transit(mite_chan);
486 return mite_device_bytes_transferred(mite_chan) - in_transit_count;
488 EXPORT_SYMBOL_GPL(mite_bytes_written_to_memory_ub);
490 /* returns lower bound for number of bytes read from memory to device */
491 u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
493 u32 device_byte_count;
495 device_byte_count = mite_device_bytes_transferred(mite_chan);
496 return device_byte_count + mite_bytes_in_transit(mite_chan);
498 EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_lb);
500 /* returns upper bound for number of bytes read from memory to device */
501 u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan)
503 u32 in_transit_count;
505 in_transit_count = mite_bytes_in_transit(mite_chan);
506 return mite_device_bytes_transferred(mite_chan) + in_transit_count;
508 EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_ub);
510 unsigned mite_dma_tcr(struct mite_channel *mite_chan)
512 struct mite_struct *mite = mite_chan->mite;
516 lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
517 tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
518 MDPRINTK("mite_dma_tcr ch%i, lkar=0x%08x tcr=%d\n", mite_chan->channel,
523 EXPORT_SYMBOL_GPL(mite_dma_tcr);
525 void mite_dma_disarm(struct mite_channel *mite_chan)
527 struct mite_struct *mite = mite_chan->mite;
532 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
534 EXPORT_SYMBOL_GPL(mite_dma_disarm);
536 int mite_sync_input_dma(struct mite_channel *mite_chan,
537 struct comedi_async *async)
540 unsigned int nbytes, old_alloc_count;
541 const unsigned bytes_per_scan = cfc_bytes_per_scan(async->subdevice);
543 old_alloc_count = async->buf_write_alloc_count;
544 /* write alloc as much as we can */
545 comedi_buf_write_alloc(async, async->prealloc_bufsz);
547 nbytes = mite_bytes_written_to_memory_lb(mite_chan);
548 if ((int)(mite_bytes_written_to_memory_ub(mite_chan) -
549 old_alloc_count) > 0) {
550 dev_warn(async->subdevice->device->class_dev,
551 "mite: DMA overwrite of free area\n");
552 async->events |= COMEDI_CB_OVERFLOW;
556 count = nbytes - async->buf_write_count;
557 /* it's possible count will be negative due to
558 * conservative value returned by mite_bytes_written_to_memory_lb */
562 comedi_buf_write_free(async, count);
564 async->scan_progress += count;
565 if (async->scan_progress >= bytes_per_scan) {
566 async->scan_progress %= bytes_per_scan;
567 async->events |= COMEDI_CB_EOS;
569 async->events |= COMEDI_CB_BLOCK;
572 EXPORT_SYMBOL_GPL(mite_sync_input_dma);
574 int mite_sync_output_dma(struct mite_channel *mite_chan,
575 struct comedi_async *async)
578 u32 nbytes_ub, nbytes_lb;
579 unsigned int old_alloc_count;
581 async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
583 old_alloc_count = async->buf_read_alloc_count;
584 /* read alloc as much as we can */
585 comedi_buf_read_alloc(async, async->prealloc_bufsz);
586 nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
587 if (async->cmd.stop_src == TRIG_COUNT &&
588 (int)(nbytes_lb - stop_count) > 0)
589 nbytes_lb = stop_count;
590 nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan);
591 if (async->cmd.stop_src == TRIG_COUNT &&
592 (int)(nbytes_ub - stop_count) > 0)
593 nbytes_ub = stop_count;
594 if ((int)(nbytes_ub - old_alloc_count) > 0) {
595 dev_warn(async->subdevice->device->class_dev,
596 "mite: DMA underrun\n");
597 async->events |= COMEDI_CB_OVERFLOW;
600 count = nbytes_lb - async->buf_read_count;
605 comedi_buf_read_free(async, count);
606 async->events |= COMEDI_CB_BLOCK;
610 EXPORT_SYMBOL_GPL(mite_sync_output_dma);
612 unsigned mite_get_status(struct mite_channel *mite_chan)
614 struct mite_struct *mite = mite_chan->mite;
618 spin_lock_irqsave(&mite->lock, flags);
619 status = readl(mite->mite_io_addr + MITE_CHSR(mite_chan->channel));
620 if (status & CHSR_DONE) {
623 mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
626 spin_unlock_irqrestore(&mite->lock, flags);
629 EXPORT_SYMBOL_GPL(mite_get_status);
631 int mite_done(struct mite_channel *mite_chan)
633 struct mite_struct *mite = mite_chan->mite;
637 mite_get_status(mite_chan);
638 spin_lock_irqsave(&mite->lock, flags);
639 done = mite_chan->done;
640 spin_unlock_irqrestore(&mite->lock, flags);
643 EXPORT_SYMBOL_GPL(mite_done);
647 /* names of bits in mite registers */
649 static const char *const mite_CHOR_strings[] = {
650 "start", "cont", "stop", "abort",
651 "freset", "clrlc", "clrrb", "clrdone",
652 "clr_lpause", "set_lpause", "clr_send_tc",
653 "set_send_tc", "12", "13", "14",
654 "15", "16", "17", "18",
655 "19", "20", "21", "22",
656 "23", "24", "25", "26",
657 "27", "28", "29", "30",
661 static const char *const mite_CHCR_strings[] = {
662 "continue", "ringbuff", "2", "3",
664 "8", "9", "10", "11",
665 "12", "13", "bursten", "fifodis",
666 "clr_cont_rb_ie", "set_cont_rb_ie", "clr_lc_ie", "set_lc_ie",
667 "clr_drdy_ie", "set_drdy_ie", "clr_mrdy_ie", "set_mrdy_ie",
668 "clr_done_ie", "set_done_ie", "clr_sar_ie", "set_sar_ie",
669 "clr_linkp_ie", "set_linkp_ie", "clr_dma_ie", "set_dma_ie",
672 static const char *const mite_MCR_strings[] = {
673 "amdevice", "1", "2", "3",
674 "4", "5", "portio", "portvxi",
675 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "11",
676 "12", "13", "blocken", "berhand",
677 "reqsintlim/reqs0", "reqs1", "reqs2", "rd32",
678 "rd512", "rl1", "rl2", "rl8",
679 "24", "25", "26", "27",
680 "28", "29", "30", "stopen",
683 static const char *const mite_DCR_strings[] = {
684 "amdevice", "1", "2", "3",
685 "4", "5", "portio", "portvxi",
686 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "aseqxp2",
687 "aseqxp8", "13", "blocken", "berhand",
688 "reqsintlim", "reqs1", "reqs2", "rd32",
689 "rd512", "rl1", "rl2", "rl8",
690 "23", "24", "25", "27",
691 "28", "wsdevc", "wsdevs", "rwdevpack",
694 static const char *const mite_LKCR_strings[] = {
695 "amdevice", "1", "2", "3",
696 "4", "5", "portio", "portvxi",
697 "psizebyte", "psizehalf (byte & half = word)", "asequp", "aseqdown",
698 "12", "13", "14", "berhand",
699 "16", "17", "18", "rd32",
700 "rd512", "rl1", "rl2", "rl8",
701 "24", "25", "26", "27",
702 "28", "29", "30", "chngend",
705 static const char *const mite_CHSR_strings[] = {
706 "d.err0", "d.err1", "m.err0", "m.err1",
707 "l.err0", "l.err1", "drq0", "drq1",
708 "end", "xferr", "operr0", "operr1",
709 "stops", "habort", "sabort", "error",
710 "16", "conts_rb", "18", "linkc",
711 "20", "drdy", "22", "mrdy",
712 "24", "done", "26", "sars",
713 "28", "lpauses", "30", "int",
716 static void mite_decode(const char *const *bit_str, unsigned int bits)
720 for (i = 31; i >= 0; i--) {
722 pr_debug(" %s\n", bit_str[i]);
726 void mite_dump_regs(struct mite_channel *mite_chan)
728 void __iomem *mite_io_addr = mite_chan->mite->mite_io_addr;
731 int channel = mite_chan->channel;
733 pr_debug("mite_dump_regs ch%i\n", channel);
734 pr_debug("mite address is =%p\n", mite_io_addr);
736 offset = MITE_CHOR(channel);
737 value = readl(mite_io_addr + offset);
738 pr_debug("mite status[CHOR] at 0x%08x =0x%08x\n", offset, value);
739 mite_decode(mite_CHOR_strings, value);
740 offset = MITE_CHCR(channel);
741 value = readl(mite_io_addr + offset);
742 pr_debug("mite status[CHCR] at 0x%08x =0x%08x\n", offset, value);
743 mite_decode(mite_CHCR_strings, value);
744 offset = MITE_TCR(channel);
745 value = readl(mite_io_addr + offset);
746 pr_debug("mite status[TCR] at 0x%08x =0x%08x\n", offset, value);
747 offset = MITE_MCR(channel);
748 value = readl(mite_io_addr + offset);
749 pr_debug("mite status[MCR] at 0x%08x =0x%08x\n", offset, value);
750 mite_decode(mite_MCR_strings, value);
751 offset = MITE_MAR(channel);
752 value = readl(mite_io_addr + offset);
753 pr_debug("mite status[MAR] at 0x%08x =0x%08x\n", offset, value);
754 offset = MITE_DCR(channel);
755 value = readl(mite_io_addr + offset);
756 pr_debug("mite status[DCR] at 0x%08x =0x%08x\n", offset, value);
757 mite_decode(mite_DCR_strings, value);
758 offset = MITE_DAR(channel);
759 value = readl(mite_io_addr + offset);
760 pr_debug("mite status[DAR] at 0x%08x =0x%08x\n", offset, value);
761 offset = MITE_LKCR(channel);
762 value = readl(mite_io_addr + offset);
763 pr_debug("mite status[LKCR] at 0x%08x =0x%08x\n", offset, value);
764 mite_decode(mite_LKCR_strings, value);
765 offset = MITE_LKAR(channel);
766 value = readl(mite_io_addr + offset);
767 pr_debug("mite status[LKAR] at 0x%08x =0x%08x\n", offset, value);
768 offset = MITE_CHSR(channel);
769 value = readl(mite_io_addr + offset);
770 pr_debug("mite status[CHSR] at 0x%08x =0x%08x\n", offset, value);
771 mite_decode(mite_CHSR_strings, value);
772 offset = MITE_FCR(channel);
773 value = readl(mite_io_addr + offset);
774 pr_debug("mite status[FCR] at 0x%08x =0x%08x\n", offset, value);
776 EXPORT_SYMBOL_GPL(mite_dump_regs);
779 static int __init mite_module_init(void)
784 static void __exit mite_module_exit(void)
788 module_init(mite_module_init);
789 module_exit(mite_module_exit);
791 MODULE_AUTHOR("Comedi http://www.comedi.org");
792 MODULE_DESCRIPTION("Comedi low-level driver");
793 MODULE_LICENSE("GPL");