aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/me4000/Kconfig10
-rw-r--r--drivers/staging/me4000/Makefile1
-rw-r--r--drivers/staging/me4000/README13
-rw-r--r--drivers/staging/me4000/me4000.c6109
-rw-r--r--drivers/staging/me4000/me4000.h966
-rw-r--r--drivers/staging/me4000/me4000_firmware.h10033
-rw-r--r--drivers/staging/me4000/me4610_firmware.h5409
9 files changed, 0 insertions, 22544 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index ee073ce3974..d76f6b356de 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -47,8 +47,6 @@ source "drivers/staging/slicoss/Kconfig"
source "drivers/staging/sxg/Kconfig"
-source "drivers/staging/me4000/Kconfig"
-
source "drivers/staging/meilhaus/Kconfig"
source "drivers/staging/go7007/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index c5c8cae3645..01bf2284520 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -6,7 +6,6 @@ obj-$(CONFIG_STAGING) += staging.o
obj-$(CONFIG_ET131X) += et131x/
obj-$(CONFIG_SLICOSS) += slicoss/
obj-$(CONFIG_SXG) += sxg/
-obj-$(CONFIG_ME4000) += me4000/
obj-$(CONFIG_MEILHAUS) += meilhaus/
obj-$(CONFIG_VIDEO_GO7007) += go7007/
obj-$(CONFIG_USB_IP_COMMON) += usbip/
diff --git a/drivers/staging/me4000/Kconfig b/drivers/staging/me4000/Kconfig
deleted file mode 100644
index 5e6c9de1f11..00000000000
--- a/drivers/staging/me4000/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-config ME4000
- tristate "Meilhaus ME-4000 support"
- default n
- depends on PCI
- help
- This driver supports the Meilhaus ME-4000 family of boards
- that do data collection and multipurpose I/O.
-
- To compile this driver as a module, choose M here: the module
- will be called me4000.
diff --git a/drivers/staging/me4000/Makefile b/drivers/staging/me4000/Makefile
deleted file mode 100644
index 74487cd7bec..00000000000
--- a/drivers/staging/me4000/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-$(CONFIG_ME4000) += me4000.o
diff --git a/drivers/staging/me4000/README b/drivers/staging/me4000/README
deleted file mode 100644
index bbb83863220..00000000000
--- a/drivers/staging/me4000/README
+++ /dev/null
@@ -1,13 +0,0 @@
-
-TODO:
- - checkpatch.pl cleanups
- - sparse cleanups
- - possible /proc interaction cleanups
- - more info needed for Kconfig entry
- - real device id?
- - module parameter cleanup
-
-Please send patches to Greg Kroah-Hartman <gregkh@suse.de>
-and Cc: Wolfgang Beiter <w.beiter@aon.at> and
-Guenter Gebhardt <g.gebhardt@meilhaus.de>
-
diff --git a/drivers/staging/me4000/me4000.c b/drivers/staging/me4000/me4000.c
deleted file mode 100644
index 01017b731d0..00000000000
--- a/drivers/staging/me4000/me4000.c
+++ /dev/null
@@ -1,6109 +0,0 @@
-/* Device driver for Meilhaus ME-4000 board family.
- * ================================================
- *
- * Copyright (C) 2003 Meilhaus Electronic GmbH (support@meilhaus.de)
- *
- * This file 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Author: Guenter Gebhardt <g.gebhardt@meilhaus.de>
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/mm.h>
-#include <linux/unistd.h>
-#include <linux/list.h>
-#include <linux/proc_fs.h>
-#include <linux/types.h>
-#include <linux/poll.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <asm/pgtable.h>
-#include <linux/uaccess.h>
-#include <linux/io.h>
-#include <asm/system.h>
-
-/* Include-File for the Meilhaus ME-4000 I/O board */
-#include "me4000.h"
-#include "me4000_firmware.h"
-#include "me4610_firmware.h"
-
-/* Administrative stuff for modinfo */
-MODULE_AUTHOR("Guenter Gebhardt <g.gebhardt@meilhaus.de>");
-MODULE_DESCRIPTION
- ("Device Driver Module for Meilhaus ME-4000 boards version 1.0.5");
-MODULE_SUPPORTED_DEVICE("Meilhaus ME-4000 Multi I/O boards");
-MODULE_LICENSE("GPL");
-
-/* Board specific data are kept in a global list */
-static LIST_HEAD(me4000_board_info_list);
-
-/* Major Device Numbers. 0 means to get it automatically from the System */
-static int me4000_ao_major_driver_no;
-static int me4000_ai_major_driver_no;
-static int me4000_dio_major_driver_no;
-static int me4000_cnt_major_driver_no;
-static int me4000_ext_int_major_driver_no;
-
-/* Let the user specify a custom major driver number */
-module_param(me4000_ao_major_driver_no, int, 0);
-MODULE_PARM_DESC(me4000_ao_major_driver_no,
- "Major driver number for analog output (default 0)");
-
-module_param(me4000_ai_major_driver_no, int, 0);
-MODULE_PARM_DESC(me4000_ai_major_driver_no,
- "Major driver number for analog input (default 0)");
-
-module_param(me4000_dio_major_driver_no, int, 0);
-MODULE_PARM_DESC(me4000_dio_major_driver_no,
- "Major driver number digital I/O (default 0)");
-
-module_param(me4000_cnt_major_driver_no, int, 0);
-MODULE_PARM_DESC(me4000_cnt_major_driver_no,
- "Major driver number for counter (default 0)");
-
-module_param(me4000_ext_int_major_driver_no, int, 0);
-MODULE_PARM_DESC(me4000_ext_int_major_driver_no,
- "Major driver number for external interrupt (default 0)");
-
-/*-----------------------------------------------------------------------------
- Board detection and initialization
- ---------------------------------------------------------------------------*/
-static int me4000_probe(struct pci_dev *dev, const struct pci_device_id *id);
-static int me4000_xilinx_download(struct me4000_info *);
-static int me4000_reset_board(struct me4000_info *);
-
-static void clear_board_info_list(void);
-static void release_ao_contexts(struct me4000_info *board_info);
-/*-----------------------------------------------------------------------------
- Stuff used by all device parts
- ---------------------------------------------------------------------------*/
-static int me4000_open(struct inode *, struct file *);
-static int me4000_release(struct inode *, struct file *);
-
-static int me4000_get_user_info(struct me4000_user_info *,
- struct me4000_info *board_info);
-static int me4000_read_procmem(char *, char **, off_t, int, int *, void *);
-
-/*-----------------------------------------------------------------------------
- Analog output stuff
- ---------------------------------------------------------------------------*/
-static ssize_t me4000_ao_write_sing(struct file *, const char *, size_t,
- loff_t *);
-static ssize_t me4000_ao_write_wrap(struct file *, const char *, size_t,
- loff_t *);
-static ssize_t me4000_ao_write_cont(struct file *, const char *, size_t,
- loff_t *);
-
-static int me4000_ao_ioctl_sing(struct inode *, struct file *, unsigned int,
- unsigned long);
-static int me4000_ao_ioctl_wrap(struct inode *, struct file *, unsigned int,
- unsigned long);
-static int me4000_ao_ioctl_cont(struct inode *, struct file *, unsigned int,
- unsigned long);
-
-static unsigned int me4000_ao_poll_cont(struct file *, poll_table *);
-static int me4000_ao_fsync_cont(struct file *, struct dentry *, int);
-
-static int me4000_ao_start(unsigned long *, struct me4000_ao_context *);
-static int me4000_ao_stop(struct me4000_ao_context *);
-static int me4000_ao_immediate_stop(struct me4000_ao_context *);
-static int me4000_ao_timer_set_divisor(u32 *, struct me4000_ao_context *);
-static int me4000_ao_preload(struct me4000_ao_context *);
-static int me4000_ao_preload_update(struct me4000_ao_context *);
-static int me4000_ao_ex_trig_set_edge(int *, struct me4000_ao_context *);
-static int me4000_ao_ex_trig_enable(struct me4000_ao_context *);
-static int me4000_ao_ex_trig_disable(struct me4000_ao_context *);
-static int me4000_ao_prepare(struct me4000_ao_context *ao_info);
-static int me4000_ao_reset(struct me4000_ao_context *ao_info);
-static int me4000_ao_enable_do(struct me4000_ao_context *);
-static int me4000_ao_disable_do(struct me4000_ao_context *);
-static int me4000_ao_fsm_state(int *, struct me4000_ao_context *);
-
-static int me4000_ao_simultaneous_ex_trig(struct me4000_ao_context *ao_context);
-static int me4000_ao_simultaneous_sw(struct me4000_ao_context *ao_context);
-static int me4000_ao_simultaneous_disable(struct me4000_ao_context *ao_context);
-static int me4000_ao_simultaneous_update(
- struct me4000_ao_channel_list *channels,
- struct me4000_ao_context *ao_context);
-
-static int me4000_ao_synchronous_ex_trig(struct me4000_ao_context *ao_context);
-static int me4000_ao_synchronous_sw(struct me4000_ao_context *ao_context);
-static int me4000_ao_synchronous_disable(struct me4000_ao_context *ao_context);
-
-static int me4000_ao_ex_trig_timeout(unsigned long *arg,
- struct me4000_ao_context *ao_context);
-static int me4000_ao_get_free_buffer(unsigned long *arg,
- struct me4000_ao_context *ao_context);
-
-/*-----------------------------------------------------------------------------
- Analog input stuff
- ---------------------------------------------------------------------------*/
-static int me4000_ai_single(struct me4000_ai_single *,
- struct me4000_ai_context *);
-static int me4000_ai_ioctl_sing(struct inode *, struct file *, unsigned int,
- unsigned long);
-
-static ssize_t me4000_ai_read(struct file *, char *, size_t, loff_t *);
-static int me4000_ai_ioctl_sw(struct inode *, struct file *, unsigned int,
- unsigned long);
-static unsigned int me4000_ai_poll(struct file *, poll_table *);
-static int me4000_ai_fasync(int fd, struct file *file_p, int mode);
-
-static int me4000_ai_ioctl_ext(struct inode *, struct file *, unsigned int,
- unsigned long);
-
-static int me4000_ai_prepare(struct me4000_ai_context *ai_context);
-static int me4000_ai_reset(struct me4000_ai_context *ai_context);
-static int me4000_ai_config(struct me4000_ai_config *,
- struct me4000_ai_context *);
-static int me4000_ai_start(struct me4000_ai_context *);
-static int me4000_ai_start_ex(unsigned long *, struct me4000_ai_context *);
-static int me4000_ai_stop(struct me4000_ai_context *);
-static int me4000_ai_immediate_stop(struct me4000_ai_context *);
-static int me4000_ai_ex_trig_enable(struct me4000_ai_context *);
-static int me4000_ai_ex_trig_disable(struct me4000_ai_context *);
-static int me4000_ai_ex_trig_setup(struct me4000_ai_trigger *,
- struct me4000_ai_context *);
-static int me4000_ai_sc_setup(struct me4000_ai_sc *arg,
- struct me4000_ai_context *ai_context);
-static int me4000_ai_offset_enable(struct me4000_ai_context *ai_context);
-static int me4000_ai_offset_disable(struct me4000_ai_context *ai_context);
-static int me4000_ai_fullscale_enable(struct me4000_ai_context *ai_context);
-static int me4000_ai_fullscale_disable(struct me4000_ai_context *ai_context);
-static int me4000_ai_fsm_state(int *arg, struct me4000_ai_context *ai_context);
-static int me4000_ai_get_count_buffer(unsigned long *arg,
- struct me4000_ai_context *ai_context);
-
-/*-----------------------------------------------------------------------------
- EEPROM stuff
- ---------------------------------------------------------------------------*/
-static int me4000_eeprom_read(struct me4000_eeprom *arg,
- struct me4000_ai_context *ai_context);
-static int me4000_eeprom_write(struct me4000_eeprom *arg,
- struct me4000_ai_context *ai_context);
-
-/*-----------------------------------------------------------------------------
- Digital I/O stuff
- ---------------------------------------------------------------------------*/
-static int me4000_dio_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
-static int me4000_dio_config(struct me4000_dio_config *,
- struct me4000_dio_context *);
-static int me4000_dio_get_byte(struct me4000_dio_byte *,
- struct me4000_dio_context *);
-static int me4000_dio_set_byte(struct me4000_dio_byte *,
- struct me4000_dio_context *);
-static int me4000_dio_reset(struct me4000_dio_context *);
-
-/*-----------------------------------------------------------------------------
- Counter stuff
- ---------------------------------------------------------------------------*/
-static int me4000_cnt_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
-static int me4000_cnt_config(struct me4000_cnt_config *,
- struct me4000_cnt_context *);
-static int me4000_cnt_read(struct me4000_cnt *, struct me4000_cnt_context *);
-static int me4000_cnt_write(struct me4000_cnt *, struct me4000_cnt_context *);
-static int me4000_cnt_reset(struct me4000_cnt_context *);
-
-/*-----------------------------------------------------------------------------
- External interrupt routines
- ---------------------------------------------------------------------------*/
-static int me4000_ext_int_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
-static int me4000_ext_int_enable(struct me4000_ext_int_context *);
-static int me4000_ext_int_disable(struct me4000_ext_int_context *);
-static int me4000_ext_int_count(unsigned long *arg,
- struct me4000_ext_int_context *ext_int_context);
-static int me4000_ext_int_fasync(int fd, struct file *file_ptr, int mode);
-
-/*-----------------------------------------------------------------------------
- The interrupt service routines
- ---------------------------------------------------------------------------*/
-static irqreturn_t me4000_ao_isr(int, void *);
-static irqreturn_t me4000_ai_isr(int, void *);
-static irqreturn_t me4000_ext_int_isr(int, void *);
-
-/*-----------------------------------------------------------------------------
- Inline functions
- ---------------------------------------------------------------------------*/
-
-static inline int me4000_buf_count(struct me4000_circ_buf buf, int size)
-{
- return (buf.head - buf.tail) & (size - 1);
-}
-
-static inline int me4000_buf_space(struct me4000_circ_buf buf, int size)
-{
- return (buf.tail - (buf.head + 1)) & (size - 1);
-}
-
-static inline int me4000_values_to_end(struct me4000_circ_buf buf, int size)
-{
- int end;
- int n;
- end = size - buf.tail;
- n = (buf.head + end) & (size - 1);
- return (n < end) ? n : end;
-}
-
-static inline int me4000_space_to_end(struct me4000_circ_buf buf, int size)
-{
- int end;
- int n;
-
- end = size - 1 - buf.head;
- n = (end + buf.tail) & (size - 1);
- return (n <= end) ? n : (end + 1);
-}
-
-static inline void me4000_outb(unsigned char value, unsigned long port)
-{
- PORT_PDEBUG("--> 0x%02X port 0x%04lX\n", value, port);
- outb(value, port);
-}
-
-static inline void me4000_outl(unsigned long value, unsigned long port)
-{
- PORT_PDEBUG("--> 0x%08lX port 0x%04lX\n", value, port);
- outl(value, port);
-}
-
-static inline unsigned long me4000_inl(unsigned long port)
-{
- unsigned long value;
- value = inl(port);
- PORT_PDEBUG("<-- 0x%08lX port 0x%04lX\n", value, port);
- return value;
-}
-
-static inline unsigned char me4000_inb(unsigned long port)
-{
- unsigned char value;
- value = inb(port);
- PORT_PDEBUG("<-- 0x%08X port 0x%04lX\n", value, port);
- return value;
-}
-
-static struct pci_driver me4000_driver = {
- .name = ME4000_NAME,
- .id_table = me4000_pci_table,
- .probe = me4000_probe
-};
-
-static const struct file_operations me4000_ao_fops_sing = {
- .owner = THIS_MODULE,
- .write = me4000_ao_write_sing,
- .ioctl = me4000_ao_ioctl_sing,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_ao_fops_wrap = {
- .owner = THIS_MODULE,
- .write = me4000_ao_write_wrap,
- .ioctl = me4000_ao_ioctl_wrap,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_ao_fops_cont = {
- .owner = THIS_MODULE,
- .write = me4000_ao_write_cont,
- .poll = me4000_ao_poll_cont,
- .ioctl = me4000_ao_ioctl_cont,
- .open = me4000_open,
- .release = me4000_release,
- .fsync = me4000_ao_fsync_cont,
-};
-
-static const struct file_operations me4000_ai_fops_sing = {
- .owner = THIS_MODULE,
- .ioctl = me4000_ai_ioctl_sing,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_ai_fops_cont_sw = {
- .owner = THIS_MODULE,
- .read = me4000_ai_read,
- .poll = me4000_ai_poll,
- .ioctl = me4000_ai_ioctl_sw,
- .open = me4000_open,
- .release = me4000_release,
- .fasync = me4000_ai_fasync,
-};
-
-static const struct file_operations me4000_ai_fops_cont_et = {
- .owner = THIS_MODULE,
- .read = me4000_ai_read,
- .poll = me4000_ai_poll,
- .ioctl = me4000_ai_ioctl_ext,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_ai_fops_cont_et_value = {
- .owner = THIS_MODULE,
- .read = me4000_ai_read,
- .poll = me4000_ai_poll,
- .ioctl = me4000_ai_ioctl_ext,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_ai_fops_cont_et_chanlist = {
- .owner = THIS_MODULE,
- .read = me4000_ai_read,
- .poll = me4000_ai_poll,
- .ioctl = me4000_ai_ioctl_ext,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_dio_fops = {
- .owner = THIS_MODULE,
- .ioctl = me4000_dio_ioctl,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_cnt_fops = {
- .owner = THIS_MODULE,
- .ioctl = me4000_cnt_ioctl,
- .open = me4000_open,
- .release = me4000_release,
-};
-
-static const struct file_operations me4000_ext_int_fops = {
- .owner = THIS_MODULE,
- .ioctl = me4000_ext_int_ioctl,
- .open = me4000_open,
- .release = me4000_release,
- .fasync = me4000_ext_int_fasync,
-};
-
-static const struct file_operations *me4000_ao_fops_array[] = {
- /* single operations */
- &me4000_ao_fops_sing,
- /* wraparound operations */
- &me4000_ao_fops_wrap,
- /* continuous operations */
- &me4000_ao_fops_cont,
-};
-
-static const struct file_operations *me4000_ai_fops_array[] = {
- /* single operations */
- &me4000_ai_fops_sing,
- /* continuous operations with software start */
- &me4000_ai_fops_cont_sw,
- /* continuous operations with external trigger */
- &me4000_ai_fops_cont_et,
- /* sample values by external trigger */
- &me4000_ai_fops_cont_et_value,
- /* work through one channel list by external trigger */
- &me4000_ai_fops_cont_et_chanlist,
-};
-
-static int __init me4000_init_module(void)
-{
- int result;
-
- CALL_PDEBUG("init_module() is executed\n");
-
- /* Register driver capabilities */
- result = pci_register_driver(&me4000_driver);
- PDEBUG("init_module():%d devices detected\n", result);
- if (result < 0) {
- printk(KERN_ERR "ME4000:init_module():Can't register driver\n");
- goto INIT_ERROR_1;
- }
-
- /* Allocate major number for analog output */
- result =
- register_chrdev(me4000_ao_major_driver_no, ME4000_AO_NAME,
- &me4000_ao_fops_sing);
- if (result < 0) {
- printk(KERN_ERR "ME4000:init_module():Can't get AO major no\n");
- goto INIT_ERROR_2;
- } else {
- me4000_ao_major_driver_no = result;
- }
- PDEBUG("init_module():Major driver number for AO = %ld\n",
- me4000_ao_major_driver_no);
-
- /* Allocate major number for analog input */
- result =
- register_chrdev(me4000_ai_major_driver_no, ME4000_AI_NAME,
- &me4000_ai_fops_sing);
- if (result < 0) {
- printk(KERN_ERR "ME4000:init_module():Can't get AI major no\n");
- goto INIT_ERROR_3;
- } else {
- me4000_ai_major_driver_no = result;
- }
- PDEBUG("init_module():Major driver number for AI = %ld\n",
- me4000_ai_major_driver_no);
-
- /* Allocate major number for digital I/O */
- result =
- register_chrdev(me4000_dio_major_driver_no, ME4000_DIO_NAME,
- &me4000_dio_fops);
- if (result < 0) {
- printk(KERN_ERR
- "ME4000:init_module():Can't get DIO major no\n");
- goto INIT_ERROR_4;
- } else {
- me4000_dio_major_driver_no = result;
- }
- PDEBUG("init_module():Major driver number for DIO = %ld\n",
- me4000_dio_major_driver_no);
-
- /* Allocate major number for counter */
- result =
- register_chrdev(me4000_cnt_major_driver_no, ME4000_CNT_NAME,
- &me4000_cnt_fops);
- if (result < 0) {
- printk(KERN_ERR
- "ME4000:init_module():Can't get CNT major no\n");
- goto INIT_ERROR_5;
- } else {
- me4000_cnt_major_driver_no = result;
- }
- PDEBUG("init_module():Major driver number for CNT = %ld\n",
- me4000_cnt_major_driver_no);
-
- /* Allocate major number for external interrupt */
- result =
- register_chrdev(me4000_ext_int_major_driver_no, ME4000_EXT_INT_NAME,
- &me4000_ext_int_fops);
- if (result < 0) {
- printk(KERN_ERR
- "ME4000:init_module():Can't get major no for external interrupt\n");
- goto INIT_ERROR_6;
- } else {
- me4000_ext_int_major_driver_no = result;
- }
- PDEBUG
- ("init_module():Major driver number for external interrupt = %ld\n",
- me4000_ext_int_major_driver_no);
-
- /* Create the /proc/me4000 entry */
- if (!create_proc_read_entry
- ("me4000", 0, NULL, me4000_read_procmem, NULL)) {
- result = -ENODEV;
- printk(KERN_ERR
- "ME4000:init_module():Can't create proc entry\n");
- goto INIT_ERROR_7;
- }
-
- return 0;
-
-INIT_ERROR_7:
- unregister_chrdev(me4000_ext_int_major_driver_no, ME4000_EXT_INT_NAME);
-
-INIT_ERROR_6:
- unregister_chrdev(me4000_cnt_major_driver_no, ME4000_CNT_NAME);
-
-INIT_ERROR_5:
- unregister_chrdev(me4000_dio_major_driver_no, ME4000_DIO_NAME);
-
-INIT_ERROR_4:
- unregister_chrdev(me4000_ai_major_driver_no, ME4000_AI_NAME);
-
-INIT_ERROR_3:
- unregister_chrdev(me4000_ao_major_driver_no, ME4000_AO_NAME);
-
-INIT_ERROR_2:
- pci_unregister_driver(&me4000_driver);
- clear_board_info_list();
-
-INIT_ERROR_1:
- return result;
-}
-
-module_init(me4000_init_module);
-
-static void clear_board_info_list(void)
-{
- struct me4000_info *board_info, *board_info_safe;
- struct me4000_ao_context *ao_context, *ao_context_safe;
-
- /* Clear context lists */
- list_for_each_entry(board_info, &me4000_board_info_list, list) {
- /* Clear analog output context list */
- list_for_each_entry_safe(ao_context, ao_context_safe,
- &board_info->ao_context_list, list) {
- me4000_ao_reset(ao_context);
- free_irq(ao_context->irq, ao_context);
- kfree(ao_context->circ_buf.buf);
- list_del(&ao_context->list);
- kfree(ao_context);
- }
-
- /* Clear analog input context */
- kfree(board_info->ai_context->circ_buf.buf);
- kfree(board_info->ai_context);
-
- /* Clear digital I/O context */
- kfree(board_info->dio_context);
-
- /* Clear counter context */
- kfree(board_info->cnt_context);
-
- /* Clear external interrupt context */
- kfree(board_info->ext_int_context);
- }
-
- /* Clear the board info list */
- list_for_each_entry_safe(board_info, board_info_safe,
- &me4000_board_info_list, list) {
- pci_release_regions(board_info->pci_dev_p);
- list_del(&board_info->list);
- kfree(board_info);
- }
-}
-
-static int get_registers(struct pci_dev *dev, struct me4000_info *board_info)
-{
-
- /*--------------------------- plx regbase ---------------------------------*/
-
- board_info->plx_regbase = pci_resource_start(dev, 1);
- if (board_info->plx_regbase == 0) {
- printk(KERN_ERR
- "ME4000:get_registers():PCI base address 1 is not available\n");
- return -ENODEV;
- }
- board_info->plx_regbase_size = pci_resource_len(dev, 1);
-
- PDEBUG
- ("get_registers():PLX configuration registers at address 0x%4lX [0x%4lX]\n",
- board_info->plx_regbase, board_info->plx_regbase_size);
-
- /*--------------------------- me4000 regbase ------------------------------*/
-
- board_info->me4000_regbase = pci_resource_start(dev, 2);
- if (board_info->me4000_regbase == 0) {
- printk(KERN_ERR
- "ME4000:get_registers():PCI base address 2 is not available\n");
- return -ENODEV;
- }
- board_info->me4000_regbase_size = pci_resource_len(dev, 2);
-
- PDEBUG("get_registers():ME4000 registers at address 0x%4lX [0x%4lX]\n",
- board_info->me4000_regbase, board_info->me4000_regbase_size);
-
- /*--------------------------- timer regbase ------------------------------*/
-
- board_info->timer_regbase = pci_resource_start(dev, 3);
- if (board_info->timer_regbase == 0) {
- printk(KERN_ERR
- "ME4000:get_registers():PCI base address 3 is not available\n");
- return -ENODEV;
- }
- board_info->timer_regbase_size = pci_resource_len(dev, 3);
-
- PDEBUG("get_registers():Timer registers at address 0x%4lX [0x%4lX]\n",
- board_info->timer_regbase, board_info->timer_regbase_size);
-
- /*--------------------------- program regbase ------------------------------*/
-
- board_info->program_regbase = pci_resource_start(dev, 5);
- if (board_info->program_regbase == 0) {
- printk(KERN_ERR
- "get_registers():ME4000:PCI base address 5 is not available\n");
- return -ENODEV;
- }
- board_info->program_regbase_size = pci_resource_len(dev, 5);
-
- PDEBUG("get_registers():Program registers at address 0x%4lX [0x%4lX]\n",
- board_info->program_regbase, board_info->program_regbase_size);
-
- return 0;
-}
-
-static int init_board_info(struct pci_dev *pci_dev_p,
- struct me4000_info *board_info)
-{
- int i;
- int result;
- struct list_head *board_p;
- board_info->pci_dev_p = pci_dev_p;
-
- for (i = 0; i < ARRAY_SIZE(me4000_boards); i++) {
- if (me4000_boards[i].device_id == pci_dev_p->device) {
- board_info->board_p = &me4000_boards[i];
- break;
- }
- }
- if (i == ARRAY_SIZE(me4000_boards)) {
- printk(KERN_ERR
- "ME4000:init_board_info():Device ID not valid\n");
- return -ENODEV;
- }
-
- /* Get the index of the board in the global list */
- i = 0;
- list_for_each(board_p, &me4000_board_info_list) {
- if (board_p == &board_info->list) {
- board_info->board_count = i;
- break;
- }
- i++;
- }
- if (board_p == &me4000_board_info_list) {
- printk(KERN_ERR
- "ME4000:init_board_info():Cannot get index of board\n");
- return -ENODEV;
- }
-
- /* Init list head for analog output contexts */
- INIT_LIST_HEAD(&board_info->ao_context_list);
-
- /* Init spin locks */
- spin_lock_init(&board_info->preload_lock);
- spin_lock_init(&board_info->ai_ctrl_lock);
-
- /* Get the serial number */
- result = pci_read_config_dword(pci_dev_p, 0x2C, &board_info->serial_no);
- if (result != PCIBIOS_SUCCESSFUL) {
- printk(KERN_WARNING
- "ME4000:init_board_info: Can't get serial_no\n");
- return result;
- }
- PDEBUG("init_board_info():serial_no = 0x%x\n", board_info->serial_no);
-
- /* Get the hardware revision */
- result =
- pci_read_config_byte(pci_dev_p, 0x08, &board_info->hw_revision);
- if (result != PCIBIOS_SUCCESSFUL) {
- printk(KERN_WARNING
- "ME4000:init_board_info():Can't get hw_revision\n");
- return result;
- }
- PDEBUG("init_board_info():hw_revision = 0x%x\n",
- board_info->hw_revision);
-
- /* Get the vendor id */
- board_info->vendor_id = pci_dev_p->vendor;
- PDEBUG("init_board_info():vendor_id = 0x%x\n", board_info->vendor_id);
-
- /* Get the device id */
- board_info->device_id = pci_dev_p->device;
- PDEBUG("init_board_info():device_id = 0x%x\n", board_info->device_id);
-
- /* Get the pci device number */
- board_info->pci_dev_no = PCI_FUNC(pci_dev_p->devfn);
- PDEBUG("init_board_info():pci_func_no = 0x%x\n",
- board_info->pci_func_no);
-
- /* Get the pci slot number */
- board_info->pci_dev_no = PCI_SLOT(pci_dev_p->devfn);
- PDEBUG("init_board_info():pci_dev_no = 0x%x\n", board_info->pci_dev_no);
-
- /* Get the pci bus number */
- board_info->pci_bus_no = pci_dev_p->bus->number;
- PDEBUG("init_board_info():pci_bus_no = 0x%x\n", board_info->pci_bus_no);
-
- /* Get the irq assigned to the board */
- board_info->irq = pci_dev_p->irq;
- PDEBUG("init_board_info():irq = %d\n", board_info->irq);
-
- return 0;
-}
-
-static int alloc_ao_contexts(struct me4000_info *info)
-{
- int i;
- int err;
- struct me4000_ao_context *ao_context;
-
- for (i = 0; i < info->board_p->ao.count; i++) {
- ao_context = kzalloc(sizeof(struct me4000_ao_context),
- GFP_KERNEL);
- if (!ao_context) {
- printk(KERN_ERR
- "alloc_ao_contexts():Can't get memory for ao context\n");
- release_ao_contexts(info);
- return -ENOMEM;
- }
-
- spin_lock_init(&ao_context->use_lock);
- spin_lock_init(&ao_context->int_lock);
- ao_context->irq = info->irq;
- init_waitqueue_head(&ao_context->wait_queue);
- ao_context->board_info = info;
-
- if (info->board_p->ao.fifo_count) {
- /* Allocate circular buffer */
- ao_context->circ_buf.buf =
- kzalloc(ME4000_AO_BUFFER_SIZE, GFP_KERNEL);
- if (!ao_context->circ_buf.buf) {
- printk(KERN_ERR
- "alloc_ao_contexts():Can't get circular buffer\n");
- release_ao_contexts(info);
- return -ENOMEM;
- }
-
- /* Clear the circular buffer */
- ao_context->circ_buf.head = 0;
- ao_context->circ_buf.tail = 0;
- }
-
- switch (i) {
- case 0:
- ao_context->ctrl_reg =
- info->me4000_regbase + ME4000_AO_00_CTRL_REG;
- ao_context->status_reg =
- info->me4000_regbase + ME4000_AO_00_STATUS_REG;
- ao_context->fifo_reg =
- info->me4000_regbase + ME4000_AO_00_FIFO_REG;
- ao_context->single_reg =
- info->me4000_regbase + ME4000_AO_00_SINGLE_REG;
- ao_context->timer_reg =
- info->me4000_regbase + ME4000_AO_00_TIMER_REG;
- ao_context->irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
- ao_context->preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
- break;
- case 1:
- ao_context->ctrl_reg =
- info->me4000_regbase + ME4000_AO_01_CTRL_REG;
- ao_context->status_reg =
- info->me4000_regbase + ME4000_AO_01_STATUS_REG;
- ao_context->fifo_reg =
- info->me4000_regbase + ME4000_AO_01_FIFO_REG;
- ao_context->single_reg =
- info->me4000_regbase + ME4000_AO_01_SINGLE_REG;
- ao_context->timer_reg =
- info->me4000_regbase + ME4000_AO_01_TIMER_REG;
- ao_context->irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
- ao_context->preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
- break;
- case 2:
- ao_context->ctrl_reg =
- info->me4000_regbase + ME4000_AO_02_CTRL_REG;
- ao_context->status_reg =
- info->me4000_regbase + ME4000_AO_02_STATUS_REG;
- ao_context->fifo_reg =
- info->me4000_regbase + ME4000_AO_02_FIFO_REG;
- ao_context->single_reg =
- info->me4000_regbase + ME4000_AO_02_SINGLE_REG;
- ao_context->timer_reg =
- info->me4000_regbase + ME4000_AO_02_TIMER_REG;
- ao_context->irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
- ao_context->preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
- break;
- case 3:
- ao_context->ctrl_reg =
- info->me4000_regbase + ME4000_AO_03_CTRL_REG;
- ao_context->status_reg =
- info->me4000_regbase + ME4000_AO_03_STATUS_REG;
- ao_context->fifo_reg =
- info->me4000_regbase + ME4000_AO_03_FIFO_REG;
- ao_context->single_reg =
- info->me4000_regbase + ME4000_AO_03_SINGLE_REG;
- ao_context->timer_reg =
- info->me4000_regbase + ME4000_AO_03_TIMER_REG;
- ao_context->irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
- ao_context->preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
- break;
- default:
- break;
- }
-
- if (info->board_p->ao.fifo_count) {
- /* Request the interrupt line */
- err =
- request_irq(ao_context->irq, me4000_ao_isr,
- IRQF_DISABLED | IRQF_SHARED,
- ME4000_NAME, ao_context);
- if (err) {
- printk(KERN_ERR
- "%s:Can't get interrupt line", __func__);
- kfree(ao_context->circ_buf.buf);
- kfree(ao_context);
- release_ao_contexts(info);
- return -ENODEV;
- }
- }
-
- list_add_tail(&ao_context->list, &info->ao_context_list);
- ao_context->index = i;
- }
-
- return 0;
-}
-
-static void release_ao_contexts(struct me4000_info *board_info)
-{
- struct me4000_ao_context *ao_context, *ao_context_safe;
-
- /* Clear analog output context list */
- list_for_each_entry_safe(ao_context, ao_context_safe,
- &board_info->ao_context_list, list) {
- free_irq(ao_context->irq, ao_context);
- kfree(ao_context->circ_buf.buf);
- list_del(&ao_context->list);
- kfree(ao_context);
- }
-}
-
-static int alloc_ai_context(struct me4000_info *info)
-{
- struct me4000_ai_context *ai_context;
-
- if (info->board_p->ai.count) {
- ai_context = kzalloc(sizeof(struct me4000_ai_context),
- GFP_KERNEL);
- if (!ai_context) {
- printk(KERN_ERR
- "ME4000:alloc_ai_context():Can't get memory for ai context\n");
- return -ENOMEM;
- }
-
- info->ai_context = ai_context;
-
- spin_lock_init(&ai_context->use_lock);
- spin_lock_init(&ai_context->int_lock);
- ai_context->number = 0;
- ai_context->irq = info->irq;
- init_waitqueue_head(&ai_context->wait_queue);
- ai_context->board_info = info;
-
- ai_context->ctrl_reg =
- info->me4000_regbase + ME4000_AI_CTRL_REG;
- ai_context->status_reg =
- info->me4000_regbase + ME4000_AI_STATUS_REG;
- ai_context->channel_list_reg =
- info->me4000_regbase + ME4000_AI_CHANNEL_LIST_REG;
- ai_context->data_reg =
- info->me4000_regbase + ME4000_AI_DATA_REG;
- ai_context->chan_timer_reg =
- info->me4000_regbase + ME4000_AI_CHAN_TIMER_REG;
- ai_context->chan_pre_timer_reg =
- info->me4000_regbase + ME4000_AI_CHAN_PRE_TIMER_REG;
- ai_context->scan_timer_low_reg =
- info->me4000_regbase + ME4000_AI_SCAN_TIMER_LOW_REG;
- ai_co