Commit 5790b427 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: comedi_parport: tidy up the register map

Rename the register map defines to better describe the hardware.

Add defines for the control register bits that enable the irq and
change the direction of the data register. This gets rid of the
"magic" numbers.

Remove PARPORT_SIZE, it's only used when requesting the i/o region
with comedi_request_region().
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6ea79c1d
...@@ -82,11 +82,14 @@ pin, which can be used to wake up tasks. ...@@ -82,11 +82,14 @@ pin, which can be used to wake up tasks.
#include "comedi_fc.h" #include "comedi_fc.h"
#define PARPORT_SIZE 3 /*
* Register map
#define PARPORT_A 0 */
#define PARPORT_B 1 #define PARPORT_DATA_REG 0x00
#define PARPORT_C 2 #define PARPORT_STATUS_REG 0x01
#define PARPORT_CTRL_REG 0x02
#define PARPORT_CTRL_IRQ_ENA (1 << 4)
#define PARPORT_CTRL_BIDIR_ENA (1 << 5)
struct parport_private { struct parport_private {
unsigned int a_data; unsigned int a_data;
...@@ -103,10 +106,10 @@ static int parport_insn_a(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -103,10 +106,10 @@ static int parport_insn_a(struct comedi_device *dev, struct comedi_subdevice *s,
devpriv->a_data &= ~data[0]; devpriv->a_data &= ~data[0];
devpriv->a_data |= (data[0] & data[1]); devpriv->a_data |= (data[0] & data[1]);
outb(devpriv->a_data, dev->iobase + PARPORT_A); outb(devpriv->a_data, dev->iobase + PARPORT_DATA_REG);
} }
data[1] = inb(dev->iobase + PARPORT_A); data[1] = inb(dev->iobase + PARPORT_DATA_REG);
return insn->n; return insn->n;
} }
...@@ -119,12 +122,12 @@ static int parport_insn_config_a(struct comedi_device *dev, ...@@ -119,12 +122,12 @@ static int parport_insn_config_a(struct comedi_device *dev,
if (data[0]) { if (data[0]) {
s->io_bits = 0xff; s->io_bits = 0xff;
devpriv->c_data &= ~(1 << 5); devpriv->c_data &= ~PARPORT_CTRL_BIDIR_ENA;
} else { } else {
s->io_bits = 0; s->io_bits = 0;
devpriv->c_data |= (1 << 5); devpriv->c_data |= PARPORT_CTRL_BIDIR_ENA;
} }
outb(devpriv->c_data, dev->iobase + PARPORT_C); outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG);
return 1; return 1;
} }
...@@ -137,7 +140,7 @@ static int parport_insn_b(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -137,7 +140,7 @@ static int parport_insn_b(struct comedi_device *dev, struct comedi_subdevice *s,
/* anyone??? */ /* anyone??? */
} }
data[1] = (inb(dev->iobase + PARPORT_B) >> 3); data[1] = (inb(dev->iobase + PARPORT_STATUS_REG) >> 3);
return insn->n; return insn->n;
} }
...@@ -152,7 +155,7 @@ static int parport_insn_c(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -152,7 +155,7 @@ static int parport_insn_c(struct comedi_device *dev, struct comedi_subdevice *s,
devpriv->c_data &= ~data[0]; devpriv->c_data &= ~data[0];
devpriv->c_data |= (data[0] & data[1]); devpriv->c_data |= (data[0] & data[1]);
outb(devpriv->c_data, dev->iobase + PARPORT_C); outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG);
} }
data[1] = devpriv->c_data & 0xf; data[1] = devpriv->c_data & 0xf;
...@@ -215,8 +218,8 @@ static int parport_intr_cmd(struct comedi_device *dev, ...@@ -215,8 +218,8 @@ static int parport_intr_cmd(struct comedi_device *dev,
{ {
struct parport_private *devpriv = dev->private; struct parport_private *devpriv = dev->private;
devpriv->c_data |= 0x10; devpriv->c_data |= PARPORT_CTRL_IRQ_ENA;
outb(devpriv->c_data, dev->iobase + PARPORT_C); outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG);
devpriv->enable_irq = 1; devpriv->enable_irq = 1;
...@@ -228,8 +231,8 @@ static int parport_intr_cancel(struct comedi_device *dev, ...@@ -228,8 +231,8 @@ static int parport_intr_cancel(struct comedi_device *dev,
{ {
struct parport_private *devpriv = dev->private; struct parport_private *devpriv = dev->private;
devpriv->c_data &= ~0x10; devpriv->c_data &= ~PARPORT_CTRL_IRQ_ENA;
outb(devpriv->c_data, dev->iobase + PARPORT_C); outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG);
devpriv->enable_irq = 0; devpriv->enable_irq = 0;
...@@ -260,7 +263,7 @@ static int parport_attach(struct comedi_device *dev, ...@@ -260,7 +263,7 @@ static int parport_attach(struct comedi_device *dev,
unsigned int irq; unsigned int irq;
int ret; int ret;
ret = comedi_request_region(dev, it->options[0], PARPORT_SIZE); ret = comedi_request_region(dev, it->options[0], 0x03);
if (ret) if (ret)
return ret; return ret;
...@@ -325,9 +328,9 @@ static int parport_attach(struct comedi_device *dev, ...@@ -325,9 +328,9 @@ static int parport_attach(struct comedi_device *dev,
} }
devpriv->a_data = 0; devpriv->a_data = 0;
outb(devpriv->a_data, dev->iobase + PARPORT_A); outb(devpriv->a_data, dev->iobase + PARPORT_DATA_REG);
devpriv->c_data = 0; devpriv->c_data = 0;
outb(devpriv->c_data, dev->iobase + PARPORT_C); outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment