hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * module/mite.h
 * Hardware driver for NI Mite PCI interface chip
 *
 * COMEDI - Linux Control and Measurement Device Interface
 * Copyright (C) 1999 David A. Schleef <ds@schleef.org>
 */
 
#ifndef _MITE_H_
#define _MITE_H_
 
#include <linux/spinlock.h>
 
#define MAX_MITE_DMA_CHANNELS 8
 
struct comedi_device;
struct comedi_subdevice;
struct device;
struct pci_dev;
 
struct mite_dma_desc {
   __le32 count;
   __le32 addr;
   __le32 next;
   u32 dar;
};
 
struct mite_ring {
   struct device *hw_dev;
   unsigned int n_links;
   struct mite_dma_desc *descs;
   dma_addr_t dma_addr;
};
 
struct mite_channel {
   struct mite *mite;
   unsigned int channel;
   int dir;
   int done;
   struct mite_ring *ring;
};
 
struct mite {
   struct pci_dev *pcidev;
   void __iomem *mmio;
   struct mite_channel channels[MAX_MITE_DMA_CHANNELS];
   int num_channels;
   unsigned int fifo_size;
   /* protects mite_channel from being released by the driver */
   spinlock_t lock;
};
 
u32 mite_bytes_in_transit(struct mite_channel *mite_chan);
 
void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s);
void mite_ack_linkc(struct mite_channel *mite_chan, struct comedi_subdevice *s,
           bool sync);
int mite_done(struct mite_channel *mite_chan);
 
void mite_dma_arm(struct mite_channel *mite_chan);
void mite_dma_disarm(struct mite_channel *mite_chan);
 
void mite_prep_dma(struct mite_channel *mite_chan,
          unsigned int num_device_bits, unsigned int num_memory_bits);
 
struct mite_channel *mite_request_channel_in_range(struct mite *mite,
                          struct mite_ring *ring,
                          unsigned int min_channel,
                          unsigned int max_channel);
struct mite_channel *mite_request_channel(struct mite *mite,
                     struct mite_ring *ring);
void mite_release_channel(struct mite_channel *mite_chan);
 
int mite_init_ring_descriptors(struct mite_ring *ring,
                  struct comedi_subdevice *s, unsigned int nbytes);
int mite_buf_change(struct mite_ring *ring, struct comedi_subdevice *s);
 
struct mite_ring *mite_alloc_ring(struct mite *mite);
void mite_free_ring(struct mite_ring *ring);
 
struct mite *mite_attach(struct comedi_device *dev, bool use_win1);
void mite_detach(struct mite *mite);
 
/*
 * Mite registers (used outside of the mite driver)
 */
#define MITE_IODWBSR        0xc0    /* IO Device Window Base Size */
#define MITE_IODWBSR_1        0xc4    /* IO Device Window1 Base Size */
#define WENAB            BIT(7)    /* window enable */
#define MITE_IODWCR_1        0xf4
 
#endif