From: H Hartley Sweeten Date: Tue, 13 Nov 2012 20:44:53 +0000 (-0700) Subject: staging: comedi: addi_apci_1516: merge in hwdrv_apci1516.c X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=87450c0271dd9da9242b13fa3ecade3af3d31eb9;p=linux-beck.git staging: comedi: addi_apci_1516: merge in hwdrv_apci1516.c Merge the code from hwdrv_apci1516.c into the driver and delete the now unused file. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c deleted file mode 100644 index 1aa0be3271dc..000000000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c +++ /dev/null @@ -1,227 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -You should also find the complete GPL in the COPYING file accompanying this source code. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-------------------------------+---------------------------------------+ - | Project : APCI-1516 | Compiler : GCC | - | Module name : hwdrv_apci1516.c| Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-------------------------------+---------------------------------------+ - | Description : Hardware Layer Access For APCI-1516 | - +-----------------------------------------------------------------------+ - | UPDATES | - +----------+-----------+------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | | | | - | | | | - | | | | - +----------+-----------+------------------------------------------------+ -*/ - -/********* Definitions for APCI-1516 card *****/ - -/* Card Specific information */ -#define APCI1516_ADDRESS_RANGE 8 - -/* - * PCI bar 1 I/O Register map - */ -#define APCI1516_DI_REG 0x00 -#define APCI1516_DO_REG 0x04 - -/* - * 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_CTRL_ENABLE (1 << 0) -#define APCI1516_WDOG_CTRL_SOFT_TRIG (1 << 9) -#define APCI1516_WDOG_STATUS_REG 0x10 - -#define ADDIDATA_WATCHDOG 2 - -static int apci1516_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - data[1] = inw(dev->iobase + APCI1516_DI_REG); - - return insn->n; -} - -static int apci1516_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned int mask = data[0]; - unsigned int bits = data[1]; - - s->state = inw(dev->iobase + APCI1516_DO_REG); - if (mask) { - s->state &= ~mask; - s->state |= (bits & mask); - - outw(s->state, dev->iobase + APCI1516_DO_REG); - } - - data[1] = s->state; - - return insn->n; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, -| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | -| | -+----------------------------------------------------------------------------+ -| Task : Configures The Watchdog | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| struct comedi_subdevice *s, :pointer to subdevice structure -| struct comedi_insn *insn :pointer to insn structure | -| unsigned int *data : Data Pointer to read status | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1516_private *devpriv = dev->private; - - if (data[0] == 0) { - /* Disable the watchdog */ - outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); - /* Loading the Reload value */ - outw(data[1], devpriv->wdog_iobase + - APCI1516_WDOG_RELOAD_LSB_REG); - data[1] = data[1] >> 16; - outw(data[1], devpriv->wdog_iobase + - APCI1516_WDOG_RELOAD_MSB_REG); - } /* if(data[0]==0) */ - else { - printk("\nThe input parameters are wrong\n"); - return -EINVAL; - } /* elseif(data[0]==0) */ - - return insn->n; -} - - /* - +----------------------------------------------------------------------------+ - | Function Name : int i_APCI1516_StartStopWriteWatchdog | - | (struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data); | - +----------------------------------------------------------------------------+ - | Task : Start / Stop The Watchdog | - +----------------------------------------------------------------------------+ - | Input Parameters : struct comedi_device *dev : Driver handle | - | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | - | unsigned int *data : Data Pointer to read status | - +----------------------------------------------------------------------------+ - | Output Parameters : -- | - +----------------------------------------------------------------------------+ - | Return Value : TRUE : No error occur | - | : FALSE : Error occur. Return the error | - | | - +----------------------------------------------------------------------------+ - */ - -static int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1516_private *devpriv = dev->private; - - switch (data[0]) { - case 0: /* stop the watchdog */ - outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); - break; - case 1: /* start the watchdog */ - outw(APCI1516_WDOG_CTRL_ENABLE, - devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); - break; - case 2: /* Software trigger */ - outw(APCI1516_WDOG_CTRL_ENABLE | APCI1516_WDOG_CTRL_SOFT_TRIG, - devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); - break; - default: - printk("\nSpecified functionality does not exist\n"); - return -EINVAL; - } /* switch(data[0]) */ - return insn->n; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI1516_ReadWatchdog | -| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, - unsigned int *data); | -+----------------------------------------------------------------------------+ -| Task : Read The Watchdog | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | -| unsigned int *data : Data Pointer to read status | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1516_ReadWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1516_private *devpriv = dev->private; - - data[0] = inw(devpriv->wdog_iobase + APCI1516_WDOG_STATUS_REG) & 0x1; - return insn->n; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index e2d79c3b2d92..d39278dac5af 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -1,11 +1,53 @@ +/* + * addi_apci_1516.c + * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. + * Project manager: Eric Stolz + * + * ADDI-DATA GmbH + * Dieselstrasse 3 + * D-77833 Ottersweier + * Tel: +19(0)7223/9493-0 + * Fax: +49(0)7223/9493-92 + * http://www.addi-data.com + * info@addi-data.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * You should also find the complete GPL in the COPYING file accompanying + * this source code. + */ + #include "../comedidev.h" #include "comedi_fc.h" -struct apci1516_private { - unsigned long wdog_iobase; -}; +/* + * PCI bar 1 I/O Register map + */ +#define APCI1516_DI_REG 0x00 +#define APCI1516_DO_REG 0x04 -#include "addi-data/hwdrv_apci1516.c" +/* + * 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_CTRL_ENABLE (1 << 0) +#define APCI1516_WDOG_CTRL_SOFT_TRIG (1 << 9) +#define APCI1516_WDOG_STATUS_REG 0x10 struct apci1516_boardinfo { const char *name; @@ -34,6 +76,103 @@ static const struct apci1516_boardinfo apci1516_boardtypes[] = { }, }; +struct apci1516_private { + unsigned long wdog_iobase; +}; + +static int apci1516_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + data[1] = inw(dev->iobase + APCI1516_DI_REG); + + return insn->n; +} + +static int apci1516_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int mask = data[0]; + unsigned int bits = data[1]; + + s->state = inw(dev->iobase + APCI1516_DO_REG); + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); + + outw(s->state, dev->iobase + APCI1516_DO_REG); + } + + data[1] = s->state; + + return insn->n; +} + +static int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1516_private *devpriv = dev->private; + + if (data[0] == 0) { + /* Disable the watchdog */ + outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); + /* Loading the Reload value */ + outw(data[1], devpriv->wdog_iobase + + APCI1516_WDOG_RELOAD_LSB_REG); + data[1] = data[1] >> 16; + outw(data[1], devpriv->wdog_iobase + + APCI1516_WDOG_RELOAD_MSB_REG); + } /* if(data[0]==0) */ + else { + printk("\nThe input parameters are wrong\n"); + return -EINVAL; + } /* elseif(data[0]==0) */ + + return insn->n; +} + +static int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1516_private *devpriv = dev->private; + + switch (data[0]) { + case 0: /* stop the watchdog */ + outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); + break; + case 1: /* start the watchdog */ + outw(APCI1516_WDOG_CTRL_ENABLE, + devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); + break; + case 2: /* Software trigger */ + outw(APCI1516_WDOG_CTRL_ENABLE | APCI1516_WDOG_CTRL_SOFT_TRIG, + devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); + break; + default: + printk("\nSpecified functionality does not exist\n"); + return -EINVAL; + } /* switch(data[0]) */ + return insn->n; +} + +static int i_APCI1516_ReadWatchdog(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1516_private *devpriv = dev->private; + + data[0] = inw(devpriv->wdog_iobase + APCI1516_WDOG_STATUS_REG) & 0x1; + return insn->n; +} + static int apci1516_reset(struct comedi_device *dev) { const struct apci1516_boardinfo *this_board = comedi_board(dev);