Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337853
b: refs/heads/master
c: f57f797
h: refs/heads/master
i:
  337851: 5606763
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Nov 13, 2012
1 parent 5cd45de commit 4efd4c6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ecc073057330b739920bda32d57ae97f16b14c43
refs/heads/master: f57f797a6cc1d5ad101f90244b936480079c6dab
63 changes: 29 additions & 34 deletions trunk/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,22 @@ You should also find the complete GPL in the COPYING file accompanying this sour
/* Card Specific information */
#define APCI1516_ADDRESS_RANGE 8

/* DIGITAL INPUT-OUTPUT DEFINE */

#define APCI1516_DIGITAL_OP 4
#define APCI1516_DIGITAL_OP_RW 4
#define APCI1516_DIGITAL_IP 0
/*
* PCI bar 1 I/O Register map
*/
#define APCI1516_DI_REG 0x00
#define APCI1516_DO_REG 0x04

/* TIMER COUNTER WATCHDOG DEFINES */
/*
* PCI bar 2 I/O Register map
*/
#define APCI1516_WDOG_REG 0x00
#define APCI1516_WDOG_RELOAD_LSB_REG 0x04
#define APCI1516_WDOG_RELOAD_MSB_REG 0x06
#define APCI1516_WDOG_CTRL_REG 0x0c
#define APCI1516_WDOG_STATUS_REG 0x10

#define ADDIDATA_WATCHDOG 2
#define APCI1516_DIGITAL_OP_WATCHDOG 0
#define APCI1516_WATCHDOG_ENABLEDISABLE 12
#define APCI1516_WATCHDOG_RELOAD_VALUE 4
#define APCI1516_WATCHDOG_STATUS 16

static int apci1516_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
Expand All @@ -72,7 +75,7 @@ static int apci1516_di_insn_bits(struct comedi_device *dev,
{
struct addi_private *devpriv = dev->private;

data[1] = inw(devpriv->iobase + APCI1516_DIGITAL_IP);
data[1] = inw(devpriv->iobase + APCI1516_DI_REG);

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

s->state = inw(devpriv->iobase + APCI1516_DIGITAL_OP_RW);
s->state = inw(devpriv->iobase + APCI1516_DO_REG);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);

outw(s->state, devpriv->iobase + APCI1516_DIGITAL_OP);
outw(s->state, devpriv->iobase + APCI1516_DO_REG);
}

data[1] = s->state;
Expand Down Expand Up @@ -130,17 +133,13 @@ static int i_APCI1516_ConfigWatchdog(struct comedi_device *dev,

if (data[0] == 0) {
/* Disable the watchdog */
outw(0x0,
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_ENABLEDISABLE);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WDOG_CTRL_REG);
/* Loading the Reload value */
outw(data[1],
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_RELOAD_VALUE);
outw(data[1], devpriv->i_IobaseAddon +
APCI1516_WDOG_RELOAD_LSB_REG);
data[1] = data[1] >> 16;
outw(data[1],
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_RELOAD_VALUE + 2);
outw(data[1], devpriv->i_IobaseAddon +
APCI1516_WDOG_RELOAD_MSB_REG);
} /* if(data[0]==0) */
else {
printk("\nThe input parameters are wrong\n");
Expand Down Expand Up @@ -180,17 +179,13 @@ static int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev,

switch (data[0]) {
case 0: /* stop the watchdog */
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WDOG_CTRL_REG);
break;
case 1: /* start the watchdog */
outw(0x0001,
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_ENABLEDISABLE);
outw(0x0001, devpriv->i_IobaseAddon + APCI1516_WDOG_CTRL_REG);
break;
case 2: /* Software trigger */
outw(0x0201,
devpriv->i_IobaseAddon +
APCI1516_WATCHDOG_ENABLEDISABLE);
outw(0x0201, devpriv->i_IobaseAddon + APCI1516_WDOG_CTRL_REG);
break;
default:
printk("\nSpecified functionality does not exist\n");
Expand Down Expand Up @@ -227,7 +222,7 @@ static int i_APCI1516_ReadWatchdog(struct comedi_device *dev,
{
struct addi_private *devpriv = dev->private;

data[0] = inw(devpriv->i_IobaseAddon + APCI1516_WATCHDOG_STATUS) & 0x1;
data[0] = inw(devpriv->i_IobaseAddon + APCI1516_WDOG_STATUS_REG) & 0x1;
return insn->n;
}

Expand All @@ -250,9 +245,9 @@ static int i_APCI1516_Reset(struct comedi_device *dev)
{
struct addi_private *devpriv = dev->private;

outw(0x0, devpriv->iobase + APCI1516_DIGITAL_OP); /* RESETS THE DIGITAL OUTPUTS */
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE + 2);
outw(0x0, devpriv->iobase + APCI1516_DO_REG);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WDOG_CTRL_REG);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WDOG_RELOAD_LSB_REG);
outw(0x0, devpriv->i_IobaseAddon + APCI1516_WDOG_RELOAD_MSB_REG);
return 0;
}

0 comments on commit 4efd4c6

Please sign in to comment.