Commit 1d7f14dd authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: daqboard2000: use macros from "plx9080.h"

The Daqboard/2000 uses a PLX PCI-9080 chip to interface with the PCI
bus.  The "daqboard2000" driver uses the PCI-9080 "CNTRL" register to
perform various tasks, but defines its own macros for the register
values.  Use the macros from "plx9080.h" instead.  The various functions
that change the CNTRL register just wiggle individual bits up and down,
but they ignore the current register value - the old macros defined the
full value to be written to the register.  Change them to read and
modify the register value.

Also remove a read of the CNTRL register in `daqboard2000_auto_attach()`
where the value is just thrown away, as it seems to serve no purpose
there (such as flushing PCI writes).
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 168400d0
...@@ -109,23 +109,13 @@ ...@@ -109,23 +109,13 @@
#include "../comedi_pci.h" #include "../comedi_pci.h"
#include "8255.h" #include "8255.h"
#include "plx9080.h"
#define DAQBOARD2000_FIRMWARE "daqboard2000_firmware.bin" #define DAQBOARD2000_FIRMWARE "daqboard2000_firmware.bin"
#define DAQBOARD2000_SUBSYSTEM_IDS2 0x0002 /* Daqboard/2000 - 2 Dacs */ #define DAQBOARD2000_SUBSYSTEM_IDS2 0x0002 /* Daqboard/2000 - 2 Dacs */
#define DAQBOARD2000_SUBSYSTEM_IDS4 0x0004 /* Daqboard/2000 - 4 Dacs */ #define DAQBOARD2000_SUBSYSTEM_IDS4 0x0004 /* Daqboard/2000 - 4 Dacs */
/* Initialization bits for the Serial EEPROM Control Register */
#define DB2K_SECR_PROG_PIN_HI 0x8001767e
#define DB2K_SECR_PROG_PIN_LO 0x8000767e
#define DB2K_SECR_LOCAL_BUS_HI 0xc000767e
#define DB2K_SECR_LOCAL_BUS_LO 0x8000767e
#define DB2K_SECR_RELOAD_HI 0xa000767e
#define DB2K_SECR_RELOAD_LO 0x8000767e
/* SECR status bits */
#define DAQBOARD2000_EEPROM_PRESENT 0x10000000
/* CPLD status bits */ /* CPLD status bits */
#define DAQBOARD2000_CPLD_INIT 0x0002 #define DAQBOARD2000_CPLD_INIT 0x0002
#define DAQBOARD2000_CPLD_DONE 0x0004 #define DAQBOARD2000_CPLD_DONE 0x0004
...@@ -434,32 +424,45 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, ...@@ -434,32 +424,45 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev,
static void daqboard2000_reset_local_bus(struct comedi_device *dev) static void daqboard2000_reset_local_bus(struct comedi_device *dev)
{ {
struct daqboard2000_private *devpriv = dev->private; struct daqboard2000_private *devpriv = dev->private;
u32 cntrl;
writel(DB2K_SECR_LOCAL_BUS_HI, devpriv->plx + 0x6c); cntrl = readl(devpriv->plx + PLX_REG_CNTRL);
cntrl |= PLX_CNTRL_RESET;
writel(cntrl, devpriv->plx + PLX_REG_CNTRL);
mdelay(10); mdelay(10);
writel(DB2K_SECR_LOCAL_BUS_LO, devpriv->plx + 0x6c); cntrl &= ~PLX_CNTRL_RESET;
writel(cntrl, devpriv->plx + PLX_REG_CNTRL);
mdelay(10); mdelay(10);
} }
static void daqboard2000_reload_plx(struct comedi_device *dev) static void daqboard2000_reload_plx(struct comedi_device *dev)
{ {
struct daqboard2000_private *devpriv = dev->private; struct daqboard2000_private *devpriv = dev->private;
u32 cntrl;
writel(DB2K_SECR_RELOAD_LO, devpriv->plx + 0x6c); cntrl = readl(devpriv->plx + PLX_REG_CNTRL);
cntrl &= ~PLX_CNTRL_EERELOAD;
writel(cntrl, devpriv->plx + PLX_REG_CNTRL);
mdelay(10); mdelay(10);
writel(DB2K_SECR_RELOAD_HI, devpriv->plx + 0x6c); cntrl |= PLX_CNTRL_EERELOAD;
writel(cntrl, devpriv->plx + PLX_REG_CNTRL);
mdelay(10); mdelay(10);
writel(DB2K_SECR_RELOAD_LO, devpriv->plx + 0x6c); cntrl &= ~PLX_CNTRL_EERELOAD;
writel(cntrl, devpriv->plx + PLX_REG_CNTRL);
mdelay(10); mdelay(10);
} }
static void daqboard2000_pulse_prog_pin(struct comedi_device *dev) static void daqboard2000_pulse_prog_pin(struct comedi_device *dev)
{ {
struct daqboard2000_private *devpriv = dev->private; struct daqboard2000_private *devpriv = dev->private;
u32 cntrl;
writel(DB2K_SECR_PROG_PIN_HI, devpriv->plx + 0x6c); cntrl = readl(devpriv->plx + PLX_REG_CNTRL);
cntrl |= PLX_CNTRL_USERO;
writel(cntrl, devpriv->plx + PLX_REG_CNTRL);
mdelay(10); mdelay(10);
writel(DB2K_SECR_PROG_PIN_LO, devpriv->plx + 0x6c); cntrl &= ~PLX_CNTRL_USERO;
writel(cntrl, devpriv->plx + PLX_REG_CNTRL);
mdelay(10); /* Not in the original code, but I like symmetry... */ mdelay(10); /* Not in the original code, but I like symmetry... */
} }
...@@ -501,14 +504,13 @@ static int daqboard2000_load_firmware(struct comedi_device *dev, ...@@ -501,14 +504,13 @@ static int daqboard2000_load_firmware(struct comedi_device *dev,
{ {
struct daqboard2000_private *devpriv = dev->private; struct daqboard2000_private *devpriv = dev->private;
int result = -EIO; int result = -EIO;
/* Read the serial EEPROM control register */ u32 cntrl;
int secr;
int retry; int retry;
size_t i; size_t i;
/* Check to make sure the serial eeprom is present on the board */ /* Check to make sure the serial eeprom is present on the board */
secr = readl(devpriv->plx + 0x6c); cntrl = readl(devpriv->plx + PLX_REG_CNTRL);
if (!(secr & DAQBOARD2000_EEPROM_PRESENT)) if (!(cntrl & PLX_CNTRL_EEPRESENT))
return -EIO; return -EIO;
for (retry = 0; retry < 3; retry++) { for (retry = 0; retry < 3; retry++) {
...@@ -677,8 +679,6 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, ...@@ -677,8 +679,6 @@ static int daqboard2000_auto_attach(struct comedi_device *dev,
if (result) if (result)
return result; return result;
readl(devpriv->plx + 0x6c);
result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev, result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
DAQBOARD2000_FIRMWARE, DAQBOARD2000_FIRMWARE,
daqboard2000_load_firmware, 0); daqboard2000_load_firmware, 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