Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 317706
b: refs/heads/master
c: 29f747c
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jul 6, 2012
1 parent 8588451 commit d582d3a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 43 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: 99953ea1ec780c22bacf065fc7c9750f0182c0f4
refs/heads/master: 29f747c21e4318cc41efa82dac217da9ee8d5533
81 changes: 39 additions & 42 deletions trunk/drivers/staging/comedi/drivers/dmm32at.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ Configuration Options:
#define DMM32AT_DIOC 0x0e
#define DMM32AT_DIOCONF 0x0f

#define dmm_outb(cdev, reg, valu) outb(valu, (cdev->iobase)+reg)

/* Board register values. */

/* DMM32AT_DACSTAT 0x04 */
Expand Down Expand Up @@ -221,13 +219,13 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev,
/* printk("channel=0x%02x, range=%d\n",chan,range); */

/* zero scan and fifo control and reset fifo */
dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_FIFORESET);
outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL);

/* write the ai channel range regs */
dmm_outb(dev, DMM32AT_AILOW, chan);
dmm_outb(dev, DMM32AT_AIHIGH, chan);
outb(chan, dev->iobase + DMM32AT_AILOW);
outb(chan, dev->iobase + DMM32AT_AIHIGH);
/* set the range bits */
dmm_outb(dev, DMM32AT_AICONF, dmm32at_rangebits[range]);
outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF);

/* wait for circuit to settle */
for (i = 0; i < 40000; i++) {
Expand All @@ -243,7 +241,7 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev,
/* convert n samples */
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
dmm_outb(dev, DMM32AT_CONV, 0xff);
outb(0xff, dev->iobase + DMM32AT_CONV);
/* wait for conversion to end */
for (i = 0; i < 40000; i++) {
status = inb(dev->iobase + DMM32AT_AISTAT);
Expand Down Expand Up @@ -489,23 +487,22 @@ static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec)
lo2 = both2 & 0x00ff;

/* set the counter frequency to 10mhz */
dmm_outb(dev, DMM32AT_CNTRDIO, 0);
outb(0, dev->iobase + DMM32AT_CNTRDIO);

/* get access to the clock regs */
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_CLKACC);
outb(DMM32AT_CLKACC, dev->iobase + DMM32AT_CNTRL);

/* write the counter 1 control word and low byte to counter */
dmm_outb(dev, DMM32AT_CLKCT, DMM32AT_CLKCT1);
dmm_outb(dev, DMM32AT_CLK1, lo1);
outb(DMM32AT_CLKCT1, dev->iobase + DMM32AT_CLKCT);
outb(lo1, dev->iobase + DMM32AT_CLK1);

/* write the counter 2 control word and low byte then to counter */
dmm_outb(dev, DMM32AT_CLKCT, DMM32AT_CLKCT2);
dmm_outb(dev, DMM32AT_CLK2, lo2);
dmm_outb(dev, DMM32AT_CLK2, hi2);
outb(DMM32AT_CLKCT2, dev->iobase + DMM32AT_CLKCT);
outb(lo2, dev->iobase + DMM32AT_CLK2);
outb(hi2, dev->iobase + DMM32AT_CLK2);

/* enable the ai conversion interrupt and the clock to start scans */
dmm_outb(dev, DMM32AT_INTCLOCK, DMM32AT_ADINT | DMM32AT_CLKSEL);

outb(DMM32AT_ADINT | DMM32AT_CLKSEL, dev->iobase + DMM32AT_INTCLOCK);
}

static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
Expand All @@ -525,20 +522,20 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
range = CR_RANGE(cmd->chanlist[0]);

/* reset fifo */
dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_FIFORESET);
outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL);

/* set scan enable */
dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_SCANENABLE);
outb(DMM32AT_SCANENABLE, dev->iobase + DMM32AT_FIFOCNTRL);

/* write the ai channel range regs */
dmm_outb(dev, DMM32AT_AILOW, chanlo);
dmm_outb(dev, DMM32AT_AIHIGH, chanhi);
outb(chanlo, dev->iobase + DMM32AT_AILOW);
outb(chanhi, dev->iobase + DMM32AT_AIHIGH);

/* set the range bits */
dmm_outb(dev, DMM32AT_AICONF, dmm32at_rangebits[range]);
outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF);

/* reset the interrupt just in case */
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_INTRESET);
outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL);

if (cmd->stop_src == TRIG_COUNT)
devpriv->ai_scans_left = cmd->stop_arg;
Expand All @@ -563,8 +560,8 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
dmm32at_setaitimer(dev, cmd->scan_begin_arg);
} else {
/* start the interrups and initiate a single scan */
dmm_outb(dev, DMM32AT_INTCLOCK, DMM32AT_ADINT);
dmm_outb(dev, DMM32AT_CONV, 0xff);
outb(DMM32AT_ADINT, dev->iobase + DMM32AT_INTCLOCK);
outb(0xff, dev->iobase + DMM32AT_CONV);
}

