[PATCH 02/14] staging: comedi: daqboard2000: define macros for CPLD registers

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

 



The Daqboard/2000 uses a write-only data register and a read-only status
register in a pre-programmed CPLD device to program the main firmware on
the board.  Both registers are at offset 0x1000 from PCI BAR 2.  Define
macros for the register offsets.  Rename the existing macros for the
status register values for consistency.  (Two status bits are defined,
but the driver code only seems to use one of them.)

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/daqboard2000.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index b23a9feb975c..954a1a536fb4 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -116,10 +116,6 @@
 #define DAQBOARD2000_SUBSYSTEM_IDS2	0x0002	/* Daqboard/2000 - 2 Dacs */
 #define DAQBOARD2000_SUBSYSTEM_IDS4	0x0004	/* Daqboard/2000 - 4 Dacs */
 
-/* CPLD status bits */
-#define DAQBOARD2000_CPLD_INIT		0x0002
-#define DAQBOARD2000_CPLD_DONE		0x0004
-
 static const struct comedi_lrange range_daqboard2000_ai = {
 	13, {
 		BIP_RANGE(10),
@@ -173,6 +169,10 @@ static const struct comedi_lrange range_daqboard2000_ai = {
 #define DB2K_REG_TRIG_DACS			0xbc		/* u16 */
 #define DB2K_REG_DIO_P2_EXP_IO_16_BIT(x)	(0xc0 + (x) * 2) /* s16 */
 
+/* CPLD registers */
+#define DB2K_REG_CPLD_STATUS			0x1000		/* u16 (r) */
+#define DB2K_REG_CPLD_WDATA			0x1000		/* u16 (w) */
+
 /* Scan Sequencer programming */
 #define DB2K_ACQ_CONTROL_SEQ_START_SCAN_LIST		0x0011
 #define DB2K_ACQ_CONTROL_SEQ_STOP_SCAN_LIST		0x0010
@@ -238,6 +238,10 @@ static const struct comedi_lrange range_daqboard2000_ai = {
 #define DB2K_REF_DACS_SELECT_POS_REF			0x0100
 #define DB2K_REF_DACS_SELECT_NEG_REF			0x0000
 
+/* CPLD status bits */
+#define DB2K_CPLD_STATUS_INIT				0x0002
+#define DB2K_CPLD_STATUS_TXDONE				0x0004
+
 struct daq200_boardtype {
 	const char *name;
 	int id;
@@ -474,7 +478,7 @@ static int daqboard2000_poll_cpld(struct comedi_device *dev, int mask)
 
 	/* timeout after 50 tries -> 5ms */
 	for (i = 0; i < 50; i++) {
-		cpld = readw(dev->mmio + 0x1000);
+		cpld = readw(dev->mmio + DB2K_REG_CPLD_STATUS);
 		if ((cpld & mask) == mask) {
 			result = 1;
 			break;
@@ -490,11 +494,10 @@ static int daqboard2000_write_cpld(struct comedi_device *dev, int data)
 	int result = 0;
 
 	usleep_range(10, 20);
-	writew(data, dev->mmio + 0x1000);
-	if ((readw(dev->mmio + 0x1000) & DAQBOARD2000_CPLD_INIT) ==
-	    DAQBOARD2000_CPLD_INIT) {
+	writew(data, dev->mmio + DB2K_REG_CPLD_WDATA);
+	if (readw(dev->mmio + DB2K_REG_CPLD_STATUS) & DB2K_CPLD_STATUS_INIT)
 		result = 1;
-	}
+
 	return result;
 }
 
@@ -517,7 +520,7 @@ static int daqboard2000_load_firmware(struct comedi_device *dev,
 		daqboard2000_reset_local_bus(dev);
 		daqboard2000_reload_plx(dev);
 		daqboard2000_pulse_prog_pin(dev);
-		if (daqboard2000_poll_cpld(dev, DAQBOARD2000_CPLD_INIT)) {
+		if (daqboard2000_poll_cpld(dev, DB2K_CPLD_STATUS_INIT)) {
 			for (i = 0; i < len; i++) {
 				if (cpld_array[i] == 0xff &&
 				    cpld_array[i + 1] == 0x20)
-- 
2.11.0

_______________________________________________
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