Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304526
b: refs/heads/master
c: 3c5510b
h: refs/heads/master
v: v3
  • Loading branch information
Ravishankar Karkala Mallikarjunayya authored and Greg Kroah-Hartman committed Apr 30, 2012
1 parent 0543cac commit 0c08d37
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ed7dcb47f6f83923476942ad08be4fd6c2fef8b4
refs/heads/master: 3c5510ba5091f3d7be338875c84451b07a3dd498
72 changes: 50 additions & 22 deletions trunk/drivers/staging/comedi/drivers/cb_pcidda.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ Please report success/failure with other different cards to
#include "comedi_pci.h"
#include "8255.h"

#define PCI_VENDOR_ID_CB 0x1307 /* PCI vendor number of ComputerBoards */

/* PCI vendor number of ComputerBoards */
#define PCI_VENDOR_ID_CB 0x1307
#define EEPROM_SIZE 128 /* number of entries in eeprom */
#define MAX_AO_CHANNELS 8 /* maximum number of ao channels for supported boards */
/* maximum number of ao channels for supported boards */
#define MAX_AO_CHANNELS 8

/* PCI-DDA base addresses */
#define DIGITALIO_BADRINDEX 2
Expand Down Expand Up @@ -94,20 +97,26 @@ Please report success/failure with other different cards to

#define DACALIBRATION1 4 /* D/A CALIBRATION REGISTER 1 */
/* write bits */
#define SERIAL_IN_BIT 0x1 /* serial data input for eeprom, caldacs, reference dac */
/* serial data input for eeprom, caldacs, reference dac */
#define SERIAL_IN_BIT 0x1
#define CAL_CHANNEL_MASK (0x7 << 1)
#define CAL_CHANNEL_BITS(channel) (((channel) << 1) & CAL_CHANNEL_MASK)
/* read bits */
#define CAL_COUNTER_MASK 0x1f
#define CAL_COUNTER_OVERFLOW_BIT 0x20 /* calibration counter overflow status bit */
#define AO_BELOW_REF_BIT 0x40 /* analog output is less than reference dac voltage */
/* calibration counter overflow status bit */
#define CAL_COUNTER_OVERFLOW_BIT 0x20
/* analog output is less than reference dac voltage */
#define AO_BELOW_REF_BIT 0x40
#define SERIAL_OUT_BIT 0x80 /* serial data out, for reading from eeprom */

#define DACALIBRATION2 6 /* D/A CALIBRATION REGISTER 2 */
#define SELECT_EEPROM_BIT 0x1 /* send serial data in to eeprom */
#define DESELECT_REF_DAC_BIT 0x2 /* don't send serial data to MAX542 reference dac */
#define DESELECT_CALDAC_BIT(n) (0x4 << (n)) /* don't send serial data to caldac n */
#define DUMMY_BIT 0x40 /* manual says to set this bit with no explanation */
/* don't send serial data to MAX542 reference dac */
#define DESELECT_REF_DAC_BIT 0x2
/* don't send serial data to caldac n */
#define DESELECT_CALDAC_BIT(n) (0x4 << (n))
/* manual says to set this bit with no explanation */
#define DUMMY_BIT 0x40

#define DADATA 8 /* FIRST D/A DATA REGISTER (0) */

Expand Down Expand Up @@ -212,9 +221,12 @@ MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
*/
#define thisboard ((const struct cb_pcidda_board *)dev->board_ptr)

/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct. */
/*
* this structure is for data unique to this hardware driver. If
* several hardware drivers keep similar information in this structure,
* feel free to suggest moving the variable to the struct comedi_device
* struct.
*/
struct cb_pcidda_private {
int data;

Expand All @@ -227,8 +239,10 @@ struct cb_pcidda_private {
/* unsigned long control_status; */
/* unsigned long adc_fifo; */

unsigned int dac_cal1_bits; /* bits last written to da calibration register 1 */
unsigned int ao_range[MAX_AO_CHANNELS]; /* current range settings for output channels */
/* bits last written to da calibration register 1 */
unsigned int dac_cal1_bits;
/* current range settings for output channels */
unsigned int ao_range[MAX_AO_CHANNELS];
u16 eeprom_data[EEPROM_SIZE]; /* software copy of board's eeprom */
};

Expand Down Expand Up @@ -377,7 +391,8 @@ static int cb_pcidda_attach(struct comedi_device *dev,
dev_dbg(dev->hw_dev, "eeprom:\n");
for (index = 0; index < EEPROM_SIZE; index++) {
devpriv->eeprom_data[index] = cb_pcidda_read_eeprom(dev, index);
dev_dbg(dev->hw_dev, "%i:0x%x\n", index, devpriv->eeprom_data[index]);
dev_dbg(dev->hw_dev, "%i:0x%x\n", index,
devpriv->eeprom_data[index]);
}

/* set calibrations dacs */
Expand Down Expand Up @@ -484,7 +499,10 @@ static int cb_pcidda_ai_cmdtest(struct comedi_device *dev,
if (err)
return 1;

/* step 2: make sure trigger sources are unique and mutually compatible */
/*
* step 2: make sure trigger sources are unique and mutually
* compatible
*/

/* note that mutual compatibility is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER
Expand Down Expand Up @@ -696,8 +714,10 @@ static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
unsigned int i;
unsigned int cal2_bits;
unsigned int value;
const int max_num_caldacs = 4; /* one caldac for every two dac channels */
const int read_instruction = 0x6; /* bits to send to tell eeprom we want to read */
/* one caldac for every two dac channels */
const int max_num_caldacs = 4;
/* bits to send to tell eeprom we want to read */
const int read_instruction = 0x6;
const int instruction_length = 3;
const int address_length = 8;

Expand Down Expand Up @@ -729,9 +749,11 @@ static void cb_pcidda_write_caldac(struct comedi_device *dev,
{
unsigned int cal2_bits;
unsigned int i;
const int num_channel_bits = 3; /* caldacs use 3 bit channel specification */
/* caldacs use 3 bit channel specification */
const int num_channel_bits = 3;
const int num_caldac_bits = 8; /* 8 bit calibration dacs */
const int max_num_caldacs = 4; /* one caldac for every two dac channels */
/* one caldac for every two dac channels */
const int max_num_caldacs = 4;

/* write 3 bit channel */
cb_pcidda_serial_out(dev, channel, num_channel_bits);
Expand Down Expand Up @@ -790,14 +812,20 @@ static unsigned int offset_eeprom_address(unsigned int ao_channel,
return 0x7 + 2 * range + 12 * ao_channel;
}

/* returns eeprom address that provides gain calibration for given ao channel and range */
/*
* returns eeprom address that provides gain calibration for given ao
* channel and range
*/
static unsigned int gain_eeprom_address(unsigned int ao_channel,
unsigned int range)
{
return 0x8 + 2 * range + 12 * ao_channel;
}

/* returns upper byte of eeprom entry, which gives the coarse adjustment values */
/*
* returns upper byte of eeprom entry, which gives the coarse adjustment
* values
*/
static unsigned int eeprom_coarse_byte(unsigned int word)
{
return (word >> 8) & 0xff;
Expand All @@ -815,7 +843,7 @@ static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
{
unsigned int coarse_offset, fine_offset, coarse_gain, fine_gain;

/* remember range so we can tell when we need to readjust calibration */
/* remember range so we can tell when we need to readjust calibration */
devpriv->ao_range[channel] = range;

/* get values from eeprom data */
Expand Down

0 comments on commit 0c08d37

Please sign in to comment.