#define DT3000_CHANNEL_MODE_DI 1
struct dt3k_private {
- void __iomem *io_addr;
unsigned int lock;
unsigned int ao_readback[2];
unsigned int ai_front;
static void dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd)
{
- struct dt3k_private *devpriv = dev->private;
int i;
unsigned int status = 0;
- writew(cmd, devpriv->io_addr + DPR_Command_Mbx);
+ writew(cmd, dev->mmio + DPR_Command_Mbx);
for (i = 0; i < TIMEOUT; i++) {
- status = readw(devpriv->io_addr + DPR_Command_Mbx);
+ status = readw(dev->mmio + DPR_Command_Mbx);
if ((status & DT3000_COMPLETION_MASK) != DT3000_NOTPROCESSED)
break;
udelay(1);
unsigned int subsys, unsigned int chan,
unsigned int gain)
{
- struct dt3k_private *devpriv = dev->private;
-
- writew(subsys, devpriv->io_addr + DPR_SubSys);
+ writew(subsys, dev->mmio + DPR_SubSys);
- writew(chan, devpriv->io_addr + DPR_Params(0));
- writew(gain, devpriv->io_addr + DPR_Params(1));
+ writew(chan, dev->mmio + DPR_Params(0));
+ writew(gain, dev->mmio + DPR_Params(1));
dt3k_send_cmd(dev, CMD_READSINGLE);
- return readw(devpriv->io_addr + DPR_Params(2));
+ return readw(dev->mmio + DPR_Params(2));
}
static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys,
unsigned int chan, unsigned int data)
{
- struct dt3k_private *devpriv = dev->private;
-
- writew(subsys, devpriv->io_addr + DPR_SubSys);
+ writew(subsys, dev->mmio + DPR_SubSys);
- writew(chan, devpriv->io_addr + DPR_Params(0));
- writew(0, devpriv->io_addr + DPR_Params(1));
- writew(data, devpriv->io_addr + DPR_Params(2));
+ writew(chan, dev->mmio + DPR_Params(0));
+ writew(0, dev->mmio + DPR_Params(1));
+ writew(data, dev->mmio + DPR_Params(2));
dt3k_send_cmd(dev, CMD_WRITESINGLE);
}
int i;
unsigned short data;
- front = readw(devpriv->io_addr + DPR_AD_Buf_Front);
+ front = readw(dev->mmio + DPR_AD_Buf_Front);
count = front - devpriv->ai_front;
if (count < 0)
count += AI_FIFO_DEPTH;
rear = devpriv->ai_rear;
for (i = 0; i < count; i++) {
- data = readw(devpriv->io_addr + DPR_ADC_buffer + rear);
+ data = readw(dev->mmio + DPR_ADC_buffer + rear);
comedi_buf_put(s, data);
rear++;
if (rear >= AI_FIFO_DEPTH)
}
devpriv->ai_rear = rear;
- writew(rear, devpriv->io_addr + DPR_AD_Buf_Rear);
+ writew(rear, dev->mmio + DPR_AD_Buf_Rear);
}
-static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dt3k_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
- struct dt3k_private *devpriv = dev->private;
-
- writew(SUBS_AI, devpriv->io_addr + DPR_SubSys);
+ writew(SUBS_AI, dev->mmio + DPR_SubSys);
dt3k_send_cmd(dev, CMD_STOP);
- writew(0, devpriv->io_addr + DPR_Int_Mask);
+ writew(0, dev->mmio + DPR_Int_Mask);
return 0;
}
static irqreturn_t dt3k_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- struct dt3k_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
unsigned int status;
if (!dev->attached)
return IRQ_NONE;
- status = readw(devpriv->io_addr + DPR_Intr_Flag);
+ status = readw(dev->mmio + DPR_Intr_Flag);
if (status & DT3000_ADFULL) {
dt3k_ai_empty_fifo(dev, s);
static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
- struct dt3k_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int i;
unsigned int chan, range, aref;
chan = CR_CHAN(cmd->chanlist[i]);
range = CR_RANGE(cmd->chanlist[i]);
- writew((range << 6) | chan,
- devpriv->io_addr + DPR_ADC_buffer + i);
+ writew((range << 6) | chan, dev->mmio + DPR_ADC_buffer + i);
}
aref = CR_AREF(cmd->chanlist[0]);
- writew(cmd->scan_end_arg, devpriv->io_addr + DPR_Params(0));
+ writew(cmd->scan_end_arg, dev->mmio + DPR_Params(0));
if (cmd->convert_src == TRIG_TIMER) {
divider = dt3k_ns_to_timer(50, &cmd->convert_arg, cmd->flags);
- writew((divider >> 16), devpriv->io_addr + DPR_Params(1));
- writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2));
+ writew((divider >> 16), dev->mmio + DPR_Params(1));
+ writew((divider & 0xffff), dev->mmio + DPR_Params(2));
}
if (cmd->scan_begin_src == TRIG_TIMER) {
tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
cmd->flags);
- writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3));
- writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4));
+ writew((tscandiv >> 16), dev->mmio + DPR_Params(3));
+ writew((tscandiv & 0xffff), dev->mmio + DPR_Params(4));
}
mode = DT3000_AD_RETRIG_INTERNAL | 0 | 0;
- writew(mode, devpriv->io_addr + DPR_Params(5));
- writew(aref == AREF_DIFF, devpriv->io_addr + DPR_Params(6));
+ writew(mode, dev->mmio + DPR_Params(5));
+ writew(aref == AREF_DIFF, dev->mmio + DPR_Params(6));
- writew(AI_FIFO_DEPTH / 2, devpriv->io_addr + DPR_Params(7));
+ writew(AI_FIFO_DEPTH / 2, dev->mmio + DPR_Params(7));
- writew(SUBS_AI, devpriv->io_addr + DPR_SubSys);
+ writew(SUBS_AI, dev->mmio + DPR_SubSys);
dt3k_send_cmd(dev, CMD_CONFIG);
writew(DT3000_ADFULL | DT3000_ADSWERR | DT3000_ADHWERR,
- devpriv->io_addr + DPR_Int_Mask);
+ dev->mmio + DPR_Int_Mask);
debug_n_ints = 0;
- writew(SUBS_AI, devpriv->io_addr + DPR_SubSys);
+ writew(SUBS_AI, dev->mmio + DPR_SubSys);
dt3k_send_cmd(dev, CMD_START);
return 0;
static void dt3k_dio_config(struct comedi_device *dev, int bits)
{
- struct dt3k_private *devpriv = dev->private;
-
/* XXX */
- writew(SUBS_DOUT, devpriv->io_addr + DPR_SubSys);
+ writew(SUBS_DOUT, dev->mmio + DPR_SubSys);
- writew(bits, devpriv->io_addr + DPR_Params(0));
+ writew(bits, dev->mmio + DPR_Params(0));
#if 0
/* don't know */
- writew(0, devpriv->io_addr + DPR_Params(1));
- writew(0, devpriv->io_addr + DPR_Params(2));
+ writew(0, dev->mmio + DPR_Params(1));
+ writew(0, dev->mmio + DPR_Params(2));
#endif
dt3k_send_cmd(dev, CMD_CONFIG);
static int dt3k_mem_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- struct dt3k_private *devpriv = dev->private;
unsigned int addr = CR_CHAN(insn->chanspec);
int i;
for (i = 0; i < insn->n; i++) {
- writew(SUBS_MEM, devpriv->io_addr + DPR_SubSys);
- writew(addr, devpriv->io_addr + DPR_Params(0));
- writew(1, devpriv->io_addr + DPR_Params(1));
+ writew(SUBS_MEM, dev->mmio + DPR_SubSys);
+ writew(addr, dev->mmio + DPR_Params(0));
+ writew(1, dev->mmio + DPR_Params(1));
dt3k_send_cmd(dev, CMD_READCODE);
- data[i] = readw(devpriv->io_addr + DPR_Params(2));
+ data[i] = readw(dev->mmio + DPR_Params(2));
}
return i;
if (ret < 0)
return ret;
- devpriv->io_addr = pci_ioremap_bar(pcidev, 0);
- if (!devpriv->io_addr)
+ dev->mmio = pci_ioremap_bar(pcidev, 0);
+ if (!dev->mmio)
return -ENOMEM;
if (pcidev->irq) {
static void dt3000_detach(struct comedi_device *dev)
{
- struct dt3k_private *devpriv = dev->private;
-
if (dev->irq)
free_irq(dev->irq, dev);
- if (devpriv) {
- if (devpriv->io_addr)
- iounmap(devpriv->io_addr);
- }
+ if (dev->mmio)
+ iounmap(dev->mmio);
comedi_pci_disable(dev);
}