提交 fe970e4d 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

staging: comedi: cb_pcidas: refactor 'trimpot' boardinfo

Only the pci-das1602/16 boards have an AD8402 trimpot. The rest of
the boards supported by this driver have an AD7376 trimpot.

Replace the 'enum trimpot_module' in the boardinfo with a bit-field
flag 'has_ad8402' to save a bit of space.
Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: NIan Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 873524c8
...@@ -207,11 +207,6 @@ static const struct comedi_lrange cb_pcidas_ao_ranges = { ...@@ -207,11 +207,6 @@ static const struct comedi_lrange cb_pcidas_ao_ranges = {
} }
}; };
enum trimpot_model {
AD7376,
AD8402,
};
enum cb_pcidas_boardid { enum cb_pcidas_boardid {
BOARD_PCIDAS1602_16, BOARD_PCIDAS1602_16,
BOARD_PCIDAS1200, BOARD_PCIDAS1200,
...@@ -228,11 +223,11 @@ struct cb_pcidas_board { ...@@ -228,11 +223,11 @@ struct cb_pcidas_board {
int ai_speed; /* fastest conversion period in ns */ int ai_speed; /* fastest conversion period in ns */
int ao_scan_speed; /* analog output scan speed for 1602 series */ int ao_scan_speed; /* analog output scan speed for 1602 series */
int fifo_size; /* number of samples fifo can hold */ int fifo_size; /* number of samples fifo can hold */
enum trimpot_model trimpot;
unsigned int is_16bit; /* ai/ao is 1=16-bit; 0=12-bit */ unsigned int is_16bit; /* ai/ao is 1=16-bit; 0=12-bit */
unsigned int use_alt_range:1; /* use alternate ai range table */ unsigned int use_alt_range:1; /* use alternate ai range table */
unsigned int has_ao:1; /* has 2 analog output channels */ unsigned int has_ao:1; /* has 2 analog output channels */
unsigned int has_ao_fifo:1; /* analog output has fifo */ unsigned int has_ao_fifo:1; /* analog output has fifo */
unsigned int has_ad8402:1; /* trimpot type 1=AD8402; 0=AD7376 */
unsigned int has_dac08:1; unsigned int has_dac08:1;
unsigned int is_1602:1; unsigned int is_1602:1;
}; };
...@@ -243,10 +238,10 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -243,10 +238,10 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.ai_speed = 5000, .ai_speed = 5000,
.ao_scan_speed = 10000, .ao_scan_speed = 10000,
.fifo_size = 512, .fifo_size = 512,
.trimpot = AD8402,
.is_16bit = 1, .is_16bit = 1,
.has_ao = 1, .has_ao = 1,
.has_ao_fifo = 1, .has_ao_fifo = 1,
.has_ad8402 = 1,
.has_dac08 = 1, .has_dac08 = 1,
.is_1602 = 1, .is_1602 = 1,
}, },
...@@ -254,7 +249,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -254,7 +249,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.name = "pci-das1200", .name = "pci-das1200",
.ai_speed = 3200, .ai_speed = 3200,
.fifo_size = 1024, .fifo_size = 1024,
.trimpot = AD7376,
.has_ao = 1, .has_ao = 1,
}, },
[BOARD_PCIDAS1602_12] = { [BOARD_PCIDAS1602_12] = {
...@@ -262,7 +256,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -262,7 +256,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.ai_speed = 3200, .ai_speed = 3200,
.ao_scan_speed = 4000, .ao_scan_speed = 4000,
.fifo_size = 1024, .fifo_size = 1024,
.trimpot = AD7376,
.has_ao = 1, .has_ao = 1,
.has_ao_fifo = 1, .has_ao_fifo = 1,
.is_1602 = 1, .is_1602 = 1,
...@@ -271,14 +264,13 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -271,14 +264,13 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.name = "pci-das1200/jr", .name = "pci-das1200/jr",
.ai_speed = 3200, .ai_speed = 3200,
.fifo_size = 1024, .fifo_size = 1024,
.trimpot = AD7376,
}, },
[BOARD_PCIDAS1602_16_JR] = { [BOARD_PCIDAS1602_16_JR] = {
.name = "pci-das1602/16/jr", .name = "pci-das1602/16/jr",
.ai_speed = 5000, .ai_speed = 5000,
.fifo_size = 512, .fifo_size = 512,
.trimpot = AD8402,
.is_16bit = 1, .is_16bit = 1,
.has_ad8402 = 1,
.has_dac08 = 1, .has_dac08 = 1,
.is_1602 = 1, .is_1602 = 1,
}, },
...@@ -286,13 +278,11 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -286,13 +278,11 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.name = "pci-das1000", .name = "pci-das1000",
.ai_speed = 4000, .ai_speed = 4000,
.fifo_size = 1024, .fifo_size = 1024,
.trimpot = AD7376,
}, },
[BOARD_PCIDAS1001] = { [BOARD_PCIDAS1001] = {
.name = "pci-das1001", .name = "pci-das1001",
.ai_speed = 6800, .ai_speed = 6800,
.fifo_size = 1024, .fifo_size = 1024,
.trimpot = AD7376,
.use_alt_range = 1, .use_alt_range = 1,
.has_ao = 1, .has_ao = 1,
}, },
...@@ -300,7 +290,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -300,7 +290,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.name = "pci-das1002", .name = "pci-das1002",
.ai_speed = 6800, .ai_speed = 6800,
.fifo_size = 1024, .fifo_size = 1024,
.trimpot = AD7376,
.has_ao = 1, .has_ao = 1,
}, },
}; };
...@@ -634,12 +623,12 @@ static void cb_pcidas_trimpot_write(struct comedi_device *dev, ...@@ -634,12 +623,12 @@ static void cb_pcidas_trimpot_write(struct comedi_device *dev,
{ {
const struct cb_pcidas_board *board = dev->board_ptr; const struct cb_pcidas_board *board = dev->board_ptr;
if (board->trimpot == AD7376) { if (board->has_ad8402) {
/* write 7-bit value to trimpot */ /* write 10-bit channel/value to AD8402 trimpot */
cb_pcidas_calib_write(dev, val, 7, true);
} else { /* AD8402 */
/* write 10-bit channel/value to trimpot */
cb_pcidas_calib_write(dev, (chan << 8) | val, 10, true); cb_pcidas_calib_write(dev, (chan << 8) | val, 10, true);
} else {
/* write 7-bit value to AD7376 trimpot */
cb_pcidas_calib_write(dev, val, 7, true);
} }
} }
...@@ -1402,17 +1391,18 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, ...@@ -1402,17 +1391,18 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
s = &dev->subdevices[5]; s = &dev->subdevices[5];
s->type = COMEDI_SUBD_CALIB; s->type = COMEDI_SUBD_CALIB;
s->subdev_flags = SDF_WRITABLE | SDF_INTERNAL; s->subdev_flags = SDF_WRITABLE | SDF_INTERNAL;
if (board->trimpot == AD7376) { if (board->has_ad8402) {
s->n_chan = 1;
s->maxdata = 0x7f;
} else { /* AD8402 */
/* /*
* For pci-das1602/16: * pci-das1602/16 have an AD8402 trimpot:
* chan 0 : adc gain * chan 0 : adc gain
* chan 1 : adc postgain offset * chan 1 : adc postgain offset
*/ */
s->n_chan = 2; s->n_chan = 2;
s->maxdata = 0xff; s->maxdata = 0xff;
} else {
/* all other boards have an AD7376 trimpot */
s->n_chan = 1;
s->maxdata = 0x7f;
} }
s->insn_write = cb_pcidas_trimpot_insn_write; s->insn_write = cb_pcidas_trimpot_insn_write;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册