/* printk("dmmat32 in command\n"); */
Expand Down Expand Up @@ -619,7 +616,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
devpriv->ai_scans_left--;
if (devpriv->ai_scans_left == 0) {
/* disable further interrupts and clocks */
dmm_outb(dev, DMM32AT_INTCLOCK, 0x0);
outb(0x0, dev->iobase + DMM32AT_INTCLOCK);
/* set the buffer to be flushed with an EOF */
s->async->events |= COMEDI_CB_EOA;
}
Expand All @@ -630,7 +627,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
}

/* reset the interrupt */
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_INTRESET);
outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL);
return IRQ_HANDLED;
}

Expand All @@ -654,8 +651,8 @@ static int dmm32at_ao_winsn(struct comedi_device *dev,
hi = (data[i] >> 8) + chan * (1 << 6);
/* printk("writing 0x%02x 0x%02x\n",hi,lo); */
/* write the low and high values to the board */
dmm_outb(dev, DMM32AT_DACLSB, lo);
dmm_outb(dev, DMM32AT_DACMSB, hi);
outb(lo, dev->iobase + DMM32AT_DACLSB);
outb(hi, dev->iobase + DMM32AT_DACMSB);

/* wait for circuit to settle */
for (i = 0; i < 40000; i++) {
Expand Down Expand Up @@ -712,21 +709,21 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev,
}

/* get access to the DIO regs */
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL);

/* if either part of dio is set for output */
if (((devpriv->dio_config & DMM32AT_DIRCL) == 0) ||
((devpriv->dio_config & DMM32AT_DIRCH) == 0)) {
diobits = (s->state & 0x00ff0000) >> 16;
dmm_outb(dev, DMM32AT_DIOC, diobits);
outb(diobits, dev->iobase + DMM32AT_DIOC);
}
if ((devpriv->dio_config & DMM32AT_DIRB) == 0) {
diobits = (s->state & 0x0000ff00) >> 8;
dmm_outb(dev, DMM32AT_DIOB, diobits);
outb(diobits, dev->iobase + DMM32AT_DIOB);
}
if ((devpriv->dio_config & DMM32AT_DIRA) == 0) {
diobits = (s->state & 0x000000ff);
dmm_outb(dev, DMM32AT_DIOA, diobits);
outb(diobits, dev->iobase + DMM32AT_DIOA);
}

/* now read the state back in */
Expand Down Expand Up @@ -777,9 +774,9 @@ static int dmm32at_dio_insn_config(struct comedi_device *dev,
else
devpriv->dio_config |= chanbit;
/* get access to the DIO regs */
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL);
/* set the DIO's to the new configuration setting */
dmm_outb(dev, DMM32AT_DIOCONF, devpriv->dio_config);
outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF);

return 1;
}
Expand Down Expand Up @@ -813,23 +810,23 @@ static int dmm32at_attach(struct comedi_device *dev,
it to a known state */

/* reset the board */
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_RESET);
outb(DMM32AT_RESET, dev->iobase + DMM32AT_CNTRL);

/* allow a millisecond to reset */
udelay(1000);

/* zero scan and fifo control */
dmm_outb(dev, DMM32AT_FIFOCNTRL, 0x0);
outb(0x0, dev->iobase + DMM32AT_FIFOCNTRL);

/* zero interrupt and clock control */
dmm_outb(dev, DMM32AT_INTCLOCK, 0x0);
outb(0x0, dev->iobase + DMM32AT_INTCLOCK);

/* write a test channel range, the high 3 bits should drop */
dmm_outb(dev, DMM32AT_AILOW, 0x80);
dmm_outb(dev, DMM32AT_AIHIGH, 0xff);
outb(0x80, dev->iobase + DMM32AT_AILOW);
outb(0xff, dev->iobase + DMM32AT_AIHIGH);

/* set the range at 10v unipolar */
dmm_outb(dev, DMM32AT_AICONF, DMM32AT_RANGE_U10);
outb(DMM32AT_RANGE_U10, dev->iobase + DMM32AT_AICONF);

/* should take 10 us to settle, here's a hundred */
udelay(100);
Expand Down Expand Up @@ -908,11 +905,11 @@ static int dmm32at_attach(struct comedi_device *dev,
if (board->have_dio) {

/* get access to the DIO regs */
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL);
/* set the DIO's to the defualt input setting */
devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB |
DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE;
dmm_outb(dev, DMM32AT_DIOCONF, devpriv->dio_config);
outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF);

/* set up the subdevice */
s->type = COMEDI_SUBD_DIO;
Expand Down

0 comments on commit d582d3a

Please sign in to comment.