linux/drivers/comedi/drivers/s626.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * comedi/drivers/s626.c
 * Sensoray s626 Comedi driver
 *
 * COMEDI - Linux Control and Measurement Device Interface
 * Copyright (C) 2000 David A. Schleef <[email protected]>
 *
 * Based on Sensoray Model 626 Linux driver Version 0.2
 * Copyright (C) 2002-2004 Sensoray Co., Inc.
 */

/*
 * Driver: s626
 * Description: Sensoray 626 driver
 * Devices: [Sensoray] 626 (s626)
 * Authors: Gianluca Palli <[email protected]>,
 * Updated: Fri, 15 Feb 2008 10:28:42 +0000
 * Status: experimental

 * Configuration options: not applicable, uses PCI auto config

 * INSN_CONFIG instructions:
 *   analog input:
 *    none
 *
 *   analog output:
 *    none
 *
 *   digital channel:
 *    s626 has 3 dio subdevices (2,3 and 4) each with 16 i/o channels
 *    supported configuration options:
 *    INSN_CONFIG_DIO_QUERY
 *    COMEDI_INPUT
 *    COMEDI_OUTPUT
 *
 *   encoder:
 *    Every channel must be configured before reading.
 *
 *   Example code
 *
 *    insn.insn=INSN_CONFIG;   //configuration instruction
 *    insn.n=1;                //number of operation (must be 1)
 *    insn.data=&initialvalue; //initial value loaded into encoder
 *                             //during configuration
 *    insn.subdev=5;           //encoder subdevice
 *    insn.chanspec=CR_PACK(encoder_channel,0,AREF_OTHER); //encoder_channel
 *                                                         //to configure
 *
 *    comedi_do_insn(cf,&insn); //executing configuration
 */

#include <linux/module.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/comedi/comedi_pci.h>

#include "s626.h"

struct s626_buffer_dma {};

/**
 * struct s626_private - Working data for s626 driver.
 * @ai_cmd_running: non-zero if ai_cmd is running.
 * @ai_sample_timer: time between samples in units of the timer.
 * @ai_convert_count: conversion counter.
 * @ai_convert_timer: time between conversion in units of the timer.
 * @counter_int_enabs: counter interrupt enable mask for MISC2 register.
 * @adc_items: number of items in ADC poll list.
 * @rps_buf: DMA buffer used to hold ADC (RPS1) program.
 * @ana_buf:  DMA buffer used to receive ADC data and hold DAC data.
 * @dac_wbuf: pointer to logical adrs of DMA buffer used to hold DAC data.
 * @dacpol: image of DAC polarity register.
 * @trim_setpoint: images of TrimDAC setpoints.
 * @i2c_adrs: I2C device address for onboard EEPROM (board rev dependent)
 */
struct s626_private {};

/* Counter overflow/index event flag masks for RDMISC2. */
#define S626_INDXMASK(C)
#define S626_OVERMASK(C)

/*
 * Enable/disable a function or test status bit(s) that are accessed
 * through Main Control Registers 1 or 2.
 */
static void s626_mc_enable(struct comedi_device *dev,
			   unsigned int cmd, unsigned int reg)
{}

static void s626_mc_disable(struct comedi_device *dev,
			    unsigned int cmd, unsigned int reg)
{}

static bool s626_mc_test(struct comedi_device *dev,
			 unsigned int cmd, unsigned int reg)
{}

#define S626_BUGFIX_STREG(REGADRS)

/* Write a time slot control record to TSL2. */
#define S626_VECTPORT(VECTNUM)

static const struct comedi_lrange s626_range_table =;

/*
 * Execute a DEBI transfer.  This must be called from within a critical section.
 */
static void s626_debi_transfer(struct comedi_device *dev)
{}

/*
 * Read a value from a gate array register.
 */
static u16 s626_debi_read(struct comedi_device *dev, u16 addr)
{}

/*
 * Write a value to a gate array register.
 */
static void s626_debi_write(struct comedi_device *dev, u16 addr,
			    u16 wdata)
{}

/*
 * Replace the specified bits in a gate array register.  Imports: mask
 * specifies bits that are to be preserved, wdata is new value to be
 * or'd with the masked original.
 */
static void s626_debi_replace(struct comedi_device *dev, unsigned int addr,
			      unsigned int mask, unsigned int wdata)
{}

/* **************  EEPROM ACCESS FUNCTIONS  ************** */

static int s626_i2c_handshake_eoc(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  struct comedi_insn *insn,
				  unsigned long context)
{}

static int s626_i2c_handshake(struct comedi_device *dev, u32 val)
{}

/* Read u8 from EEPROM. */
static u8 s626_i2c_read(struct comedi_device *dev, u8 addr)
{}

/* ***********  DAC FUNCTIONS *********** */

/* TrimDac LogicalChan-to-PhysicalChan mapping table. */
static const u8 s626_trimchan[] =;

/* TrimDac LogicalChan-to-EepromAdrs mapping table. */
static const u8 s626_trimadrs[] =;

enum {};

static int s626_send_dac_eoc(struct comedi_device *dev,
			     struct comedi_subdevice *s,
			     struct comedi_insn *insn,
			     unsigned long context)
{}

/*
 * Private helper function: Transmit serial data to DAC via Audio
 * channel 2.  Assumes: (1) TSL2 slot records initialized, and (2)
 * dacpol contains valid target image.
 */
static int s626_send_dac(struct comedi_device *dev, u32 val)
{}

/*
 * Private helper function: Write setpoint to an application DAC channel.
 */
static int s626_set_dac(struct comedi_device *dev,
			u16 chan, int16_t dacdata)
{}

static int s626_write_trim_dac(struct comedi_device *dev,
			       u8 logical_chan, u8 dac_data)
{}

static int s626_load_trim_dacs(struct comedi_device *dev)
{}

/* ******  COUNTER FUNCTIONS  ******* */

/*
 * All counter functions address a specific counter by means of the
 * "Counter" argument, which is a logical counter number.  The Counter
 * argument may have any of the following legal values: 0=0A, 1=1A,
 * 2=2A, 3=0B, 4=1B, 5=2B.
 */

/*
 * Return/set a counter pair's latch trigger source.  0: On read
 * access, 1: A index latches A, 2: B index latches B, 3: A overflow
 * latches B.
 */
static void s626_set_latch_source(struct comedi_device *dev,
				  unsigned int chan, u16 value)
{}

/*
 * Write value into counter preload register.
 */
static void s626_preload(struct comedi_device *dev,
			 unsigned int chan, u32 value)
{}

/* ******  PRIVATE COUNTER FUNCTIONS ****** */

/*
 * Reset a counter's index and overflow event capture flags.
 */
static void s626_reset_cap_flags(struct comedi_device *dev,
				 unsigned int chan)
{}

/*
 * Set the operating mode for the specified counter.  The setup
 * parameter is treated as a COUNTER_SETUP data type.  The following
 * parameters are programmable (all other parms are ignored): ClkMult,
 * ClkPol, ClkEnab, IndexSrc, IndexPol, LoadSrc.
 */
static void s626_set_mode_a(struct comedi_device *dev,
			    unsigned int chan, u16 setup,
			    u16 disable_int_src)
{}

static void s626_set_mode_b(struct comedi_device *dev,
			    unsigned int chan, u16 setup,
			    u16 disable_int_src)
{}

static void s626_set_mode(struct comedi_device *dev,
			  unsigned int chan,
			  u16 setup, u16 disable_int_src)
{}

/*
 * Return/set a counter's enable.  enab: 0=always enabled, 1=enabled by index.
 */
static void s626_set_enable(struct comedi_device *dev,
			    unsigned int chan, u16 enab)
{}

/*
 * Return/set the event that will trigger transfer of the preload
 * register into the counter.  0=ThisCntr_Index, 1=ThisCntr_Overflow,
 * 2=OverflowA (B counters only), 3=disabled.
 */
static void s626_set_load_trig(struct comedi_device *dev,
			       unsigned int chan, u16 trig)
{}

/*
 * Return/set counter interrupt source and clear any captured
 * index/overflow events.  int_source: 0=Disabled, 1=OverflowOnly,
 * 2=IndexOnly, 3=IndexAndOverflow.
 */
static void s626_set_int_src(struct comedi_device *dev,
			     unsigned int chan, u16 int_source)
{}

/*
 * Generate an index pulse.
 */
static void s626_pulse_index(struct comedi_device *dev,
			     unsigned int chan)
{}

static unsigned int s626_ai_reg_to_uint(unsigned int data)
{}

static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan)
{}

static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int group,
			      unsigned int mask)
{}

static int s626_dio_clear_irq(struct comedi_device *dev)
{}

static void s626_handle_dio_interrupt(struct comedi_device *dev,
				      u16 irqbit, u8 group)
{}

