linux/drivers/comedi/drivers/mite.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * comedi/drivers/mite.c
 * Hardware driver for NI Mite PCI interface chip
 *
 * COMEDI - Linux Control and Measurement Device Interface
 * Copyright (C) 1997-2002 David A. Schleef <[email protected]>
 */

/*
 * The PCI-MIO E series driver was originally written by
 * Tomasz Motylewski <...>, and ported to comedi by ds.
 *
 * References for specifications:
 *
 *    321747b.pdf  Register Level Programmer Manual (obsolete)
 *    321747c.pdf  Register Level Programmer Manual (new)
 *    DAQ-STC reference manual
 *
 * Other possibly relevant info:
 *
 *    320517c.pdf  User manual (obsolete)
 *    320517f.pdf  User manual (new)
 *    320889a.pdf  delete
 *    320906c.pdf  maximum signal ratings
 *    321066a.pdf  about 16x
 *    321791a.pdf  discontinuation of at-mio-16e-10 rev. c
 *    321808a.pdf  about at-mio-16e-10 rev P
 *    321837a.pdf  discontinuation of at-mio-16de-10 rev d
 *    321838a.pdf  about at-mio-16de-10 rev N
 *
 * ISSUES:
 *
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/slab.h>
#include <linux/log2.h>
#include <linux/comedi/comedi_pci.h>

#include "mite.h"

/*
 * Mite registers
 */
#define MITE_UNKNOWN_DMA_BURST_REG
#define UNKNOWN_DMA_BURST_ENABLE_BITS

#define MITE_PCI_CONFIG_OFFSET
#define MITE_CSIGR
#define CSIGR_TO_IOWINS(x)
#define CSIGR_TO_WINS(x)
#define CSIGR_TO_WPDEP(x)
#define CSIGR_TO_DMAC(x)
#define CSIGR_TO_IMODE(x)
#define CSIGR_TO_MMODE(x)
#define CSIGR_TO_TYPE(x)
#define CSIGR_TO_VER(x)

#define MITE_CHAN(x)
#define MITE_CHOR(x)
#define CHOR_DMARESET
#define CHOR_SET_SEND_TC
#define CHOR_CLR_SEND_TC
#define CHOR_SET_LPAUSE
#define CHOR_CLR_LPAUSE
#define CHOR_CLRDONE
#define CHOR_CLRRB
#define CHOR_CLRLC
#define CHOR_FRESET
#define CHOR_ABORT
#define CHOR_STOP
#define CHOR_CONT
#define CHOR_START
#define MITE_CHCR(x)
#define CHCR_SET_DMA_IE
#define CHCR_CLR_DMA_IE
#define CHCR_SET_LINKP_IE
#define CHCR_CLR_LINKP_IE
#define CHCR_SET_SAR_IE
#define CHCR_CLR_SAR_IE
#define CHCR_SET_DONE_IE
#define CHCR_CLR_DONE_IE
#define CHCR_SET_MRDY_IE
#define CHCR_CLR_MRDY_IE
#define CHCR_SET_DRDY_IE
#define CHCR_CLR_DRDY_IE
#define CHCR_SET_LC_IE
#define CHCR_CLR_LC_IE
#define CHCR_SET_CONT_RB_IE
#define CHCR_CLR_CONT_RB_IE
#define CHCR_FIFO(x)
#define CHCR_FIFODIS
#define CHCR_FIFO_ON
#define CHCR_BURST(x)
#define CHCR_BURSTEN
#define CHCR_NO_BURSTEN
#define CHCR_BYTE_SWAP_DEVICE
#define CHCR_BYTE_SWAP_MEMORY
#define CHCR_DIR(x)
#define CHCR_DEV_TO_MEM
#define CHCR_MEM_TO_DEV
#define CHCR_MODE(x)
#define CHCR_NORMAL
#define CHCR_CONTINUE
#define CHCR_RINGBUFF
#define CHCR_LINKSHORT
#define CHCR_LINKLONG
#define MITE_TCR(x)
#define MITE_MCR(x)
#define MITE_MAR(x)
#define MITE_DCR(x)
#define DCR_NORMAL
#define MITE_DAR(x)
#define MITE_LKCR(x)
#define MITE_LKAR(x)
#define MITE_LLKAR(x)
#define MITE_BAR(x)
#define MITE_BCR(x)
#define MITE_SAR(x)
#define MITE_WSCR(x)
#define MITE_WSER(x)
#define MITE_CHSR(x)
#define CHSR_INT
#define CHSR_LPAUSES
#define CHSR_SARS
#define CHSR_DONE
#define CHSR_MRDY
#define CHSR_DRDY
#define CHSR_LINKC
#define CHSR_CONTS_RB
#define CHSR_ERROR
#define CHSR_SABORT
#define CHSR_HABORT
#define CHSR_STOPS
#define CHSR_OPERR(x)
#define CHSR_OPERR_MASK
#define CHSR_OPERR_NOERROR
#define CHSR_OPERR_FIFOERROR
#define CHSR_OPERR_LINKERROR
#define CHSR_XFERR
#define CHSR_END
#define CHSR_DRQ1
#define CHSR_DRQ0
#define CHSR_LERR(x)
#define CHSR_LERR_MASK
#define CHSR_LBERR
#define CHSR_LRERR
#define CHSR_LOERR
#define CHSR_MERR(x)
#define CHSR_MERR_MASK
#define CHSR_MBERR
#define CHSR_MRERR
#define CHSR_MOERR
#define CHSR_DERR(x)
#define CHSR_DERR_MASK
#define CHSR_DBERR
#define CHSR_DRERR
#define CHSR_DOERR
#define MITE_FCR(x)

