staging: comedi: addi_apci_3501: start defining i/o map
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 23 Jan 2013 19:43:35 +0000 (12:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Jan 2013 20:00:30 +0000 (12:00 -0800)
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>
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
drivers/staging/comedi/drivers/addi_apci_3501.c

index f7098533d16a15c98f3499685c84ba8c3c6a0392..bbdda4ec523ce8908efc692d923ec9834021fe16 100644 (file)
@@ -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
 
@@ -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;
@@ -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;
        }
 
@@ -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;
index d345daa00f482d67b5c046f01d18844b0e2644f4..6207622467a6520e2a9ee5ca94ea253dcd0eb4ae 100644 (file)
@@ -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;
@@ -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;
 }
@@ -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;
@@ -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;
                }
 
@@ -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);
                }
        }