Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 318000
b: refs/heads/master
c: d254eb7
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jul 17, 2012
1 parent 3f5c0fd commit 9d61c25
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 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: b70ac75eeff0fb1f356924e58f6f543c9b3d3077
refs/heads/master: d254eb7418e389e063831d8d77b7dac240288f02
55 changes: 29 additions & 26 deletions trunk/drivers/staging/comedi/drivers/dt282x.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,8 @@ struct dt282x_private {
* Some useless abstractions
*/
#define chan_to_DAC(a) ((a)&1)
#define update_dacsr(a) outw(devpriv->dacsr|(a), dev->iobase+DT2821_DACSR)
#define update_adcsr(a) outw(devpriv->adcsr|(a), dev->iobase+DT2821_ADCSR)
#define mux_busy() (inw(dev->iobase+DT2821_ADCSR)&DT2821_MUXBUSY)
#define ad_done() (inw(dev->iobase+DT2821_ADCSR)&DT2821_ADDONE)
#define update_supcsr(a) outw(devpriv->supcsr|(a), dev->iobase+DT2821_SUPCSR)

/*
* danger! macro abuse... a is the expression to wait on, and b is
Expand Down Expand Up @@ -317,7 +314,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
int i;
struct comedi_subdevice *s = dev->subdevices + 1;

update_supcsr(DT2821_CLRDMADNE);
outw(devpriv->supcsr | DT2821_CLRDMADNE, dev->iobase + DT2821_SUPCSR);

if (!s->async->prealloc_buf) {
printk(KERN_ERR "async->data disappeared. dang!\n");
Expand Down Expand Up @@ -350,7 +347,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
int ret;
struct comedi_subdevice *s = dev->subdevices;

update_supcsr(DT2821_CLRDMADNE);
outw(devpriv->supcsr | DT2821_CLRDMADNE, dev->iobase + DT2821_SUPCSR);

if (!s->async->prealloc_buf) {
printk(KERN_ERR "async->data disappeared. dang!\n");
Expand Down Expand Up @@ -387,7 +384,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
/* XXX probably wrong */
if (!devpriv->ntrig) {
devpriv->supcsr &= ~(DT2821_DDMA);
update_supcsr(0);
outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}
#endif
/* restart the channel */
Expand Down Expand Up @@ -513,7 +510,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
s->async->events |= COMEDI_CB_EOA;
} else {
if (supcsr & DT2821_SCDN)
update_supcsr(DT2821_STRIG);
outw(devpriv->supcsr | DT2821_STRIG,
dev->iobase + DT2821_SUPCSR);
}
handled = 1;
}
Expand All @@ -534,7 +532,8 @@ static void dt282x_load_changain(struct comedi_device *dev, int n,
for (i = 0; i < n; i++) {
chan = CR_CHAN(chanlist[i]);
range = CR_RANGE(chanlist[i]);
update_adcsr((range << 4) | (chan));
outw(devpriv->adcsr | (range << 4) | chan,
dev->iobase + DT2821_ADCSR);
}
outw(n - 1, dev->iobase + DT2821_CHANCSR);
}
Expand All @@ -553,15 +552,16 @@ static int dt282x_ai_insn_read(struct comedi_device *dev,

/* XXX should we really be enabling the ad clock here? */
devpriv->adcsr = DT2821_ADCLK;
update_adcsr(0);
outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR);

dt282x_load_changain(dev, 1, &insn->chanspec);

update_supcsr(DT2821_PRLD);
outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR);
wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);

for (i = 0; i < insn->n; i++) {
update_supcsr(DT2821_STRIG);
outw(devpriv->supcsr | DT2821_STRIG,
dev->iobase + DT2821_SUPCSR);
wait_for(ad_done(), comedi_error(dev, "timeout\n");
return -ETIME;);

Expand Down Expand Up @@ -718,7 +718,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* external trigger */
devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0 | DT2821_DS1;
}
update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT);
outw(devpriv->supcsr | DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT,
dev->iobase + DT2821_SUPCSR);

devpriv->ntrig = cmd->stop_arg * cmd->scan_end_arg;
devpriv->nread = devpriv->ntrig;
Expand All @@ -729,24 +730,25 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->ntrig) {
prep_ai_dma(dev, 1, 0);
devpriv->supcsr |= DT2821_DDMA;
update_supcsr(0);
outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}

devpriv->adcsr = 0;

dt282x_load_changain(dev, cmd->chanlist_len, cmd->chanlist);

devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE;
update_adcsr(0);
outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR);

update_supcsr(DT2821_PRLD);
outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR);
wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);

if (cmd->scan_begin_src == TRIG_FOLLOW) {
update_supcsr(DT2821_STRIG);
outw(devpriv->supcsr | DT2821_STRIG,
dev->iobase + DT2821_SUPCSR);
} else {
devpriv->supcsr |= DT2821_XTRIG;
update_supcsr(0);
outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}

return 0;
Expand All @@ -766,10 +768,10 @@ static int dt282x_ai_cancel(struct comedi_device *dev,
dt282x_disable_dma(dev);

devpriv->adcsr = 0;
update_adcsr(0);
outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR);

devpriv->supcsr = 0;
update_supcsr(DT2821_ADCINIT);
outw(devpriv->supcsr | DT2821_ADCINIT, dev->iobase + DT2821_SUPCSR);

return 0;
}
Expand Down Expand Up @@ -845,11 +847,11 @@ static int dt282x_ao_insn_write(struct comedi_device *dev,
d ^= (1 << (boardtype.dabits - 1));
}

update_dacsr(0);
outw(devpriv->dacsr, dev->iobase + DT2821_DACSR);

outw(d, dev->iobase + DT2821_DADAT);

update_supcsr(DT2821_DACON);
outw(devpriv->supcsr | DT2821_DACON, dev->iobase + DT2821_SUPCSR);

return 1;
}
Expand Down Expand Up @@ -972,7 +974,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev,
}
prep_ao_dma(dev, 1, size);

update_supcsr(DT2821_STRIG);
outw(devpriv->supcsr | DT2821_STRIG, dev->iobase + DT2821_SUPCSR);
s->async->inttrig = NULL;

return 1;
Expand All @@ -993,7 +995,8 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
dt282x_disable_dma(dev);

devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS1 | DT2821_DDMA;
update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_DACINIT);
outw(devpriv->supcsr | DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_DACINIT,
dev->iobase + DT2821_SUPCSR);

devpriv->ntrig = cmd->stop_arg * cmd->chanlist_len;
devpriv->nread = devpriv->ntrig;
Expand All @@ -1005,7 +1008,7 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
outw(timer, dev->iobase + DT2821_TMRCTR);

devpriv->dacsr = DT2821_SSEL | DT2821_DACLK | DT2821_IDARDY;
update_dacsr(0);
outw(devpriv->dacsr, dev->iobase + DT2821_DACSR);

s->async->inttrig = dt282x_ao_inttrig;

Expand All @@ -1018,10 +1021,10 @@ static int dt282x_ao_cancel(struct comedi_device *dev,
dt282x_disable_dma(dev);

devpriv->dacsr = 0;
update_dacsr(0);
outw(devpriv->dacsr, dev->iobase + DT2821_DACSR);

devpriv->supcsr = 0;
update_supcsr(DT2821_DACINIT);
outw(devpriv->supcsr | DT2821_DACINIT, dev->iobase + DT2821_SUPCSR);

return 0;
}
Expand Down

0 comments on commit 9d61c25

Please sign in to comment.