devpriv->tsk_current = current;
if (data[0] == ADDIDATA_TIMER) {
/* First Stop The Timer */
- ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG);
+ ul_Command1 = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG);
ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
/* Stop The Timer */
- outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ outl(ul_Command1, devpriv->timer + APCI1564_TIMER_CTRL_REG);
devpriv->timer_select_mode = ADDIDATA_TIMER;
if (data[1] == 1) {
/* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
- outl(0x02, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ outl(0x02, devpriv->timer + APCI1564_TIMER_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);
devpriv->counters + APCI1564_COUNTER_IRQ_REG(2));
} else {
/* disable Timer interrupt */
- outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG);
}
/* Loading Timebase */
- outl(data[2], dev->iobase + APCI1564_TIMER_TIMEBASE_REG);
+ outl(data[2], devpriv->timer + APCI1564_TIMER_TIMEBASE_REG);
/* Loading the Reload value */
- outl(data[3], dev->iobase + APCI1564_TIMER_RELOAD_REG);
+ outl(data[3], devpriv->timer + APCI1564_TIMER_RELOAD_REG);
- ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG);
+ ul_Command1 = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG);
ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL;
/* mode 2 */
- outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ outl(ul_Command1, devpriv->timer + APCI1564_TIMER_CTRL_REG);
} else if (data[0] == ADDIDATA_COUNTER) {
devpriv->timer_select_mode = ADDIDATA_COUNTER;
if (devpriv->timer_select_mode == ADDIDATA_TIMER) {
if (data[1] == 1) {
- ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG);
+ ul_Command1 = inl(devpriv->timer +
+ APCI1564_TIMER_CTRL_REG);
ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
/* Enable the Timer */
- outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ outl(ul_Command1,
+ devpriv->timer + APCI1564_TIMER_CTRL_REG);
} else if (data[1] == 0) {
/* Stop The Timer */
- ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG);
+ ul_Command1 = inl(devpriv->timer +
+ APCI1564_TIMER_CTRL_REG);
ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
- outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ outl(ul_Command1,
+ devpriv->timer + APCI1564_TIMER_CTRL_REG);
}
} else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) {
ul_Command1 = inl(devpriv->counters +
if (devpriv->timer_select_mode == ADDIDATA_TIMER) {
/* Stores the status of the Timer */
- data[0] = inl(dev->iobase + APCI1564_TIMER_STATUS_REG) & 0x1;
+ data[0] = inl(devpriv->timer + APCI1564_TIMER_STATUS_REG) & 0x1;
/* Stores the Actual value of the Timer */
- data[1] = inl(dev->iobase + APCI1564_TIMER_REG);
+ data[1] = inl(devpriv->timer + APCI1564_TIMER_REG);
} else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) {
/* Read the Counter Actual Value. */
data[0] = inl(devpriv->counters +
#define APCI1564_EEPROM_DO (1 << 2)
#define APCI1564_EEPROM_CS (1 << 1)
#define APCI1564_EEPROM_CLK (1 << 0)
+#define APCI1564_REV1_TIMER_IOBASE 0x04
#define APCI1564_REV2_MAIN_IOBASE 0x04
+#define APCI1564_REV2_TIMER_IOBASE 0x48
/*
* PCI BAR 1
#define APCI1564_WDOG_IRQ_REG 0x38
#define APCI1564_WDOG_WARN_TIMEVAL_REG 0x3c
#define APCI1564_WDOG_WARN_TIMEBASE_REG 0x40
-#define APCI1564_TIMER_REG 0x44
-#define APCI1564_TIMER_RELOAD_REG 0x48
-#define APCI1564_TIMER_TIMEBASE_REG 0x4c
-#define APCI1564_TIMER_CTRL_REG 0x50
-#define APCI1564_TIMER_STATUS_REG 0x54
-#define APCI1564_TIMER_IRQ_REG 0x58
-#define APCI1564_TIMER_WARN_TIMEVAL_REG 0x5c /* Rev 2.x only */
-#define APCI1564_TIMER_WARN_TIMEBASE_REG 0x60 /* Rev 2.x only */
+/*
+ * devpriv->timer Register Map
+ * 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 */
struct apci1564_private {
unsigned long eeprom; /* base address of EEPROM register */
+ unsigned long timer; /* base address of 12-bit timer */
unsigned long counters; /* base address of 32-bit counters */
unsigned int mode1; /* riding-edge/high level channels */
unsigned int mode2; /* falling-edge/low level channels */
addi_watchdog_reset(dev->iobase + APCI1564_WDOG_REG);
/* Reset the timer registers */
- outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG);
- outl(0x0, dev->iobase + APCI1564_TIMER_RELOAD_REG);
+ outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG);
+ outl(0x0, devpriv->timer + APCI1564_TIMER_RELOAD_REG);
/* Reset the counter registers */
outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0));
outl(status, dev->iobase + APCI1564_DI_IRQ_REG);
}
- status = inl(dev->iobase + APCI1564_TIMER_IRQ_REG);
+ status = inl(devpriv->timer + APCI1564_TIMER_IRQ_REG);
if (status & 0x01) {
/* Disable Timer Interrupt */
- ctrl = inl(dev->iobase + APCI1564_TIMER_CTRL_REG);
- outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG);
+ outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG);
/* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_current, 0);
/* Enable Timer Interrupt */
- outl(ctrl, dev->iobase + APCI1564_TIMER_CTRL_REG);
+ outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG);
}
for (chan = 0; chan < 4; chan++) {
/* PLD Revision 1.0 I/O Mapping */
dev->iobase = pci_resource_start(pcidev, 1) +
APCI1564_REV1_MAIN_IOBASE;
+ devpriv->timer = devpriv->eeprom + APCI1564_REV1_TIMER_IOBASE;
dev_err(dev->class_dev,
"PLD Revision 1.0 detected, not yet supported\n");
return -ENXIO;
} else {
/* PLD Revision 2.x I/O Mapping */
dev->iobase = devpriv->eeprom + APCI1564_REV2_MAIN_IOBASE;
+ devpriv->timer = devpriv->eeprom + APCI1564_REV2_TIMER_IOBASE;
devpriv->counters = pci_resource_start(pcidev, 1);
}