static void s626_check_dio_interrupts(struct comedi_device *dev)
{}

static void s626_check_counter_interrupts(struct comedi_device *dev)
{}

static bool s626_handle_eos_interrupt(struct comedi_device *dev)
{}

static irqreturn_t s626_irq_handler(int irq, void *d)
{}

/*
 * This function builds the RPS program for hardware driven acquisition.
 */
static void s626_reset_adc(struct comedi_device *dev, u8 *ppl)
{}

static int s626_ai_eoc(struct comedi_device *dev,
		       struct comedi_subdevice *s,
		       struct comedi_insn *insn,
		       unsigned long context)
{}

static int s626_ai_insn_read(struct comedi_device *dev,
			     struct comedi_subdevice *s,
			     struct comedi_insn *insn,
			     unsigned int *data)
{}

static int s626_ai_load_polllist(u8 *ppl, struct comedi_cmd *cmd)
{}

static int s626_ai_inttrig(struct comedi_device *dev,
			   struct comedi_subdevice *s,
			   unsigned int trig_num)
{}

/*
 * This function doesn't require a particular form, this is just what
 * happens to be used in some of the drivers.  It should convert ns
 * nanoseconds to a counter value suitable for programming the device.
 * Also, it should adjust ns so that it cooresponds to the actual time
 * that the device will use.
 */
static int s626_ns_to_timer(unsigned int *nanosec, unsigned int flags)
{}

static void s626_timer_load(struct comedi_device *dev,
			    unsigned int chan, int tick)
{}

/* TO COMPLETE  */
static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{}

static int s626_ai_cmdtest(struct comedi_device *dev,
			   struct comedi_subdevice *s, struct comedi_cmd *cmd)
{}

static int s626_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{}

static int s626_ao_insn_write(struct comedi_device *dev,
			      struct comedi_subdevice *s,
			      struct comedi_insn *insn,
			      unsigned int *data)
{}

/* *************** DIGITAL I/O FUNCTIONS *************** */

/*
 * All DIO functions address a group of DIO channels by means of
 * "group" argument.  group may be 0, 1 or 2, which correspond to DIO
 * ports A, B and C, respectively.
 */

static void s626_dio_init(struct comedi_device *dev)
{}

static int s626_dio_insn_bits(struct comedi_device *dev,
			      struct comedi_subdevice *s,
			      struct comedi_insn *insn,
			      unsigned int *data)
{}

static int s626_dio_insn_config(struct comedi_device *dev,
				struct comedi_subdevice *s,
				struct comedi_insn *insn,
				unsigned int *data)
{}

/*
 * Now this function initializes the value of the counter (data[0])
 * and set the subdevice. To complete with trigger and interrupt
 * configuration.
 *
 * FIXME: data[0] is supposed to be an INSN_CONFIG_xxx constant indicating
 * what is being configured, but this function appears to be using data[0]
 * as a variable.
 */
static int s626_enc_insn_config(struct comedi_device *dev,
				struct comedi_subdevice *s,
				struct comedi_insn *insn, unsigned int *data)
{}

static int s626_enc_insn_read(struct comedi_device *dev,
			      struct comedi_subdevice *s,
			      struct comedi_insn *insn,
			      unsigned int *data)
{}

static int s626_enc_insn_write(struct comedi_device *dev,
			       struct comedi_subdevice *s,
			       struct comedi_insn *insn, unsigned int *data)
{}

static void s626_write_misc2(struct comedi_device *dev, u16 new_image)
{}

static void s626_counters_init(struct comedi_device *dev)
{}

static int s626_allocate_dma_buffers(struct comedi_device *dev)
{}

static void s626_free_dma_buffers(struct comedi_device *dev)
{}

static int s626_initialize(struct comedi_device *dev)
{}

static int s626_auto_attach(struct comedi_device *dev,
			    unsigned long context_unused)
{}

static void s626_detach(struct comedi_device *dev)
{}

static struct comedi_driver s626_driver =;

static int s626_pci_probe(struct pci_dev *dev,
			  const struct pci_device_id *id)
{}

/*
 * For devices with vendor:device id == 0x1131:0x7146 you must specify
 * also subvendor:subdevice ids, because otherwise it will conflict with
 * Philips SAA7146 media/dvb based cards.
 */
static const struct pci_device_id s626_pci_table[] =;
MODULE_DEVICE_TABLE(pci, s626_pci_table);

static struct pci_driver s626_pci_driver =;
module_comedi_pci_driver();

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