1
2
3
4
5
6
7
8
9
10 #ifndef _MITE_H_
11 #define _MITE_H_
12
13 #include <linux/spinlock.h>
14
15 #define MAX_MITE_DMA_CHANNELS 8
16
17 struct comedi_device;
18 struct comedi_subdevice;
19 struct device;
20 struct pci_dev;
21
22 struct mite_dma_desc {
23 __le32 count;
24 __le32 addr;
25 __le32 next;
26 u32 dar;
27 };
28
29 struct mite_ring {
30 struct device *hw_dev;
31 unsigned int n_links;
32 struct mite_dma_desc *descs;
33 dma_addr_t dma_addr;
34 };
35
36 struct mite_channel {
37 struct mite *mite;
38 unsigned int channel;
39 int dir;
40 int done;
41 struct mite_ring *ring;
42 };
43
44 struct mite {
45 struct pci_dev *pcidev;
46 void __iomem *mmio;
47 struct mite_channel channels[MAX_MITE_DMA_CHANNELS];
48 int num_channels;
49 unsigned int fifo_size;
50
51 spinlock_t lock;
52 };
53
54 u32 mite_bytes_in_transit(struct mite_channel *mite_chan);
55
56 void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s);
57 void mite_ack_linkc(struct mite_channel *mite_chan, struct comedi_subdevice *s,
58 bool sync);
59 int mite_done(struct mite_channel *mite_chan);
60
61 void mite_dma_arm(struct mite_channel *mite_chan);
62 void mite_dma_disarm(struct mite_channel *mite_chan);
63
64 void mite_prep_dma(struct mite_channel *mite_chan,
65 unsigned int num_device_bits, unsigned int num_memory_bits);
66
67 struct mite_channel *mite_request_channel_in_range(struct mite *mite,
68 struct mite_ring *ring,
69 unsigned int min_channel,
70 unsigned int max_channel);
71 struct mite_channel *mite_request_channel(struct mite *mite,
72 struct mite_ring *ring);
73 void mite_release_channel(struct mite_channel *mite_chan);
74
75 int mite_init_ring_descriptors(struct mite_ring *ring,
76 struct comedi_subdevice *s, unsigned int nbytes);
77 int mite_buf_change(struct mite_ring *ring, struct comedi_subdevice *s);
78
79 struct mite_ring *mite_alloc_ring(struct mite *mite);
80 void mite_free_ring(struct mite_ring *ring);
81
82 struct mite *mite_attach(struct comedi_device *dev, bool use_win1);
83 void mite_detach(struct mite *mite);
84
85
86
87
88 #define MITE_IODWBSR 0xc0
89 #define MITE_IODWBSR_1 0xc4
90 #define WENAB BIT(7)
91 #define MITE_IODWCR_1 0xf4
92
93 #endif