aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-11-13 15:36:19 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-13 18:12:45 -0500
commit2a366e7b9d7118e657980399bcf41b353894ab92 (patch)
treea0fa7e684312d0715accd7014099422c7f74b65c
parent848ce5112e7fcb38aaafff28253314da330b681e (diff)
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: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/Kconfig13
-rw-r--r--drivers/staging/comedi/drivers/Makefile1
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c240
-rw-r--r--drivers/staging/comedi/drivers/addi_apci_1516.c17
-rw-r--r--drivers/staging/comedi/drivers/addi_apci_2016.c68
5 files changed, 19 insertions, 320 deletions
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 6246bed00ef..bede5736532 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -594,10 +594,10 @@ config COMEDI_ADDI_APCI_1500
594 called addi_apci_1500. 594 called addi_apci_1500.
595 595
596config COMEDI_ADDI_APCI_1516 596config COMEDI_ADDI_APCI_1516
597 tristate "ADDI-DATA APCI_1516 support" 597 tristate "ADDI-DATA APCI-1516/2016 support"
598 depends on VIRT_TO_BUS 598 depends on VIRT_TO_BUS
599 ---help--- 599 ---help---
600 Enable support for ADDI-DATA APCI_1516 cards 600 Enable support for ADDI-DATA APCI-1516 and APCI-2016 boards.
601 601
602 To compile this driver as a module, choose M here: the module will be 602 To compile this driver as a module, choose M here: the module will be
603 called addi_apci_1516. 603 called addi_apci_1516.
@@ -620,15 +620,6 @@ config COMEDI_ADDI_APCI_16XX
620 To compile this driver as a module, choose M here: the module will be 620 To compile this driver as a module, choose M here: the module will be
621 called addi_apci_16xx. 621 called addi_apci_16xx.
622 622
623config COMEDI_ADDI_APCI_2016
624 tristate "ADDI-DATA APCI_2016 support"
625 depends on VIRT_TO_BUS
626 ---help---
627 Enable support for ADDI-DATA APCI_2016 cards
628
629 To compile this driver as a module, choose M here: the module will be
630 called addi_apci_2016.
631
632config COMEDI_ADDI_APCI_2032 623config COMEDI_ADDI_APCI_2032
633 tristate "ADDI-DATA APCI_2032 support" 624 tristate "ADDI-DATA APCI_2032 support"
634 depends on VIRT_TO_BUS 625 depends on VIRT_TO_BUS
diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile
index c784bedb911..0de4d2eb76f 100644
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -62,7 +62,6 @@ obj-$(CONFIG_COMEDI_ADDI_APCI_1500) += addi_apci_1500.o
62obj-$(CONFIG_COMEDI_ADDI_APCI_1516) += addi_apci_1516.o 62obj-$(CONFIG_COMEDI_ADDI_APCI_1516) += addi_apci_1516.o
63obj-$(CONFIG_COMEDI_ADDI_APCI_1564) += addi_apci_1564.o 63obj-$(CONFIG_COMEDI_ADDI_APCI_1564) += addi_apci_1564.o
64obj-$(CONFIG_COMEDI_ADDI_APCI_16XX) += addi_apci_16xx.o 64obj-$(CONFIG_COMEDI_ADDI_APCI_16XX) += addi_apci_16xx.o
65obj-$(CONFIG_COMEDI_ADDI_APCI_2016) += addi_apci_2016.o
66obj-$(CONFIG_COMEDI_ADDI_APCI_2032) += addi_apci_2032.o 65obj-$(CONFIG_COMEDI_ADDI_APCI_2032) += addi_apci_2032.o
67obj-$(CONFIG_COMEDI_ADDI_APCI_2200) += addi_apci_2200.o 66obj-$(CONFIG_COMEDI_ADDI_APCI_2200) += addi_apci_2200.o
68obj-$(CONFIG_COMEDI_ADDI_APCI_3120) += addi_apci_3120.o 67obj-$(CONFIG_COMEDI_ADDI_APCI_3120) += addi_apci_3120.o
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c
deleted file mode 100644
index c1a58398266..00000000000
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c
+++ /dev/null
@@ -1,240 +0,0 @@
1/**
2@verbatim
3
4Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
5
6 ADDI-DATA GmbH
7 Dieselstrasse 3
8 D-77833 Ottersweier
9 Tel: +19(0)7223/9493-0
10 Fax: +49(0)7223/9493-92
11 http://www.addi-data.com
12 info@addi-data.com
13
14This 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.
15
16This 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.
17
18You 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
19
20You should also find the complete GPL in the COPYING file accompanying this source code.
21
22@endverbatim
23*/
24/*
25
26 +-----------------------------------------------------------------------+
27 | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
28 +-----------------------------------------------------------------------+
29 | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
30 | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
31 +-------------------------------+---------------------------------------+
32 | Project : APCI-2016 | Compiler : GCC |
33 | Module name : hwdrv_apci2016.c| Version : 2.96 |
34 +-------------------------------+---------------------------------------+
35 | Project manager: Eric Stolz | Date : 02/12/2002 |
36 +-------------------------------+---------------------------------------+
37 | Description : Hardware Layer Access For APCI-2016 |
38 +-----------------------------------------------------------------------+
39 | UPDATES |
40 +----------+-----------+------------------------------------------------+
41 | Date | Author | Description of updates |
42 +----------+-----------+------------------------------------------------+
43 | | | |
44 | | | |
45 | | | |
46 +----------+-----------+------------------------------------------------+
47*/
48
49/********* Definitions for APCI-2016 card *****/
50
51#define APCI2016_ADDRESS_RANGE 8
52
53/* DIGITAL INPUT-OUTPUT DEFINE */
54
55#define APCI2016_DIGITAL_OP 0x04
56#define APCI2016_DIGITAL_OP_RW 4
57
58/* TIMER COUNTER WATCHDOG DEFINES */
59
60#define ADDIDATA_WATCHDOG 2
61#define APCI2016_DIGITAL_OP_WATCHDOG 0
62#define APCI2016_WATCHDOG_ENABLEDISABLE 12
63#define APCI2016_WATCHDOG_RELOAD_VALUE 4
64#define APCI2016_WATCHDOG_STATUS 16
65
66static int apci2016_do_insn_bits(struct comedi_device *dev,
67 struct comedi_subdevice *s,
68 struct comedi_insn *insn,
69 unsigned int *data)
70{
71 struct addi_private *devpriv = dev->private;
72 unsigned int mask = data[0];
73 unsigned int bits = data[1];
74
75 s->state = inw(devpriv->iobase + APCI2016_DIGITAL_OP_RW);
76 if (mask) {
77 s->state &= ~mask;
78 s->state |= (bits & mask);
79
80 outw(s->state, devpriv->iobase + APCI2016_DIGITAL_OP);
81 }
82
83 data[1] = s->state;
84
85 return insn->n;
86}
87
88/*
89+----------------------------------------------------------------------------+
90| Function Name : int i_APCI2016_ConfigWatchdog |
91| (struct comedi_device *dev,struct comedi_subdevice *s, |
92| struct comedi_insn *insn,unsigned int *data) |
93+----------------------------------------------------------------------------+
94| Task : Configures The Watchdog |
95+----------------------------------------------------------------------------+
96| Input Parameters : struct comedi_device *dev : Driver handle |
97| struct comedi_subdevice *s, :pointer to subdevice structure |
98| struct comedi_insn *insn :pointer to insn structure |
99| unsigned int *data : Data Pointer to read status |
100+----------------------------------------------------------------------------+
101| Output Parameters : -- |
102+----------------------------------------------------------------------------+
103| Return Value : TRUE : No error occur |
104| : FALSE : Error occur. Return the error |
105| |
106+----------------------------------------------------------------------------+
107*/
108static int i_APCI2016_ConfigWatchdog(struct comedi_device *dev,
109 struct comedi_subdevice *s,
110 struct comedi_insn *insn,
111 unsigned int *data)
112{
113 struct addi_private *devpriv = dev->private;
114
115 if (data[0] == 0) {
116 /* Disable the watchdog */
117 outw(0x0,
118 devpriv->i_IobaseAddon +
119 APCI2016_WATCHDOG_ENABLEDISABLE);
120 /* Loading the Reload value */
121 outw(data[1],
122 devpriv->i_IobaseAddon +
123 APCI2016_WATCHDOG_RELOAD_VALUE);
124 data[1] = data[1] >> 16;
125 outw(data[1],
126 devpriv->i_IobaseAddon +
127 APCI2016_WATCHDOG_RELOAD_VALUE + 2);
128 } else {
129 printk("\nThe input parameters are wrong\n");
130 }
131 return insn->n;
132}
133
134/*
135+----------------------------------------------------------------------------+
136| Function Name : int i_APCI2016_StartStopWriteWatchdog |
137| (struct comedi_device *dev,struct comedi_subdevice *s, |
138| struct comedi_insn *insn,unsigned int *data) |
139+----------------------------------------------------------------------------+
140| Task : Start / Stop The Watchdog |
141+----------------------------------------------------------------------------+
142| Input Parameters : struct comedi_device *dev : Driver handle |
143| struct comedi_subdevice *s, :pointer to subdevice structure |
144| struct comedi_insn *insn :pointer to insn structure |
145| unsigned int *data : Data Pointer to read status |
146+----------------------------------------------------------------------------+
147| Output Parameters : -- |
148+----------------------------------------------------------------------------+
149| Return Value : TRUE : No error occur |
150| : FALSE : Error occur. Return the error |
151| |
152+----------------------------------------------------------------------------+
153*/
154static int i_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev,
155 struct comedi_subdevice *s,
156 struct comedi_insn *insn,
157 unsigned int *data)
158{
159 struct addi_private *devpriv = dev->private;
160
161 switch (data[0]) {
162 case 0: /* stop the watchdog */
163 outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */
164 break;
165 case 1: /* start the watchdog */
166 outw(0x0001,
167 devpriv->i_IobaseAddon +
168 APCI2016_WATCHDOG_ENABLEDISABLE);
169 break;
170 case 2: /* Software trigger */
171 outw(0x0201,
172 devpriv->i_IobaseAddon +
173 APCI2016_WATCHDOG_ENABLEDISABLE);
174 break;
175 default:
176 printk("\nSpecified functionality does not exist\n");
177 return -EINVAL;
178 } /* switch(data[0]) */
179
180 return insn->n;
181}
182
183/*
184+----------------------------------------------------------------------------+
185| Function Name : int i_APCI2016_ReadWatchdog |
186| (struct comedi_device *dev,struct comedi_subdevice *s, |
187| struct comedi_insn *insn,unsigned int *data) |
188+----------------------------------------------------------------------------+
189| Task : Read The Watchdog |
190+----------------------------------------------------------------------------+
191| Input Parameters : struct comedi_device *dev : Driver handle |
192| struct comedi_subdevice *s, :pointer to subdevice structure |
193| struct comedi_insn *insn :pointer to insn structure |
194| unsigned int *data : Data Pointer to read status |
195+----------------------------------------------------------------------------+
196| Output Parameters : -- |
197+----------------------------------------------------------------------------+
198| Return Value : TRUE : No error occur |
199| : FALSE : Error occur. Return the error |
200| |
201+----------------------------------------------------------------------------+
202*/
203
204static int i_APCI2016_ReadWatchdog(struct comedi_device *dev,
205 struct comedi_subdevice *s,
206 struct comedi_insn *insn,
207 unsigned int *data)
208{
209 struct addi_private *devpriv = dev->private;
210
211 udelay(5);
212 data[0] = inw(devpriv->i_IobaseAddon + APCI2016_WATCHDOG_STATUS) & 0x1;
213 return insn->n;
214}
215
216/*
217+----------------------------------------------------------------------------+
218| Function Name : int i_APCI2016_Reset(struct comedi_device *dev) | |
219+----------------------------------------------------------------------------+
220| Task :resets all the registers |
221+----------------------------------------------------------------------------+
222| Input Parameters : struct comedi_device *dev
223+----------------------------------------------------------------------------+
224| Output Parameters : -- |
225+----------------------------------------------------------------------------+
226| Return Value : |
227| |
228+----------------------------------------------------------------------------+
229*/
230
231static int i_APCI2016_Reset(struct comedi_device *dev)
232{
233 struct addi_private *devpriv = dev->private;
234
235 outw(0x0, devpriv->iobase + APCI2016_DIGITAL_OP); /* Resets the digital output channels */
236 outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE);
237 outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE);
238 outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE + 2);
239 return 0;
240}
diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c
index 0382844fdc0..cada79ce026 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1516.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1516.c
@@ -27,6 +27,22 @@ static const struct addi_board apci1516_boardtypes[] = {
27 .timer_config = i_APCI1516_ConfigWatchdog, 27 .timer_config = i_APCI1516_ConfigWatchdog,
28 .timer_write = i_APCI1516_StartStopWriteWatchdog, 28 .timer_write = i_APCI1516_StartStopWriteWatchdog,
29 .timer_read = i_APCI1516_ReadWatchdog, 29 .timer_read = i_APCI1516_ReadWatchdog,
30 }, {
31 .pc_DriverName = "apci2016",
32 .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
33 .i_DeviceId = 0x1002,
34 .i_IorangeBase0 = 128,
35 .i_IorangeBase1 = APCI1516_ADDRESS_RANGE,
36 .i_IorangeBase2 = 32,
37 .i_PCIEeprom = ADDIDATA_EEPROM,
38 .pc_EepromChip = ADDIDATA_S5920,
39 .i_NbrDoChannel = 16,
40 .i_Timer = 1,
41 .reset = i_APCI1516_Reset,
42 .do_bits = apci1516_do_insn_bits,
43 .timer_config = i_APCI1516_ConfigWatchdog,
44 .timer_write = i_APCI1516_StartStopWriteWatchdog,
45 .timer_read = i_APCI1516_ReadWatchdog,
30 }, 46 },
31}; 47};
32 48
@@ -53,6 +69,7 @@ static void __devexit apci1516_pci_remove(struct pci_dev *dev)
53 69
54static DEFINE_PCI_DEVICE_TABLE(apci1516_pci_table) = { 70static DEFINE_PCI_DEVICE_TABLE(apci1516_pci_table) = {
55 { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1001) }, 71 { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1001) },
72 { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1002) },
56 { 0 } 73 { 0 }
57}; 74};
58MODULE_DEVICE_TABLE(pci, apci1516_pci_table); 75MODULE_DEVICE_TABLE(pci, apci1516_pci_table);
diff --git a/drivers/staging/comedi/drivers/addi_apci_2016.c b/drivers/staging/comedi/drivers/addi_apci_2016.c
deleted file mode 100644
index 54b05d3fa1b..00000000000
--- a/drivers/staging/comedi/drivers/addi_apci_2016.c
+++ /dev/null
@@ -1,68 +0,0 @@
1#include "../comedidev.h"
2#include "comedi_fc.h"
3#include "amcc_s5933.h"
4
5#include "addi-data/addi_common.h"
6
7#include "addi-data/addi_eeprom.c"
8#include "addi-data/hwdrv_apci2016.c"
9#include "addi-data/addi_common.c"
10
11static const struct addi_board apci2016_boardtypes[] = {
12 {
13 .pc_DriverName = "apci2016",
14 .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
15 .i_DeviceId = 0x1002,
16 .i_IorangeBase0 = 128,
17 .i_IorangeBase1 = APCI2016_ADDRESS_RANGE,
18 .i_IorangeBase2 = 32,
19 .i_PCIEeprom = ADDIDATA_EEPROM,
20 .pc_EepromChip = ADDIDATA_S5920,
21 .i_NbrDoChannel = 16,
22 .i_Timer = 1,
23 .reset = i_APCI2016_Reset,
24 .do_bits = apci2016_do_insn_bits,
25 .timer_config = i_APCI2016_ConfigWatchdog,
26 .timer_write = i_APCI2016_StartStopWriteWatchdog,
27 .timer_read = i_APCI2016_ReadWatchdog,
28 },
29};
30
31static struct comedi_driver apci2016_driver = {
32 .driver_name = "addi_apci_2016",
33 .module = THIS_MODULE,
34 .auto_attach = addi_auto_attach,
35 .detach = i_ADDI_Detach,
36 .num_names = ARRAY_SIZE(apci2016_boardtypes),
37 .board_name = &apci2016_boardtypes[0].pc_DriverName,
38 .offset = sizeof(struct addi_board),
39};
40
41static int __devinit apci2016_pci_probe(struct pci_dev *dev,
42 const struct pci_device_id *ent)
43{
44 return comedi_pci_auto_config(dev, &apci2016_driver);
45}
46
47static void __devexit apci2016_pci_remove(struct pci_dev *dev)
48{
49 comedi_pci_auto_unconfig(dev);
50}
51
52static DEFINE_PCI_DEVICE_TABLE(apci2016_pci_table) = {
53 { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1002) },
54 { 0 }
55};
56MODULE_DEVICE_TABLE(pci, apci2016_pci_table);
57
58static struct pci_driver apci2016_pci_driver = {
59 .name = "addi_apci_2016",
60 .id_table = apci2016_pci_table,
61 .probe = apci2016_pci_probe,
62 .remove = __devexit_p(apci2016_pci_remove),
63};
64module_comedi_pci_driver(apci2016_driver, apci2016_pci_driver);
65
66MODULE_AUTHOR("Comedi http://www.comedi.org");
67MODULE_DESCRIPTION("Comedi low-level driver");
68MODULE_LICENSE("GPL");