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