Skip to content

Commit

Permalink
staging: comedi: addi_apci_3501: start defining i/o map
Browse files Browse the repository at this point in the history
Create, and use, defines for the analog output and digital i/o
registers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jan 25, 2013
1 parent 015aebe commit 1bc5062
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
24 changes: 4 additions & 20 deletions drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,7 @@ You should also find the complete GPL in the COPYING file accompanying this sour
+----------+-----------+------------------------------------------------+
*/

/* Card Specific information */
#define APCI3501_ADDRESS_RANGE 255

#define APCI3501_DIGITAL_IP 0x50
#define APCI3501_DIGITAL_OP 0x40
#define APCI3501_ANALOG_OUTPUT 0x00

/* Analog Output related Defines */
#define APCI3501_AO_VOLT_MODE 0
#define APCI3501_AO_PROG 4
#define APCI3501_AO_TRIG_SCS 8
#define UNIPOLAR 0
#define BIPOLAR 1
#define MODE0 0
#define MODE1 1

Expand Down Expand Up @@ -117,9 +105,7 @@ static int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev,
{
struct apci3501_private *devpriv = dev->private;

outl(data[0],
dev->iobase + APCI3501_ANALOG_OUTPUT +
APCI3501_AO_VOLT_MODE);
outl(data[0], dev->iobase + APCI3501_AO_CTRL_STATUS_REG);

if (data[0]) {
devpriv->b_InterruptMode = MODE1;
Expand Down Expand Up @@ -181,10 +167,10 @@ static int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev,
printk("\nIn WriteAnalogOutput :: Not Valid Channel\n");
} /* end if((ul_Channel_no<0)||(ul_Channel_no>7)) */

ul_DAC_Ready = inl(dev->iobase + APCI3501_ANALOG_OUTPUT);
ul_DAC_Ready = inl(dev->iobase + APCI3501_AO_CTRL_STATUS_REG);

while (ul_DAC_Ready == 0) {
ul_DAC_Ready = inl(dev->iobase + APCI3501_ANALOG_OUTPUT);
ul_DAC_Ready = inl(dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
ul_DAC_Ready = (ul_DAC_Ready >> 8) & 1;
}

Expand All @@ -194,9 +180,7 @@ static int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev,
(unsigned int) ((unsigned int) (ul_Channel_no & 0xFF) |
(unsigned int) ((*data << 0x8) & 0x7FFFFF00L) |
(unsigned int) (ul_Polarity));
outl(ul_Command1,
dev->iobase + APCI3501_ANALOG_OUTPUT +
APCI3501_AO_PROG);
outl(ul_Command1, dev->iobase + APCI3501_AO_DATA_REG);
}

return insn->n;
Expand Down
30 changes: 19 additions & 11 deletions drivers/staging/comedi/drivers/addi_apci_3501.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
#include "comedi_fc.h"
#include "amcc_s5933.h"

/*
* PCI bar 1 register I/O map
*/
#define APCI3501_AO_CTRL_STATUS_REG 0x00
#define APCI3501_AO_CTRL_BIPOLAR (1 << 0)
#define APCI3501_AO_STATUS_READY (1 << 8)
#define APCI3501_AO_DATA_REG 0x04
#define APCI3501_AO_TRIG_SCS_REG 0x08
#define APCI3501_DO_REG 0x40
#define APCI3501_DI_REG 0x50

struct apci3501_private {
int i_IobaseAmcc;
struct task_struct *tsk_Current;
Expand Down Expand Up @@ -36,7 +47,7 @@ static int apci3501_di_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
data[1] = inl(dev->iobase + APCI3501_DIGITAL_IP) & 0x3;
data[1] = inl(dev->iobase + APCI3501_DI_REG) & 0x3;

return insn->n;
}
Expand All @@ -49,12 +60,12 @@ static int apci3501_do_insn_bits(struct comedi_device *dev,
unsigned int mask = data[0];
unsigned int bits = data[1];

s->state = inl(dev->iobase + APCI3501_DIGITAL_OP);
s->state = inl(dev->iobase + APCI3501_DO_REG);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);

outl(s->state, dev->iobase + APCI3501_DIGITAL_OP);
outl(s->state, dev->iobase + APCI3501_DO_REG);
}

data[1] = s->state;
Expand Down Expand Up @@ -193,18 +204,17 @@ static int apci3501_reset(struct comedi_device *dev)
int i_Count = 0, i_temp = 0;
unsigned int ul_Command1 = 0, ul_Polarity, ul_DAC_Ready = 0;

outl(0x0, dev->iobase + APCI3501_DIGITAL_OP);
outl(1, dev->iobase + APCI3501_ANALOG_OUTPUT +
APCI3501_AO_VOLT_MODE);
outl(0x0, dev->iobase + APCI3501_DO_REG);
outl(1, dev->iobase + APCI3501_AO_CTRL_STATUS_REG);

ul_Polarity = 0x80000000;

for (i_Count = 0; i_Count <= 7; i_Count++) {
ul_DAC_Ready = inl(dev->iobase + APCI3501_ANALOG_OUTPUT);
ul_DAC_Ready = inl(dev->iobase + APCI3501_AO_CTRL_STATUS_REG);

while (ul_DAC_Ready == 0) {
ul_DAC_Ready =
inl(dev->iobase + APCI3501_ANALOG_OUTPUT);
inl(dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
ul_DAC_Ready = (ul_DAC_Ready >> 8) & 1;
}

Expand All @@ -214,9 +224,7 @@ static int apci3501_reset(struct comedi_device *dev)
(unsigned int) ((unsigned int) (i_Count & 0xFF) |
(unsigned int) ((i_temp << 0x8) & 0x7FFFFF00L) |
(unsigned int) (ul_Polarity));
outl(ul_Command1,
dev->iobase + APCI3501_ANALOG_OUTPUT +
APCI3501_AO_PROG);
outl(ul_Command1, dev->iobase + APCI3501_AO_DATA_REG);
}
}

Expand Down

0 comments on commit 1bc5062

Please sign in to comment.