Commit 17733219 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_stc.h: add a 'is_m_series' flag to private data

The (board->reg_type & ni_reg_m_series_mask) test is commonly used
in ni_mio_common.c to detect if the driver is being used with a
National Instruments "M series" DAQ board. Simplify the code a bit
by adding an 'is_m_series' bit-field flag to the private data.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0fd90b74
...@@ -532,10 +532,9 @@ static void ni_release_cdo_mite_channel(struct comedi_device *dev) ...@@ -532,10 +532,9 @@ static void ni_release_cdo_mite_channel(struct comedi_device *dev)
static void ni_e_series_enable_second_irq(struct comedi_device *dev, static void ni_e_series_enable_second_irq(struct comedi_device *dev,
unsigned gpct_index, short enable) unsigned gpct_index, short enable)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
return; return;
switch (gpct_index) { switch (gpct_index) {
case 0: case 0:
...@@ -1650,7 +1649,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev, ...@@ -1650,7 +1649,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
unsigned offset; unsigned offset;
unsigned int dither; unsigned int dither;
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
ni_m_series_load_channelgain_list(dev, n_chan, list); ni_m_series_load_channelgain_list(dev, n_chan, list);
return; return;
} }
...@@ -1853,7 +1852,7 @@ static int ni_ai_insn_read(struct comedi_device *dev, ...@@ -1853,7 +1852,7 @@ static int ni_ai_insn_read(struct comedi_device *dev,
("ni_mio_common: timeout in ni_ai_insn_read\n"); ("ni_mio_common: timeout in ni_ai_insn_read\n");
return -ETIME; return -ETIME;
} }
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
dl = devpriv->readl(dev, M_Offset_AI_FIFO_Data); dl = devpriv->readl(dev, M_Offset_AI_FIFO_Data);
dl &= mask; dl &= mask;
data[n] = dl; data[n] = dl;
...@@ -2496,7 +2495,7 @@ static int ni_ai_insn_config(struct comedi_device *dev, ...@@ -2496,7 +2495,7 @@ static int ni_ai_insn_config(struct comedi_device *dev,
case INSN_CONFIG_ANALOG_TRIG: case INSN_CONFIG_ANALOG_TRIG:
return ni_ai_config_analog_trig(dev, s, insn, data); return ni_ai_config_analog_trig(dev, s, insn, data);
case INSN_CONFIG_ALT_SOURCE: case INSN_CONFIG_ALT_SOURCE:
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
if (data[1] & ~(MSeries_AI_Bypass_Cal_Sel_Pos_Mask | if (data[1] & ~(MSeries_AI_Bypass_Cal_Sel_Pos_Mask |
MSeries_AI_Bypass_Cal_Sel_Neg_Mask | MSeries_AI_Bypass_Cal_Sel_Neg_Mask |
MSeries_AI_Bypass_Mode_Mux_Mask | MSeries_AI_Bypass_Mode_Mux_Mask |
...@@ -2692,9 +2691,9 @@ static int ni_ao_config_chanlist(struct comedi_device *dev, ...@@ -2692,9 +2691,9 @@ static int ni_ao_config_chanlist(struct comedi_device *dev,
unsigned int chanspec[], unsigned int n_chans, unsigned int chanspec[], unsigned int n_chans,
int timed) int timed)
{ {
const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
return ni_m_series_ao_config_chanlist(dev, s, chanspec, n_chans, return ni_m_series_ao_config_chanlist(dev, s, chanspec, n_chans,
timed); timed);
else else
...@@ -2716,7 +2715,6 @@ static int ni_ao_insn_write(struct comedi_device *dev, ...@@ -2716,7 +2715,6 @@ static int ni_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int invert; unsigned int invert;
...@@ -2725,7 +2723,7 @@ static int ni_ao_insn_write(struct comedi_device *dev, ...@@ -2725,7 +2723,7 @@ static int ni_ao_insn_write(struct comedi_device *dev,
devpriv->ao[chan] = data[0]; devpriv->ao[chan] = data[0];
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
devpriv->writew(dev, data[0], M_Offset_DAC_Direct_Data(chan)); devpriv->writew(dev, data[0], M_Offset_DAC_Direct_Data(chan));
} else } else
devpriv->writew(dev, data[0] ^ invert, devpriv->writew(dev, data[0] ^ invert,
...@@ -2938,7 +2936,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -2938,7 +2936,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
switch (cmd->stop_src) { switch (cmd->stop_src) {
case TRIG_COUNT: case TRIG_COUNT:
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
/* this is how the NI example code does it for m-series boards, verified correct with 6259 */ /* this is how the NI example code does it for m-series boards, verified correct with 6259 */
devpriv->stc_writel(dev, cmd->stop_arg - 1, devpriv->stc_writel(dev, cmd->stop_arg - 1,
AO_UC_Load_A_Register); AO_UC_Load_A_Register);
...@@ -3006,8 +3004,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -3006,8 +3004,8 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
unsigned bits; unsigned bits;
devpriv->ao_mode1 &= ~AO_Multiple_Channels; devpriv->ao_mode1 &= ~AO_Multiple_Channels;
bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z); bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z);
if (board->reg_type & if (devpriv->is_m_series ||
(ni_reg_m_series_mask | ni_reg_6xxx_mask)) { board->reg_type & ni_reg_6xxx_mask) {
bits |= AO_Number_Of_Channels(0); bits |= AO_Number_Of_Channels(0);
} else { } else {
bits |= bits |=
...@@ -3041,7 +3039,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -3041,7 +3039,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
#if 0 #if 0
/* F Hess: windows driver does not set AO_Number_Of_DAC_Packages bit for 6281, /* F Hess: windows driver does not set AO_Number_Of_DAC_Packages bit for 6281,
verified with bus analyzer. */ verified with bus analyzer. */
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
bits |= AO_Number_Of_DAC_Packages; bits |= AO_Number_Of_DAC_Packages;
#endif #endif
devpriv->stc_writew(dev, bits, AO_Personal_Register); devpriv->stc_writew(dev, bits, AO_Personal_Register);
...@@ -3172,7 +3170,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -3172,7 +3170,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register); devpriv->stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
devpriv->ao_mode2 = 0; devpriv->ao_mode2 = 0;
devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register); devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
devpriv->ao_mode3 = AO_Last_Gate_Disable; devpriv->ao_mode3 = AO_Last_Gate_Disable;
else else
devpriv->ao_mode3 = 0; devpriv->ao_mode3 = 0;
...@@ -3454,7 +3452,6 @@ static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -3454,7 +3452,6 @@ static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
static void handle_cdio_interrupt(struct comedi_device *dev) static void handle_cdio_interrupt(struct comedi_device *dev)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
unsigned cdio_status; unsigned cdio_status;
struct comedi_subdevice *s = &dev->subdevices[NI_DIO_SUBDEV]; struct comedi_subdevice *s = &dev->subdevices[NI_DIO_SUBDEV];
...@@ -3462,7 +3459,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev) ...@@ -3462,7 +3459,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev)
unsigned long flags; unsigned long flags;
#endif #endif
if ((board->reg_type & ni_reg_m_series_mask) == 0) if (!devpriv->is_m_series)
return; return;
#ifdef PCIDMA #ifdef PCIDMA
spin_lock_irqsave(&devpriv->mite_channel_lock, flags); spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
...@@ -4434,9 +4431,9 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev, ...@@ -4434,9 +4431,9 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev,
static unsigned ni_get_pfi_routing(struct comedi_device *dev, unsigned chan) static unsigned ni_get_pfi_routing(struct comedi_device *dev, unsigned chan)
{ {
const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
return ni_m_series_get_pfi_routing(dev, chan); return ni_m_series_get_pfi_routing(dev, chan);
else else
return ni_old_get_pfi_routing(dev, chan); return ni_old_get_pfi_routing(dev, chan);
...@@ -4445,9 +4442,9 @@ static unsigned ni_get_pfi_routing(struct comedi_device *dev, unsigned chan) ...@@ -4445,9 +4442,9 @@ static unsigned ni_get_pfi_routing(struct comedi_device *dev, unsigned chan)
static int ni_set_pfi_routing(struct comedi_device *dev, unsigned chan, static int ni_set_pfi_routing(struct comedi_device *dev, unsigned chan,
unsigned source) unsigned source)
{ {
const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
return ni_m_series_set_pfi_routing(dev, chan, source); return ni_m_series_set_pfi_routing(dev, chan, source);
else else
return ni_old_set_pfi_routing(dev, chan, source); return ni_old_set_pfi_routing(dev, chan, source);
...@@ -4457,12 +4454,12 @@ static int ni_config_filter(struct comedi_device *dev, ...@@ -4457,12 +4454,12 @@ static int ni_config_filter(struct comedi_device *dev,
unsigned pfi_channel, unsigned pfi_channel,
enum ni_pfi_filter_select filter) enum ni_pfi_filter_select filter)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
unsigned bits; unsigned bits;
if ((board->reg_type & ni_reg_m_series_mask) == 0) if (!devpriv->is_m_series)
return -ENOTSUPP; return -ENOTSUPP;
bits = devpriv->readl(dev, M_Offset_PFI_Filter); bits = devpriv->readl(dev, M_Offset_PFI_Filter);
bits &= ~MSeries_PFI_Filter_Select_Mask(pfi_channel); bits &= ~MSeries_PFI_Filter_Select_Mask(pfi_channel);
bits |= MSeries_PFI_Filter_Select_Bits(pfi_channel, filter); bits |= MSeries_PFI_Filter_Select_Bits(pfi_channel, filter);
...@@ -4516,10 +4513,9 @@ static int ni_pfi_insn_bits(struct comedi_device *dev, ...@@ -4516,10 +4513,9 @@ static int ni_pfi_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
if (!(board->reg_type & ni_reg_m_series_mask)) if (!devpriv->is_m_series)
return -ENOTSUPP; return -ENOTSUPP;
if (comedi_dio_update_state(s, data)) if (comedi_dio_update_state(s, data))
...@@ -4820,7 +4816,6 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, ...@@ -4820,7 +4816,6 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev,
static int ni_set_master_clock(struct comedi_device *dev, static int ni_set_master_clock(struct comedi_device *dev,
unsigned source, unsigned period_ns) unsigned source, unsigned period_ns)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
if (source == NI_MIO_INTERNAL_CLOCK) { if (source == NI_MIO_INTERNAL_CLOCK) {
...@@ -4828,7 +4823,7 @@ static int ni_set_master_clock(struct comedi_device *dev, ...@@ -4828,7 +4823,7 @@ static int ni_set_master_clock(struct comedi_device *dev,
devpriv->stc_writew(dev, devpriv->rtsi_trig_direction_reg, devpriv->stc_writew(dev, devpriv->rtsi_trig_direction_reg,
RTSI_Trig_Direction_Register); RTSI_Trig_Direction_Register);
devpriv->clock_ns = TIMEBASE_1_NS; devpriv->clock_ns = TIMEBASE_1_NS;
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
devpriv->clock_and_fout2 &= devpriv->clock_and_fout2 &=
~(MSeries_Timebase1_Select_Bit | ~(MSeries_Timebase1_Select_Bit |
MSeries_Timebase3_Select_Bit); MSeries_Timebase3_Select_Bit);
...@@ -4838,7 +4833,7 @@ static int ni_set_master_clock(struct comedi_device *dev, ...@@ -4838,7 +4833,7 @@ static int ni_set_master_clock(struct comedi_device *dev,
} }
devpriv->clock_source = source; devpriv->clock_source = source;
} else { } else {
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
return ni_mseries_set_pll_master_clock(dev, source, return ni_mseries_set_pll_master_clock(dev, source,
period_ns); period_ns);
} else { } else {
...@@ -4867,9 +4862,9 @@ static int ni_set_master_clock(struct comedi_device *dev, ...@@ -4867,9 +4862,9 @@ static int ni_set_master_clock(struct comedi_device *dev,
static unsigned num_configurable_rtsi_channels(struct comedi_device *dev) static unsigned num_configurable_rtsi_channels(struct comedi_device *dev)
{ {
const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
return 8; return 8;
else else
return 7; return 7;
...@@ -4878,7 +4873,7 @@ static unsigned num_configurable_rtsi_channels(struct comedi_device *dev) ...@@ -4878,7 +4873,7 @@ static unsigned num_configurable_rtsi_channels(struct comedi_device *dev)
static int ni_valid_rtsi_output_source(struct comedi_device *dev, static int ni_valid_rtsi_output_source(struct comedi_device *dev,
unsigned chan, unsigned source) unsigned chan, unsigned source)
{ {
const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private;
if (chan >= num_configurable_rtsi_channels(dev)) { if (chan >= num_configurable_rtsi_channels(dev)) {
if (chan == old_RTSI_clock_channel) { if (chan == old_RTSI_clock_channel) {
...@@ -4906,7 +4901,7 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev, ...@@ -4906,7 +4901,7 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev,
return 1; return 1;
break; break;
case NI_RTSI_OUTPUT_RTSI_OSC: case NI_RTSI_OUTPUT_RTSI_OSC:
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
return 1; return 1;
else else
return 0; return 0;
...@@ -4963,7 +4958,6 @@ static int ni_rtsi_insn_config(struct comedi_device *dev, ...@@ -4963,7 +4958,6 @@ static int ni_rtsi_insn_config(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
...@@ -4971,8 +4965,7 @@ static int ni_rtsi_insn_config(struct comedi_device *dev, ...@@ -4971,8 +4965,7 @@ static int ni_rtsi_insn_config(struct comedi_device *dev,
case INSN_CONFIG_DIO_OUTPUT: case INSN_CONFIG_DIO_OUTPUT:
if (chan < num_configurable_rtsi_channels(dev)) { if (chan < num_configurable_rtsi_channels(dev)) {
devpriv->rtsi_trig_direction_reg |= devpriv->rtsi_trig_direction_reg |=
RTSI_Output_Bit(chan, RTSI_Output_Bit(chan, devpriv->is_m_series);
(board->reg_type & ni_reg_m_series_mask) != 0);
} else if (chan == old_RTSI_clock_channel) { } else if (chan == old_RTSI_clock_channel) {
devpriv->rtsi_trig_direction_reg |= devpriv->rtsi_trig_direction_reg |=
Drive_RTSI_Clock_Bit; Drive_RTSI_Clock_Bit;
...@@ -4983,8 +4976,7 @@ static int ni_rtsi_insn_config(struct comedi_device *dev, ...@@ -4983,8 +4976,7 @@ static int ni_rtsi_insn_config(struct comedi_device *dev,
case INSN_CONFIG_DIO_INPUT: case INSN_CONFIG_DIO_INPUT:
if (chan < num_configurable_rtsi_channels(dev)) { if (chan < num_configurable_rtsi_channels(dev)) {
devpriv->rtsi_trig_direction_reg &= devpriv->rtsi_trig_direction_reg &=
~RTSI_Output_Bit(chan, ~RTSI_Output_Bit(chan, devpriv->is_m_series);
(board->reg_type & ni_reg_m_series_mask) != 0);
} else if (chan == old_RTSI_clock_channel) { } else if (chan == old_RTSI_clock_channel) {
devpriv->rtsi_trig_direction_reg &= devpriv->rtsi_trig_direction_reg &=
~Drive_RTSI_Clock_Bit; ~Drive_RTSI_Clock_Bit;
...@@ -4996,8 +4988,7 @@ static int ni_rtsi_insn_config(struct comedi_device *dev, ...@@ -4996,8 +4988,7 @@ static int ni_rtsi_insn_config(struct comedi_device *dev,
if (chan < num_configurable_rtsi_channels(dev)) { if (chan < num_configurable_rtsi_channels(dev)) {
data[1] = data[1] =
(devpriv->rtsi_trig_direction_reg & (devpriv->rtsi_trig_direction_reg &
RTSI_Output_Bit(chan, RTSI_Output_Bit(chan, devpriv->is_m_series))
(board->reg_type & ni_reg_m_series_mask) != 0))
? INSN_CONFIG_DIO_OUTPUT ? INSN_CONFIG_DIO_OUTPUT
: INSN_CONFIG_DIO_INPUT; : INSN_CONFIG_DIO_INPUT;
} else if (chan == old_RTSI_clock_channel) { } else if (chan == old_RTSI_clock_channel) {
...@@ -5042,7 +5033,6 @@ static int ni_rtsi_insn_bits(struct comedi_device *dev, ...@@ -5042,7 +5033,6 @@ static int ni_rtsi_insn_bits(struct comedi_device *dev,
static void ni_rtsi_init(struct comedi_device *dev) static void ni_rtsi_init(struct comedi_device *dev)
{ {
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
/* Initialises the RTSI bus signal switch to a default state */ /* Initialises the RTSI bus signal switch to a default state */
...@@ -5068,7 +5058,7 @@ static void ni_rtsi_init(struct comedi_device *dev) ...@@ -5068,7 +5058,7 @@ static void ni_rtsi_init(struct comedi_device *dev)
RTSI_Trig_Output_Bits(5, RTSI_Trig_Output_Bits(5,
NI_RTSI_OUTPUT_G_SRC0) | NI_RTSI_OUTPUT_G_SRC0) |
RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE0); RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE0);
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
devpriv->rtsi_trig_b_output_reg |= devpriv->rtsi_trig_b_output_reg |=
RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC); RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC);
devpriv->stc_writew(dev, devpriv->rtsi_trig_b_output_reg, devpriv->stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
...@@ -5303,7 +5293,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5303,7 +5293,7 @@ static int ni_E_init(struct comedi_device *dev)
s->subdev_flags |= SDF_GROUND | SDF_COMMON | SDF_OTHER; s->subdev_flags |= SDF_GROUND | SDF_COMMON | SDF_OTHER;
if (board->adbits > 16) if (board->adbits > 16)
s->subdev_flags |= SDF_LSAMPL; s->subdev_flags |= SDF_LSAMPL;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
s->subdev_flags |= SDF_SOFT_CALIBRATED; s->subdev_flags |= SDF_SOFT_CALIBRATED;
s->n_chan = board->n_adchan; s->n_chan = board->n_adchan;
s->len_chanlist = 512; s->len_chanlist = 512;
...@@ -5329,7 +5319,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5329,7 +5319,7 @@ static int ni_E_init(struct comedi_device *dev)
if (board->n_aochan) { if (board->n_aochan) {
s->type = COMEDI_SUBD_AO; s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE | SDF_DEGLITCH | SDF_GROUND; s->subdev_flags = SDF_WRITABLE | SDF_DEGLITCH | SDF_GROUND;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
s->subdev_flags |= SDF_SOFT_CALIBRATED; s->subdev_flags |= SDF_SOFT_CALIBRATED;
s->n_chan = board->n_aochan; s->n_chan = board->n_aochan;
s->maxdata = (1 << board->aobits) - 1; s->maxdata = (1 << board->aobits) - 1;
...@@ -5351,7 +5341,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5351,7 +5341,7 @@ static int ni_E_init(struct comedi_device *dev)
s->do_cmd = &ni_ao_cmd; s->do_cmd = &ni_ao_cmd;
s->do_cmdtest = &ni_ao_cmdtest; s->do_cmdtest = &ni_ao_cmdtest;
s->len_chanlist = board->n_aochan; s->len_chanlist = board->n_aochan;
if ((board->reg_type & ni_reg_m_series_mask) == 0) if (!devpriv->is_m_series)
s->munge = ni_ao_munge; s->munge = ni_ao_munge;
} }
s->cancel = &ni_ao_reset; s->cancel = &ni_ao_reset;
...@@ -5370,7 +5360,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5370,7 +5360,7 @@ static int ni_E_init(struct comedi_device *dev)
s->io_bits = 0; /* all bits input */ s->io_bits = 0; /* all bits input */
s->range_table = &range_digital; s->range_table = &range_digital;
s->n_chan = board->num_p0_dio_channels; s->n_chan = board->num_p0_dio_channels;
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
s->subdev_flags |= s->subdev_flags |=
SDF_LSAMPL | SDF_CMD_WRITE /* | SDF_CMD_READ */; SDF_LSAMPL | SDF_CMD_WRITE /* | SDF_CMD_READ */;
s->insn_bits = &ni_m_series_dio_insn_bits; s->insn_bits = &ni_m_series_dio_insn_bits;
...@@ -5410,7 +5400,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5410,7 +5400,7 @@ static int ni_E_init(struct comedi_device *dev)
/* calibration subdevice -- ai and ao */ /* calibration subdevice -- ai and ao */
s = &dev->subdevices[NI_CALIBRATION_SUBDEV]; s = &dev->subdevices[NI_CALIBRATION_SUBDEV];
s->type = COMEDI_SUBD_CALIB; s->type = COMEDI_SUBD_CALIB;
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
/* internal PWM analog output used for AI nonlinearity calibration */ /* internal PWM analog output used for AI nonlinearity calibration */
s->subdev_flags = SDF_INTERNAL; s->subdev_flags = SDF_INTERNAL;
s->insn_config = &ni_m_series_pwm_config; s->insn_config = &ni_m_series_pwm_config;
...@@ -5435,7 +5425,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5435,7 +5425,7 @@ static int ni_E_init(struct comedi_device *dev)
s->type = COMEDI_SUBD_MEMORY; s->type = COMEDI_SUBD_MEMORY;
s->subdev_flags = SDF_READABLE | SDF_INTERNAL; s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
s->maxdata = 0xff; s->maxdata = 0xff;
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
s->n_chan = M_SERIES_EEPROM_SIZE; s->n_chan = M_SERIES_EEPROM_SIZE;
s->insn_read = &ni_m_series_eeprom_insn_read; s->insn_read = &ni_m_series_eeprom_insn_read;
} else { } else {
...@@ -5447,7 +5437,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5447,7 +5437,7 @@ static int ni_E_init(struct comedi_device *dev)
s = &dev->subdevices[NI_PFI_DIO_SUBDEV]; s = &dev->subdevices[NI_PFI_DIO_SUBDEV];
s->type = COMEDI_SUBD_DIO; s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
if (board->reg_type & ni_reg_m_series_mask) { if (devpriv->is_m_series) {
unsigned i; unsigned i;
s->n_chan = 16; s->n_chan = 16;
devpriv->writew(dev, s->state, M_Offset_PFI_DO); devpriv->writew(dev, s->state, M_Offset_PFI_DO);
...@@ -5459,7 +5449,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5459,7 +5449,7 @@ static int ni_E_init(struct comedi_device *dev)
s->n_chan = 10; s->n_chan = 10;
} }
s->maxdata = 1; s->maxdata = 1;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
s->insn_bits = &ni_pfi_insn_bits; s->insn_bits = &ni_pfi_insn_bits;
s->insn_config = &ni_pfi_insn_config; s->insn_config = &ni_pfi_insn_config;
ni_set_bits(dev, IO_Bidirection_Pin_Register, ~0, 0); ni_set_bits(dev, IO_Bidirection_Pin_Register, ~0, 0);
...@@ -5500,7 +5490,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5500,7 +5490,7 @@ static int ni_E_init(struct comedi_device *dev)
s->insn_config = ni_rtsi_insn_config; s->insn_config = ni_rtsi_insn_config;
ni_rtsi_init(dev); ni_rtsi_init(dev);
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
counter_variant = ni_gpct_variant_m_series; counter_variant = ni_gpct_variant_m_series;
else else
counter_variant = ni_gpct_variant_e_series; counter_variant = ni_gpct_variant_e_series;
...@@ -5518,7 +5508,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5518,7 +5508,7 @@ static int ni_E_init(struct comedi_device *dev)
s->type = COMEDI_SUBD_COUNTER; s->type = COMEDI_SUBD_COUNTER;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL;
s->n_chan = 3; s->n_chan = 3;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
s->maxdata = 0xffffffff; s->maxdata = 0xffffffff;
else else
s->maxdata = 0xffffff; s->maxdata = 0xffffff;
...@@ -5592,7 +5582,7 @@ static int ni_E_init(struct comedi_device *dev) ...@@ -5592,7 +5582,7 @@ static int ni_E_init(struct comedi_device *dev)
if (board->reg_type & ni_reg_6xxx_mask) { if (board->reg_type & ni_reg_6xxx_mask) {
devpriv->writeb(dev, 0, Magic_611x); devpriv->writeb(dev, 0, Magic_611x);
} else if (board->reg_type & ni_reg_m_series_mask) { } else if (devpriv->is_m_series) {
int channel; int channel;
for (channel = 0; channel < board->n_aochan; ++channel) { for (channel = 0; channel < board->n_aochan; ++channel) {
devpriv->writeb(dev, 0xf, devpriv->writeb(dev, 0xf,
......
...@@ -1540,6 +1540,8 @@ static int pcimio_auto_attach(struct comedi_device *dev, ...@@ -1540,6 +1540,8 @@ static int pcimio_auto_attach(struct comedi_device *dev,
devpriv->writel = pcimio_writel; devpriv->writel = pcimio_writel;
if (board->reg_type & ni_reg_m_series_mask) { if (board->reg_type & ni_reg_m_series_mask) {
devpriv->is_m_series = 1;
devpriv->stc_writew = m_series_stc_writew; devpriv->stc_writew = m_series_stc_writew;
devpriv->stc_readw = m_series_stc_readw; devpriv->stc_readw = m_series_stc_readw;
devpriv->stc_writel = m_series_stc_writel; devpriv->stc_writel = m_series_stc_writel;
...@@ -1573,7 +1575,7 @@ static int pcimio_auto_attach(struct comedi_device *dev, ...@@ -1573,7 +1575,7 @@ static int pcimio_auto_attach(struct comedi_device *dev,
if (devpriv->gpct_mite_ring[1] == NULL) if (devpriv->gpct_mite_ring[1] == NULL)
return -ENOMEM; return -ENOMEM;
if (board->reg_type & ni_reg_m_series_mask) if (devpriv->is_m_series)
m_series_init_eeprom_buffer(dev); m_series_init_eeprom_buffer(dev);
if (board->reg_type == ni_reg_6143) if (board->reg_type == ni_reg_6143)
init_6143(dev); init_6143(dev);
......
...@@ -1503,6 +1503,8 @@ struct ni_private { ...@@ -1503,6 +1503,8 @@ struct ni_private {
struct mite_dma_descriptor_ring *ao_mite_ring; struct mite_dma_descriptor_ring *ao_mite_ring;
struct mite_dma_descriptor_ring *cdo_mite_ring; struct mite_dma_descriptor_ring *cdo_mite_ring;
struct mite_dma_descriptor_ring *gpct_mite_ring[NUM_GPCT]; struct mite_dma_descriptor_ring *gpct_mite_ring[NUM_GPCT];
unsigned int is_m_series:1;
}; };
#endif /* _COMEDI_NI_STC_H */ #endif /* _COMEDI_NI_STC_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment