Commit 2a366e7b authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_1516: merge in addi_apci_2016 driver

The low-level hardware support code for these drivers, hwdrv_apci1516.c
and hwdrv_apci2016.c, is identical. Both of these boards are 16 channel
dio boards. The 1516 board has 8 input/8 output channels and the 2016
has 16 output channels.

To ease maintainability, merge the boardinfo and pci device information
from the addi_apci_2016 driver into the addi_apci_1516 driver and modify
the Kconfig and Makefile appropriately.

This allows deleting the addi_apci_2016.c and hwdrv_apci2016.c files.
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 848ce511
......@@ -594,10 +594,10 @@ config COMEDI_ADDI_APCI_1500
called addi_apci_1500.
config COMEDI_ADDI_APCI_1516
tristate "ADDI-DATA APCI_1516 support"
tristate "ADDI-DATA APCI-1516/2016 support"
depends on VIRT_TO_BUS
---help---
Enable support for ADDI-DATA APCI_1516 cards
Enable support for ADDI-DATA APCI-1516 and APCI-2016 boards.
To compile this driver as a module, choose M here: the module will be
called addi_apci_1516.
......@@ -620,15 +620,6 @@ config COMEDI_ADDI_APCI_16XX
To compile this driver as a module, choose M here: the module will be
called addi_apci_16xx.
config COMEDI_ADDI_APCI_2016
tristate "ADDI-DATA APCI_2016 support"
depends on VIRT_TO_BUS
---help---
Enable support for ADDI-DATA APCI_2016 cards
To compile this driver as a module, choose M here: the module will be
called addi_apci_2016.
config COMEDI_ADDI_APCI_2032
tristate "ADDI-DATA APCI_2032 support"
depends on VIRT_TO_BUS
......
......@@ -62,7 +62,6 @@ obj-$(CONFIG_COMEDI_ADDI_APCI_1500) += addi_apci_1500.o
obj-$(CONFIG_COMEDI_ADDI_APCI_1516) += addi_apci_1516.o
obj-$(CONFIG_COMEDI_ADDI_APCI_1564) += addi_apci_1564.o
obj-$(CONFIG_COMEDI_ADDI_APCI_16XX) += addi_apci_16xx.o
obj-$(CONFIG_COMEDI_ADDI_APCI_2016) += addi_apci_2016.o
obj-$(CONFIG_COMEDI_ADDI_APCI_2032) += addi_apci_2032.o
obj-$(CONFIG_COMEDI_ADDI_APCI_2200) += addi_apci_2200.o
obj-$(CONFIG_COMEDI_ADDI_APCI_3120) += addi_apci_3120.o
......
/**
@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-2016 | Compiler : GCC |
| Module name : hwdrv_apci2016.c| Version : 2.96 |
+-------------------------------+---------------------------------------+
| Project manager: Eric Stolz | Date : 02/12/2002 |
+-------------------------------+---------------------------------------+
| Description : Hardware Layer Access For APCI-2016 |
+-----------------------------------------------------------------------+
| UPDATES |
+----------+-----------+------------------------------------------------+
| Date | Author | Description of updates |
+----------+-----------+------------------------------------------------+
| | | |
| | | |
| | | |
+----------+-----------+------------------------------------------------+
*/
/********* Definitions for APCI-2016 card *****/
#define APCI2016_ADDRESS_RANGE 8
/* DIGITAL INPUT-OUTPUT DEFINE */
#define APCI2016_DIGITAL_OP 0x04
#define APCI2016_DIGITAL_OP_RW 4
/* TIMER COUNTER WATCHDOG DEFINES */
#define ADDIDATA_WATCHDOG 2
#define APCI2016_DIGITAL_OP_WATCHDOG 0
#define APCI2016_WATCHDOG_ENABLEDISABLE 12
#define APCI2016_WATCHDOG_RELOAD_VALUE 4
#define APCI2016_WATCHDOG_STATUS 16
static int apci2016_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inw(devpriv->iobase + APCI2016_DIGITAL_OP_RW);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
outw(s->state, devpriv->iobase + APCI2016_DIGITAL_OP);
}
data[1] = s->state;
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2016_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_APCI2016_ConfigWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
if (data[0] == 0) {
/* Disable the watchdog */
outw(0x0,
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_ENABLEDISABLE);
/* Loading the Reload value */
outw(data[1],
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_RELOAD_VALUE);
data[1] = data[1] >> 16;
outw(data[1],
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_RELOAD_VALUE + 2);
} else {
printk("\nThe input parameters are wrong\n");
}
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2016_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_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
switch (data[0]) {
case 0: /* stop the watchdog */
outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */
break;
case 1: /* start the watchdog */
outw(0x0001,
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_ENABLEDISABLE);
break;
case 2: /* Software trigger */
outw(0x0201,
devpriv->i_IobaseAddon +
APCI2016_WATCHDOG_ENABLEDISABLE);
break;
default:
printk("\nSpecified functionality does not exist\n");
return -EINVAL;
} /* switch(data[0]) */
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2016_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_APCI2016_ReadWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
udelay(5);
data[0] = inw(devpriv->i_IobaseAddon + APCI2016_WATCHDOG_STATUS) & 0x1;
return insn->n;
}
/*
+----------------------------------------------------------------------------+
| Function Name : int i_APCI2016_Reset(struct comedi_device *dev) | |
+----------------------------------------------------------------------------+
| Task :resets all the registers |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev
+----------------------------------------------------------------------------+
| Output Parameters : -- |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
static int i_APCI2016_Reset(struct comedi_device *dev)
{
struct addi_private *devpriv = dev->private;
outw(0x0, devpriv->iobase + APCI2016_DIGITAL_OP); /* Resets the digital output channels */
outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE);
outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE);
outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE + 2);
return 0;
}
......@@ -27,6 +27,22 @@ static const struct addi_board apci1516_boardtypes[] = {
.timer_config = i_APCI1516_ConfigWatchdog,
.timer_write = i_APCI1516_StartStopWriteWatchdog,
.timer_read = i_APCI1516_ReadWatchdog,
}, {
.pc_DriverName = "apci2016",
.i_VendorId = PCI_VENDOR_ID_ADDIDATA,
.i_DeviceId = 0x1002,
.i_IorangeBase0 = 128,
.i_IorangeBase1 = APCI1516_ADDRESS_RANGE,
.i_IorangeBase2 = 32,
.i_PCIEeprom = ADDIDATA_EEPROM,
.pc_EepromChip = ADDIDATA_S5920,
.i_NbrDoChannel = 16,
.i_Timer = 1,
.reset = i_APCI1516_Reset,
.do_bits = apci1516_do_insn_bits,
.timer_config = i_APCI1516_ConfigWatchdog,
.timer_write = i_APCI1516_StartStopWriteWatchdog,
.timer_read = i_APCI1516_ReadWatchdog,
},
};
......@@ -53,6 +69,7 @@ static void __devexit apci1516_pci_remove(struct pci_dev *dev)
static DEFINE_PCI_DEVICE_TABLE(apci1516_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1001) },
{ PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1002) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, apci1516_pci_table);
......
#include "../comedidev.h"
#include "comedi_fc.h"
#include "amcc_s5933.h"
#include "addi-data/addi_common.h"
#include "addi-data/addi_eeprom.c"
#include "addi-data/hwdrv_apci2016.c"
#include "addi-data/addi_common.c"
static const struct addi_board apci2016_boardtypes[] = {
{
.pc_DriverName = "apci2016",
.i_VendorId = PCI_VENDOR_ID_ADDIDATA,
.i_DeviceId = 0x1002,
.i_IorangeBase0 = 128,
.i_IorangeBase1 = APCI2016_ADDRESS_RANGE,
.i_IorangeBase2 = 32,
.i_PCIEeprom = ADDIDATA_EEPROM,
.pc_EepromChip = ADDIDATA_S5920,
.i_NbrDoChannel = 16,
.i_Timer = 1,
.reset = i_APCI2016_Reset,
.do_bits = apci2016_do_insn_bits,
.timer_config = i_APCI2016_ConfigWatchdog,
.timer_write = i_APCI2016_StartStopWriteWatchdog,
.timer_read = i_APCI2016_ReadWatchdog,
},
};
static struct comedi_driver apci2016_driver = {
.driver_name = "addi_apci_2016",
.module = THIS_MODULE,
.auto_attach = addi_auto_attach,
.detach = i_ADDI_Detach,
.num_names = ARRAY_SIZE(apci2016_boardtypes),
.board_name = &apci2016_boardtypes[0].pc_DriverName,
.offset = sizeof(struct addi_board),
};
static int __devinit apci2016_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, &apci2016_driver);
}
static void __devexit apci2016_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
static DEFINE_PCI_DEVICE_TABLE(apci2016_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1002) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, apci2016_pci_table);
static struct pci_driver apci2016_pci_driver = {
.name = "addi_apci_2016",
.id_table = apci2016_pci_table,
.probe = apci2016_pci_probe,
.remove = __devexit_p(apci2016_pci_remove),
};
module_comedi_pci_driver(apci2016_driver, apci2016_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
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