[PATCH 12/15] staging: comedi: addi_apci_1564: use addi_tcw.h defines for timer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the generic TCW (timer/counter/watchdog) defines for the 12-bit timer.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 .../comedi/drivers/addi-data/hwdrv_apci1564.c      | 24 +++++++++++-----------
 drivers/staging/comedi/drivers/addi_apci_1564.c    | 23 ++++++++-------------
 2 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index 23bc8de..2f403e5 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -28,14 +28,14 @@ static int apci1564_timer_insn_config(struct comedi_device *dev,
 	devpriv->tsk_current = current;
 
 	/* First Stop The Timer */
-	ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG);
+	ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG);
 	ctrl &= 0xfffff9fe;
 	/* Stop The Timer */
-	outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+	outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG);
 
 	if (data[1] == 1) {
 		/* Enable timer int & disable all the other int sources */
-		outl(0x02, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+		outl(0x02, devpriv->timer + ADDI_TCW_CTRL_REG);
 		outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG);
 		outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG);
 		outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG);
@@ -49,20 +49,20 @@ static int apci1564_timer_insn_config(struct comedi_device *dev,
 		}
 	} else {
 		/* disable Timer interrupt */
-		outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+		outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG);
 	}
 
 	/* Loading Timebase */
-	outl(data[2], devpriv->timer + APCI1564_TIMER_TIMEBASE_REG);
+	outl(data[2], devpriv->timer + ADDI_TCW_TIMEBASE_REG);
 
 	/* Loading the Reload value */
-	outl(data[3], devpriv->timer + APCI1564_TIMER_RELOAD_REG);
+	outl(data[3], devpriv->timer + ADDI_TCW_RELOAD_REG);
 
-	ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG);
+	ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG);
 	ctrl &= 0xfff719e2;
 	ctrl |= (2 << 13) | 0x10;
 	/* mode 2 */
-	outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+	outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG);
 
 	return insn->n;
 }
@@ -75,7 +75,7 @@ static int apci1564_timer_insn_write(struct comedi_device *dev,
 	struct apci1564_private *devpriv = dev->private;
 	unsigned int ctrl;
 
-	ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG);
+	ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG);
 	switch (data[1]) {
 	case 0:	/* Stop The Timer */
 		ctrl &= 0xfffff9fe;
@@ -85,7 +85,7 @@ static int apci1564_timer_insn_write(struct comedi_device *dev,
 		ctrl |= 0x1;
 		break;
 	}
-	outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+	outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG);
 
 	return insn->n;
 }
@@ -98,10 +98,10 @@ static int apci1564_timer_insn_read(struct comedi_device *dev,
 	struct apci1564_private *devpriv = dev->private;
 
 	/* Stores the status of the Timer */
-	data[0] = inl(devpriv->timer + APCI1564_TIMER_STATUS_REG) & 0x1;
+	data[0] = inl(devpriv->timer + ADDI_TCW_STATUS_REG) & 0x1;
 
 	/* Stores the Actual value of the Timer */
-	data[1] = inl(devpriv->timer + APCI1564_TIMER_REG);
+	data[1] = inl(devpriv->timer + ADDI_TCW_VAL_REG);
 
 	return insn->n;
 }
diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c
index 359880d..d47904e 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1564.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1564.c
@@ -28,6 +28,7 @@
 
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "addi_tcw.h"
 #include "addi_watchdog.h"
 
 /*
@@ -94,18 +95,10 @@
 #define APCI1564_WDOG_WARN_TIMEBASE_REG		0x40
 
 /*
- * devpriv->timer Register Map
+ * devpriv->timer Register Map (see addi_tcw.h for register/bit defines)
  *   PLD Revision 1.0 - PCI BAR 0 + 0x04
  *   PLD Revision 2.x - PCI BAR 0 + 0x48
  */
-#define APCI1564_TIMER_REG			0x00
-#define APCI1564_TIMER_RELOAD_REG		0x04
-#define APCI1564_TIMER_TIMEBASE_REG		0x08
-#define APCI1564_TIMER_CTRL_REG			0x0c
-#define APCI1564_TIMER_STATUS_REG		0x10
-#define APCI1564_TIMER_IRQ_REG			0x14
-#define APCI1564_TIMER_WARN_TIMEVAL_REG		0x18  /* Rev 2.x only */
-#define APCI1564_TIMER_WARN_TIMEBASE_REG	0x1c  /* Rev 2.x only */
 
 /*
  * devpriv->counters Register Map
@@ -150,8 +143,8 @@ static int apci1564_reset(struct comedi_device *dev)
 	addi_watchdog_reset(dev->iobase + APCI1564_WDOG_REG);
 
 	/* Reset the timer registers */
-	outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG);
-	outl(0x0, devpriv->timer + APCI1564_TIMER_RELOAD_REG);
+	outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG);
+	outl(0x0, devpriv->timer + ADDI_TCW_RELOAD_REG);
 
 	if (devpriv->counters) {
 		/* Reset the counter registers */
@@ -187,17 +180,17 @@ static irqreturn_t apci1564_interrupt(int irq, void *d)
 		outl(status, dev->iobase + APCI1564_DI_IRQ_REG);
 	}
 
-	status = inl(devpriv->timer + APCI1564_TIMER_IRQ_REG);
+	status = inl(devpriv->timer + ADDI_TCW_IRQ_REG);
 	if (status & 0x01) {
 		/*  Disable Timer Interrupt */
-		ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG);
-		outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+		ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG);
+		outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG);
 
 		/* Send a signal to from kernel to user space */
 		send_sig(SIGIO, devpriv->tsk_current, 0);
 
 		/*  Enable Timer Interrupt */
-		outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+		outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG);
 	}
 
 	if (devpriv->counters) {
-- 
2.0.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux