Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | /*
* das6402.c
* Comedi driver for DAS6402 compatible boards
* Copyright(c) 2014 H Hartley Sweeten <hsweeten@visionengravers.com>
*
* Rewrite of an experimental driver by:
* Copyright (C) 1999 Oystein Svendsen <svendsen@pvv.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*
* Driver: das6402
* Description: Keithley Metrabyte DAS6402 (& compatibles)
* Devices: [Keithley Metrabyte] DAS6402-12 (das6402-12),
* DAS6402-16 (das6402-16)
* Author: H Hartley Sweeten <hsweeten@visionengravers.com>
* Updated: Fri, 14 Mar 2014 10:18:43 -0700
* Status: unknown
*
* Configuration Options:
* [0] - I/O base address
* [1] - IRQ (optional, needed for async command support)
*/
#include <linux/module.h>
#include <linux/interrupt.h>
#include "../comedidev.h"
#include "comedi_8254.h"
/*
* Register I/O map
*/
#define DAS6402_AI_DATA_REG 0x00
#define DAS6402_AI_MUX_REG 0x02
#define DAS6402_AI_MUX_LO(x) (((x) & 0x3f) << 0)
#define DAS6402_AI_MUX_HI(x) (((x) & 0x3f) << 8)
#define DAS6402_DI_DO_REG 0x03
#define DAS6402_AO_DATA_REG(x) (0x04 + ((x) * 2))
#define DAS6402_AO_LSB_REG(x) (0x04 + ((x) * 2))
#define DAS6402_AO_MSB_REG(x) (0x05 + ((x) * 2))
#define DAS6402_STATUS_REG 0x08
#define DAS6402_STATUS_FFNE (1 << 0)
#define DAS6402_STATUS_FHALF (1 << 1)
#define DAS6402_STATUS_FFULL (1 << 2)
#define DAS6402_STATUS_XINT (1 << 3)
#define DAS6402_STATUS_INT (1 << 4)
#define DAS6402_STATUS_XTRIG (1 << 5)
#define DAS6402_STATUS_INDGT (1 << 6)
#define DAS6402_STATUS_10MHZ (1 << 7)
#define DAS6402_STATUS_W_CLRINT (1 << 0)
#define DAS6402_STATUS_W_CLRXTR (1 << 1)
#define DAS6402_STATUS_W_CLRXIN (1 << 2)
#define DAS6402_STATUS_W_EXTEND (1 << 4)
#define DAS6402_STATUS_W_ARMED (1 << 5)
#define DAS6402_STATUS_W_POSTMODE (1 << 6)
#define DAS6402_STATUS_W_10MHZ (1 << 7)
#define DAS6402_CTRL_REG 0x09
#define DAS6402_CTRL_SOFT_TRIG (0 << 0)
#define DAS6402_CTRL_EXT_FALL_TRIG (1 << 0)
#define DAS6402_CTRL_EXT_RISE_TRIG (2 << 0)
#define DAS6402_CTRL_PACER_TRIG (3 << 0)
#define DAS6402_CTRL_BURSTEN (1 << 2)
#define DAS6402_CTRL_XINTE (1 << 3)
#define DAS6402_CTRL_IRQ(x) ((x) << 4)
#define DAS6402_CTRL_INTE (1 << 7)
#define DAS6402_TRIG_REG 0x0a
#define DAS6402_TRIG_TGEN (1 << 0)
#define DAS6402_TRIG_TGSEL (1 << 1)
#define DAS6402_TRIG_TGPOL (1 << 2)
#define DAS6402_TRIG_PRETRIG (1 << 3)
#define DAS6402_AO_RANGE(_chan, _range) ((_range) << ((_chan) ? 6 : 4))
#define DAS6402_AO_RANGE_MASK(_chan) (3 << ((_chan) ? 6 : 4))
#define DAS6402_MODE_REG 0x0b
#define DAS6402_MODE_RANGE(x) ((x) << 0)
#define DAS6402_MODE_POLLED (0 << 2)
#define DAS6402_MODE_FIFONEPTY (1 << 2)
#define DAS6402_MODE_FIFOHFULL (2 << 2)
#define DAS6402_MODE_EOB (3 << 2)
#define DAS6402_MODE_ENHANCED (1 << 4)
#define DAS6402_MODE_SE (1 << 5)
#define DAS6402_MODE_UNI (1 << 6)
#define DAS6402_MODE_DMA1 (0 << 7)
#define DAS6402_MODE_DMA3 (1 << 7)
#define DAS6402_TIMER_BASE 0x0c
static const struct comedi_lrange das6402_ai_ranges = {
8, {
BIP_RANGE(10),
BIP_RANGE(5),
BIP_RANGE(2.5),
BIP_RANGE(1.25),
UNI_RANGE(10),
UNI_RANGE(5),
UNI_RANGE(2.5),
UNI_RANGE(1.25)
}
};
/*
* Analog output ranges are programmable on the DAS6402/12.
* For the DAS6402/16 the range bits have no function, the
* DAC ranges are selected by switches on the board.
*/
static const struct comedi_lrange das6402_ao_ranges = {
4, {
BIP_RANGE(5),
BIP_RANGE(10),
UNI_RANGE(5),
UNI_RANGE(10)
}
};
struct das6402_boardinfo {
const char *name;
unsigned int maxdata;
};
static struct das6402_boardinfo das6402_boards[] = {
{
.name = "das6402-12",
.maxdata = 0x0fff,
}, {
.name = "das6402-16",
.maxdata = 0xffff,
},
};
struct das6402_private {
unsigned int irq;
unsigned int ao_range;
};
static void das6402_set_mode(struct comedi_device *dev,
unsigned int mode)
{
outb(DAS6402_MODE_ENHANCED | mode, dev->iobase + DAS6402_MODE_REG);
}
static void das6402_set_extended(struct comedi_device *dev,
unsigned int val)
{
outb(DAS6402_STATUS_W_EXTEND, dev->iobase + DAS6402_STATUS_REG);
outb(DAS6402_STATUS_W_EXTEND | val, dev->iobase + DAS6402_STATUS_REG);
outb(val, dev->iobase + DAS6402_STATUS_REG);
}
static void das6402_clear_all_interrupts(struct comedi_device *dev)
{
outb(DAS6402_STATUS_W_CLRINT |
DAS6402_STATUS_W_CLRXTR |
DAS6402_STATUS_W_CLRXIN, dev->iobase + DAS6402_STATUS_REG);
}
static void das6402_ai_clear_eoc(struct comedi_device *dev)
{
outb(DAS6402_STATUS_W_CLRINT, dev->iobase + DAS6402_STATUS_REG);
}
static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
struct comedi_subdevice *s)
{
unsigned int val;
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
if (s->maxdata == 0x0fff)
val >>= 4;
return val;
}
static irqreturn_t das6402_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int status;
status = inb(dev->iobase + DAS6402_STATUS_REG);
if ((status & DAS6402_STATUS_INT) == 0)
return IRQ_NONE;
if (status & DAS6402_STATUS_FFULL) {
async->events |= COMEDI_CB_OVERFLOW;
} else if (status & DAS6402_STATUS_FFNE) {
unsigned int val;
val = das6402_ai_read_sample(dev, s);
comedi_buf_write_samples(s, &val, 1);
if (cmd->stop_src == TRIG_COUNT &&
async->scans_done >= cmd->stop_arg)
async->events |= COMEDI_CB_EOA;
}
das6402_clear_all_interrupts(dev);
comedi_handle_events(dev, s);
return IRQ_HANDLED;
}
static void das6402_ai_set_mode(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int chanspec,
unsigned int mode)
{
unsigned int range = CR_RANGE(chanspec);
unsigned int aref = CR_AREF(chanspec);
mode |= DAS6402_MODE_RANGE(range);
if (aref == AREF_GROUND)
mode |= DAS6402_MODE_SE;
if (comedi_range_is_unipolar(s, range))
mode |= DAS6402_MODE_UNI;
das6402_set_mode(dev, mode);
}
static int das6402_ai_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
struct das6402_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int chan_lo = CR_CHAN(cmd->chanlist[0]);
unsigned int chan_hi = CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]);
das6402_ai_set_mode(dev, s, cmd->chanlist[0], DAS6402_MODE_FIFONEPTY);
/* load the mux for chanlist conversion */
outw(DAS6402_AI_MUX_HI(chan_hi) | DAS6402_AI_MUX_LO(chan_lo),
dev->iobase + DAS6402_AI_MUX_REG);
comedi_8254_update_divisors(dev->pacer);
comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
/* enable interrupt and pacer trigger */
outb(DAS6402_CTRL_INTE |
DAS6402_CTRL_IRQ(devpriv->irq) |
DAS6402_CTRL_PACER_TRIG, dev->iobase + DAS6402_CTRL_REG);
return 0;
}
static int das6402_ai_check_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
int i;
for (i = 1; i < cmd->chanlist_len; i++) {
unsigned int chan = CR_CHAN(cmd->chanlist[i]);
unsigned int range = CR_RANGE(cmd->chanlist[i]);
unsigned int aref = CR_AREF(cmd->chanlist[i]);
if (chan != chan0 + i) {
dev_dbg(dev->class_dev,
"chanlist must be consecutive\n");
return -EINVAL;
}
if (range != range0) {
dev_dbg(dev->class_dev,
"chanlist must have the same range\n");
return -EINVAL;
}
if (aref != aref0) {
dev_dbg(dev->class_dev,
"chanlist must have the same reference\n");
return -EINVAL;
}
if (aref0 == AREF_DIFF && chan > (s->n_chan / 2)) {
dev_dbg(dev->class_dev,
"chanlist differential channel to large\n");
return -EINVAL;
}
}
return 0;
}
static int das6402_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
int err = 0;
unsigned int arg;
/* Step 1 : check if triggers are trivially valid */
err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
if (err)
return 1;
/* Step 2a : make sure trigger sources are unique */
err |= comedi_check_trigger_is_unique(cmd->stop_src);
/* Step 2b : and mutually compatible */
if (err)
return 2;
/* Step 3: check if arguments are trivially valid */
err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
cmd->chanlist_len);
if (cmd->stop_src == TRIG_COUNT)
err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
else /* TRIG_NONE */
err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
if (err)
return 3;
/* step 4: fix up any arguments */
arg = cmd->convert_arg;
comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
if (err)
return 4;
/* Step 5: check channel list if it exists */
if (cmd->chanlist && cmd->chanlist_len > 0)
err |= das6402_ai_check_chanlist(dev, s, cmd);
if (err)
return 5;
return 0;
}
static int das6402_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
outb(DAS6402_CTRL_SOFT_TRIG, dev->iobase + DAS6402_CTRL_REG);
return 0;
}
static void das6402_ai_soft_trig(struct comedi_device *dev)
{
outw(0, dev->iobase + DAS6402_AI_DATA_REG);
}
static int das6402_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inb(dev->iobase + DAS6402_STATUS_REG);
if (status & DAS6402_STATUS_FFNE)
return 0;
return -EBUSY;
}
static int das6402_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int aref = CR_AREF(insn->chanspec);
int ret;
int i;
if (aref == AREF_DIFF && chan > (s->n_chan / 2))
return -EINVAL;
/* enable software conversion trigger */
outb(DAS6402_CTRL_SOFT_TRIG, dev->iobase + DAS6402_CTRL_REG);
das6402_ai_set_mode(dev, s, insn->chanspec, DAS6402_MODE_POLLED);
/* load the mux for single channel conversion */
outw(DAS6402_AI_MUX_HI(chan) | DAS6402_AI_MUX_LO(chan),
dev->iobase + DAS6402_AI_MUX_REG);
for (i = 0; i < insn->n; i++) {
das6402_ai_clear_eoc(dev);
das6402_ai_soft_trig(dev);
ret = comedi_timeout(dev, s, insn, das6402_ai_eoc, 0);
if (ret)
break;
data[i] = das6402_ai_read_sample(dev, s);
}
das6402_ai_clear_eoc(dev);
return insn->n;
}
static int das6402_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct das6402_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec);
unsigned int val;
int i;
/* set the range for this channel */
val = devpriv->ao_range;
val &= ~DAS6402_AO_RANGE_MASK(chan);
val |= DAS6402_AO_RANGE(chan, range);
if (val != devpriv->ao_range) {
devpriv->ao_range = val;
outb(val, dev->iobase + DAS6402_TRIG_REG);
}
/*
* The DAS6402/16 has a jumper to select either individual
* update (UPDATE) or simultaneous updating (XFER) of both
* DAC's. In UPDATE mode, when the MSB is written, that DAC
* is updated. In XFER mode, after both DAC's are loaded,
* a read cycle of any DAC register will update both DAC's
* simultaneously.
*
* If you have XFER mode enabled a (*insn_read) will need
* to be performed in order to update the DAC's with the
* last value written.
*/
for (i = 0; i < insn->n; i++) {
val = data[i];
s->readback[chan] = val;
if (s->maxdata == 0x0fff) {
/*
* DAS6402/12 has the two 8-bit DAC registers, left
* justified (the 4 LSB bits are don't care). Data
* can be written as one word.
*/
val <<= 4;
outw(val, dev->iobase + DAS6402_AO_DATA_REG(chan));
} else {
/*
* DAS6402/16 uses both 8-bit DAC registers and needs
* to be written LSB then MSB.
*/
outb(val & 0xff,
dev->iobase + DAS6402_AO_LSB_REG(chan));
outb((val >> 8) & 0xff,
dev->iobase + DAS6402_AO_LSB_REG(chan));
}
}
return insn->n;
}
static int das6402_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
/*
* If XFER mode is enabled, reading any DAC register
* will update both DAC's simultaneously.
*/
inw(dev->iobase + DAS6402_AO_LSB_REG(chan));
return comedi_readback_insn_read(dev, s, insn, data);
}
static int das6402_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
data[1] = inb(dev->iobase + DAS6402_DI_DO_REG);
return insn->n;
}
static int das6402_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
if (comedi_dio_update_state(s, data))
outb(s->state, dev->iobase + DAS6402_DI_DO_REG);
data[1] = s->state;
return insn->n;
}
static void das6402_reset(struct comedi_device *dev)
{
struct das6402_private *devpriv = dev->private;
/* enable "Enhanced" mode */
outb(DAS6402_MODE_ENHANCED, dev->iobase + DAS6402_MODE_REG);
/* enable 10MHz pacer clock */
das6402_set_extended(dev, DAS6402_STATUS_W_10MHZ);
/* enable software conversion trigger */
outb(DAS6402_CTRL_SOFT_TRIG, dev->iobase + DAS6402_CTRL_REG);
/* default ADC to single-ended unipolar 10V inputs */
das6402_set_mode(dev, DAS6402_MODE_RANGE(0) |
DAS6402_MODE_POLLED |
DAS6402_MODE_SE |
DAS6402_MODE_UNI);
/* default mux for single channel conversion (channel 0) */
outw(DAS6402_AI_MUX_HI(0) | DAS6402_AI_MUX_LO(0),
dev->iobase + DAS6402_AI_MUX_REG);
/* set both DAC's for unipolar 5V output range */
devpriv->ao_range = DAS6402_AO_RANGE(0, 2) | DAS6402_AO_RANGE(1, 2);
outb(devpriv->ao_range, dev->iobase + DAS6402_TRIG_REG);
/* set both DAC's to 0V */
outw(0, dev->iobase + DAS6402_AO_DATA_REG(0));
outw(0, dev->iobase + DAS6402_AO_DATA_REG(0));
inw(dev->iobase + DAS6402_AO_LSB_REG(0));
/* set all digital outputs low */
outb(0, dev->iobase + DAS6402_DI_DO_REG);
das6402_clear_all_interrupts(dev);
}
static int das6402_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
const struct das6402_boardinfo *board = dev->board_ptr;
struct das6402_private *devpriv;
struct comedi_subdevice *s;
int ret;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
ret = comedi_request_region(dev, it->options[0], 0x10);
if (ret)
return ret;
das6402_reset(dev);
/* IRQs 2,3,5,6,7, 10,11,15 are valid for "enhanced" mode */
if ((1 << it->options[1]) & 0x8cec) {
ret = request_irq(it->options[1], das6402_interrupt, 0,
dev->board_name, dev);
if (ret == 0) {
dev->irq = it->options[1];
switch (dev->irq) {
case 10:
devpriv->irq = 4;
break;
case 11:
devpriv->irq = 1;
break;
case 15:
devpriv->irq = 6;
break;
default:
devpriv->irq = dev->irq;
break;
}
}
}
dev->pacer = comedi_8254_init(dev->iobase + DAS6402_TIMER_BASE,
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
if (!dev->pacer)
return -ENOMEM;
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
return ret;
/* Analog Input subdevice */
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
s->n_chan = 64;
s->maxdata = board->maxdata;
s->range_table = &das6402_ai_ranges;
s->insn_read = das6402_ai_insn_read;
if (dev->irq) {
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
s->len_chanlist = s->n_chan;
s->do_cmdtest = das6402_ai_cmdtest;
s->do_cmd = das6402_ai_cmd;
s->cancel = das6402_ai_cancel;
}
/* Analog Output subdevice */
s = &dev->subdevices[1];
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 2;
s->maxdata = board->maxdata;
s->range_table = &das6402_ao_ranges;
s->insn_write = das6402_ao_insn_write;
s->insn_read = das6402_ao_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
/* Digital Input subdevice */
s = &dev->subdevices[2];
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
s->n_chan = 8;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = das6402_di_insn_bits;
/* Digital Input subdevice */
s = &dev->subdevices[3];
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 8;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = das6402_do_insn_bits;
return 0;
}
static struct comedi_driver das6402_driver = {
.driver_name = "das6402",
.module = THIS_MODULE,
.attach = das6402_attach,
.detach = comedi_legacy_detach,
.board_name = &das6402_boards[0].name,
.num_names = ARRAY_SIZE(das6402_boards),
.offset = sizeof(struct das6402_boardinfo),
};
module_comedi_driver(das6402_driver)
MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>");
MODULE_DESCRIPTION("Comedi driver for DAS6402 compatible boards");
MODULE_LICENSE("GPL");
|