/* common bits for the memory/device/link config registers */
#define CR_RL(x)
#define CR_REQS(x)
#define CR_REQS_MASK
#define CR_ASEQ(x)
#define CR_ASEQDONT
#define CR_ASEQUP
#define CR_ASEQDOWN
#define CR_ASEQ_MASK
#define CR_PSIZE(x)
#define CR_PSIZE8
#define CR_PSIZE16
#define CR_PSIZE32
#define CR_PORT(x)
#define CR_PORTCPU
#define CR_PORTIO
#define CR_PORTVXI
#define CR_PORTMXI
#define CR_AMDEVICE

static unsigned int MITE_IODWBSR_1_WSIZE_bits(unsigned int size)
{}

static unsigned int mite_retry_limit(unsigned int retry_limit)
{}

static unsigned int mite_drq_reqs(unsigned int drq_line)
{}

static unsigned int mite_fifo_size(struct mite *mite, unsigned int channel)
{}

static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan)
{}

/**
 * mite_bytes_in_transit() - Returns the number of unread bytes in the fifo.
 * @mite_chan: MITE dma channel.
 */
u32 mite_bytes_in_transit(struct mite_channel *mite_chan)
{}
EXPORT_SYMBOL_GPL();

/* returns lower bound for number of bytes transferred from device to memory */
static u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
{}

/* returns upper bound for number of bytes transferred from device to memory */
static u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
{}

/* returns lower bound for number of bytes read from memory to device */
static u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
{}

/* returns upper bound for number of bytes read from memory to device */
static u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan)
{}

static void mite_sync_input_dma(struct mite_channel *mite_chan,
				struct comedi_subdevice *s)
{}

static void mite_sync_output_dma(struct mite_channel *mite_chan,
				 struct comedi_subdevice *s)
{}

/**
 * mite_sync_dma() - Sync the MITE dma with the COMEDI async buffer.
 * @mite_chan: MITE dma channel.
 * @s: COMEDI subdevice.
 */
void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s)
{}
EXPORT_SYMBOL_GPL();

static unsigned int mite_get_status(struct mite_channel *mite_chan)
{}

/**
 * mite_ack_linkc() - Check and ack the LINKC interrupt,
 * @mite_chan: MITE dma channel.
 * @s: COMEDI subdevice.
 * @sync: flag to force a mite_sync_dma().
 *
 * This will also ack the DONE interrupt if active.
 */
void mite_ack_linkc(struct mite_channel *mite_chan,
		    struct comedi_subdevice *s,
		    bool sync)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_done() - Check is a MITE dma transfer is complete.
 * @mite_chan: MITE dma channel.
 *
 * This will also ack the DONE interrupt if active.
 */
int mite_done(struct mite_channel *mite_chan)
{}
EXPORT_SYMBOL_GPL();

static void mite_dma_reset(struct mite_channel *mite_chan)
{}

/**
 * mite_dma_arm() - Start a MITE dma transfer.
 * @mite_chan: MITE dma channel.
 */
void mite_dma_arm(struct mite_channel *mite_chan)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_dma_disarm() - Stop a MITE dma transfer.
 * @mite_chan: MITE dma channel.
 */
void mite_dma_disarm(struct mite_channel *mite_chan)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_prep_dma() - Prepare a MITE dma channel for transfers.
 * @mite_chan: MITE dma channel.
 * @num_device_bits: device transfer size (8, 16, or 32-bits).
 * @num_memory_bits: memory transfer size (8, 16, or 32-bits).
 */
void mite_prep_dma(struct mite_channel *mite_chan,
		   unsigned int num_device_bits, unsigned int num_memory_bits)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_request_channel_in_range() - Request a MITE dma channel.
 * @mite: MITE device.
 * @ring: MITE dma ring.
 * @min_channel: minimum channel index to use.
 * @max_channel: maximum channel index to use.
 */
struct mite_channel *mite_request_channel_in_range(struct mite *mite,
						   struct mite_ring *ring,
						   unsigned int min_channel,
						   unsigned int max_channel)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_request_channel() - Request a MITE dma channel.
 * @mite: MITE device.
 * @ring: MITE dma ring.
 */
struct mite_channel *mite_request_channel(struct mite *mite,
					  struct mite_ring *ring)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_release_channel() - Release a MITE dma channel.
 * @mite_chan: MITE dma channel.
 */
void mite_release_channel(struct mite_channel *mite_chan)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_init_ring_descriptors() - Initialize a MITE dma ring descriptors.
 * @ring: MITE dma ring.
 * @s: COMEDI subdevice.
 * @nbytes: the size of the dma ring (in bytes).
 *
 * Initializes the ring buffer descriptors to provide correct DMA transfer
 * links to the exact amount of memory required. When the ring buffer is
 * allocated by mite_buf_change(), the default is to initialize the ring
 * to refer to the entire DMA data buffer. A command may call this function
 * later to re-initialize and shorten the amount of memory that will be
 * transferred.
 */
int mite_init_ring_descriptors(struct mite_ring *ring,
			       struct comedi_subdevice *s,
			       unsigned int nbytes)
{}
EXPORT_SYMBOL_GPL();

static void mite_free_dma_descs(struct mite_ring *ring)
{}

/**
 * mite_buf_change() - COMEDI subdevice (*buf_change) for a MITE dma ring.
 * @ring: MITE dma ring.
 * @s: COMEDI subdevice.
 */
int mite_buf_change(struct mite_ring *ring, struct comedi_subdevice *s)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_alloc_ring() - Allocate a MITE dma ring.
 * @mite: MITE device.
 */
struct mite_ring *mite_alloc_ring(struct mite *mite)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_free_ring() - Free a MITE dma ring and its descriptors.
 * @ring: MITE dma ring.
 */
void mite_free_ring(struct mite_ring *ring)
{}
EXPORT_SYMBOL_GPL();

static int mite_setup(struct comedi_device *dev, struct mite *mite,
		      bool use_win1)
{}

/**
 * mite_attach() - Allocate and initialize a MITE device for a comedi driver.
 * @dev: COMEDI device.
 * @use_win1: flag to use I/O Window 1 instead of I/O Window 0.
 *
 * Called by a COMEDI drivers (*auto_attach).
 *
 * Returns a pointer to the MITE device on success, or NULL if the MITE cannot
 * be allocated or remapped.
 */
struct mite *mite_attach(struct comedi_device *dev, bool use_win1)
{}
EXPORT_SYMBOL_GPL();

/**
 * mite_detach() - Unmap and free a MITE device for a comedi driver.
 * @mite: MITE device.
 *
 * Called by a COMEDI drivers (*detach).
 */
void mite_detach(struct mite *mite)
{}
EXPORT_SYMBOL_GPL();

static int __init mite_module_init(void)
{}
module_init();

static void __exit mite_module_exit(void)
{}
module_exit(mite_module_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();