Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bc5062a authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: addi_apci_3501: start defining i/o map



Create, and use, defines for the analog output and digital i/o
registers.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 015aebe7
Loading
Loading
Loading
Loading
+4 −20
Original line number Diff line number Diff line
@@ -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;
+19 −11
Original line number Diff line number Diff line
@@ -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);
		}
	}