Commit 934efe63 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_2200: use addi_watchdog module

The current watchdog support in hwdrv_apci2200.c does not conform
to the comedi API.

Use the addi_watchdog module to provide support for the watchdog
subdevice and remove the now unneeded hwdrv_apci2200.c file.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent de59c285
/**
@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-2200 | Compiler : GCC |
| Module name : hwdrv_apci2200.c| Version : 2.96 |
+-------------------------------+---------------------------------------+
| Project manager: Eric Stolz | Date : 02/12/2002 |
+-------------------------------+---------------------------------------+
| Description : Hardware Layer Access For APCI-2200 |
+-----------------------------------------------------------------------+
| UPDATES |
+----------+-----------+------------------------------------------------+
| Date | Author | Description of updates |
+----------+-----------+------------------------------------------------+
| | | |
| | | |
| | | |
+----------+-----------+------------------------------------------------+
*/
/* TIMER COUNTER WATCHDOG DEFINES */
#define APCI2200_WATCHDOG 0x08
#define APCI2200_WATCHDOG_ENABLEDISABLE 12
#define APCI2200_WATCHDOG_RELOAD_VALUE 4
#define APCI2200_WATCHDOG_STATUS 16
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2200_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_APCI2200_ConfigWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
if (data[0] == 0) {
/* Disable the watchdog */
outw(0x0, dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
/* Loading the Reload value */
outw(data[1], dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_RELOAD_VALUE);
data[1] = data[1] >> 16;
outw(data[1], dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_RELOAD_VALUE + 2);
} /* 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_APCI2200_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_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
switch (data[0]) {
case 0: /* stop the watchdog */
outw(0x0, dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
break;
case 1: /* start the watchdog */
outw(0x0001, dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
break;
case 2: /* Software trigger */
outw(0x0201, dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE);
break;
default:
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
} /* switch(data[0]) */
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2200_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_APCI2200_ReadWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
data[0] = inw(dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_STATUS) & 0x1;
return insn->n;
}
#include "../comedidev.h" #include "../comedidev.h"
#include "addi_watchdog.h"
#include "comedi_fc.h" #include "comedi_fc.h"
#include "addi-data/addi_common.h" #include "addi-data/addi_common.h"
#include "addi-data/hwdrv_apci2200.c"
/* /*
* I/O Register Map * I/O Register Map
*/ */
#define APCI2200_DI_REG 0x00 #define APCI2200_DI_REG 0x00
#define APCI2200_DO_REG 0x04 #define APCI2200_DO_REG 0x04
#define APCI2200_WDOG_REG 0x08
static const struct addi_board apci2200_boardtypes[] = { static const struct addi_board apci2200_boardtypes[] = {
{ {
.pc_DriverName = "apci2200", .pc_DriverName = "apci2200",
.i_VendorId = PCI_VENDOR_ID_ADDIDATA, .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
.i_DeviceId = 0x1005, .i_DeviceId = 0x1005,
.i_Timer = 1,
.timer_config = i_APCI2200_ConfigWatchdog,
.timer_write = i_APCI2200_StartStopWriteWatchdog,
.timer_read = i_APCI2200_ReadWatchdog,
}, },
}; };
...@@ -57,12 +53,8 @@ static int apci2200_do_insn_bits(struct comedi_device *dev, ...@@ -57,12 +53,8 @@ static int apci2200_do_insn_bits(struct comedi_device *dev,
static int apci2200_reset(struct comedi_device *dev) static int apci2200_reset(struct comedi_device *dev)
{ {
outw(0x0, dev->iobase + APCI2200_DO_REG); outw(0x0, dev->iobase + APCI2200_DO_REG);
outw(0x0, dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_ENABLEDISABLE); addi_watchdog_reset(dev->iobase + APCI2200_WDOG_REG);
outw(0x0, dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_RELOAD_VALUE);
outw(0x0, dev->iobase + APCI2200_WATCHDOG +
APCI2200_WATCHDOG_RELOAD_VALUE + 2);
return 0; return 0;
} }
...@@ -143,21 +135,9 @@ static int apci2200_auto_attach(struct comedi_device *dev, ...@@ -143,21 +135,9 @@ static int apci2200_auto_attach(struct comedi_device *dev,
/* Allocate and Initialise Timer Subdevice Structures */ /* Allocate and Initialise Timer Subdevice Structures */
s = &dev->subdevices[4]; s = &dev->subdevices[4];
if (this_board->i_Timer) { ret = addi_watchdog_init(s, dev->iobase + APCI2200_WDOG_REG);
s->type = COMEDI_SUBD_TIMER; if (ret)
s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; return ret;
s->n_chan = 1;
s->maxdata = 0;
s->len_chanlist = 1;
s->range_table = &range_digital;
s->insn_write = this_board->timer_write;
s->insn_read = this_board->timer_read;
s->insn_config = this_board->timer_config;
s->insn_bits = this_board->timer_bits;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
/* Allocate and Initialise TTL */ /* Allocate and Initialise TTL */
s = &dev->subdevices[5]; s = &dev->subdevices[5];
...@@ -180,6 +160,8 @@ static void apci2200_detach(struct comedi_device *dev) ...@@ -180,6 +160,8 @@ static void apci2200_detach(struct comedi_device *dev)
if (dev->iobase) if (dev->iobase)
apci2200_reset(dev); apci2200_reset(dev);
} }
if (dev->subdevices)
addi_watchdog_cleanup(&dev->subdevices[4]);
if (pcidev) { if (pcidev) {
if (dev->iobase) if (dev->iobase)
comedi_pci_disable(pcidev); comedi_pci_disable(pcidev);
......
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