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)))
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 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_channel *mite_request_channel_in_range(struct mite_struct *mite,
262 mite_dma_descriptor_ring
263 *ring, unsigned min_channel,
264 unsigned max_channel)
268 struct mite_channel *channel = NULL;
270 /* spin lock so mite_release_channel can be called safely
273 spin_lock_irqsave(&mite->lock, flags);
274 for (i = min_channel; i <= max_channel; ++i) {
275 if (mite->channel_allocated[i] == 0) {
276 mite->channel_allocated[i] = 1;
277 channel = &mite->channels[i];
278 channel->ring = ring;
282 spin_unlock_irqrestore(&mite->lock, flags);
285 EXPORT_SYMBOL(mite_request_channel_in_range);
287 void mite_release_channel(struct mite_channel *mite_chan)
289 struct mite_struct *mite = mite_chan->mite;
292 /* spin lock to prevent races with mite_request_channel */
293 spin_lock_irqsave(&mite->lock, flags);
294 if (mite->channel_allocated[mite_chan->channel]) {
295 mite_dma_disarm(mite_chan);
296 mite_dma_reset(mite_chan);
298 * disable all channel's interrupts (do it after disarm/reset so
299 * MITE_CHCR reg isn't changed while dma is still active!)
301 writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
302 CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
303 CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
304 CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
305 mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
306 mite->channel_allocated[mite_chan->channel] = 0;
307 mite_chan->ring = NULL;
310 spin_unlock_irqrestore(&mite->lock, flags);
312 EXPORT_SYMBOL(mite_release_channel);
314 void mite_dma_arm(struct mite_channel *mite_chan)
316 struct mite_struct *mite = mite_chan->mite;
320 MDPRINTK("mite_dma_arm ch%i\n", channel);
322 * memory barrier is intended to insure any twiddling with the buffer
323 * is done before writing to the mite to arm dma transfer
328 spin_lock_irqsave(&mite->lock, flags);
330 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
332 spin_unlock_irqrestore(&mite->lock, flags);
333 /* mite_dma_tcr(mite, channel); */
335 EXPORT_SYMBOL(mite_dma_arm);
337 /**************************************/
339 int mite_buf_change(struct mite_dma_descriptor_ring *ring,
340 struct comedi_async *async)
342 unsigned int n_links;
345 if (ring->descriptors) {
346 dma_free_coherent(ring->hw_dev,
348 sizeof(struct mite_dma_descriptor),
350 ring->descriptors_dma_addr);
352 ring->descriptors = NULL;
353 ring->descriptors_dma_addr = 0;
356 if (async->prealloc_bufsz == 0)
359 n_links = async->prealloc_bufsz >> PAGE_SHIFT;
361 MDPRINTK("ring->hw_dev=%p, n_links=0x%04x\n", ring->hw_dev, n_links);
364 dma_alloc_coherent(ring->hw_dev,
365 n_links * sizeof(struct mite_dma_descriptor),
366 &ring->descriptors_dma_addr, GFP_KERNEL);
367 if (!ring->descriptors) {
368 printk(KERN_ERR "mite: ring buffer allocation failed\n");
371 ring->n_links = n_links;
373 for (i = 0; i < n_links; i++) {
374 ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE);
375 ring->descriptors[i].addr =
376 cpu_to_le32(async->buf_page_list[i].dma_addr);
377 ring->descriptors[i].next =
378 cpu_to_le32(ring->descriptors_dma_addr + (i +
380 sizeof(struct mite_dma_descriptor));
382 ring->descriptors[n_links - 1].next =
383 cpu_to_le32(ring->descriptors_dma_addr);
385 * barrier is meant to insure that all the writes to the dma descriptors
386 * have completed before the dma controller is commanded to read them
391 EXPORT_SYMBOL(mite_buf_change);
393 void mite_prep_dma(struct mite_channel *mite_chan,
394 unsigned int num_device_bits, unsigned int num_memory_bits)
396 unsigned int chor, chcr, mcr, dcr, lkcr;
397 struct mite_struct *mite = mite_chan->mite;
399 MDPRINTK("mite_prep_dma ch%i\n", mite_chan->channel);
401 /* reset DMA and FIFO */
402 chor = CHOR_DMARESET | CHOR_FRESET;
403 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
405 /* short link chaining mode */
406 chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE |
409 * Link Complete Interrupt: interrupt every time a link
410 * in MITE_RING is completed. This can generate a lot of
411 * extra interrupts, but right now we update the values
412 * of buf_int_ptr and buf_int_count at each interrupt. A
413 * better method is to poll the MITE before each user
414 * "read()" to calculate the number of bytes available.
416 chcr |= CHCR_SET_LC_IE;
417 if (num_memory_bits == 32 && num_device_bits == 16) {
419 * Doing a combined 32 and 16 bit byteswap gets the 16 bit
420 * samples into the fifo in the right order. Tested doing 32 bit
421 * memory to 16 bit device transfers to the analog out of a
422 * pxi-6281, which has mite version = 1, type = 4. This also
423 * works for dma reads from the counters on e-series boards.
425 chcr |= CHCR_BYTE_SWAP_DEVICE | CHCR_BYTE_SWAP_MEMORY;
427 if (mite_chan->dir == COMEDI_INPUT)
428 chcr |= CHCR_DEV_TO_MEM;
430 writel(chcr, mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
433 mcr = CR_RL(64) | CR_ASEQUP;
434 switch (num_memory_bits) {
445 printk(KERN_WARNING "mite: bug! invalid mem bit width for dma "
449 writel(mcr, mite->mite_io_addr + MITE_MCR(mite_chan->channel));
452 dcr = CR_RL(64) | CR_ASEQUP;
453 dcr |= CR_PORTIO | CR_AMDEVICE | CR_REQSDRQ(mite_chan->channel);
454 switch (num_device_bits) {
465 printk(KERN_WARNING "mite: bug! invalid dev bit width for dma "
469 writel(dcr, mite->mite_io_addr + MITE_DCR(mite_chan->channel));
472 writel(0, mite->mite_io_addr + MITE_DAR(mite_chan->channel));
474 /* the link is 32bits */
475 lkcr = CR_RL(64) | CR_ASEQUP | CR_PSIZE32;
476 writel(lkcr, mite->mite_io_addr + MITE_LKCR(mite_chan->channel));
478 /* starting address for link chaining */
479 writel(mite_chan->ring->descriptors_dma_addr,
480 mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
482 MDPRINTK("exit mite_prep_dma\n");
484 EXPORT_SYMBOL(mite_prep_dma);
486 u32 mite_device_bytes_transferred(struct mite_channel *mite_chan)
488 struct mite_struct *mite = mite_chan->mite;
489 return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel));
492 u32 mite_bytes_in_transit(struct mite_channel *mite_chan)
494 struct mite_struct *mite = mite_chan->mite;
495 return readl(mite->mite_io_addr +
496 MITE_FCR(mite_chan->channel)) & 0x000000FF;
498 EXPORT_SYMBOL(mite_bytes_in_transit);
500 /* returns lower bound for number of bytes transferred from device to memory */
501 u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
503 u32 device_byte_count;
505 device_byte_count = mite_device_bytes_transferred(mite_chan);
506 return device_byte_count - mite_bytes_in_transit(mite_chan);
508 EXPORT_SYMBOL(mite_bytes_written_to_memory_lb);
510 /* returns upper bound for number of bytes transferred from device to memory */
511 u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
513 u32 in_transit_count;
515 in_transit_count = mite_bytes_in_transit(mite_chan);
516 return mite_device_bytes_transferred(mite_chan) - in_transit_count;
518 EXPORT_SYMBOL(mite_bytes_written_to_memory_ub);
520 /* returns lower bound for number of bytes read from memory to device */
521 u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
523 u32 device_byte_count;
525 device_byte_count = mite_device_bytes_transferred(mite_chan);
526 return device_byte_count + mite_bytes_in_transit(mite_chan);
528 EXPORT_SYMBOL(mite_bytes_read_from_memory_lb);
530 /* returns upper bound for number of bytes read from memory to device */
531 u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan)
533 u32 in_transit_count;
535 in_transit_count = mite_bytes_in_transit(mite_chan);
536 return mite_device_bytes_transferred(mite_chan) + in_transit_count;
538 EXPORT_SYMBOL(mite_bytes_read_from_memory_ub);
540 unsigned mite_dma_tcr(struct mite_channel *mite_chan)
542 struct mite_struct *mite = mite_chan->mite;
546 lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
547 tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
548 MDPRINTK("mite_dma_tcr ch%i, lkar=0x%08x tcr=%d\n", mite_chan->channel,
553 EXPORT_SYMBOL(mite_dma_tcr);
555 void mite_dma_disarm(struct mite_channel *mite_chan)
557 struct mite_struct *mite = mite_chan->mite;
562 writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
564 EXPORT_SYMBOL(mite_dma_disarm);
566 int mite_sync_input_dma(struct mite_channel *mite_chan,
567 struct comedi_async *async)
570 unsigned int nbytes, old_alloc_count;
571 const unsigned bytes_per_scan = cfc_bytes_per_scan(async->subdevice);
573 old_alloc_count = async->buf_write_alloc_count;
574 /* write alloc as much as we can */
575 comedi_buf_write_alloc(async, async->prealloc_bufsz);
577 nbytes = mite_bytes_written_to_memory_lb(mite_chan);
578 if ((int)(mite_bytes_written_to_memory_ub(mite_chan) -
579 old_alloc_count) > 0) {
580 printk("mite: DMA overwrite of free area\n");
581 async->events |= COMEDI_CB_OVERFLOW;
585 count = nbytes - async->buf_write_count;
586 /* it's possible count will be negative due to
587 * conservative value returned by mite_bytes_written_to_memory_lb */
591 comedi_buf_write_free(async, count);
593 async->scan_progress += count;
594 if (async->scan_progress >= bytes_per_scan) {
595 async->scan_progress %= bytes_per_scan;
596 async->events |= COMEDI_CB_EOS;
598 async->events |= COMEDI_CB_BLOCK;
601 EXPORT_SYMBOL(mite_sync_input_dma);
603 int mite_sync_output_dma(struct mite_channel *mite_chan,
604 struct comedi_async *async)
607 u32 nbytes_ub, nbytes_lb;
608 unsigned int old_alloc_count;
610 async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
612 old_alloc_count = async->buf_read_alloc_count;
613 /* read alloc as much as we can */
614 comedi_buf_read_alloc(async, async->prealloc_bufsz);
615 nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
616 if (async->cmd.stop_src == TRIG_COUNT &&
617 (int)(nbytes_lb - stop_count) > 0)
618 nbytes_lb = stop_count;
619 nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan);
620 if (async->cmd.stop_src == TRIG_COUNT &&
621 (int)(nbytes_ub - stop_count) > 0)
622 nbytes_ub = stop_count;
623 if ((int)(nbytes_ub - old_alloc_count) > 0) {
624 printk(KERN_ERR "mite: DMA underrun\n");
625 async->events |= COMEDI_CB_OVERFLOW;
628 count = nbytes_lb - async->buf_read_count;
633 comedi_buf_read_free(async, count);
634 async->events |= COMEDI_CB_BLOCK;
638 EXPORT_SYMBOL(mite_sync_output_dma);
640 unsigned mite_get_status(struct mite_channel *mite_chan)
642 struct mite_struct *mite = mite_chan->mite;
646 spin_lock_irqsave(&mite->lock, flags);
647 status = readl(mite->mite_io_addr + MITE_CHSR(mite_chan->channel));
648 if (status & CHSR_DONE) {
651 mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
654 spin_unlock_irqrestore(&mite->lock, flags);
657 EXPORT_SYMBOL(mite_get_status);
659 int mite_done(struct mite_channel *mite_chan)
661 struct mite_struct *mite = mite_chan->mite;
665 mite_get_status(mite_chan);
666 spin_lock_irqsave(&mite->lock, flags);
667 done = mite_chan->done;
668 spin_unlock_irqrestore(&mite->lock, flags);
671 EXPORT_SYMBOL(mite_done);
675 static void mite_decode(char **bit_str, unsigned int bits);
677 /* names of bits in mite registers */
679 static const char *const mite_CHOR_strings[] = {
680 "start", "cont", "stop", "abort",
681 "freset", "clrlc", "clrrb", "clrdone",
682 "clr_lpause", "set_lpause", "clr_send_tc",
683 "set_send_tc", "12", "13", "14",
684 "15", "16", "17", "18",
685 "19", "20", "21", "22",
686 "23", "24", "25", "26",
687 "27", "28", "29", "30",
691 static const char *const mite_CHCR_strings[] = {
692 "continue", "ringbuff", "2", "3",
694 "8", "9", "10", "11",
695 "12", "13", "bursten", "fifodis",
696 "clr_cont_rb_ie", "set_cont_rb_ie", "clr_lc_ie", "set_lc_ie",
697 "clr_drdy_ie", "set_drdy_ie", "clr_mrdy_ie", "set_mrdy_ie",
698 "clr_done_ie", "set_done_ie", "clr_sar_ie", "set_sar_ie",
699 "clr_linkp_ie", "set_linkp_ie", "clr_dma_ie", "set_dma_ie",
702 static const char *const mite_MCR_strings[] = {
703 "amdevice", "1", "2", "3",
704 "4", "5", "portio", "portvxi",
705 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "11",
706 "12", "13", "blocken", "berhand",
707 "reqsintlim/reqs0", "reqs1", "reqs2", "rd32",
708 "rd512", "rl1", "rl2", "rl8",
709 "24", "25", "26", "27",
710 "28", "29", "30", "stopen",
713 static const char *const mite_DCR_strings[] = {
714 "amdevice", "1", "2", "3",
715 "4", "5", "portio", "portvxi",
716 "psizebyte", "psizehalf (byte & half = word)", "aseqxp1", "aseqxp2",
717 "aseqxp8", "13", "blocken", "berhand",
718 "reqsintlim", "reqs1", "reqs2", "rd32",
719 "rd512", "rl1", "rl2", "rl8",
720 "23", "24", "25", "27",
721 "28", "wsdevc", "wsdevs", "rwdevpack",
724 static const char *const mite_LKCR_strings[] = {
725 "amdevice", "1", "2", "3",
726 "4", "5", "portio", "portvxi",
727 "psizebyte", "psizehalf (byte & half = word)", "asequp", "aseqdown",
728 "12", "13", "14", "berhand",
729 "16", "17", "18", "rd32",
730 "rd512", "rl1", "rl2", "rl8",
731 "24", "25", "26", "27",
732 "28", "29", "30", "chngend",
735 static const char *const mite_CHSR_strings[] = {
736 "d.err0", "d.err1", "m.err0", "m.err1",
737 "l.err0", "l.err1", "drq0", "drq1",
738 "end", "xferr", "operr0", "operr1",
739 "stops", "habort", "sabort", "error",
740 "16", "conts_rb", "18", "linkc",
741 "20", "drdy", "22", "mrdy",
742 "24", "done", "26", "sars",
743 "28", "lpauses", "30", "int",
746 void mite_dump_regs(struct mite_channel *mite_chan)
748 unsigned long mite_io_addr =
749 (unsigned long)mite_chan->mite->mite_io_addr;
750 unsigned long addr = 0;
751 unsigned long temp = 0;
753 printk(KERN_DEBUG "mite_dump_regs ch%i\n", mite_chan->channel);
754 printk(KERN_DEBUG "mite address is =0x%08lx\n", mite_io_addr);
756 addr = mite_io_addr + MITE_CHOR(channel);
757 printk(KERN_DEBUG "mite status[CHOR]at 0x%08lx =0x%08lx\n", addr,
759 mite_decode(mite_CHOR_strings, temp);
760 addr = mite_io_addr + MITE_CHCR(channel);
761 printk(KERN_DEBUG "mite status[CHCR]at 0x%08lx =0x%08lx\n", addr,
763 mite_decode(mite_CHCR_strings, temp);
764 addr = mite_io_addr + MITE_TCR(channel);
765 printk(KERN_DEBUG "mite status[TCR] at 0x%08lx =0x%08x\n", addr,
767 addr = mite_io_addr + MITE_MCR(channel);
768 printk(KERN_DEBUG "mite status[MCR] at 0x%08lx =0x%08lx\n", addr,
770 mite_decode(mite_MCR_strings, temp);
772 addr = mite_io_addr + MITE_MAR(channel);
773 printk(KERN_DEBUG "mite status[MAR] at 0x%08lx =0x%08x\n", addr,
775 addr = mite_io_addr + MITE_DCR(channel);
776 printk(KERN_DEBUG "mite status[DCR] at 0x%08lx =0x%08lx\n", addr,
778 mite_decode(mite_DCR_strings, temp);
779 addr = mite_io_addr + MITE_DAR(channel);
780 printk(KERN_DEBUG "mite status[DAR] at 0x%08lx =0x%08x\n", addr,
782 addr = mite_io_addr + MITE_LKCR(channel);
783 printk(KERN_DEBUG "mite status[LKCR]at 0x%08lx =0x%08lx\n", addr,
785 mite_decode(mite_LKCR_strings, temp);
786 addr = mite_io_addr + MITE_LKAR(channel);
787 printk(KERN_DEBUG "mite status[LKAR]at 0x%08lx =0x%08x\n", addr,
789 addr = mite_io_addr + MITE_CHSR(channel);
790 printk(KERN_DEBUG "mite status[CHSR]at 0x%08lx =0x%08lx\n", addr,
792 mite_decode(mite_CHSR_strings, temp);
793 addr = mite_io_addr + MITE_FCR(channel);
794 printk(KERN_DEBUG "mite status[FCR] at 0x%08lx =0x%08x\n\n", addr,
797 EXPORT_SYMBOL(mite_dump_regs);
799 static void mite_decode(char **bit_str, unsigned int bits)
803 for (i = 31; i >= 0; i--) {
805 printk(KERN_DEBUG " %s", bit_str[i]);
807 printk(KERN_DEBUG "\n");
809 EXPORT_SYMBOL(mite_decode);
813 int __init init_module(void)
821 void __exit cleanup_module(void)
827 MODULE_AUTHOR("Comedi http://www.comedi.org");
828 MODULE_DESCRIPTION("Comedi low-level driver");
829 MODULE_LICENSE("GPL");