3 * Hardware driver for NI Mite PCI interface chip
5 * COMEDI - Linux Control and Measurement Device Interface
6 * Copyright (C) 1999 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.
22 #include <linux/spinlock.h>
24 #define MAX_MITE_DMA_CHANNELS 8
27 struct comedi_subdevice;
31 struct mite_dma_desc {
39 struct device *hw_dev;
41 struct mite_dma_desc *descs;
50 struct mite_ring *ring;
54 struct pci_dev *pcidev;
56 struct mite_channel channels[MAX_MITE_DMA_CHANNELS];
58 unsigned int fifo_size;
59 /* protects mite_channel from being released by the driver */
63 u32 mite_bytes_in_transit(struct mite_channel *mite_chan);
65 void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s);
66 void mite_ack_linkc(struct mite_channel *mite_chan, struct comedi_subdevice *s,
68 int mite_done(struct mite_channel *mite_chan);
70 void mite_dma_arm(struct mite_channel *mite_chan);
71 void mite_dma_disarm(struct mite_channel *mite_chan);
73 void mite_prep_dma(struct mite_channel *mite_chan,
74 unsigned int num_device_bits, unsigned int num_memory_bits);
76 struct mite_channel *mite_request_channel_in_range(struct mite *mite,
77 struct mite_ring *ring,
78 unsigned int min_channel,
79 unsigned int max_channel);
80 struct mite_channel *mite_request_channel(struct mite *mite,
81 struct mite_ring *ring);
82 void mite_release_channel(struct mite_channel *mite_chan);
84 int mite_init_ring_descriptors(struct mite_ring *ring,
85 struct comedi_subdevice *s, unsigned int nbytes);
86 int mite_buf_change(struct mite_ring *ring, struct comedi_subdevice *s);
88 struct mite_ring *mite_alloc_ring(struct mite *mite);
89 void mite_free_ring(struct mite_ring *ring);
91 struct mite *mite_attach(struct comedi_device *dev, bool use_win1);
92 void mite_detach(struct mite *mite);
95 * Mite registers (used outside of the mite driver)
97 #define MITE_IODWBSR 0xc0 /* IO Device Window Base Size */
98 #define MITE_IODWBSR_1 0xc4 /* IO Device Window1 Base Size */
99 #define WENAB BIT(7) /* window enable */
100 #define MITE_IODWCR_1 0xf4