diff options
Diffstat (limited to 'drivers/staging/comedi')
45 files changed, 7367 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedi_fops.h b/drivers/staging/comedi/comedi_fops.h new file mode 100644 index 00000000000..da4b4f5553f --- /dev/null +++ b/drivers/staging/comedi/comedi_fops.h | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | |||
| 2 | #ifndef _COMEDI_FOPS_H | ||
| 3 | #define _COMEDI_FOPS_H | ||
| 4 | |||
| 5 | extern struct class *comedi_class; | ||
| 6 | extern const struct file_operations comedi_fops; | ||
| 7 | extern int comedi_autoconfig; | ||
| 8 | extern struct comedi_driver *comedi_drivers; | ||
| 9 | |||
| 10 | #endif /* _COMEDI_FOPS_H */ | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h new file mode 100644 index 00000000000..81346dbc35f --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_PCI_BUS_CLOCK 0 | ||
| 19 | #define APCI1710_FRONT_CONNECTOR_INPUT 1 | ||
| 20 | #define APCI1710_TIMER_READVALUE 0 | ||
| 21 | #define APCI1710_TIMER_GETOUTPUTLEVEL 1 | ||
| 22 | #define APCI1710_TIMER_GETPROGRESSSTATUS 2 | ||
| 23 | #define APCI1710_TIMER_WRITEVALUE 3 | ||
| 24 | |||
| 25 | #define APCI1710_TIMER_READINTERRUPT 1 | ||
| 26 | #define APCI1710_TIMER_READALLTIMER 2 | ||
| 27 | |||
| 28 | /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ | ||
| 29 | #ifndef APCI1710_10MHZ | ||
| 30 | #define APCI1710_10MHZ 10 | ||
| 31 | #endif | ||
| 32 | /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ | ||
| 33 | |||
| 34 | /* | ||
| 35 | * 82X54 TIMER INISIALISATION FUNCTION | ||
| 36 | */ | ||
| 37 | int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 38 | struct comedi_insn *insn, unsigned int *data); | ||
| 39 | |||
| 40 | int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev, | ||
| 41 | struct comedi_subdevice *s, | ||
| 42 | struct comedi_insn *insn, unsigned int *data); | ||
| 43 | |||
| 44 | /* | ||
| 45 | * 82X54 READ FUNCTION | ||
| 46 | */ | ||
| 47 | int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 48 | struct comedi_insn *insn, unsigned int *data); | ||
| 49 | |||
| 50 | int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 51 | struct comedi_insn *insn, unsigned int *data); | ||
| 52 | |||
| 53 | /* | ||
| 54 | * 82X54 READ & WRITE FUNCTION | ||
| 55 | */ | ||
| 56 | int i_APCI1710_ReadTimerValue(struct comedi_device *dev, | ||
| 57 | unsigned char b_ModulNbr, unsigned char b_TimerNbr, | ||
| 58 | unsigned int *pul_TimerValue); | ||
| 59 | |||
| 60 | int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev, | ||
| 61 | unsigned char b_ModulNbr, unsigned char b_TimerNbr, | ||
| 62 | unsigned char *pb_OutputLevel); | ||
| 63 | |||
| 64 | int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, | ||
| 65 | unsigned char b_ModulNbr, unsigned char b_TimerNbr, | ||
| 66 | unsigned char *pb_TimerStatus); | ||
| 67 | |||
| 68 | /* | ||
| 69 | * 82X54 WRITE FUNCTION | ||
| 70 | */ | ||
| 71 | int i_APCI1710_WriteTimerValue(struct comedi_device *dev, | ||
| 72 | unsigned char b_ModulNbr, unsigned char b_TimerNbr, | ||
| 73 | unsigned int ul_WriteValue); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h new file mode 100644 index 00000000000..29bad1d144a --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data-com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_30MHZ 30 | ||
| 19 | #define APCI1710_33MHZ 33 | ||
| 20 | #define APCI1710_40MHZ 40 | ||
| 21 | |||
| 22 | #define APCI1710_SINGLE 0 | ||
| 23 | #define APCI1710_CONTINUOUS 1 | ||
| 24 | |||
| 25 | #define APCI1710_CHRONO_PROGRESS_STATUS 0 | ||
| 26 | #define APCI1710_CHRONO_READVALUE 1 | ||
| 27 | #define APCI1710_CHRONO_CONVERTVALUE 2 | ||
| 28 | #define APCI1710_CHRONO_READINTERRUPT 3 | ||
| 29 | |||
| 30 | #define APCI1710_CHRONO_SET_CHANNELON 0 | ||
| 31 | #define APCI1710_CHRONO_SET_CHANNELOFF 1 | ||
| 32 | #define APCI1710_CHRONO_READ_CHANNEL 2 | ||
| 33 | #define APCI1710_CHRONO_READ_PORT 3 | ||
| 34 | |||
| 35 | /* | ||
| 36 | * CHRONOMETER INISIALISATION FUNCTION | ||
| 37 | */ | ||
| 38 | int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 39 | struct comedi_insn *insn, unsigned int *data); | ||
| 40 | |||
| 41 | int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, | ||
| 42 | struct comedi_subdevice *s, | ||
| 43 | struct comedi_insn *insn, | ||
| 44 | unsigned int *data); | ||
| 45 | |||
| 46 | /* | ||
| 47 | * CHRONOMETER READ FUNCTION | ||
| 48 | */ | ||
| 49 | int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 50 | struct comedi_insn *insn, unsigned int *data); | ||
| 51 | |||
| 52 | int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev, | ||
| 53 | unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus); | ||
| 54 | |||
| 55 | int i_APCI1710_ReadChronoValue(struct comedi_device *dev, | ||
| 56 | unsigned char b_ModulNbr, | ||
| 57 | unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus, | ||
| 58 | unsigned int *pul_ChronoValue); | ||
| 59 | |||
| 60 | int i_APCI1710_ConvertChronoValue(struct comedi_device *dev, | ||
| 61 | unsigned char b_ModulNbr, | ||
| 62 | unsigned int ul_ChronoValue, | ||
| 63 | unsigned int *pul_Hour, | ||
| 64 | unsigned char *pb_Minute, | ||
| 65 | unsigned char *pb_Second, | ||
| 66 | unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond, | ||
| 67 | unsigned int *pui_NanoSecond); | ||
| 68 | |||
| 69 | /* | ||
| 70 | * CHRONOMETER DIGITAL INPUT OUTPUT FUNCTION | ||
| 71 | */ | ||
| 72 | int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev, | ||
| 73 | struct comedi_subdevice *s, struct comedi_insn *insn, | ||
| 74 | unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h new file mode 100644 index 00000000000..cc3973d7c2a --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_ON 1 /* Digital Output ON or OFF */ | ||
| 19 | #define APCI1710_OFF 0 | ||
| 20 | |||
| 21 | #define APCI1710_INPUT 0 /* Digital I/O */ | ||
| 22 | #define APCI1710_OUTPUT 1 | ||
| 23 | |||
| 24 | #define APCI1710_DIGIO_MEMORYONOFF 0x10 | ||
| 25 | #define APCI1710_DIGIO_INIT 0x11 | ||
| 26 | |||
| 27 | /* | ||
| 28 | * DIGITAL I/O INISIALISATION FUNCTION | ||
| 29 | */ | ||
| 30 | int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 31 | struct comedi_insn *insn, unsigned int *data); | ||
| 32 | |||
| 33 | /* | ||
| 34 | * INPUT OUTPUT FUNCTIONS | ||
| 35 | */ | ||
| 36 | int i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev, | ||
| 37 | struct comedi_subdevice *s, | ||
| 38 | struct comedi_insn *insn, unsigned int *data); | ||
| 39 | |||
| 40 | int i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev, | ||
| 41 | struct comedi_subdevice *s, | ||
| 42 | struct comedi_insn *insn, unsigned int *data); | ||
| 43 | |||
| 44 | int i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev, | ||
| 45 | struct comedi_subdevice *s, | ||
| 46 | struct comedi_insn *insn, unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h new file mode 100644 index 00000000000..358298bfc64 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h | |||
| @@ -0,0 +1,271 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_16BIT_COUNTER 0x10 | ||
| 19 | #define APCI1710_32BIT_COUNTER 0x0 | ||
| 20 | #define APCI1710_QUADRUPLE_MODE 0x0 | ||
| 21 | #define APCI1710_DOUBLE_MODE 0x3 | ||
| 22 | #define APCI1710_SIMPLE_MODE 0xF | ||
| 23 | #define APCI1710_DIRECT_MODE 0x80 | ||
| 24 | #define APCI1710_HYSTERESIS_ON 0x60 | ||
| 25 | #define APCI1710_HYSTERESIS_OFF 0x0 | ||
| 26 | #define APCI1710_INCREMENT 0x60 | ||
| 27 | #define APCI1710_DECREMENT 0x0 | ||
| 28 | #define APCI1710_LATCH_COUNTER 0x1 | ||
| 29 | #define APCI1710_CLEAR_COUNTER 0x0 | ||
| 30 | #define APCI1710_LOW 0x0 | ||
| 31 | #define APCI1710_HIGH 0x1 | ||
| 32 | |||
| 33 | /*********************/ | ||
| 34 | /* Version 0600-0229 */ | ||
| 35 | /*********************/ | ||
| 36 | #define APCI1710_HIGH_EDGE_CLEAR_COUNTER 0x0 | ||
| 37 | #define APCI1710_HIGH_EDGE_LATCH_COUNTER 0x1 | ||
| 38 | #define APCI1710_LOW_EDGE_CLEAR_COUNTER 0x2 | ||
| 39 | #define APCI1710_LOW_EDGE_LATCH_COUNTER 0x3 | ||
| 40 | #define APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER 0x4 | ||
| 41 | #define APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER 0x5 | ||
| 42 | #define APCI1710_SOURCE_0 0x0 | ||
| 43 | #define APCI1710_SOURCE_1 0x1 | ||
| 44 | |||
| 45 | #define APCI1710_30MHZ 30 | ||
| 46 | #define APCI1710_33MHZ 33 | ||
| 47 | #define APCI1710_40MHZ 40 | ||
| 48 | |||
| 49 | #define APCI1710_ENABLE_LATCH_INT 0x80 | ||
| 50 | #define APCI1710_DISABLE_LATCH_INT (~APCI1710_ENABLE_LATCH_INT) | ||
| 51 | |||
| 52 | #define APCI1710_INDEX_LATCH_COUNTER 0x10 | ||
| 53 | #define APCI1710_INDEX_AUTO_MODE 0x8 | ||
| 54 | #define APCI1710_ENABLE_INDEX 0x4 | ||
| 55 | #define APCI1710_DISABLE_INDEX (~APCI1710_ENABLE_INDEX) | ||
| 56 | #define APCI1710_ENABLE_LATCH_AND_CLEAR 0x8 | ||
| 57 | #define APCI1710_DISABLE_LATCH_AND_CLEAR (~APCI1710_ENABLE_LATCH_AND_CLEAR) | ||
| 58 | #define APCI1710_SET_LOW_INDEX_LEVEL 0x4 | ||
| 59 | #define APCI1710_SET_HIGH_INDEX_LEVEL (~APCI1710_SET_LOW_INDEX_LEVEL) | ||
| 60 | #define APCI1710_INVERT_INDEX_RFERENCE 0x2 | ||
| 61 | #define APCI1710_DEFAULT_INDEX_RFERENCE (~APCI1710_INVERT_INDEX_RFERENCE) | ||
| 62 | |||
| 63 | #define APCI1710_ENABLE_INDEX_INT 0x1 | ||
| 64 | #define APCI1710_DISABLE_INDEX_INT (~APCI1710_ENABLE_INDEX_INT) | ||
| 65 | |||
| 66 | #define APCI1710_ENABLE_FREQUENCY 0x4 | ||
| 67 | #define APCI1710_DISABLE_FREQUENCY (~APCI1710_ENABLE_FREQUENCY) | ||
| 68 | |||
| 69 | #define APCI1710_ENABLE_FREQUENCY_INT 0x8 | ||
| 70 | #define APCI1710_DISABLE_FREQUENCY_INT (~APCI1710_ENABLE_FREQUENCY_INT) | ||
| 71 | |||
| 72 | #define APCI1710_ENABLE_40MHZ_FREQUENCY 0x40 | ||
| 73 | #define APCI1710_DISABLE_40MHZ_FREQUENCY (~APCI1710_ENABLE_40MHZ_FREQUENCY) | ||
| 74 | |||
| 75 | #define APCI1710_ENABLE_40MHZ_FILTER 0x80 | ||
| 76 | #define APCI1710_DISABLE_40MHZ_FILTER (~APCI1710_ENABLE_40MHZ_FILTER) | ||
| 77 | |||
| 78 | #define APCI1710_ENABLE_COMPARE_INT 0x2 | ||
| 79 | #define APCI1710_DISABLE_COMPARE_INT (~APCI1710_ENABLE_COMPARE_INT) | ||
| 80 | |||
| 81 | #define APCI1710_ENABLE_INDEX_ACTION 0x20 | ||
| 82 | #define APCI1710_DISABLE_INDEX_ACTION (~APCI1710_ENABLE_INDEX_ACTION) | ||
| 83 | #define APCI1710_REFERENCE_HIGH 0x40 | ||
| 84 | #define APCI1710_REFERENCE_LOW (~APCI1710_REFERENCE_HIGH) | ||
| 85 | |||
| 86 | #define APCI1710_TOR_GATE_LOW 0x40 | ||
| 87 | #define APCI1710_TOR_GATE_HIGH (~APCI1710_TOR_GATE_LOW) | ||
| 88 | |||
| 89 | /* INSN CONFIG */ | ||
| 90 | #define APCI1710_INCCPT_INITCOUNTER 100 | ||
| 91 | #define APCI1710_INCCPT_COUNTERAUTOTEST 101 | ||
| 92 | #define APCI1710_INCCPT_INITINDEX 102 | ||
| 93 | #define APCI1710_INCCPT_INITREFERENCE 103 | ||
| 94 | #define APCI1710_INCCPT_INITEXTERNALSTROBE 104 | ||
| 95 | #define APCI1710_INCCPT_INITCOMPARELOGIC 105 | ||
| 96 | #define APCI1710_INCCPT_INITFREQUENCYMEASUREMENT 106 | ||
| 97 | |||
| 98 | /* INSN READ */ | ||
| 99 | #define APCI1710_INCCPT_READLATCHREGISTERSTATUS 200 | ||
| 100 | #define APCI1710_INCCPT_READLATCHREGISTERVALUE 201 | ||
| 101 | #define APCI1710_INCCPT_READ16BITCOUNTERVALUE 202 | ||
| 102 | #define APCI1710_INCCPT_READ32BITCOUNTERVALUE 203 | ||
| 103 | #define APCI1710_INCCPT_GETINDEXSTATUS 204 | ||
| 104 | #define APCI1710_INCCPT_GETREFERENCESTATUS 205 | ||
| 105 | #define APCI1710_INCCPT_GETUASSTATUS 206 | ||
| 106 | #define APCI1710_INCCPT_GETCBSTATUS 207 | ||
| 107 | #define APCI1710_INCCPT_GET16BITCBSTATUS 208 | ||
| 108 | #define APCI1710_INCCPT_GETUDSTATUS 209 | ||
| 109 | #define APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS 210 | ||
| 110 | #define APCI1710_INCCPT_READFREQUENCYMEASUREMENT 211 | ||
| 111 | #define APCI1710_INCCPT_READINTERRUPT 212 | ||
| 112 | |||
| 113 | /* INSN BITS */ | ||
| 114 | #define APCI1710_INCCPT_CLEARCOUNTERVALUE 300 | ||
| 115 | #define APCI1710_INCCPT_CLEARALLCOUNTERVALUE 301 | ||
| 116 | #define APCI1710_INCCPT_SETINPUTFILTER 302 | ||
| 117 | #define APCI1710_INCCPT_LATCHCOUNTER 303 | ||
| 118 | #define APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE 304 | ||
| 119 | #define APCI1710_INCCPT_SETDIGITALCHLON 305 | ||
| 120 | #define APCI1710_INCCPT_SETDIGITALCHLOFF 306 | ||
| 121 | |||
| 122 | /* INSN WRITE */ | ||
| 123 | #define APCI1710_INCCPT_ENABLELATCHINTERRUPT 400 | ||
| 124 | #define APCI1710_INCCPT_DISABLELATCHINTERRUPT 401 | ||
| 125 | #define APCI1710_INCCPT_WRITE16BITCOUNTERVALUE 402 | ||
| 126 | #define APCI1710_INCCPT_WRITE32BITCOUNTERVALUE 403 | ||
| 127 | #define APCI1710_INCCPT_ENABLEINDEX 404 | ||
| 128 | #define APCI1710_INCCPT_DISABLEINDEX 405 | ||
| 129 | #define APCI1710_INCCPT_ENABLECOMPARELOGIC 406 | ||
| 130 | #define APCI1710_INCCPT_DISABLECOMPARELOGIC 407 | ||
| 131 | #define APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT 408 | ||
| 132 | #define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT 409 | ||
| 133 | |||
| 134 | /************ Main Functions *************/ | ||
| 135 | int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 136 | struct comedi_insn *insn, unsigned int * data); | ||
| 137 | |||
| 138 | int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, | ||
| 139 | struct comedi_insn *insn, unsigned int * data); | ||
| 140 | |||
| 141 | int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, | ||
| 142 | struct comedi_insn *insn, unsigned int * data); | ||
| 143 | |||
| 144 | int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice * s, | ||
| 145 | struct comedi_insn *insn, unsigned int * data); | ||
| 146 | |||
| 147 | /*********** Supplementary Functions********/ | ||
| 148 | |||
| 149 | /* INSN CONFIG */ | ||
| 150 | int i_APCI1710_InitCounter(struct comedi_device *dev, | ||
| 151 | unsigned char b_ModulNbr, | ||
| 152 | unsigned char b_CounterRange, | ||
| 153 | unsigned char b_FirstCounterModus, | ||
| 154 | unsigned char b_FirstCounterOption, | ||
| 155 | unsigned char b_SecondCounterModus, | ||
| 156 | unsigned char b_SecondCounterOption); | ||
| 157 | |||
| 158 | int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char * pb_TestStatus); | ||
| 159 | |||
| 160 | int i_APCI1710_InitIndex(struct comedi_device *dev, | ||
| 161 | unsigned char b_ModulNbr, | ||
| 162 | unsigned char b_ReferenceAction, | ||
| 163 | unsigned char b_IndexOperation, unsigned char b_AutoMode, | ||
| 164 | unsigned char b_InterruptEnable); | ||
| 165 | |||
| 166 | int i_APCI1710_InitReference(struct comedi_device *dev, | ||
| 167 | unsigned char b_ModulNbr, unsigned char b_ReferenceLevel); | ||
| 168 | |||
| 169 | int i_APCI1710_InitExternalStrobe(struct comedi_device *dev, | ||
| 170 | unsigned char b_ModulNbr, unsigned char b_ExternalStrobe, | ||
| 171 | unsigned char b_ExternalStrobeLevel); | ||
| 172 | |||
| 173 | int i_APCI1710_InitCompareLogic(struct comedi_device *dev, | ||
| 174 | unsigned char b_ModulNbr, unsigned int ui_CompareValue); | ||
| 175 | |||
| 176 | int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev, | ||
| 177 | unsigned char b_ModulNbr, | ||
| 178 | unsigned char b_PCIInputClock, | ||
| 179 | unsigned char b_TimingUnity, | ||
| 180 | unsigned int ul_TimingInterval, | ||
| 181 | unsigned int *pul_RealTimingInterval); | ||
| 182 | |||
| 183 | /* INSN BITS */ | ||
| 184 | int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 185 | |||
| 186 | int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev); | ||
| 187 | |||
| 188 | int i_APCI1710_SetInputFilter(struct comedi_device *dev, | ||
| 189 | unsigned char b_ModulNbr, unsigned char b_PCIInputClock, | ||
| 190 | unsigned char b_Filter); | ||
| 191 | |||
| 192 | int i_APCI1710_LatchCounter(struct comedi_device *dev, | ||
| 193 | unsigned char b_ModulNbr, unsigned char b_LatchReg); | ||
| 194 | |||
| 195 | int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev, | ||
| 196 | unsigned char b_ModulNbr, | ||
| 197 | unsigned char b_SourceSelection); | ||
| 198 | |||
| 199 | int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 200 | |||
| 201 | int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 202 | |||
| 203 | /* INSN WRITE */ | ||
| 204 | int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 205 | |||
| 206 | int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 207 | |||
| 208 | int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev, | ||
| 209 | unsigned char b_ModulNbr, unsigned char b_SelectedCounter, | ||
| 210 | unsigned int ui_WriteValue); | ||
| 211 | |||
| 212 | int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev, | ||
| 213 | unsigned char b_ModulNbr, unsigned int ul_WriteValue); | ||
| 214 | |||
| 215 | int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 216 | |||
| 217 | int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 218 | |||
| 219 | int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 220 | |||
| 221 | int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr); | ||
| 222 | |||
| 223 | int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev, | ||
| 224 | unsigned char b_ModulNbr, | ||
| 225 | unsigned char b_InterruptEnable); | ||
| 226 | |||
| 227 | int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, | ||
| 228 | unsigned char b_ModulNbr); | ||
| 229 | |||
| 230 | /* INSN READ */ | ||
| 231 | int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev, | ||
| 232 | unsigned char b_ModulNbr, unsigned char b_LatchReg, | ||
| 233 | unsigned char *pb_LatchStatus); | ||
| 234 | |||
| 235 | int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev, | ||
| 236 | unsigned char b_ModulNbr, unsigned char b_LatchReg, | ||
| 237 | unsigned int *pul_LatchValue); | ||
| 238 | |||
| 239 | int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev, | ||
| 240 | unsigned char b_ModulNbr, unsigned char b_SelectedCounter, | ||
| 241 | unsigned int *pui_CounterValue); | ||
| 242 | |||
| 243 | int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev, | ||
| 244 | unsigned char b_ModulNbr, unsigned int *pul_CounterValue); | ||
| 245 | |||
| 246 | int i_APCI1710_GetIndexStatus(struct comedi_device *dev, | ||
| 247 | unsigned char b_ModulNbr, unsigned char *pb_IndexStatus); | ||
| 248 | |||
| 249 | int i_APCI1710_GetReferenceStatus(struct comedi_device *dev, | ||
| 250 | unsigned char b_ModulNbr, unsigned char *pb_ReferenceStatus); | ||
| 251 | |||
| 252 | int i_APCI1710_GetUASStatus(struct comedi_device *dev, | ||
| 253 | unsigned char b_ModulNbr, unsigned char *pb_UASStatus); | ||
| 254 | |||
| 255 | int i_APCI1710_GetCBStatus(struct comedi_device *dev, | ||
| 256 | unsigned char b_ModulNbr, unsigned char *pb_CBStatus); | ||
| 257 | |||
| 258 | int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev, | ||
| 259 | unsigned char b_ModulNbr, unsigned char *pb_CBStatusCounter0, | ||
| 260 | unsigned char *pb_CBStatusCounter1); | ||
| 261 | |||
| 262 | int i_APCI1710_GetUDStatus(struct comedi_device *dev, | ||
| 263 | unsigned char b_ModulNbr, unsigned char *pb_UDStatus); | ||
| 264 | |||
| 265 | int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev, | ||
| 266 | unsigned char b_ModulNbr, unsigned char *pb_UDStatus); | ||
| 267 | |||
| 268 | int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev, | ||
| 269 | unsigned char b_ModulNbr, | ||
| 270 | unsigned char *pb_Status, unsigned char *pb_UDStatus, | ||
| 271 | unsigned int *pul_ReadValue); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h new file mode 100644 index 00000000000..31fbb0bec52 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_SINGLE 0 | ||
| 19 | #define APCI1710_CONTINUOUS 1 | ||
| 20 | |||
| 21 | #define APCI1710_PULSEENCODER_READ 0 | ||
| 22 | #define APCI1710_PULSEENCODER_WRITE 1 | ||
| 23 | |||
| 24 | int i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev, | ||
| 25 | struct comedi_subdevice *s, | ||
| 26 | struct comedi_insn *insn, unsigned int *data); | ||
| 27 | |||
| 28 | int i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev, | ||
| 29 | struct comedi_subdevice *s, | ||
| 30 | struct comedi_insn *insn, | ||
| 31 | unsigned int *data); | ||
| 32 | |||
| 33 | /* | ||
| 34 | * READ PULSE ENCODER FUNCTIONS | ||
| 35 | */ | ||
| 36 | int i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev, | ||
| 37 | struct comedi_subdevice *s, | ||
| 38 | struct comedi_insn *insn, | ||
| 39 | unsigned int *data); | ||
| 40 | |||
| 41 | /* | ||
| 42 | * WRITE PULSE ENCODER FUNCTIONS | ||
| 43 | */ | ||
| 44 | int i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev, | ||
| 45 | struct comedi_subdevice *s, | ||
| 46 | struct comedi_insn *insn, | ||
| 47 | unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h new file mode 100644 index 00000000000..d8ad0b9cf50 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_30MHZ 30 | ||
| 19 | #define APCI1710_33MHZ 33 | ||
| 20 | #define APCI1710_40MHZ 40 | ||
| 21 | |||
| 22 | #define APCI1710_PWM_INIT 0 | ||
| 23 | #define APCI1710_PWM_GETINITDATA 1 | ||
| 24 | |||
| 25 | #define APCI1710_PWM_DISABLE 0 | ||
| 26 | #define APCI1710_PWM_ENABLE 1 | ||
| 27 | #define APCI1710_PWM_NEWTIMING 2 | ||
| 28 | |||
| 29 | int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 30 | struct comedi_insn *insn, unsigned int *data); | ||
| 31 | |||
| 32 | int i_APCI1710_InitPWM(struct comedi_device *dev, | ||
| 33 | unsigned char b_ModulNbr, | ||
| 34 | unsigned char b_PWM, | ||
| 35 | unsigned char b_ClockSelection, | ||
| 36 | unsigned char b_TimingUnit, | ||
| 37 | unsigned int ul_LowTiming, | ||
| 38 | unsigned int ul_HighTiming, | ||
| 39 | unsigned int *pul_RealLowTiming, unsigned int *pul_RealHighTiming); | ||
| 40 | |||
| 41 | int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev, | ||
| 42 | unsigned char b_ModulNbr, | ||
| 43 | unsigned char b_PWM, | ||
| 44 | unsigned char *pb_TimingUnit, | ||
| 45 | unsigned int *pul_LowTiming, | ||
| 46 | unsigned int *pul_HighTiming, | ||
| 47 | unsigned char *pb_StartLevel, | ||
| 48 | unsigned char *pb_StopMode, | ||
| 49 | unsigned char *pb_StopLevel, | ||
| 50 | unsigned char *pb_ExternGate, | ||
| 51 | unsigned char *pb_InterruptEnable, unsigned char *pb_Enable); | ||
| 52 | |||
| 53 | int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 54 | struct comedi_insn *insn, unsigned int *data); | ||
| 55 | |||
| 56 | int i_APCI1710_EnablePWM(struct comedi_device *dev, | ||
| 57 | unsigned char b_ModulNbr, | ||
| 58 | unsigned char b_PWM, | ||
| 59 | unsigned char b_StartLevel, | ||
| 60 | unsigned char b_StopMode, | ||
| 61 | unsigned char b_StopLevel, unsigned char b_ExternGate, | ||
| 62 | unsigned char b_InterruptEnable); | ||
| 63 | |||
| 64 | int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev, | ||
| 65 | unsigned char b_ModulNbr, | ||
| 66 | unsigned char b_PWM, unsigned char b_TimingUnit, | ||
| 67 | unsigned int ul_LowTiming, unsigned int ul_HighTiming); | ||
| 68 | |||
| 69 | int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, unsigned char b_PWM); | ||
| 70 | |||
| 71 | int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 72 | struct comedi_insn *insn, unsigned int *data); | ||
| 73 | |||
| 74 | int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev, | ||
| 75 | struct comedi_subdevice *s, | ||
| 76 | struct comedi_insn *insn, unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h new file mode 100644 index 00000000000..ef4d88789d5 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_30MHZ 30 | ||
| 19 | #define APCI1710_33MHZ 33 | ||
| 20 | #define APCI1710_40MHZ 40 | ||
| 21 | |||
| 22 | #define APCI1710_BINARY_MODE 0x1 | ||
| 23 | #define APCI1710_GRAY_MODE 0x0 | ||
| 24 | |||
| 25 | #define APCI1710_SSI_READ1VALUE 1 | ||
| 26 | #define APCI1710_SSI_READALLVALUE 2 | ||
| 27 | |||
| 28 | #define APCI1710_SSI_SET_CHANNELON 0 | ||
| 29 | #define APCI1710_SSI_SET_CHANNELOFF 1 | ||
| 30 | #define APCI1710_SSI_READ_1CHANNEL 2 | ||
| 31 | #define APCI1710_SSI_READ_ALLCHANNEL 3 | ||
| 32 | |||
| 33 | /* | ||
| 34 | * SSI INISIALISATION FUNCTION | ||
| 35 | */ | ||
| 36 | int i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 37 | struct comedi_insn *insn, unsigned int *data); | ||
| 38 | |||
| 39 | int i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 40 | struct comedi_insn *insn, unsigned int *data); | ||
| 41 | |||
| 42 | int i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 43 | struct comedi_insn *insn, unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h new file mode 100644 index 00000000000..537d4755132 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_30MHZ 30 | ||
| 19 | #define APCI1710_33MHZ 33 | ||
| 20 | #define APCI1710_40MHZ 40 | ||
| 21 | |||
| 22 | #define APCI1710_GATE_INPUT 10 | ||
| 23 | |||
| 24 | #define APCI1710_TOR_SIMPLE_MODE 2 | ||
| 25 | #define APCI1710_TOR_DOUBLE_MODE 3 | ||
| 26 | #define APCI1710_TOR_QUADRUPLE_MODE 4 | ||
| 27 | |||
| 28 | #define APCI1710_SINGLE 0 | ||
| 29 | #define APCI1710_CONTINUOUS 1 | ||
| 30 | |||
| 31 | #define APCI1710_TOR_GETPROGRESSSTATUS 0 | ||
| 32 | #define APCI1710_TOR_GETCOUNTERVALUE 1 | ||
| 33 | #define APCI1710_TOR_READINTERRUPT 2 | ||
| 34 | |||
| 35 | /* | ||
| 36 | * TOR_COUNTER INISIALISATION FUNCTION | ||
| 37 | */ | ||
| 38 | int i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev, | ||
| 39 | struct comedi_subdevice *s, | ||
| 40 | struct comedi_insn *insn, unsigned int *data); | ||
| 41 | |||
| 42 | int i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev, | ||
| 43 | struct comedi_subdevice *s, | ||
| 44 | struct comedi_insn *insn, | ||
| 45 | unsigned int *data); | ||
| 46 | |||
| 47 | int i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev, | ||
| 48 | struct comedi_subdevice *s, | ||
| 49 | struct comedi_insn *insn, | ||
| 50 | unsigned int *data); | ||
| 51 | /* | ||
| 52 | * TOR_COUNTER READ FUNCTION | ||
| 53 | */ | ||
| 54 | int i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev, | ||
| 55 | struct comedi_subdevice *s, | ||
| 56 | struct comedi_insn *insn, | ||
| 57 | unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h new file mode 100644 index 00000000000..adcab824b25 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define APCI1710_TTL_INIT 0 | ||
| 19 | #define APCI1710_TTL_INITDIRECTION 1 | ||
| 20 | |||
| 21 | #define APCI1710_TTL_READCHANNEL 0 | ||
| 22 | #define APCI1710_TTL_READPORT 1 | ||
| 23 | |||
| 24 | /* | ||
| 25 | * TTL INISIALISATION FUNCTION | ||
| 26 | */ | ||
| 27 | int i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 28 | struct comedi_insn *insn, unsigned int *data); | ||
| 29 | |||
| 30 | /* | ||
| 31 | * TTL INPUT FUNCTION | ||
| 32 | */ | ||
| 33 | int i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 34 | struct comedi_insn *insn, unsigned int *data); | ||
| 35 | int i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev, | ||
| 36 | struct comedi_subdevice *s, | ||
| 37 | struct comedi_insn *insn, unsigned int *data); | ||
| 38 | |||
| 39 | /* | ||
| 40 | * TTL OUTPUT FUNCTIONS | ||
| 41 | */ | ||
| 42 | int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev, | ||
| 43 | struct comedi_subdevice *s, | ||
| 44 | struct comedi_insn *insn, unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c new file mode 100644 index 00000000000..b973095146f --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | /** | ||
| 2 | @verbatim | ||
| 3 | |||
| 4 | Copyright (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 | |||
| 14 | 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. | ||
| 15 | |||
| 16 | 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. | ||
| 17 | |||
| 18 | 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 | ||
| 19 | |||
| 20 | You should also find the complete GPL in the COPYING file accompanying this source code. | ||
| 21 | |||
| 22 | @endverbatim | ||
| 23 | */ | ||
| 24 | /* | ||
| 25 | +-----------------------------------------------------------------------+ | ||
| 26 | | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | | ||
| 27 | +-----------------------------------------------------------------------+ | ||
| 28 | | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | | ||
| 29 | | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | | ||
| 30 | +-------------------------------+---------------------------------------+ | ||
| 31 | | Project : ADDI HEADER READ WRITER | Compiler : Visual C++ | | ||
| 32 | | Module name : S5920.cpp | Version : 6.0 | | ||
| 33 | +-------------------------------+---------------------------------------+ | ||
| 34 | | Author : E. LIBS Date : 02/05/2002 | | ||
| 35 | +-----------------------------------------------------------------------+ | ||
| 36 | | Description : DLL with the S5920 PCI Controller functions | | ||
| 37 | +-----------------------------------------------------------------------+ | ||
| 38 | | UPDATE'S | | ||
| 39 | +-----------------------------------------------------------------------+ | ||
| 40 | | Date | Author | Description of updates | | ||
| 41 | +----------+-----------+------------------------------------------------+ | ||
| 42 | | 28/08/02 | LIBS Eric | Add return codes each time a function of the | | ||
| 43 | | | | Addi Library is called | | ||
| 44 | +-----------------------------------------------------------------------+ | ||
| 45 | | 31/07/03 | KRAUTH J. | Changes for the MSX-Box | | ||
| 46 | +-----------------------------------------------------------------------+ | ||
| 47 | */ | ||
| 48 | |||
| 49 | #include "addi_amcc_S5920.h" | ||
| 50 | |||
| 51 | /*+----------------------------------------------------------------------------+*/ | ||
| 52 | /*| Function Name : int i_AddiHeaderRW_ReadEeprom |*/ | ||
| 53 | /*| (int i_NbOfWordsToRead, |*/ | ||
| 54 | /*| unsigned int dw_PCIBoardEepromAddress, |*/ | ||
| 55 | /*| unsigned short w_EepromStartAddress, |*/ | ||
| 56 | /*| unsigned short * pw_DataRead) |*/ | ||
| 57 | /*+----------------------------------------------------------------------------+*/ | ||
| 58 | /*| Task : Read word from the 5920 eeprom. |*/ | ||
| 59 | /*+----------------------------------------------------------------------------+*/ | ||
| 60 | /*| Input Parameters : int i_NbOfWordsToRead : Nbr. of word to read |*/ | ||
| 61 | /*| unsigned int dw_PCIBoardEepromAddress : Address of the eeprom |*/ | ||
| 62 | /*| unsigned short w_EepromStartAddress : Eeprom start address |*/ | ||
| 63 | /*+----------------------------------------------------------------------------+*/ | ||
| 64 | /*| Output Parameters : unsigned short * pw_DataRead : Read data |*/ | ||
| 65 | /*+----------------------------------------------------------------------------+*/ | ||
| 66 | /*| Return Value : - |*/ | ||
| 67 | /*+----------------------------------------------------------------------------+*/ | ||
| 68 | |||
| 69 | int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead, | ||
| 70 | unsigned int dw_PCIBoardEepromAddress, | ||
| 71 | unsigned short w_EepromStartAddress, unsigned short *pw_DataRead) | ||
| 72 | { | ||
| 73 | unsigned int dw_eeprom_busy = 0; | ||
| 74 | int i_Counter = 0; | ||
| 75 | int i_WordCounter; | ||
| 76 | int i; | ||
| 77 | unsigned char pb_ReadByte[1]; | ||
| 78 | unsigned char b_ReadLowByte = 0; | ||
| 79 | unsigned char b_ReadHighByte = 0; | ||
| 80 | unsigned char b_SelectedAddressLow = 0; | ||
| 81 | unsigned char b_SelectedAddressHigh = 0; | ||
| 82 | unsigned short w_ReadWord = 0; | ||
| 83 | |||
| 84 | for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead; | ||
| 85 | i_WordCounter++) { | ||
| 86 | do { | ||
| 87 | dw_eeprom_busy = | ||
| 88 | inl(dw_PCIBoardEepromAddress + | ||
| 89 | AMCC_OP_REG_MCSR); | ||
| 90 | dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; | ||
| 91 | } while (dw_eeprom_busy == EEPROM_BUSY); | ||
| 92 | |||
| 93 | for (i_Counter = 0; i_Counter < 2; i_Counter++) { | ||
| 94 | b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; /* Read the low 8 bit part */ | ||
| 95 | b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; /* Read the high 8 bit part */ | ||
| 96 | |||
| 97 | /* Select the load low address mode */ | ||
| 98 | outb(NVCMD_LOAD_LOW, | ||
| 99 | dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + | ||
| 100 | 3); | ||
| 101 | |||
| 102 | /* Wait on busy */ | ||
| 103 | do { | ||
| 104 | dw_eeprom_busy = | ||
| 105 | inl(dw_PCIBoardEepromAddress + | ||
| 106 | AMCC_OP_REG_MCSR); | ||
| 107 | dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; | ||
| 108 | } while (dw_eeprom_busy == EEPROM_BUSY); | ||
| 109 | |||
| 110 | /* Load the low address */ | ||
| 111 | outb(b_SelectedAddressLow, | ||
| 112 | dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + | ||
| 113 | 2); | ||
| 114 | |||
| 115 | /* Wait on busy */ | ||
| 116 | do { | ||
| 117 | dw_eeprom_busy = | ||
| 118 | inl(dw_PCIBoardEepromAddress + | ||
| 119 | AMCC_OP_REG_MCSR); | ||
| 120 | dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; | ||
| 121 | } while (dw_eeprom_busy == EEPROM_BUSY); | ||
| 122 | |||
| 123 | /* Select the load high address mode */ | ||
| 124 | outb(NVCMD_LOAD_HIGH, | ||
| 125 | dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + | ||
| 126 | 3); | ||
| 127 | |||
| 128 | /* Wait on busy */ | ||
| 129 | do { | ||
| 130 | dw_eeprom_busy = | ||
| 131 | inl(dw_PCIBoardEepromAddress + | ||
| 132 | AMCC_OP_REG_MCSR); | ||
| 133 | dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; | ||
| 134 | } while (dw_eeprom_busy == EEPROM_BUSY); | ||
| 135 | |||
| 136 | /* Load the high address */ | ||
| 137 | outb(b_SelectedAddressHigh, | ||
| 138 | dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + | ||
| 139 | 2); | ||
| 140 | |||
| 141 | /* Wait on busy */ | ||
| 142 | do { | ||
| 143 | dw_eeprom_busy = | ||
| 144 | inl(dw_PCIBoardEepromAddress + | ||
| 145 | AMCC_OP_REG_MCSR); | ||
| 146 | dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; | ||
| 147 | } while (dw_eeprom_busy == EEPROM_BUSY); | ||
| 148 | |||
| 149 | /* Select the READ mode */ | ||
| 150 | outb(NVCMD_BEGIN_READ, | ||
| 151 | dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + | ||
| 152 | 3); | ||
| 153 | |||
| 154 | /* Wait on busy */ | ||
| 155 | do { | ||
| 156 | dw_eeprom_busy = | ||
| 157 | inl(dw_PCIBoardEepromAddress + | ||
| 158 | AMCC_OP_REG_MCSR); | ||
| 159 | dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; | ||
| 160 | } while (dw_eeprom_busy == EEPROM_BUSY); | ||
| 161 | |||
| 162 | /* Read data into the EEPROM */ | ||
| 163 | *pb_ReadByte = | ||
| 164 | inb(dw_PCIBoardEepromAddress + | ||
| 165 | AMCC_OP_REG_MCSR + 2); | ||
| 166 | |||
| 167 | /* Wait on busy */ | ||
| 168 | do { | ||
| 169 | dw_eeprom_busy = | ||
| 170 | inl(dw_PCIBoardEepromAddress + | ||
| 171 | AMCC_OP_REG_MCSR); | ||
| 172 | dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; | ||
| 173 | } while (dw_eeprom_busy == EEPROM_BUSY); | ||
| 174 | |||
| 175 | /* Select the upper address part */ | ||
| 176 | if (i_Counter == 0) | ||
| 177 | b_ReadLowByte = pb_ReadByte[0]; | ||
| 178 | else | ||
| 179 | b_ReadHighByte = pb_ReadByte[0]; | ||
| 180 | |||
| 181 | /* Sleep */ | ||
| 182 | msleep(1); | ||
| 183 | |||
| 184 | } | ||
| 185 | w_ReadWord = | ||
| 186 | (b_ReadLowByte | (((unsigned short)b_ReadHighByte) * | ||
| 187 | 256)); | ||
| 188 | |||
| 189 | pw_DataRead[i_WordCounter] = w_ReadWord; | ||
| 190 | |||
| 191 | w_EepromStartAddress += 2; /* to read the next word */ | ||
| 192 | |||
| 193 | } /* for (...) i_NbOfWordsToRead */ | ||
| 194 | return 0; | ||
| 195 | } | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h new file mode 100644 index 00000000000..9afdb1357aa --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define AMCC_OP_REG_MCSR 0x3c | ||
| 19 | #define EEPROM_BUSY 0x80000000 | ||
| 20 | #define NVCMD_LOAD_LOW (0x4 << 5) /* nvRam load low command */ | ||
| 21 | #define NVCMD_LOAD_HIGH (0x5 << 5) /* nvRam load high command */ | ||
| 22 | #define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */ | ||
| 23 | #define NVCMD_BEGIN_WRITE (0x6 << 5) /* EEPROM begin write command */ | ||
| 24 | |||
| 25 | int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead, | ||
| 26 | unsigned int dw_PCIBoardEepromAddress, | ||
| 27 | unsigned short w_EepromStartAddress, unsigned short *pw_DataRead); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h new file mode 100644 index 00000000000..35a3ea19359 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h | |||
| @@ -0,0 +1,475 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* Header file for AMCC s 5933 */ | ||
| 19 | |||
| 20 | #ifndef _AMCC_S5933_H_ | ||
| 21 | #define _AMCC_S5933_H_ | ||
| 22 | |||
| 23 | #include "../../comedidev.h" | ||
| 24 | |||
| 25 | #include "../comedi_pci.h" | ||
| 26 | |||
| 27 | #ifdef PCI_SUPPORT_VER1 | ||
| 28 | #error No support for 2.1.55 and older | ||
| 29 | #endif | ||
| 30 | |||
| 31 | /* written on base0 */ | ||
| 32 | #define FIFO_ADVANCE_ON_BYTE_2 0x20000000 | ||
| 33 | |||
| 34 | /* added for step 6 dma written on base2 */ | ||
| 35 | #define AMWEN_ENABLE 0x02 | ||
| 36 | |||
| 37 | #define A2P_FIFO_WRITE_ENABLE 0x01 | ||
| 38 | |||
| 39 | /* for transfer count enable bit */ | ||
| 40 | #define AGCSTS_TC_ENABLE 0x10000000 | ||
| 41 | |||
| 42 | /* | ||
| 43 | * ADDON RELATED ADDITIONS | ||
| 44 | */ | ||
| 45 | /* Constant */ | ||
| 46 | #define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW 0x00 | ||
| 47 | #define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH 0x1200 | ||
| 48 | #define APCI3120_A2P_FIFO_MANAGEMENT 0x04000400L | ||
| 49 | #define APCI3120_AMWEN_ENABLE 0x02 | ||
| 50 | #define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01 | ||
| 51 | #define APCI3120_FIFO_ADVANCE_ON_BYTE_2 0x20000000L | ||
| 52 | #define APCI3120_ENABLE_WRITE_TC_INT 0x00004000L | ||
| 53 | #define APCI3120_CLEAR_WRITE_TC_INT 0x00040000L | ||
| 54 | #define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE 0x0 | ||
| 55 | #define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0 | ||
| 56 | #define APCI3120_DISABLE_BUS_MASTER_PCI 0x0 | ||
| 57 | |||
| 58 | /* ADD_ON ::: this needed since apci supports 16 bit interface to add on */ | ||
| 59 | #define APCI3120_ADD_ON_AGCSTS_LOW 0x3C | ||
| 60 | #define APCI3120_ADD_ON_AGCSTS_HIGH (APCI3120_ADD_ON_AGCSTS_LOW + 2) | ||
| 61 | #define APCI3120_ADD_ON_MWAR_LOW 0x24 | ||
| 62 | #define APCI3120_ADD_ON_MWAR_HIGH (APCI3120_ADD_ON_MWAR_LOW + 2) | ||
| 63 | #define APCI3120_ADD_ON_MWTC_LOW 0x058 | ||
| 64 | #define APCI3120_ADD_ON_MWTC_HIGH (APCI3120_ADD_ON_MWTC_LOW + 2) | ||
| 65 | |||
| 66 | /* AMCC */ | ||
| 67 | #define APCI3120_AMCC_OP_MCSR 0x3C | ||
| 68 | #define APCI3120_AMCC_OP_REG_INTCSR 0x38 | ||
| 69 | |||
| 70 | /* | ||
| 71 | * AMCC Operation Register Offsets - PCI | ||
| 72 | */ | ||
| 73 | #define AMCC_OP_REG_OMB1 0x00 | ||
| 74 | #define AMCC_OP_REG_OMB2 0x04 | ||
| 75 | #define AMCC_OP_REG_OMB3 0x08 | ||
| 76 | #define AMCC_OP_REG_OMB4 0x0c | ||
| 77 | #define AMCC_OP_REG_IMB1 0x10 | ||
| 78 | #define AMCC_OP_REG_IMB2 0x14 | ||
| 79 | #define AMCC_OP_REG_IMB3 0x18 | ||
| 80 | #define AMCC_OP_REG_IMB4 0x1c | ||
| 81 | #define AMCC_OP_REG_FIFO 0x20 | ||
| 82 | #define AMCC_OP_REG_MWAR 0x24 | ||
| 83 | #define AMCC_OP_REG_MWTC 0x28 | ||
| 84 | #define AMCC_OP_REG_MRAR 0x2c | ||
| 85 | #define AMCC_OP_REG_MRTC 0x30 | ||
| 86 | #define AMCC_OP_REG_MBEF 0x34 | ||
| 87 | #define AMCC_OP_REG_INTCSR 0x38 | ||
| 88 | /* int source */ | ||
| 89 | #define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2) | ||
| 90 | /* FIFO ctrl */ | ||
| 91 | #define AMCC_OP_REG_INTCSR_FEC (AMCC_OP_REG_INTCSR + 3) | ||
| 92 | #define AMCC_OP_REG_MCSR 0x3c | ||
| 93 | /* Data in byte 2 */ | ||
| 94 | #define AMCC_OP_REG_MCSR_NVDATA (AMCC_OP_REG_MCSR + 2) | ||
| 95 | /* Command in byte 3 */ | ||
| 96 | #define AMCC_OP_REG_MCSR_NVCMD (AMCC_OP_REG_MCSR + 3) | ||
| 97 | |||
| 98 | #define AMCC_FIFO_DEPTH_DWORD 8 | ||
| 99 | #define AMCC_FIFO_DEPTH_BYTES (8 * sizeof(u32)) | ||
| 100 | |||
| 101 | /* | ||
| 102 | * AMCC Operation Registers Size - PCI | ||
| 103 | */ | ||
| 104 | #define AMCC_OP_REG_SIZE 64 /* in bytes */ | ||
| 105 | |||
| 106 | /* | ||
| 107 | * AMCC Operation Register Offsets - Add-on | ||
| 108 | */ | ||
| 109 | #define AMCC_OP_REG_AIMB1 0x00 | ||
| 110 | #define AMCC_OP_REG_AIMB2 0x04 | ||
| 111 | #define AMCC_OP_REG_AIMB3 0x08 | ||
| 112 | #define AMCC_OP_REG_AIMB4 0x0c | ||
| 113 | #define AMCC_OP_REG_AOMB1 0x10 | ||
| 114 | #define AMCC_OP_REG_AOMB2 0x14 | ||
| 115 | #define AMCC_OP_REG_AOMB3 0x18 | ||
| 116 | #define AMCC_OP_REG_AOMB4 0x1c | ||
| 117 | #define AMCC_OP_REG_AFIFO 0x20 | ||
| 118 | #define AMCC_OP_REG_AMWAR 0x24 | ||
| 119 | #define AMCC_OP_REG_APTA 0x28 | ||
| 120 | #define AMCC_OP_REG_APTD 0x2c | ||
| 121 | #define AMCC_OP_REG_AMRAR 0x30 | ||
| 122 | #define AMCC_OP_REG_AMBEF 0x34 | ||
| 123 | #define AMCC_OP_REG_AINT 0x38 | ||
| 124 | #define AMCC_OP_REG_AGCSTS 0x3c | ||
| 125 | #define AMCC_OP_REG_AMWTC 0x58 | ||
| 126 | #define AMCC_OP_REG_AMRTC 0x5c | ||
| 127 | |||
| 128 | /* | ||
| 129 | * AMCC - Add-on General Control/Status Register | ||
| 130 | */ | ||
| 131 | #define AGCSTS_CONTROL_MASK 0xfffff000 | ||
| 132 | #define AGCSTS_NV_ACC_MASK 0xe0000000 | ||
| 133 | #define AGCSTS_RESET_MASK 0x0e000000 | ||
| 134 | #define AGCSTS_NV_DA_MASK 0x00ff0000 | ||
| 135 | #define AGCSTS_BIST_MASK 0x0000f000 | ||
| 136 | #define AGCSTS_STATUS_MASK 0x000000ff | ||
| 137 | #define AGCSTS_TCZERO_MASK 0x000000c0 | ||
| 138 | #define AGCSTS_FIFO_ST_MASK 0x0000003f | ||
| 139 | |||
| 140 | #define AGCSTS_RESET_MBFLAGS 0x08000000 | ||
| 141 | #define AGCSTS_RESET_P2A_FIFO 0x04000000 | ||
| 142 | #define AGCSTS_RESET_A2P_FIFO 0x02000000 | ||
| 143 | #define AGCSTS_RESET_FIFOS (AGCSTS_RESET_A2P_FIFO | AGCSTS_RESET_P2A_FIFO) | ||
| 144 | |||
| 145 | #define AGCSTS_A2P_TCOUNT 0x00000080 | ||
| 146 | #define AGCSTS_P2A_TCOUNT 0x00000040 | ||
| 147 | |||
| 148 | #define AGCSTS_FS_P2A_EMPTY 0x00000020 | ||
| 149 | #define AGCSTS_FS_P2A_HALF 0x00000010 | ||
| 150 | #define AGCSTS_FS_P2A_FULL 0x00000008 | ||
| 151 | |||
| 152 | #define AGCSTS_FS_A2P_EMPTY 0x00000004 | ||
| 153 | #define AGCSTS_FS_A2P_HALF 0x00000002 | ||
| 154 | #define AGCSTS_FS_A2P_FULL 0x00000001 | ||
| 155 | |||
| 156 | /* | ||
| 157 | * AMCC - Add-on Interrupt Control/Status Register | ||
| 158 | */ | ||
| 159 | #define AINT_INT_MASK 0x00ff0000 | ||
| 160 | #define AINT_SEL_MASK 0x0000ffff | ||
| 161 | #define AINT_IS_ENSEL_MASK 0x00001f1f | ||
| 162 | |||
| 163 | #define AINT_INT_ASSERTED 0x00800000 | ||
| 164 | #define AINT_BM_ERROR 0x00200000 | ||
| 165 | #define AINT_BIST_INT 0x00100000 | ||
| 166 | |||
| 167 | #define AINT_RT_COMPLETE 0x00080000 | ||
| 168 | #define AINT_WT_COMPLETE 0x00040000 | ||
| 169 | |||
| 170 | #define AINT_OUT_MB_INT 0x00020000 | ||
| 171 | #define AINT_IN_MB_INT 0x00010000 | ||
| 172 | |||
| 173 | #define AINT_READ_COMPL 0x00008000 | ||
| 174 | #define AINT_WRITE_COMPL 0x00004000 | ||
| 175 | |||
| 176 | #define AINT_OMB_ENABLE 0x00001000 | ||
| 177 | #define AINT_OMB_SELECT 0x00000c00 | ||
| 178 | #define AINT_OMB_BYTE 0x00000300 | ||
| 179 | |||
| 180 | #define AINT_IMB_ENABLE 0x00000010 | ||
| 181 | #define AINT_IMB_SELECT 0x0000000c | ||
| 182 | #define AINT_IMB_BYTE 0x00000003 | ||
| 183 | |||
| 184 | /* Enable Bus Mastering */ | ||
| 185 | #define EN_A2P_TRANSFERS 0x00000400 | ||
| 186 | /* FIFO Flag Reset */ | ||
| 187 | #define RESET_A2P_FLAGS 0x04000000L | ||
| 188 | /* FIFO Relative Priority */ | ||
| 189 | #define A2P_HI_PRIORITY 0x00000100L | ||
| 190 | /* Identify Interrupt Sources */ | ||
| 191 | #define ANY_S593X_INT 0x00800000L | ||
| 192 | #define READ_TC_INT 0x00080000L | ||
| 193 | #define WRITE_TC_INT 0x00040000L | ||
| 194 | #define IN_MB_INT 0x00020000L | ||
| 195 | #define MASTER_ABORT_INT 0x00100000L | ||
| 196 | #define TARGET_ABORT_INT 0x00200000L | ||
| 197 | #define BUS_MASTER_INT 0x00200000L | ||
| 198 | |||
| 199 | /****************************************************************************/ | ||
| 200 | |||
| 201 | struct pcilst_struct { | ||
| 202 | struct pcilst_struct *next; | ||
| 203 | int used; | ||
| 204 | struct pci_dev *pcidev; | ||
| 205 | unsigned short vendor; | ||
| 206 | unsigned short device; | ||
| 207 | unsigned char pci_bus; | ||
| 208 | unsigned char pci_slot; | ||
| 209 | unsigned char pci_func; | ||
| 210 | resource_size_t io_addr[5]; | ||
| 211 | unsigned int irq; | ||
| 212 | }; | ||
| 213 | |||
| 214 | /* ptr to root list of all amcc devices */ | ||
| 215 | static struct pcilst_struct *amcc_devices; | ||
| 216 | |||
| 217 | static const int i_ADDIDATADeviceID[] = { 0x15B8, 0x10E8 }; | ||
| 218 | |||
| 219 | /****************************************************************************/ | ||
| 220 | |||
| 221 | void v_pci_card_list_init(unsigned short pci_vendor, char display); | ||
| 222 | void v_pci_card_list_cleanup(unsigned short pci_vendor); | ||
| 223 | struct pcilst_struct *ptr_find_free_pci_card_by_device(unsigned short vendor_id, | ||
| 224 | unsigned short | ||
| 225 | device_id); | ||
| 226 | int i_find_free_pci_card_by_position(unsigned short vendor_id, | ||
| 227 | unsigned short device_id, | ||
| 228 | unsigned short pci_bus, | ||
| 229 | unsigned short pci_slot, | ||
| 230 | struct pcilst_struct **card); | ||
| 231 | struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, | ||
| 232 | unsigned short device_id, | ||
| 233 | unsigned short pci_bus, | ||
| 234 | unsigned short pci_slot, | ||
| 235 | int i_Master); | ||
| 236 | |||
| 237 | int pci_card_alloc(struct pcilst_struct *amcc, int master); | ||
| 238 | int i_pci_card_free(struct pcilst_struct *amcc); | ||
| 239 | void v_pci_card_list_display(void); | ||
| 240 | int i_pci_card_data(struct pcilst_struct *amcc, | ||
| 241 | unsigned char *pci_bus, unsigned char *pci_slot, | ||
| 242 | unsigned char *pci_func, resource_size_t * io_addr, | ||
| 243 | unsigned int *irq); | ||
| 244 | |||
| 245 | /****************************************************************************/ | ||
| 246 | |||
| 247 | /* build list of amcc cards in this system */ | ||
| 248 | void v_pci_card_list_init(unsigned short pci_vendor, char display) | ||
| 249 | { | ||
| 250 | struct pci_dev *pcidev = NULL; | ||
| 251 | struct pcilst_struct *amcc, *last; | ||
| 252 | int i; | ||
| 253 | int i_Count = 0; | ||
| 254 | amcc_devices = NULL; | ||
| 255 | last = NULL; | ||
| 256 | |||
| 257 | for_each_pci_dev(pcidev) { | ||
| 258 | for (i_Count = 0; i_Count < 2; i_Count++) { | ||
| 259 | pci_vendor = i_ADDIDATADeviceID[i_Count]; | ||
| 260 | if (pcidev->vendor == pci_vendor) { | ||
| 261 | amcc = kzalloc(sizeof(*amcc), GFP_KERNEL); | ||
| 262 | if (amcc == NULL) | ||
| 263 | continue; | ||
| 264 | |||
| 265 | amcc->pcidev = pcidev; | ||
| 266 | if (last) | ||
| 267 | last->next = amcc; | ||
| 268 | else | ||
| 269 | amcc_devices = amcc; | ||
| 270 | last = amcc; | ||
| 271 | |||
| 272 | amcc->vendor = pcidev->vendor; | ||
| 273 | amcc->device = pcidev->device; | ||
| 274 | amcc->pci_bus = pcidev->bus->number; | ||
| 275 | amcc->pci_slot = PCI_SLOT(pcidev->devfn); | ||
| 276 | amcc->pci_func = PCI_FUNC(pcidev->devfn); | ||
| 277 | /* Note: resources may be invalid if PCI device | ||
| 278 | * not enabled, but they are corrected in | ||
| 279 | * pci_card_alloc. */ | ||
| 280 | for (i = 0; i < 5; i++) | ||
| 281 | amcc->io_addr[i] = | ||
| 282 | pci_resource_start(pcidev, i); | ||
| 283 | amcc->irq = pcidev->irq; | ||
| 284 | |||
| 285 | } | ||
| 286 | } | ||
| 287 | } | ||
| 288 | |||
| 289 | if (display) | ||
| 290 | v_pci_card_list_display(); | ||
| 291 | } | ||
| 292 | |||
| 293 | /****************************************************************************/ | ||
| 294 | /* free up list of amcc cards in this system */ | ||
| 295 | void v_pci_card_list_cleanup(unsigned short pci_vendor) | ||
| 296 | { | ||
| 297 | struct pcilst_struct *amcc, *next; | ||
| 298 | |||
| 299 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 300 | next = amcc->next; | ||
| 301 | kfree(amcc); | ||
| 302 | } | ||
| 303 | |||
| 304 | amcc_devices = NULL; | ||
| 305 | } | ||
| 306 | |||
| 307 | /****************************************************************************/ | ||
| 308 | /* find first unused card with this device_id */ | ||
| 309 | struct pcilst_struct *ptr_find_free_pci_card_by_device(unsigned short vendor_id, | ||
| 310 | unsigned short device_id) | ||
| 311 | { | ||
| 312 | struct pcilst_struct *amcc, *next; | ||
| 313 | |||
| 314 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 315 | next = amcc->next; | ||
| 316 | if ((!amcc->used) && (amcc->device == device_id) | ||
| 317 | && (amcc->vendor == vendor_id)) | ||
| 318 | return amcc; | ||
| 319 | |||
| 320 | } | ||
| 321 | |||
| 322 | return NULL; | ||
| 323 | } | ||
| 324 | |||
| 325 | /****************************************************************************/ | ||
| 326 | /* find card on requested position */ | ||
| 327 | int i_find_free_pci_card_by_position(unsigned short vendor_id, | ||
| 328 | unsigned short device_id, | ||
| 329 | unsigned short pci_bus, | ||
| 330 | unsigned short pci_slot, | ||
| 331 | struct pcilst_struct **card) | ||
| 332 | { | ||
| 333 | struct pcilst_struct *amcc, *next; | ||
| 334 | |||
| 335 | *card = NULL; | ||
| 336 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 337 | next = amcc->next; | ||
| 338 | if ((amcc->vendor == vendor_id) && (amcc->device == device_id) | ||
| 339 | && (amcc->pci_bus == pci_bus) | ||
| 340 | && (amcc->pci_slot == pci_slot)) { | ||
| 341 | if (!(amcc->used)) { | ||
| 342 | *card = amcc; | ||
| 343 | return 0; /* ok, card is found */ | ||
| 344 | } else { | ||
| 345 | printk(" - \nCard on requested position is used b:s %d:%d!\n", | ||
| 346 | pci_bus, pci_slot); | ||
| 347 | return 2; /* card exist but is used */ | ||
| 348 | } | ||
| 349 | } | ||
| 350 | } | ||
| 351 | |||
| 352 | /* no card found */ | ||
| 353 | return 1; | ||
| 354 | } | ||
| 355 | |||
| 356 | /****************************************************************************/ | ||
| 357 | /* mark card as used */ | ||
| 358 | int pci_card_alloc(struct pcilst_struct *amcc, int master) | ||
| 359 | { | ||
| 360 | int i; | ||
| 361 | |||
| 362 | if (!amcc) | ||
| 363 | return -1; | ||
| 364 | |||
| 365 | if (amcc->used) | ||
| 366 | return 1; | ||
| 367 | if (comedi_pci_enable(amcc->pcidev, "addi_amcc_s5933")) | ||
| 368 | return -1; | ||
| 369 | /* Resources will be accurate now. */ | ||
| 370 | for (i = 0; i < 5; i++) | ||
| 371 | amcc->io_addr[i] = pci_resource_start(amcc->pcidev, i); | ||
| 372 | if (master) | ||
| 373 | pci_set_master(amcc->pcidev); | ||
| 374 | amcc->used = 1; | ||
| 375 | |||
| 376 | return 0; | ||
| 377 | } | ||
| 378 | |||
| 379 | /****************************************************************************/ | ||
| 380 | /* mark card as free */ | ||
| 381 | int i_pci_card_free(struct pcilst_struct *amcc) | ||
| 382 | { | ||
| 383 | if (!amcc) | ||
| 384 | return -1; | ||
| 385 | |||
| 386 | if (!amcc->used) | ||
| 387 | return 1; | ||
| 388 | amcc->used = 0; | ||
| 389 | comedi_pci_disable(amcc->pcidev); | ||
| 390 | return 0; | ||
| 391 | } | ||
| 392 | |||
| 393 | /****************************************************************************/ | ||
| 394 | /* display list of found cards */ | ||
| 395 | void v_pci_card_list_display(void) | ||
| 396 | { | ||
| 397 | struct pcilst_struct *amcc, *next; | ||
| 398 | |||
| 399 | printk(KERN_DEBUG "List of pci cards\n"); | ||
| 400 | printk(KERN_DEBUG "bus:slot:func vendor device io_amcc io_daq irq used\n"); | ||
| 401 | |||
| 402 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 403 | next = amcc->next; | ||
| 404 | printk | ||
| 405 | ("%2d %2d %2d 0x%4x 0x%4x 0x%8llx 0x%8llx %2u %2d\n", | ||
| 406 | amcc->pci_bus, amcc->pci_slot, amcc->pci_func, | ||
| 407 | amcc->vendor, amcc->device, | ||
| 408 | (unsigned long long)amcc->io_addr[0], | ||
| 409 | (unsigned long long)amcc->io_addr[2], amcc->irq, | ||
| 410 | amcc->used); | ||
| 411 | |||
| 412 | } | ||
| 413 | } | ||
| 414 | |||
| 415 | /****************************************************************************/ | ||
| 416 | /* return all card information for driver */ | ||
| 417 | int i_pci_card_data(struct pcilst_struct *amcc, | ||
| 418 | unsigned char *pci_bus, unsigned char *pci_slot, | ||
| 419 | unsigned char *pci_func, resource_size_t * io_addr, | ||
| 420 | unsigned int *irq) | ||
| 421 | { | ||
| 422 | int i; | ||
| 423 | |||
| 424 | if (!amcc) | ||
| 425 | return -1; | ||
| 426 | *pci_bus = amcc->pci_bus; | ||
| 427 | *pci_slot = amcc->pci_slot; | ||
| 428 | *pci_func = amcc->pci_func; | ||
| 429 | for (i = 0; i < 5; i++) | ||
| 430 | io_addr[i] = amcc->io_addr[i]; | ||
| 431 | *irq = amcc->irq; | ||
| 432 | return 0; | ||
| 433 | } | ||
| 434 | |||
| 435 | /****************************************************************************/ | ||
| 436 | /* select and alloc card */ | ||
| 437 | struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, | ||
| 438 | unsigned short device_id, | ||
| 439 | unsigned short pci_bus, | ||
| 440 | unsigned short pci_slot, | ||
| 441 | int i_Master) | ||
| 442 | { | ||
| 443 | struct pcilst_struct *card; | ||
| 444 | |||
| 445 | if ((pci_bus < 1) & (pci_slot < 1)) { | ||
| 446 | /* use autodetection */ | ||
| 447 | card = ptr_find_free_pci_card_by_device(vendor_id, device_id); | ||
| 448 | if (card == NULL) { | ||
| 449 | printk(" - Unused card not found in system!\n"); | ||
| 450 | return NULL; | ||
| 451 | } | ||
| 452 | } else { | ||
| 453 | switch (i_find_free_pci_card_by_position(vendor_id, device_id, | ||
| 454 | pci_bus, pci_slot, | ||
| 455 | &card)) { | ||
| 456 | case 1: | ||
| 457 | printk(" - Card not found on requested position b:s %d:%d!\n", | ||
| 458 | pci_bus, pci_slot); | ||
| 459 | return NULL; | ||
| 460 | case 2: | ||
| 461 | printk(" - Card on requested position is used b:s %d:%d!\n", | ||
| 462 | pci_bus, pci_slot); | ||
| 463 | return NULL; | ||
| 464 | } | ||
| 465 | } | ||
| 466 | |||
| 467 | if (pci_card_alloc(card, i_Master) != 0) { | ||
| 468 | printk(" - Can't allocate card!\n"); | ||
| 469 | return NULL; | ||
| 470 | |||
| 471 | } | ||
| 472 | |||
| 473 | return card; | ||
| 474 | } | ||
| 475 | #endif | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h new file mode 100644 index 00000000000..349e93c23e9 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h | |||
| @@ -0,0 +1,457 @@ | |||
| 1 | /* | ||
| 2 | Modified by umesh on 16th may 2001 | ||
| 3 | Modified by sarath on 22nd may 2001 | ||
| 4 | */ | ||
| 5 | |||
| 6 | /* | ||
| 7 | comedi/drivers/amcc_s5933_v_58.h | ||
| 8 | |||
| 9 | Stuff for AMCC S5933 PCI Controller | ||
| 10 | |||
| 11 | Author: Michal Dobes <majkl@tesnet.cz> | ||
| 12 | |||
| 13 | Inspirated from general-purpose AMCC S5933 PCI Matchmaker driver | ||
| 14 | made by Andrea Cisternino <acister@pcape1.pi.infn.it> | ||
| 15 | and as result of espionage from MITE code made by David A. Schleef. | ||
| 16 | Thanks to AMCC for their on-line documentation and bus master DMA | ||
| 17 | example. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef _AMCC_S5933_H_ | ||
| 21 | #define _AMCC_S5933_H_ | ||
| 22 | |||
| 23 | #include <linux/pci.h> | ||
| 24 | #include "../../comedidev.h" | ||
| 25 | |||
| 26 | #ifdef PCI_SUPPORT_VER1 | ||
| 27 | #error Sorry, no support for 2.1.55 and older! :-(((( | ||
| 28 | #endif | ||
| 29 | |||
| 30 | /***********Added by sarath for compatibility with APCI3120 | ||
| 31 | |||
| 32 | *************************/ | ||
| 33 | |||
| 34 | #define FIFO_ADVANCE_ON_BYTE_2 0x20000000 /* written on base0 */ | ||
| 35 | |||
| 36 | #define AMWEN_ENABLE 0x02 /* added for step 6 dma written on base2 */ | ||
| 37 | #define A2P_FIFO_WRITE_ENABLE 0x01 | ||
| 38 | |||
| 39 | #define AGCSTS_TC_ENABLE 0x10000000 /* Added for transfer count enable bit */ | ||
| 40 | |||
| 41 | /* ADDON RELATED ADDITIONS */ | ||
| 42 | /* Constant */ | ||
| 43 | #define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW 0x00 | ||
| 44 | #define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH 0x1200 | ||
| 45 | #define APCI3120_A2P_FIFO_MANAGEMENT 0x04000400L | ||
| 46 | #define APCI3120_AMWEN_ENABLE 0x02 | ||
| 47 | #define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01 | ||
| 48 | #define APCI3120_FIFO_ADVANCE_ON_BYTE_2 0x20000000L | ||
| 49 | #define APCI3120_ENABLE_WRITE_TC_INT 0x00004000L | ||
| 50 | #define APCI3120_CLEAR_WRITE_TC_INT 0x00040000L | ||
| 51 | #define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE 0x0 | ||
| 52 | #define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0 | ||
| 53 | #define APCI3120_DISABLE_BUS_MASTER_PCI 0x0 | ||
| 54 | |||
| 55 | /* ADD_ON ::: this needed since apci supports 16 bit interface to add on */ | ||
| 56 | #define APCI3120_ADD_ON_AGCSTS_LOW 0x3C | ||
| 57 | #define APCI3120_ADD_ON_AGCSTS_HIGH APCI3120_ADD_ON_AGCSTS_LOW + 2 | ||
| 58 | #define APCI3120_ADD_ON_MWAR_LOW 0x24 | ||
| 59 | #define APCI3120_ADD_ON_MWAR_HIGH APCI3120_ADD_ON_MWAR_LOW + 2 | ||
| 60 | #define APCI3120_ADD_ON_MWTC_LOW 0x058 | ||
| 61 | #define APCI3120_ADD_ON_MWTC_HIGH APCI3120_ADD_ON_MWTC_LOW + 2 | ||
| 62 | |||
| 63 | /* AMCC */ | ||
| 64 | #define APCI3120_AMCC_OP_MCSR 0x3C | ||
| 65 | #define APCI3120_AMCC_OP_REG_INTCSR 0x38 | ||
| 66 | |||
| 67 | /*******from here all upward definitions are added by sarath */ | ||
| 68 | |||
| 69 | /****************************************************************************/ | ||
| 70 | /* AMCC Operation Register Offsets - PCI */ | ||
| 71 | /****************************************************************************/ | ||
| 72 | |||
| 73 | #define AMCC_OP_REG_OMB1 0x00 | ||
| 74 | #define AMCC_OP_REG_OMB2 0x04 | ||
| 75 | #define AMCC_OP_REG_OMB3 0x08 | ||
| 76 | #define AMCC_OP_REG_OMB4 0x0c | ||
| 77 | #define AMCC_OP_REG_IMB1 0x10 | ||
| 78 | #define AMCC_OP_REG_IMB2 0x14 | ||
| 79 | #define AMCC_OP_REG_IMB3 0x18 | ||
| 80 | #define AMCC_OP_REG_IMB4 0x1c | ||
| 81 | #define AMCC_OP_REG_FIFO 0x20 | ||
| 82 | #define AMCC_OP_REG_MWAR 0x24 | ||
| 83 | #define AMCC_OP_REG_MWTC 0x28 | ||
| 84 | #define AMCC_OP_REG_MRAR 0x2c | ||
| 85 | #define AMCC_OP_REG_MRTC 0x30 | ||
| 86 | #define AMCC_OP_REG_MBEF 0x34 | ||
| 87 | #define AMCC_OP_REG_INTCSR 0x38 | ||
| 88 | #define AMCC_OP_REG_INTCSR_SRC (AMCC_OP_REG_INTCSR + 2) /* int source */ | ||
| 89 | #define AMCC_OP_REG_INTCSR_FEC (AMCC_OP_REG_INTCSR + 3) /* FIFO ctrl */ | ||
| 90 | #define AMCC_OP_REG_MCSR 0x3c | ||
| 91 | #define AMCC_OP_REG_MCSR_NVDATA (AMCC_OP_REG_MCSR + 2) /* Data in byte 2 */ | ||
| 92 | #define AMCC_OP_REG_MCSR_NVCMD (AMCC_OP_REG_MCSR + 3) /* Command in byte 3 */ | ||
| 93 | |||
| 94 | #define AMCC_FIFO_DEPTH_DWORD 8 | ||
| 95 | #define AMCC_FIFO_DEPTH_BYTES (8 * sizeof (u32)) | ||
| 96 | |||
| 97 | /****************************************************************************/ | ||
| 98 | /* AMCC Operation Registers Size - PCI */ | ||
| 99 | /****************************************************************************/ | ||
| 100 | |||
| 101 | #define AMCC_OP_REG_SIZE 64 /* in bytes */ | ||
| 102 | |||
| 103 | /****************************************************************************/ | ||
| 104 | /* AMCC Operation Register Offsets - Add-on */ | ||
| 105 | /****************************************************************************/ | ||
| 106 | |||
| 107 | #define AMCC_OP_REG_AIMB1 0x00 | ||
| 108 | #define AMCC_OP_REG_AIMB2 0x04 | ||
| 109 | #define AMCC_OP_REG_AIMB3 0x08 | ||
| 110 | #define AMCC_OP_REG_AIMB4 0x0c | ||
| 111 | #define AMCC_OP_REG_AOMB1 0x10 | ||
| 112 | #define AMCC_OP_REG_AOMB2 0x14 | ||
| 113 | #define AMCC_OP_REG_AOMB3 0x18 | ||
| 114 | #define AMCC_OP_REG_AOMB4 0x1c | ||
| 115 | #define AMCC_OP_REG_AFIFO 0x20 | ||
| 116 | #define AMCC_OP_REG_AMWAR 0x24 | ||
| 117 | #define AMCC_OP_REG_APTA 0x28 | ||
| 118 | #define AMCC_OP_REG_APTD 0x2c | ||
| 119 | #define AMCC_OP_REG_AMRAR 0x30 | ||
| 120 | #define AMCC_OP_REG_AMBEF 0x34 | ||
| 121 | #define AMCC_OP_REG_AINT 0x38 | ||
| 122 | #define AMCC_OP_REG_AGCSTS 0x3c | ||
| 123 | #define AMCC_OP_REG_AMWTC 0x58 | ||
| 124 | #define AMCC_OP_REG_AMRTC 0x5c | ||
| 125 | |||
| 126 | /****************************************************************************/ | ||
| 127 | /* AMCC - Add-on General Control/Status Register */ | ||
| 128 | /****************************************************************************/ | ||
| 129 | |||
| 130 | #define AGCSTS_CONTROL_MASK 0xfffff000 | ||
| 131 | #define AGCSTS_NV_ACC_MASK 0xe0000000 | ||
| 132 | #define AGCSTS_RESET_MASK 0x0e000000 | ||
| 133 | #define AGCSTS_NV_DA_MASK 0x00ff0000 | ||
| 134 | #define AGCSTS_BIST_MASK 0x0000f000 | ||
| 135 | #define AGCSTS_STATUS_MASK 0x000000ff | ||
| 136 | #define AGCSTS_TCZERO_MASK 0x000000c0 | ||
| 137 | #define AGCSTS_FIFO_ST_MASK 0x0000003f | ||
| 138 | |||
| 139 | #define AGCSTS_RESET_MBFLAGS 0x08000000 | ||
| 140 | #define AGCSTS_RESET_P2A_FIFO 0x04000000 | ||
| 141 | #define AGCSTS_RESET_A2P_FIFO 0x02000000 | ||
| 142 | #define AGCSTS_RESET_FIFOS (AGCSTS_RESET_A2P_FIFO | AGCSTS_RESET_P2A_FIFO) | ||
| 143 | |||
| 144 | #define AGCSTS_A2P_TCOUNT 0x00000080 | ||
| 145 | #define AGCSTS_P2A_TCOUNT 0x00000040 | ||
| 146 | |||
| 147 | #define AGCSTS_FS_P2A_EMPTY 0x00000020 | ||
| 148 | #define AGCSTS_FS_P2A_HALF 0x00000010 | ||
| 149 | #define AGCSTS_FS_P2A_FULL 0x00000008 | ||
| 150 | |||
| 151 | #define AGCSTS_FS_A2P_EMPTY 0x00000004 | ||
| 152 | #define AGCSTS_FS_A2P_HALF 0x00000002 | ||
| 153 | #define AGCSTS_FS_A2P_FULL 0x00000001 | ||
| 154 | |||
| 155 | /****************************************************************************/ | ||
| 156 | /* AMCC - Add-on Interrupt Control/Status Register */ | ||
| 157 | /****************************************************************************/ | ||
| 158 | |||
| 159 | #define AINT_INT_MASK 0x00ff0000 | ||
| 160 | #define AINT_SEL_MASK 0x0000ffff | ||
| 161 | #define AINT_IS_ENSEL_MASK 0x00001f1f | ||
| 162 | |||
| 163 | #define AINT_INT_ASSERTED 0x00800000 | ||
| 164 | #define AINT_BM_ERROR 0x00200000 | ||
| 165 | #define AINT_BIST_INT 0x00100000 | ||
| 166 | |||
| 167 | #define AINT_RT_COMPLETE 0x00080000 | ||
| 168 | #define AINT_WT_COMPLETE 0x00040000 | ||
| 169 | |||
| 170 | #define AINT_OUT_MB_INT 0x00020000 | ||
| 171 | #define AINT_IN_MB_INT 0x00010000 | ||
| 172 | |||
| 173 | #define AINT_READ_COMPL 0x00008000 | ||
| 174 | #define AINT_WRITE_COMPL 0x00004000 | ||
| 175 | |||
| 176 | #define AINT_OMB_ENABLE 0x00001000 | ||
| 177 | #define AINT_OMB_SELECT 0x00000c00 | ||
| 178 | #define AINT_OMB_BYTE 0x00000300 | ||
| 179 | |||
| 180 | #define AINT_IMB_ENABLE 0x00000010 | ||
| 181 | #define AINT_IMB_SELECT 0x0000000c | ||
| 182 | #define AINT_IMB_BYTE 0x00000003 | ||
| 183 | |||
| 184 | /* Enable Bus Mastering */ | ||
| 185 | #define EN_A2P_TRANSFERS 0x00000400 | ||
| 186 | /* FIFO Flag Reset */ | ||
| 187 | #define RESET_A2P_FLAGS 0x04000000L | ||
| 188 | /* FIFO Relative Priority */ | ||
| 189 | #define A2P_HI_PRIORITY 0x00000100L | ||
| 190 | /* Identify Interrupt Sources */ | ||
| 191 | #define ANY_S593X_INT 0x00800000L | ||
| 192 | #define READ_TC_INT 0x00080000L | ||
| 193 | #define WRITE_TC_INT 0x00040000L | ||
| 194 | #define IN_MB_INT 0x00020000L | ||
| 195 | #define MASTER_ABORT_INT 0x00100000L | ||
| 196 | #define TARGET_ABORT_INT 0x00200000L | ||
| 197 | #define BUS_MASTER_INT 0x00200000L | ||
| 198 | |||
| 199 | /****************************************************************************/ | ||
| 200 | |||
| 201 | struct pcilst_struct { | ||
| 202 | struct pcilst_struct *next; | ||
| 203 | int used; | ||
| 204 | struct pci_dev *pcidev; | ||
| 205 | unsigned short vendor; | ||
| 206 | unsigned short device; | ||
| 207 | unsigned int master; | ||
| 208 | unsigned char pci_bus; | ||
| 209 | unsigned char pci_slot; | ||
| 210 | unsigned char pci_func; | ||
| 211 | unsigned int io_addr[5]; | ||
| 212 | unsigned int irq; | ||
| 213 | }; | ||
| 214 | |||
| 215 | struct pcilst_struct *amcc_devices; /* ptr to root list of all amcc devices */ | ||
| 216 | |||
| 217 | /****************************************************************************/ | ||
| 218 | |||
| 219 | void v_pci_card_list_init(unsigned short pci_vendor, char display); | ||
| 220 | void v_pci_card_list_cleanup(unsigned short pci_vendor); | ||
| 221 | struct pcilst_struct *ptr_find_free_pci_card_by_device(unsigned short vendor_id, | ||
| 222 | unsigned short | ||
| 223 | device_id); | ||
| 224 | int i_find_free_pci_card_by_position(unsigned short vendor_id, | ||
| 225 | unsigned short device_id, | ||
| 226 | unsigned short pci_bus, | ||
| 227 | unsigned short pci_slot, | ||
| 228 | struct pcilst_struct **card); | ||
| 229 | struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, | ||
| 230 | unsigned short device_id, | ||
| 231 | unsigned short pci_bus, | ||
| 232 | unsigned short pci_slot); | ||
| 233 | |||
| 234 | int i_pci_card_alloc(struct pcilst_struct *amcc); | ||
| 235 | int i_pci_card_free(struct pcilst_struct *amcc); | ||
| 236 | void v_pci_card_list_display(void); | ||
| 237 | int i_pci_card_data(struct pcilst_struct *amcc, | ||
| 238 | unsigned char *pci_bus, unsigned char *pci_slot, | ||
| 239 | unsigned char *pci_func, unsigned short *io_addr, | ||
| 240 | unsigned short *irq, unsigned short *master); | ||
| 241 | |||
| 242 | /****************************************************************************/ | ||
| 243 | |||
| 244 | /* build list of amcc cards in this system */ | ||
| 245 | void v_pci_card_list_init(unsigned short pci_vendor, char display) | ||
| 246 | { | ||
| 247 | struct pci_dev *pcidev; | ||
| 248 | struct pcilst_struct *amcc, *last; | ||
| 249 | int i; | ||
| 250 | |||
| 251 | amcc_devices = NULL; | ||
| 252 | last = NULL; | ||
| 253 | |||
| 254 | pci_for_each_dev(pcidev) { | ||
| 255 | if (pcidev->vendor == pci_vendor) { | ||
| 256 | amcc = kzalloc(sizeof(*amcc), GFP_KERNEL); | ||
| 257 | if (amcc == NULL) | ||
| 258 | continue; | ||
| 259 | |||
| 260 | amcc->pcidev = pcidev; | ||
| 261 | if (last) { | ||
| 262 | last->next = amcc; | ||
| 263 | } else { | ||
| 264 | amcc_devices = amcc; | ||
| 265 | } | ||
| 266 | last = amcc; | ||
| 267 | |||
| 268 | amcc->vendor = pcidev->vendor; | ||
| 269 | amcc->device = pcidev->device; | ||
| 270 | #if 0 | ||
| 271 | amcc->master = pcidev->master; /* how get this information under 2.4 kernels? */ | ||
| 272 | #endif | ||
| 273 | amcc->pci_bus = pcidev->bus->number; | ||
| 274 | amcc->pci_slot = PCI_SLOT(pcidev->devfn); | ||
| 275 | amcc->pci_func = PCI_FUNC(pcidev->devfn); | ||
| 276 | for (i = 0; i < 5; i++) | ||
| 277 | amcc->io_addr[i] = | ||
| 278 | pcidev->resource[i].start & ~3UL; | ||
| 279 | amcc->irq = pcidev->irq; | ||
| 280 | } | ||
| 281 | } | ||
| 282 | |||
| 283 | if (display) | ||
| 284 | v_pci_card_list_display(); | ||
| 285 | } | ||
| 286 | |||
| 287 | /****************************************************************************/ | ||
| 288 | /* free up list of amcc cards in this system */ | ||
| 289 | void v_pci_card_list_cleanup(unsigned short pci_vendor) | ||
| 290 | { | ||
| 291 | struct pcilst_struct *amcc, *next; | ||
| 292 | |||
| 293 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 294 | next = amcc->next; | ||
| 295 | kfree(amcc); | ||
| 296 | } | ||
| 297 | |||
| 298 | amcc_devices = NULL; | ||
| 299 | } | ||
| 300 | |||
| 301 | /****************************************************************************/ | ||
| 302 | /* find first unused card with this device_id */ | ||
| 303 | struct pcilst_struct *ptr_find_free_pci_card_by_device(unsigned short vendor_id, | ||
| 304 | unsigned short device_id) | ||
| 305 | { | ||
| 306 | struct pcilst_struct *amcc, *next; | ||
| 307 | |||
| 308 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 309 | next = amcc->next; | ||
| 310 | if ((!amcc->used) && (amcc->device == device_id) | ||
| 311 | && (amcc->vendor == vendor_id)) | ||
| 312 | return amcc; | ||
| 313 | |||
| 314 | } | ||
| 315 | |||
| 316 | return NULL; | ||
| 317 | } | ||
| 318 | |||
| 319 | /****************************************************************************/ | ||
| 320 | /* find card on requested position */ | ||
| 321 | int i_find_free_pci_card_by_position(unsigned short vendor_id, | ||
| 322 | unsigned short device_id, | ||
| 323 | unsigned short pci_bus, | ||
| 324 | unsigned short pci_slot, | ||
| 325 | struct pcilst_struct **card) | ||
| 326 | { | ||
| 327 | struct pcilst_struct *amcc, *next; | ||
| 328 | |||
| 329 | *card = NULL; | ||
| 330 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 331 | next = amcc->next; | ||
| 332 | if ((amcc->vendor == vendor_id) && (amcc->device == device_id) | ||
| 333 | && (amcc->pci_bus == pci_bus) | ||
| 334 | && (amcc->pci_slot == pci_slot)) { | ||
| 335 | if (!(amcc->used)) { | ||
| 336 | *card = amcc; | ||
| 337 | return 0; /* ok, card is found */ | ||
| 338 | } else { | ||
| 339 | printk | ||
| 340 | (" - \nCard on requested position is used b:s %d:%d!\n", | ||
| 341 | pci_bus, pci_slot); | ||
| 342 | return 2; /* card exist but is used */ | ||
| 343 | } | ||
| 344 | } | ||
| 345 | } | ||
| 346 | |||
| 347 | return 1; /* no card found */ | ||
| 348 | } | ||
| 349 | |||
| 350 | /****************************************************************************/ | ||
| 351 | /* mark card as used */ | ||
| 352 | int i_pci_card_alloc(struct pcilst_struct *amcc) | ||
| 353 | { | ||
| 354 | if (!amcc) | ||
| 355 | return -1; | ||
| 356 | |||
| 357 | if (amcc->used) | ||
| 358 | return 1; | ||
| 359 | amcc->used = 1; | ||
| 360 | return 0; | ||
| 361 | } | ||
| 362 | |||
| 363 | /****************************************************************************/ | ||
| 364 | /* mark card as free */ | ||
| 365 | int i_pci_card_free(struct pcilst_struct *amcc) | ||
| 366 | { | ||
| 367 | if (!amcc) | ||
| 368 | return -1; | ||
| 369 | |||
| 370 | if (!amcc->used) | ||
| 371 | return 1; | ||
| 372 | amcc->used = 0; | ||
| 373 | return 0; | ||
| 374 | } | ||
| 375 | |||
| 376 | /****************************************************************************/ | ||
| 377 | /* display list of found cards */ | ||
| 378 | void v_pci_card_list_display(void) | ||
| 379 | { | ||
| 380 | struct pcilst_struct *amcc, *next; | ||
| 381 | |||
| 382 | printk("List of pci cards\n"); | ||
| 383 | printk("bus:slot:func vendor device master io_amcc io_daq irq used\n"); | ||
| 384 | |||
| 385 | for (amcc = amcc_devices; amcc; amcc = next) { | ||
| 386 | next = amcc->next; | ||
| 387 | printk | ||
| 388 | ("%2d %2d %2d 0x%4x 0x%4x %3s 0x%4x 0x%4x %2d %2d\n", | ||
| 389 | amcc->pci_bus, amcc->pci_slot, amcc->pci_func, | ||
| 390 | amcc->vendor, amcc->device, amcc->master ? "yes" : "no", | ||
| 391 | amcc->io_addr[0], amcc->io_addr[2], amcc->irq, amcc->used); | ||
| 392 | |||
| 393 | } | ||
| 394 | } | ||
| 395 | |||
| 396 | /****************************************************************************/ | ||
| 397 | /* return all card information for driver */ | ||
| 398 | int i_pci_card_data(struct pcilst_struct *amcc, | ||
| 399 | unsigned char *pci_bus, unsigned char *pci_slot, | ||
| 400 | unsigned char *pci_func, unsigned short *io_addr, | ||
| 401 | unsigned short *irq, unsigned short *master) | ||
| 402 | { | ||
| 403 | int i; | ||
| 404 | |||
| 405 | if (!amcc) | ||
| 406 | return -1; | ||
| 407 | *pci_bus = amcc->pci_bus; | ||
| 408 | *pci_slot = amcc->pci_slot; | ||
| 409 | *pci_func = amcc->pci_func; | ||
| 410 | for (i = 0; i < 5; i++) | ||
| 411 | io_addr[i] = amcc->io_addr[i]; | ||
| 412 | *irq = amcc->irq; | ||
| 413 | *master = amcc->master; | ||
| 414 | return 0; | ||
| 415 | } | ||
| 416 | |||
| 417 | /****************************************************************************/ | ||
| 418 | /* select and alloc card */ | ||
| 419 | struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id, | ||
| 420 | unsigned short device_id, | ||
| 421 | unsigned short pci_bus, | ||
| 422 | unsigned short pci_slot) | ||
| 423 | { | ||
| 424 | struct pcilst_struct *card; | ||
| 425 | |||
| 426 | if ((pci_bus < 1) & (pci_slot < 1)) { /* use autodetection */ | ||
| 427 | card = ptr_find_free_pci_card_by_device(vendor_id, device_id); | ||
| 428 | if (card == NULL) { | ||
| 429 | printk(" - Unused card not found in system!\n"); | ||
| 430 | return NULL; | ||
| 431 | } | ||
| 432 | } else { | ||
| 433 | switch (i_find_free_pci_card_by_position(vendor_id, device_id, | ||
| 434 | pci_bus, pci_slot, | ||
| 435 | &card)) { | ||
| 436 | case 1: | ||
| 437 | printk | ||
| 438 | (" - Card not found on requested position b:s %d:%d!\n", | ||
| 439 | pci_bus, pci_slot); | ||
| 440 | return NULL; | ||
| 441 | case 2: | ||
| 442 | printk | ||
| 443 | (" - Card on requested position is used b:s %d:%d!\n", | ||
| 444 | pci_bus, pci_slot); | ||
| 445 | return NULL; | ||
| 446 | } | ||
| 447 | } | ||
| 448 | |||
| 449 | if (i_pci_card_alloc(card) != 0) { | ||
| 450 | printk(" - Can't allocate card!\n"); | ||
| 451 | return NULL; | ||
| 452 | } | ||
| 453 | |||
| 454 | return card; | ||
| 455 | } | ||
| 456 | |||
| 457 | #endif | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h new file mode 100644 index 00000000000..89c99eb5228 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #define COMEDI_SUBD_TTLIO 11 /* Digital Input Output But TTL */ | ||
| 19 | #define COMEDI_SUBD_PWM 12 /* Pulse width Measurement */ | ||
| 20 | #define COMEDI_SUBD_SSI 13 /* Synchronous serial interface */ | ||
| 21 | #define COMEDI_SUBD_TOR 14 /* Tor counter */ | ||
| 22 | #define COMEDI_SUBD_CHRONO 15 /* Chrono meter */ | ||
| 23 | #define COMEDI_SUBD_PULSEENCODER 16 /* Pulse Encoder INP CPT */ | ||
| 24 | #define COMEDI_SUBD_INCREMENTALCOUNTER 17 /* Incremental Counter */ | ||
| 25 | |||
| 26 | #define APCI1710_BOARD_NAME "apci1710" | ||
| 27 | #define APCI1710_BOARD_VENDOR_ID 0x10E8 | ||
| 28 | #define APCI1710_BOARD_DEVICE_ID 0x818F | ||
| 29 | #define APCI1710_ADDRESS_RANGE 256 | ||
| 30 | #define APCI1710_CONFIG_ADDRESS_RANGE 8 | ||
| 31 | #define APCI1710_INCREMENTAL_COUNTER 0x53430000UL | ||
| 32 | #define APCI1710_SSI_COUNTER 0x53490000UL | ||
| 33 | #define APCI1710_TTL_IO 0x544C0000UL | ||
| 34 | #define APCI1710_DIGITAL_IO 0x44490000UL | ||
| 35 | #define APCI1710_82X54_TIMER 0x49430000UL | ||
| 36 | #define APCI1710_CHRONOMETER 0x43480000UL | ||
| 37 | #define APCI1710_PULSE_ENCODER 0x495A0000UL | ||
| 38 | #define APCI1710_TOR_COUNTER 0x544F0000UL | ||
| 39 | #define APCI1710_PWM 0x50570000UL | ||
| 40 | #define APCI1710_ETM 0x45540000UL | ||
| 41 | #define APCI1710_CDA 0x43440000UL | ||
| 42 | #define APCI1710_DISABLE 0 | ||
| 43 | #define APCI1710_ENABLE 1 | ||
| 44 | #define APCI1710_SYNCHRONOUS_MODE 1 | ||
| 45 | #define APCI1710_ASYNCHRONOUS_MODE 0 | ||
| 46 | |||
| 47 | /* MODULE INFO STRUCTURE */ | ||
| 48 | |||
| 49 | static const struct comedi_lrange range_apci1710_ttl = { 4, { | ||
| 50 | BIP_RANGE(10), | ||
| 51 | BIP_RANGE(5), | ||
| 52 | BIP_RANGE(2), | ||
| 53 | BIP_RANGE(1) | ||
| 54 | } | ||
| 55 | }; | ||
| 56 | |||
| 57 | static const struct comedi_lrange range_apci1710_ssi = { 4, { | ||
| 58 | BIP_RANGE(10), | ||
| 59 | BIP_RANGE(5), | ||
| 60 | BIP_RANGE(2), | ||
| 61 | BIP_RANGE(1) | ||
| 62 | } | ||
| 63 | }; | ||
| 64 | |||
| 65 | static const struct comedi_lrange range_apci1710_inccpt = { 4, { | ||
| 66 | BIP_RANGE(10), | ||
| 67 | BIP_RANGE(5), | ||
| 68 | BIP_RANGE(2), | ||
| 69 | BIP_RANGE(1) | ||
| 70 | } | ||
| 71 | }; | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h new file mode 100644 index 00000000000..3c700c7bf81 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* Card Specific information */ | ||
| 19 | #define APCI035_BOARD_VENDOR_ID 0x15B8 | ||
| 20 | #define APCI035_ADDRESS_RANGE 255 | ||
| 21 | |||
| 22 | /* ANALOG INPUT RANGE */ | ||
| 23 | static struct comedi_lrange range_apci035_ai = { 8, { | ||
| 24 | BIP_RANGE(10), | ||
| 25 | BIP_RANGE(5), | ||
| 26 | BIP_RANGE(2), | ||
| 27 | BIP_RANGE(1), | ||
| 28 | UNI_RANGE(10), | ||
| 29 | UNI_RANGE(5), | ||
| 30 | UNI_RANGE(2), | ||
| 31 | UNI_RANGE(1) | ||
| 32 | } | ||
| 33 | }; | ||
| 34 | |||
| 35 | /* Timer / Watchdog Related Defines */ | ||
| 36 | #define APCI035_TCW_SYNC_ENABLEDISABLE 0 | ||
| 37 | #define APCI035_TCW_RELOAD_VALUE 4 | ||
| 38 | #define APCI035_TCW_TIMEBASE 8 | ||
| 39 | #define APCI035_TCW_PROG 12 | ||
| 40 | #define APCI035_TCW_TRIG_STATUS 16 | ||
| 41 | #define APCI035_TCW_IRQ 20 | ||
| 42 | #define APCI035_TCW_WARN_TIMEVAL 24 | ||
| 43 | #define APCI035_TCW_WARN_TIMEBASE 28 | ||
| 44 | |||
| 45 | #define ADDIDATA_TIMER 0 | ||
| 46 | /* #define ADDIDATA_WATCHDOG 1 */ | ||
| 47 | |||
| 48 | #define APCI035_TW1 0 | ||
| 49 | #define APCI035_TW2 32 | ||
| 50 | #define APCI035_TW3 64 | ||
| 51 | #define APCI035_TW4 96 | ||
| 52 | |||
| 53 | #define APCI035_AI_OFFSET 0 | ||
| 54 | #define APCI035_TEMP 128 | ||
| 55 | #define APCI035_ALR_SEQ 4 | ||
| 56 | #define APCI035_START_STOP_INDEX 8 | ||
| 57 | #define APCI035_ALR_START_STOP 12 | ||
| 58 | #define APCI035_ALR_IRQ 16 | ||
| 59 | #define APCI035_EOS 20 | ||
| 60 | #define APCI035_CHAN_NO 24 | ||
| 61 | #define APCI035_CHAN_VAL 28 | ||
| 62 | #define APCI035_CONV_TIME_TIME_BASE 36 | ||
| 63 | #define APCI035_RELOAD_CONV_TIME_VAL 32 | ||
| 64 | #define APCI035_DELAY_TIME_TIME_BASE 44 | ||
| 65 | #define APCI035_RELOAD_DELAY_TIME_VAL 40 | ||
| 66 | #define ENABLE_EXT_TRIG 1 | ||
| 67 | #define ENABLE_EXT_GATE 2 | ||
| 68 | #define ENABLE_EXT_TRIG_GATE 3 | ||
| 69 | |||
| 70 | #define ANALOG_INPUT 0 | ||
| 71 | #define TEMPERATURE 1 | ||
| 72 | #define RESISTANCE 2 | ||
| 73 | |||
| 74 | #define ADDIDATA_GREATER_THAN_TEST 0 | ||
| 75 | #define ADDIDATA_LESS_THAN_TEST 1 | ||
| 76 | |||
| 77 | #define APCI035_MAXVOLT 2.5 | ||
| 78 | |||
| 79 | #define ADDIDATA_UNIPOLAR 1 | ||
| 80 | #define ADDIDATA_BIPOLAR 2 | ||
| 81 | |||
| 82 | /* ADDIDATA Enable Disable */ | ||
| 83 | #define ADDIDATA_ENABLE 1 | ||
| 84 | #define ADDIDATA_DISABLE 0 | ||
| 85 | |||
| 86 | /* Hardware Layer functions for Apci035 */ | ||
| 87 | |||
| 88 | /* TIMER */ | ||
| 89 | /* timer value is passed as u seconds */ | ||
| 90 | int i_APCI035_ConfigTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 91 | struct comedi_insn *insn, unsigned int *data); | ||
| 92 | int i_APCI035_StartStopWriteTimerWatchdog(struct comedi_device *dev, | ||
| 93 | struct comedi_subdevice *s, | ||
| 94 | struct comedi_insn *insn, unsigned int *data); | ||
| 95 | int i_APCI035_ReadTimerWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 96 | struct comedi_insn *insn, unsigned int *data); | ||
| 97 | |||
| 98 | /* Temperature Related Defines (Analog Input Subdevice) */ | ||
| 99 | |||
| 100 | int i_APCI035_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 101 | struct comedi_insn *insn, unsigned int *data); | ||
| 102 | int i_APCI035_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 103 | struct comedi_insn *insn, unsigned int *data); | ||
| 104 | |||
| 105 | /* Interrupt */ | ||
| 106 | static void v_APCI035_Interrupt(int irq, void *d); | ||
| 107 | |||
| 108 | /* Reset functions */ | ||
| 109 | int i_APCI035_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c new file mode 100644 index 00000000000..bab7b61a53b --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c | |||
| @@ -0,0 +1,287 @@ | |||
| 1 | /** | ||
| 2 | @verbatim | ||
| 3 | |||
| 4 | Copyright (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 | |||
| 14 | 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. | ||
| 15 | |||
| 16 | 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. | ||
| 17 | |||
| 18 | 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 | ||
| 19 | |||
| 20 | You 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-1032 | Compiler : GCC | | ||
| 33 | | Module name : hwdrv_apci1032.c| Version : 2.96 | | ||
| 34 | +-------------------------------+---------------------------------------+ | ||
| 35 | | Project manager: Eric Stolz | Date : 02/12/2002 | | ||
| 36 | +-------------------------------+---------------------------------------+ | ||
| 37 | | Description : Hardware Layer Access For APCI-1032 | | ||
| 38 | +-----------------------------------------------------------------------+ | ||
| 39 | | UPDATES | | ||
| 40 | +----------+-----------+------------------------------------------------+ | ||
| 41 | | Date | Author | Description of updates | | ||
| 42 | +----------+-----------+------------------------------------------------+ | ||
| 43 | | | | | | ||
| 44 | | | | | | ||
| 45 | | | | | | ||
| 46 | +----------+-----------+------------------------------------------------+ | ||
| 47 | */ | ||
| 48 | |||
| 49 | /* | ||
| 50 | +----------------------------------------------------------------------------+ | ||
| 51 | | Included files | | ||
| 52 | +----------------------------------------------------------------------------+ | ||
| 53 | */ | ||
| 54 | #include "hwdrv_apci1032.h" | ||
| 55 | #include <linux/delay.h> | ||
| 56 | |||
| 57 | static unsigned int ui_InterruptStatus; | ||
| 58 | |||
| 59 | /* | ||
| 60 | +----------------------------------------------------------------------------+ | ||
| 61 | | Function Name : int i_APCI1032_ConfigDigitalInput | | ||
| 62 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 63 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 64 | +----------------------------------------------------------------------------+ | ||
| 65 | | Task : Configures the digital input Subdevice | | ||
| 66 | +----------------------------------------------------------------------------+ | ||
| 67 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 68 | | unsigned int *data : Data Pointer contains | | ||
| 69 | | configuration parameters as below | | ||
| 70 | | | | ||
| 71 | | data[0] : 1 Enable Digital Input Interrupt | | ||
| 72 | | 0 Disable Digital Input Interrupt | | ||
| 73 | | data[1] : 0 ADDIDATA Interrupt OR LOGIC | | ||
| 74 | | : 1 ADDIDATA Interrupt AND LOGIC | | ||
| 75 | | data[2] : Interrupt mask for the mode 1 | | ||
| 76 | | data[3] : Interrupt mask for the mode 2 | | ||
| 77 | | | | ||
| 78 | +----------------------------------------------------------------------------+ | ||
| 79 | | Output Parameters : -- | | ||
| 80 | +----------------------------------------------------------------------------+ | ||
| 81 | | Return Value : TRUE : No error occur | | ||
| 82 | | : FALSE : Error occur. Return the error | | ||
| 83 | | | | ||
| 84 | +----------------------------------------------------------------------------+ | ||
| 85 | */ | ||
| 86 | |||
| 87 | int i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 88 | struct comedi_insn *insn, unsigned int *data) | ||
| 89 | { | ||
| 90 | unsigned int ui_TmpValue; | ||
| 91 | |||
| 92 | unsigned int ul_Command1 = 0; | ||
| 93 | unsigned int ul_Command2 = 0; | ||
| 94 | devpriv->tsk_Current = current; | ||
| 95 | |||
| 96 | /*******************************/ | ||
| 97 | /* Set the digital input logic */ | ||
| 98 | /*******************************/ | ||
| 99 | if (data[0] == ADDIDATA_ENABLE) { | ||
| 100 | ul_Command1 = ul_Command1 | data[2]; | ||
| 101 | ul_Command2 = ul_Command2 | data[3]; | ||
| 102 | outl(ul_Command1, | ||
| 103 | devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE1); | ||
| 104 | outl(ul_Command2, | ||
| 105 | devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE2); | ||
| 106 | if (data[1] == ADDIDATA_OR) { | ||
| 107 | outl(0x4, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); | ||
| 108 | ui_TmpValue = | ||
| 109 | inl(devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); | ||
| 110 | } /* if (data[1] == ADDIDATA_OR) */ | ||
| 111 | else | ||
| 112 | outl(0x6, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); | ||
| 113 | /* else if(data[1] == ADDIDATA_OR) */ | ||
| 114 | } /* if( data[0] == ADDIDATA_ENABLE) */ | ||
| 115 | else { | ||
| 116 | ul_Command1 = ul_Command1 & 0xFFFF0000; | ||
| 117 | ul_Command2 = ul_Command2 & 0xFFFF0000; | ||
| 118 | outl(ul_Command1, | ||
| 119 | devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE1); | ||
| 120 | outl(ul_Command2, | ||
| 121 | devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE2); | ||
| 122 | outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); | ||
| 123 | } /* else if ( data[0] == ADDIDATA_ENABLE) */ | ||
| 124 | |||
| 125 | return insn->n; | ||
| 126 | } | ||
| 127 | |||
| 128 | /* | ||
| 129 | +----------------------------------------------------------------------------+ | ||
| 130 | | Function Name : int i_APCI1032_Read1DigitalInput | | ||
| 131 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 132 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 133 | +----------------------------------------------------------------------------+ | ||
| 134 | | Task : Return the status of the digital input | | ||
| 135 | +----------------------------------------------------------------------------+ | ||
| 136 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 137 | | unsigned int ui_Channel : Channel number to read | | ||
| 138 | | unsigned int *data : Data Pointer to read status | | ||
| 139 | +----------------------------------------------------------------------------+ | ||
| 140 | | Output Parameters : -- | | ||
| 141 | +----------------------------------------------------------------------------+ | ||
| 142 | | Return Value : TRUE : No error occur | | ||
| 143 | | : FALSE : Error occur. Return the error | | ||
| 144 | | | | ||
| 145 | +----------------------------------------------------------------------------+ | ||
| 146 | */ | ||
| 147 | int i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 148 | struct comedi_insn *insn, unsigned int *data) | ||
| 149 | { | ||
| 150 | unsigned int ui_TmpValue = 0; | ||
| 151 | unsigned int ui_Channel; | ||
| 152 | ui_Channel = CR_CHAN(insn->chanspec); | ||
| 153 | if (ui_Channel <= 31) { | ||
| 154 | ui_TmpValue = (unsigned int) inl(devpriv->iobase + APCI1032_DIGITAL_IP); | ||
| 155 | /* | ||
| 156 | * since only 1 channel reqd to bring it to last bit it is rotated 8 | ||
| 157 | * +(chan - 1) times then ANDed with 1 for last bit. | ||
| 158 | */ | ||
| 159 | *data = (ui_TmpValue >> ui_Channel) & 0x1; | ||
| 160 | } /* if(ui_Channel >= 0 && ui_Channel <=31) */ | ||
| 161 | else { | ||
| 162 | /* comedi_error(dev," \n chan spec wrong\n"); */ | ||
| 163 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 164 | } /* else if(ui_Channel >= 0 && ui_Channel <=31) */ | ||
| 165 | return insn->n; | ||
| 166 | } | ||
| 167 | |||
| 168 | /* | ||
| 169 | +----------------------------------------------------------------------------+ | ||
| 170 | | Function Name : int i_APCI1032_ReadMoreDigitalInput | | ||
| 171 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 172 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 173 | +----------------------------------------------------------------------------+ | ||
| 174 | | Task : Return the status of the Requested digital inputs | | ||
| 175 | +----------------------------------------------------------------------------+ | ||
| 176 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 177 | | unsigned int ui_NoOfChannels : No Of Channels To be Read | | ||
| 178 | | unsigned int *data : Data Pointer to read status | | ||
| 179 | +----------------------------------------------------------------------------+ | ||
| 180 | | Output Parameters : -- | | ||
| 181 | +----------------------------------------------------------------------------+ | ||
| 182 | | Return Value : TRUE : No error occur | | ||
| 183 | | : FALSE : Error occur. Return the error | | ||
| 184 | | | | ||
| 185 | +----------------------------------------------------------------------------+ | ||
| 186 | */ | ||
| 187 | |||
| 188 | int i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 189 | struct comedi_insn *insn, unsigned int *data) | ||
| 190 | { | ||
| 191 | unsigned int ui_PortValue = data[0]; | ||
| 192 | unsigned int ui_Mask = 0; | ||
| 193 | unsigned int ui_NoOfChannels; | ||
| 194 | |||
| 195 | ui_NoOfChannels = CR_CHAN(insn->chanspec); | ||
| 196 | if (data[1] == 0) { | ||
| 197 | *data = (unsigned int) inl(devpriv->iobase + APCI1032_DIGITAL_IP); | ||
| 198 | switch (ui_NoOfChannels) { | ||
| 199 | case 2: | ||
| 200 | ui_Mask = 3; | ||
| 201 | *data = (*data >> (2 * ui_PortValue)) & ui_Mask; | ||
| 202 | break; | ||
| 203 | case 4: | ||
| 204 | ui_Mask = 15; | ||
| 205 | *data = (*data >> (4 * ui_PortValue)) & ui_Mask; | ||
| 206 | break; | ||
| 207 | case 8: | ||
| 208 | ui_Mask = 255; | ||
| 209 | *data = (*data >> (8 * ui_PortValue)) & ui_Mask; | ||
| 210 | break; | ||
| 211 | case 16: | ||
| 212 | ui_Mask = 65535; | ||
| 213 | *data = (*data >> (16 * ui_PortValue)) & ui_Mask; | ||
| 214 | break; | ||
| 215 | case 31: | ||
| 216 | break; | ||
| 217 | default: | ||
| 218 | /* comedi_error(dev," \nchan spec wrong\n"); */ | ||
| 219 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 220 | break; | ||
| 221 | } /* switch(ui_NoOfChannels) */ | ||
| 222 | } /* if(data[1]==0) */ | ||
| 223 | else { | ||
| 224 | if (data[1] == 1) | ||
| 225 | *data = ui_InterruptStatus; | ||
| 226 | /* if(data[1]==1) */ | ||
| 227 | } /* else if(data[1]==0) */ | ||
| 228 | return insn->n; | ||
| 229 | } | ||
| 230 | |||
| 231 | /* | ||
| 232 | +----------------------------------------------------------------------------+ | ||
| 233 | | Function Name : static void v_APCI1032_Interrupt | | ||
| 234 | | (int irq , void *d) | | ||
| 235 | +----------------------------------------------------------------------------+ | ||
| 236 | | Task : Interrupt handler for the interruptible digital inputs | | ||
| 237 | +----------------------------------------------------------------------------+ | ||
| 238 | | Input Parameters : int irq : irq number | | ||
| 239 | | void *d : void pointer | | ||
| 240 | +----------------------------------------------------------------------------+ | ||
| 241 | | Output Parameters : -- | | ||
| 242 | +----------------------------------------------------------------------------+ | ||
| 243 | | Return Value : TRUE : No error occur | | ||
| 244 | | : FALSE : Error occur. Return the error | | ||
| 245 | | | | ||
| 246 | +----------------------------------------------------------------------------+ | ||
| 247 | */ | ||
| 248 | static void v_APCI1032_Interrupt(int irq, void *d) | ||
| 249 | { | ||
| 250 | struct comedi_device *dev = d; | ||
| 251 | |||
| 252 | unsigned int ui_Temp; | ||
| 253 | /* disable the interrupt */ | ||
| 254 | ui_Temp = inl(devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); | ||
| 255 | outl(ui_Temp & APCI1032_DIGITAL_IP_INTERRUPT_DISABLE, | ||
| 256 | devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); | ||
| 257 | ui_InterruptStatus = | ||
| 258 | inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS); | ||
| 259 | ui_InterruptStatus = ui_InterruptStatus & 0X0000FFFF; | ||
| 260 | send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ | ||
| 261 | outl(ui_Temp, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); /* enable the interrupt */ | ||
| 262 | return; | ||
| 263 | } | ||
| 264 | |||
| 265 | /* | ||
| 266 | +----------------------------------------------------------------------------+ | ||
| 267 | | Function Name : int i_APCI1032_Reset(struct comedi_device *dev) | | | ||
| 268 | +----------------------------------------------------------------------------+ | ||
| 269 | | Task :resets all the registers | | ||
| 270 | +----------------------------------------------------------------------------+ | ||
| 271 | | Input Parameters : struct comedi_device *dev | ||
| 272 | +----------------------------------------------------------------------------+ | ||
| 273 | | Output Parameters : -- | | ||
| 274 | +----------------------------------------------------------------------------+ | ||
| 275 | | Return Value : | | ||
| 276 | | | | ||
| 277 | +----------------------------------------------------------------------------+ | ||
| 278 | */ | ||
| 279 | |||
| 280 | int i_APCI1032_Reset(struct comedi_device *dev) | ||
| 281 | { | ||
| 282 | outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_IRQ); /* disable the interrupts */ | ||
| 283 | inl(devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_STATUS); /* Reset the interrupt status register */ | ||
| 284 | outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE1); /* Disable the and/or interrupt */ | ||
| 285 | outl(0x0, devpriv->iobase + APCI1032_DIGITAL_IP_INTERRUPT_MODE2); | ||
| 286 | return 0; | ||
| 287 | } | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h new file mode 100644 index 00000000000..7114acb4bd2 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /********* Definitions for APCI-1032 card *****/ | ||
| 19 | |||
| 20 | #define APCI1032_BOARD_VENDOR_ID 0x15B8 | ||
| 21 | #define APCI1032_ADDRESS_RANGE 20 | ||
| 22 | /* DIGITAL INPUT DEFINE */ | ||
| 23 | |||
| 24 | #define APCI1032_DIGITAL_IP 0 | ||
| 25 | #define APCI1032_DIGITAL_IP_INTERRUPT_MODE1 4 | ||
| 26 | #define APCI1032_DIGITAL_IP_INTERRUPT_MODE2 8 | ||
| 27 | #define APCI1032_DIGITAL_IP_IRQ 16 | ||
| 28 | |||
| 29 | /* Digital Input IRQ Function Selection */ | ||
| 30 | #define ADDIDATA_OR 0 | ||
| 31 | #define ADDIDATA_AND 1 | ||
| 32 | |||
| 33 | /* Digital Input Interrupt Status */ | ||
| 34 | #define APCI1032_DIGITAL_IP_INTERRUPT_STATUS 12 | ||
| 35 | |||
| 36 | /* Digital Input Interrupt Enable Disable. */ | ||
| 37 | #define APCI1032_DIGITAL_IP_INTERRUPT_ENABLE 0x4 | ||
| 38 | #define APCI1032_DIGITAL_IP_INTERRUPT_DISABLE 0xFFFFFFFB | ||
| 39 | |||
| 40 | /* ADDIDATA Enable Disable */ | ||
| 41 | |||
| 42 | #define ADDIDATA_ENABLE 1 | ||
| 43 | #define ADDIDATA_DISABLE 0 | ||
| 44 | |||
| 45 | /* Hardware Layer functions for Apci1032 */ | ||
| 46 | |||
| 47 | /* | ||
| 48 | * DI for di read | ||
| 49 | */ | ||
| 50 | |||
| 51 | int i_APCI1032_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 52 | struct comedi_insn *insn, unsigned int *data); | ||
| 53 | |||
| 54 | int i_APCI1032_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 55 | struct comedi_insn *insn, unsigned int *data); | ||
| 56 | |||
| 57 | int i_APCI1032_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 58 | struct comedi_insn *insn, unsigned int *data); | ||
| 59 | |||
| 60 | /* Interrupt functions..... */ | ||
| 61 | |||
| 62 | static void v_APCI1032_Interrupt(int irq, void *d); | ||
| 63 | /* Reset */ | ||
| 64 | int i_APCI1032_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h new file mode 100644 index 00000000000..647f9ebf552 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h | |||
| @@ -0,0 +1,165 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /********* Definitions for APCI-1500 card *****/ | ||
| 19 | |||
| 20 | /* Card Specific information */ | ||
| 21 | #define APCI1500_BOARD_VENDOR_ID 0x10e8 | ||
| 22 | #define APCI1500_ADDRESS_RANGE 4 | ||
| 23 | |||
| 24 | /* DIGITAL INPUT-OUTPUT DEFINE */ | ||
| 25 | |||
| 26 | #define APCI1500_DIGITAL_OP 2 | ||
| 27 | #define APCI1500_DIGITAL_IP 0 | ||
| 28 | #define APCI1500_AND 2 | ||
| 29 | #define APCI1500_OR 4 | ||
| 30 | #define APCI1500_OR_PRIORITY 6 | ||
| 31 | #define APCI1500_CLK_SELECT 0 | ||
| 32 | #define COUNTER1 0 | ||
| 33 | #define COUNTER2 1 | ||
| 34 | #define COUNTER3 2 | ||
| 35 | #define APCI1500_COUNTER 0x20 | ||
| 36 | #define APCI1500_TIMER 0 | ||
| 37 | #define APCI1500_WATCHDOG 0 | ||
| 38 | #define APCI1500_SINGLE 0 | ||
| 39 | #define APCI1500_CONTINUOUS 0x80 | ||
| 40 | #define APCI1500_DISABLE 0 | ||
| 41 | #define APCI1500_ENABLE 1 | ||
| 42 | #define APCI1500_SOFTWARE_TRIGGER 0x4 | ||
| 43 | #define APCI1500_HARDWARE_TRIGGER 0x10 | ||
| 44 | #define APCI1500_SOFTWARE_GATE 0 | ||
| 45 | #define APCI1500_HARDWARE_GATE 0x8 | ||
| 46 | #define START 0 | ||
| 47 | #define STOP 1 | ||
| 48 | #define TRIGGER 2 | ||
| 49 | |||
| 50 | /* | ||
| 51 | * Zillog I/O enumeration | ||
| 52 | */ | ||
| 53 | enum { | ||
| 54 | APCI1500_Z8536_PORT_C, | ||
| 55 | APCI1500_Z8536_PORT_B, | ||
| 56 | APCI1500_Z8536_PORT_A, | ||
| 57 | APCI1500_Z8536_CONTROL_REGISTER | ||
| 58 | }; | ||
| 59 | |||
| 60 | /* | ||
| 61 | * Z8536 CIO Internal Address | ||
| 62 | */ | ||
| 63 | enum { | ||
| 64 | APCI1500_RW_MASTER_INTERRUPT_CONTROL, | ||
| 65 | APCI1500_RW_MASTER_CONFIGURATION_CONTROL, | ||
| 66 | APCI1500_RW_PORT_A_INTERRUPT_CONTROL, | ||
| 67 | APCI1500_RW_PORT_B_INTERRUPT_CONTROL, | ||
| 68 | APCI1500_RW_TIMER_COUNTER_INTERRUPT_VECTOR, | ||
| 69 | APCI1500_RW_PORT_C_DATA_PCITCH_POLARITY, | ||
| 70 | APCI1500_RW_PORT_C_DATA_DIRECTION, | ||
| 71 | APCI1500_RW_PORT_C_SPECIAL_IO_CONTROL, | ||
| 72 | |||
| 73 | APCI1500_RW_PORT_A_COMMAND_AND_STATUS, | ||
| 74 | APCI1500_RW_PORT_B_COMMAND_AND_STATUS, | ||
| 75 | APCI1500_RW_CPT_TMR1_CMD_STATUS, | ||
| 76 | APCI1500_RW_CPT_TMR2_CMD_STATUS, | ||
| 77 | APCI1500_RW_CPT_TMR3_CMD_STATUS, | ||
| 78 | APCI1500_RW_PORT_A_DATA, | ||
| 79 | APCI1500_RW_PORT_B_DATA, | ||
| 80 | APCI1500_RW_PORT_C_DATA, | ||
| 81 | |||
| 82 | APCI1500_R_CPT_TMR1_VALUE_HIGH, | ||
| 83 | APCI1500_R_CPT_TMR1_VALUE_LOW, | ||
| 84 | APCI1500_R_CPT_TMR2_VALUE_HIGH, | ||
| 85 | APCI1500_R_CPT_TMR2_VALUE_LOW, | ||
| 86 | APCI1500_R_CPT_TMR3_VALUE_HIGH, | ||
| 87 | APCI1500_R_CPT_TMR3_VALUE_LOW, | ||
| 88 | APCI1500_RW_CPT_TMR1_TIME_CST_HIGH, | ||
| 89 | APCI1500_RW_CPT_TMR1_TIME_CST_LOW, | ||
| 90 | APCI1500_RW_CPT_TMR2_TIME_CST_HIGH, | ||
| 91 | APCI1500_RW_CPT_TMR2_TIME_CST_LOW, | ||
| 92 | APCI1500_RW_CPT_TMR3_TIME_CST_HIGH, | ||
| 93 | APCI1500_RW_CPT_TMR3_TIME_CST_LOW, | ||
| 94 | APCI1500_RW_CPT_TMR1_MODE_SPECIFICATION, | ||
| 95 | APCI1500_RW_CPT_TMR2_MODE_SPECIFICATION, | ||
| 96 | APCI1500_RW_CPT_TMR3_MODE_SPECIFICATION, | ||
| 97 | APCI1500_R_CURRENT_VECTOR, | ||
| 98 | |||
| 99 | APCI1500_RW_PORT_A_SPECIFICATION, | ||
| 100 | APCI1500_RW_PORT_A_HANDSHAKE_SPECIFICATION, | ||
| 101 | APCI1500_RW_PORT_A_DATA_PCITCH_POLARITY, | ||
| 102 | APCI1500_RW_PORT_A_DATA_DIRECTION, | ||
| 103 | APCI1500_RW_PORT_A_SPECIAL_IO_CONTROL, | ||
| 104 | APCI1500_RW_PORT_A_PATTERN_POLARITY, | ||
| 105 | APCI1500_RW_PORT_A_PATTERN_TRANSITION, | ||
| 106 | APCI1500_RW_PORT_A_PATTERN_MASK, | ||
| 107 | |||
| 108 | APCI1500_RW_PORT_B_SPECIFICATION, | ||
| 109 | APCI1500_RW_PORT_B_HANDSHAKE_SPECIFICATION, | ||
| 110 | APCI1500_RW_PORT_B_DATA_PCITCH_POLARITY, | ||
| 111 | APCI1500_RW_PORT_B_DATA_DIRECTION, | ||
| 112 | APCI1500_RW_PORT_B_SPECIAL_IO_CONTROL, | ||
| 113 | APCI1500_RW_PORT_B_PATTERN_POLARITY, | ||
| 114 | APCI1500_RW_PORT_B_PATTERN_TRANSITION, | ||
| 115 | APCI1500_RW_PORT_B_PATTERN_MASK | ||
| 116 | }; | ||
| 117 | |||
| 118 | /*----------DIGITAL INPUT----------------*/ | ||
| 119 | static int i_APCI1500_Initialisation(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 120 | struct comedi_insn *insn, unsigned int *data); | ||
| 121 | static int i_APCI1500_ConfigDigitalInputEvent(struct comedi_device *dev, | ||
| 122 | struct comedi_subdevice *s, | ||
| 123 | struct comedi_insn *insn, | ||
| 124 | unsigned int *data); | ||
| 125 | |||
| 126 | static int i_APCI1500_StartStopInputEvent(struct comedi_device *dev, | ||
| 127 | struct comedi_subdevice *s, | ||
| 128 | struct comedi_insn *insn, unsigned int *data); | ||
| 129 | static int i_APCI1500_ReadMoreDigitalInput(struct comedi_device *dev, | ||
| 130 | struct comedi_subdevice *s, | ||
| 131 | struct comedi_insn *insn, unsigned int *data); | ||
| 132 | |||
| 133 | /*---------- DIGITAL OUTPUT------------*/ | ||
| 134 | static int i_APCI1500_ConfigDigitalOutputErrorInterrupt(struct comedi_device *dev, | ||
| 135 | struct comedi_subdevice *s, | ||
| 136 | struct comedi_insn *insn, | ||
| 137 | unsigned int *data); | ||
| 138 | static int i_APCI1500_WriteDigitalOutput(struct comedi_device *dev, | ||
| 139 | struct comedi_subdevice *s, | ||
| 140 | struct comedi_insn *insn, unsigned int *data); | ||
| 141 | |||
| 142 | /*----------TIMER----------------*/ | ||
| 143 | static int i_APCI1500_ConfigCounterTimerWatchdog(struct comedi_device *dev, | ||
| 144 | struct comedi_subdevice *s, | ||
| 145 | struct comedi_insn *insn, | ||
| 146 | unsigned int *data); | ||
| 147 | static int i_APCI1500_StartStopTriggerTimerCounterWatchdog(struct comedi_device *dev, | ||
| 148 | struct comedi_subdevice *s, | ||
| 149 | struct comedi_insn *insn, | ||
| 150 | unsigned int *data); | ||
| 151 | static int i_APCI1500_ReadCounterTimerWatchdog(struct comedi_device *dev, | ||
| 152 | struct comedi_subdevice *s, | ||
| 153 | struct comedi_insn *insn, | ||
| 154 | unsigned int *data); | ||
| 155 | static int i_APCI1500_ReadInterruptMask(struct comedi_device *dev, | ||
| 156 | struct comedi_subdevice *s, | ||
| 157 | struct comedi_insn *insn, unsigned int *data); | ||
| 158 | |||
| 159 | /*----------INTERRUPT HANDLER------*/ | ||
| 160 | static void v_APCI1500_Interrupt(int irq, void *d); | ||
| 161 | static int i_APCI1500_ConfigureInterrupt(struct comedi_device *dev, | ||
| 162 | struct comedi_subdevice *s, | ||
| 163 | struct comedi_insn *insn, unsigned int *data); | ||
| 164 | /*----------RESET---------------*/ | ||
| 165 | static int i_APCI1500_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c new file mode 100644 index 00000000000..8a584a014b0 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c | |||
| @@ -0,0 +1,542 @@ | |||
| 1 | /** | ||
| 2 | @verbatim | ||
| 3 | |||
| 4 | Copyright (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 | |||
| 14 | 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. | ||
| 15 | |||
| 16 | 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. | ||
| 17 | |||
| 18 | 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 | ||
| 19 | |||
| 20 | You 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-1516 | Compiler : GCC | | ||
| 33 | | Module name : hwdrv_apci1516.c| Version : 2.96 | | ||
| 34 | +-------------------------------+---------------------------------------+ | ||
| 35 | | Project manager: Eric Stolz | Date : 02/12/2002 | | ||
| 36 | +-------------------------------+---------------------------------------+ | ||
| 37 | | Description : Hardware Layer Access For APCI-1516 | | ||
| 38 | +-----------------------------------------------------------------------+ | ||
| 39 | | UPDATES | | ||
| 40 | +----------+-----------+------------------------------------------------+ | ||
| 41 | | Date | Author | Description of updates | | ||
| 42 | +----------+-----------+------------------------------------------------+ | ||
| 43 | | | | | | ||
| 44 | | | | | | ||
| 45 | | | | | | ||
| 46 | +----------+-----------+------------------------------------------------+ | ||
| 47 | */ | ||
| 48 | |||
| 49 | /* | ||
| 50 | +----------------------------------------------------------------------------+ | ||
| 51 | | Included files | | ||
| 52 | +----------------------------------------------------------------------------+ | ||
| 53 | */ | ||
| 54 | #include "hwdrv_apci1516.h" | ||
| 55 | |||
| 56 | /* | ||
| 57 | +----------------------------------------------------------------------------+ | ||
| 58 | | Function Name : int i_APCI1516_Read1DigitalInput | | ||
| 59 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 60 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 61 | +----------------------------------------------------------------------------+ | ||
| 62 | | Task : Return the status of the digital input | | ||
| 63 | +----------------------------------------------------------------------------+ | ||
| 64 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 65 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 66 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 67 | | unsigned int *data : Data Pointer to read status | | ||
| 68 | +----------------------------------------------------------------------------+ | ||
| 69 | | Output Parameters : -- | | ||
| 70 | +----------------------------------------------------------------------------+ | ||
| 71 | | Return Value : TRUE : No error occur | | ||
| 72 | | : FALSE : Error occur. Return the error | | ||
| 73 | | | | ||
| 74 | +----------------------------------------------------------------------------+ | ||
| 75 | */ | ||
| 76 | int i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 77 | struct comedi_insn *insn, unsigned int *data) | ||
| 78 | { | ||
| 79 | unsigned int ui_TmpValue = 0; | ||
| 80 | unsigned int ui_Channel; | ||
| 81 | ui_Channel = CR_CHAN(insn->chanspec); | ||
| 82 | if (ui_Channel <= 7) { | ||
| 83 | ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI1516_DIGITAL_IP); | ||
| 84 | /* since only 1 channel reqd to bring it to last bit it is rotated */ | ||
| 85 | /* 8 +(chan - 1) times then ANDed with 1 for last bit. */ | ||
| 86 | *data = (ui_TmpValue >> ui_Channel) & 0x1; | ||
| 87 | } /* if(ui_Channel >= 0 && ui_Channel <=7) */ | ||
| 88 | else { | ||
| 89 | /* comedi_error(dev," \n chan spec wrong\n"); */ | ||
| 90 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 91 | } /* else if(ui_Channel >= 0 && ui_Channel <=7) */ | ||
| 92 | |||
| 93 | return insn->n; | ||
| 94 | } | ||
| 95 | |||
| 96 | /* | ||
| 97 | +----------------------------------------------------------------------------+ | ||
| 98 | | Function Name : int i_APCI1516_ReadMoreDigitalInput | | ||
| 99 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 100 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 101 | +----------------------------------------------------------------------------+ | ||
| 102 | | Task : Return the status of the Requested digital inputs | | ||
| 103 | +----------------------------------------------------------------------------+ | ||
| 104 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 105 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 106 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 107 | | unsigned int *data : Data Pointer to read status | | ||
| 108 | +----------------------------------------------------------------------------+ | ||
| 109 | | Output Parameters : -- | | ||
| 110 | +----------------------------------------------------------------------------+ | ||
| 111 | | Return Value : TRUE : No error occur | | ||
| 112 | | : FALSE : Error occur. Return the error | | ||
| 113 | | | | ||
| 114 | +----------------------------------------------------------------------------+ | ||
| 115 | */ | ||
| 116 | |||
| 117 | int i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 118 | struct comedi_insn *insn, unsigned int *data) | ||
| 119 | { | ||
| 120 | |||
| 121 | unsigned int ui_PortValue = data[0]; | ||
| 122 | unsigned int ui_Mask = 0; | ||
| 123 | unsigned int ui_NoOfChannels; | ||
| 124 | |||
| 125 | ui_NoOfChannels = CR_CHAN(insn->chanspec); | ||
| 126 | |||
| 127 | *data = (unsigned int) inw(devpriv->iobase + APCI1516_DIGITAL_IP); | ||
| 128 | switch (ui_NoOfChannels) { | ||
| 129 | case 2: | ||
| 130 | ui_Mask = 3; | ||
| 131 | *data = (*data >> (2 * ui_PortValue)) & ui_Mask; | ||
| 132 | break; | ||
| 133 | case 4: | ||
| 134 | ui_Mask = 15; | ||
| 135 | *data = (*data >> (4 * ui_PortValue)) & ui_Mask; | ||
| 136 | break; | ||
| 137 | case 7: | ||
| 138 | break; | ||
| 139 | |||
| 140 | default: | ||
| 141 | printk("\nWrong parameters\n"); | ||
| 142 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 143 | break; | ||
| 144 | } /* switch(ui_NoOfChannels) */ | ||
| 145 | |||
| 146 | return insn->n; | ||
| 147 | } | ||
| 148 | |||
| 149 | /* | ||
| 150 | +----------------------------------------------------------------------------+ | ||
| 151 | | Function Name : int i_APCI1516_ConfigDigitalOutput (struct comedi_device *dev, | ||
| 152 | | struct comedi_subdevice *s struct comedi_insn *insn,unsigned int *data) | | ||
| 153 | | | | ||
| 154 | +----------------------------------------------------------------------------+ | ||
| 155 | | Task : Configures The Digital Output Subdevice. | | ||
| 156 | +----------------------------------------------------------------------------+ | ||
| 157 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 158 | | unsigned int *data : Data Pointer contains | | ||
| 159 | | configuration parameters as below | | ||
| 160 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 161 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 162 | | data[0] :1:Memory on | | ||
| 163 | | 0:Memory off | | ||
| 164 | | | | ||
| 165 | | | | ||
| 166 | +----------------------------------------------------------------------------+ | ||
| 167 | | Output Parameters : -- | | ||
| 168 | +----------------------------------------------------------------------------+ | ||
| 169 | | Return Value : TRUE : No error occur | | ||
| 170 | | : FALSE : Error occur. Return the error | | ||
| 171 | | | | ||
| 172 | +----------------------------------------------------------------------------+ | ||
| 173 | */ | ||
| 174 | int i_APCI1516_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 175 | struct comedi_insn *insn, unsigned int *data) | ||
| 176 | { | ||
| 177 | devpriv->b_OutputMemoryStatus = data[0]; | ||
| 178 | return insn->n; | ||
| 179 | } | ||
| 180 | |||
| 181 | /* | ||
| 182 | +----------------------------------------------------------------------------+ | ||
| 183 | | Function Name : int i_APCI1516_WriteDigitalOutput | | ||
| 184 | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, | ||
| 185 | | unsigned int *data) | | ||
| 186 | +----------------------------------------------------------------------------+ | ||
| 187 | | Task : Writes port value To the selected port | | ||
| 188 | +----------------------------------------------------------------------------+ | ||
| 189 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 190 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 191 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 192 | | unsigned int *data : Data Pointer to read status | | ||
| 193 | +----------------------------------------------------------------------------+ | ||
| 194 | | Output Parameters : -- | | ||
| 195 | +----------------------------------------------------------------------------+ | ||
| 196 | | Return Value : TRUE : No error occur | | ||
| 197 | | : FALSE : Error occur. Return the error | | ||
| 198 | | | | ||
| 199 | +----------------------------------------------------------------------------+ | ||
| 200 | */ | ||
| 201 | |||
| 202 | int i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 203 | struct comedi_insn *insn, unsigned int *data) | ||
| 204 | { | ||
| 205 | unsigned int ui_Temp, ui_Temp1; | ||
| 206 | unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ | ||
| 207 | |||
| 208 | printk("EL311003 : @=%x\n", devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 209 | |||
| 210 | if (devpriv->b_OutputMemoryStatus) { | ||
| 211 | ui_Temp = inw(devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 212 | |||
| 213 | } /* if(devpriv->b_OutputMemoryStatus ) */ | ||
| 214 | else { | ||
| 215 | ui_Temp = 0; | ||
| 216 | } /* if(devpriv->b_OutputMemoryStatus ) */ | ||
| 217 | if (data[3] == 0) { | ||
| 218 | if (data[1] == 0) { | ||
| 219 | data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; | ||
| 220 | outw(data[0], devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 221 | |||
| 222 | printk("EL311003 : d=%d @=%x\n", data[0], | ||
| 223 | devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 224 | |||
| 225 | } /* if(data[1]==0) */ | ||
| 226 | else { | ||
| 227 | if (data[1] == 1) { | ||
| 228 | switch (ui_NoOfChannel) { | ||
| 229 | |||
| 230 | case 2: | ||
| 231 | data[0] = | ||
| 232 | (data[0] << (2 * | ||
| 233 | data[2])) | ui_Temp; | ||
| 234 | break; | ||
| 235 | |||
| 236 | case 4: | ||
| 237 | data[0] = | ||
| 238 | (data[0] << (4 * | ||
| 239 | data[2])) | ui_Temp; | ||
| 240 | break; | ||
| 241 | |||
| 242 | case 7: | ||
| 243 | data[0] = data[0] | ui_Temp; | ||
| 244 | break; | ||
| 245 | |||
| 246 | default: | ||
| 247 | comedi_error(dev, " chan spec wrong"); | ||
| 248 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 249 | |||
| 250 | } /* switch(ui_NoOfChannels) */ | ||
| 251 | |||
| 252 | outw(data[0], | ||
| 253 | devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 254 | |||
| 255 | printk("EL311003 : d=%d @=%x\n", data[0], | ||
| 256 | devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 257 | } /* if(data[1]==1) */ | ||
| 258 | else { | ||
| 259 | printk("\nSpecified channel not supported\n"); | ||
| 260 | } /* else if(data[1]==1) */ | ||
| 261 | } /* elseif(data[1]==0) */ | ||
| 262 | } /* if(data[3]==0) */ | ||
| 263 | else { | ||
| 264 | if (data[3] == 1) { | ||
| 265 | if (data[1] == 0) { | ||
| 266 | data[0] = ~data[0] & 0x1; | ||
| 267 | ui_Temp1 = 1; | ||
| 268 | ui_Temp1 = ui_Temp1 << ui_NoOfChannel; | ||
| 269 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 270 | data[0] = (data[0] << ui_NoOfChannel) ^ 0xff; | ||
| 271 | data[0] = data[0] & ui_Temp; | ||
| 272 | outw(data[0], | ||
| 273 | devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 274 | |||
| 275 | printk("EL311003 : d=%d @=%x\n", data[0], | ||
| 276 | devpriv->iobase + APCI1516_DIGITAL_OP); | ||
| 277 | |||
| 278 | } /* if(data[1]==0) */ | ||
| 279 | else { | ||
| 280 | if (data[1] == 1) { | ||
| 281 | switch (ui_NoOfChannel) { | ||
| 282 | |||
| 283 | case 2: | ||
| 284 | data[0] = ~data[0] & 0x3; | ||
| 285 | ui_Temp1 = 3; | ||
| 286 | ui_Temp1 = | ||
| 287 | ui_Temp1 << 2 * data[2]; | ||
| 288 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 289 | data[0] = | ||
| 290 | ((data[0] << (2 * | ||
| 291 | data | ||
| 292 | [2])) ^ | ||
| 293 | 0xff) & ui_Temp; | ||
| 294 | break; | ||
| 295 | |||
| 296 | case 4: | ||
| 297 | data[0] = ~data[0] & 0xf; | ||
| 298 | ui_Temp1 = 15; | ||
| 299 | ui_Temp1 = | ||
| 300 | ui_Temp1 << 4 * data[2]; | ||
| 301 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 302 | data[0] = | ||
| 303 | ((data[0] << (4 * | ||
| 304 | data | ||
| 305 | [2])) ^ | ||
| 306 | 0xff) & ui_Temp; | ||
| 307 | break; | ||
| 308 | |||
| 309 | case 7: | ||
| 310 | break; | ||
| 311 | |||
| 312 | default: | ||
| 313 | comedi_error(dev, | ||
| 314 | " chan spec wrong"); | ||
| 315 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 316 | |||
| 317 | } /* switch(ui_NoOfChannels) */ | ||
| 318 | |||
| 319 | outw(data[0], | ||
| 320 | devpriv->iobase + | ||
| 321 | APCI1516_DIGITAL_OP); | ||
| 322 | |||
| 323 | printk("EL311003 : d=%d @=%x\n", | ||
| 324 | data[0], | ||
| 325 | devpriv->iobase + | ||
| 326 | APCI1516_DIGITAL_OP); | ||
| 327 | } /* if(data[1]==1) */ | ||
| 328 | else { | ||
| 329 | printk("\nSpecified channel not supported\n"); | ||
| 330 | } /* else if(data[1]==1) */ | ||
| 331 | } /* elseif(data[1]==0) */ | ||
| 332 | } /* if(data[3]==1); */ | ||
| 333 | else { | ||
| 334 | printk("\nSpecified functionality does not exist\n"); | ||
| 335 | return -EINVAL; | ||
| 336 | } /* if else data[3]==1) */ | ||
| 337 | } /* if else data[3]==0) */ | ||
| 338 | return (insn->n); | ||
| 339 | } | ||
| 340 | |||
| 341 | /* | ||
| 342 | +----------------------------------------------------------------------------+ | ||
| 343 | | Function Name : int i_APCI1516_ReadDigitalOutput | | ||
| 344 | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, | ||
| 345 | | unsigned int *data) | | ||
| 346 | +----------------------------------------------------------------------------+ | ||
| 347 | | Task : Read value of the selected channel or port | | ||
| 348 | +----------------------------------------------------------------------------+ | ||
| 349 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 350 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 351 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 352 | | unsigned int *data : Data Pointer to read status | | ||
| 353 | +----------------------------------------------------------------------------+ | ||
| 354 | | Output Parameters : -- | | ||
| 355 | +----------------------------------------------------------------------------+ | ||
| 356 | | Return Value : TRUE : No error occur | | ||
| 357 | | : FALSE : Error occur. Return the error | | ||
| 358 | | | | ||
| 359 | +----------------------------------------------------------------------------+ | ||
| 360 | */ | ||
| 361 | |||
| 362 | int i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 363 | struct comedi_insn *insn, unsigned int *data) | ||
| 364 | { | ||
| 365 | |||
| 366 | unsigned int ui_Temp; | ||
| 367 | unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ | ||
| 368 | ui_Temp = data[0]; | ||
| 369 | *data = inw(devpriv->iobase + APCI1516_DIGITAL_OP_RW); | ||
| 370 | if (ui_Temp == 0) { | ||
| 371 | *data = (*data >> ui_NoOfChannel) & 0x1; | ||
| 372 | } /* if(ui_Temp==0) */ | ||
| 373 | else { | ||
| 374 | if (ui_Temp == 1) { | ||
| 375 | switch (ui_NoOfChannel) { | ||
| 376 | |||
| 377 | case 2: | ||
| 378 | *data = (*data >> (2 * data[1])) & 3; | ||
| 379 | break; | ||
| 380 | |||
| 381 | case 4: | ||
| 382 | *data = (*data >> (4 * data[1])) & 15; | ||
| 383 | break; | ||
| 384 | |||
| 385 | case 7: | ||
| 386 | break; | ||
| 387 | |||
| 388 | default: | ||
| 389 | comedi_error(dev, " chan spec wrong"); | ||
| 390 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 391 | |||
| 392 | } /* switch(ui_NoOfChannels) */ | ||
| 393 | } /* if(ui_Temp==1) */ | ||
| 394 | else { | ||
| 395 | printk("\nSpecified channel not supported \n"); | ||
| 396 | } /* elseif(ui_Temp==1) */ | ||
| 397 | } /* elseif(ui_Temp==0) */ | ||
| 398 | return insn->n; | ||
| 399 | } | ||
| 400 | |||
| 401 | /* | ||
| 402 | +----------------------------------------------------------------------------+ | ||
| 403 | | Function Name : int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, | ||
| 404 | | struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | | ||
| 405 | | | | ||
| 406 | +----------------------------------------------------------------------------+ | ||
| 407 | | Task : Configures The Watchdog | | ||
| 408 | +----------------------------------------------------------------------------+ | ||
| 409 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 410 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 411 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 412 | | unsigned int *data : Data Pointer to read status | | ||
| 413 | +----------------------------------------------------------------------------+ | ||
| 414 | | Output Parameters : -- | | ||
| 415 | +----------------------------------------------------------------------------+ | ||
| 416 | | Return Value : TRUE : No error occur | | ||
| 417 | | : FALSE : Error occur. Return the error | | ||
| 418 | | | | ||
| 419 | +----------------------------------------------------------------------------+ | ||
| 420 | */ | ||
| 421 | |||
| 422 | int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 423 | struct comedi_insn *insn, unsigned int *data) | ||
| 424 | { | ||
| 425 | if (data[0] == 0) { | ||
| 426 | /* Disable the watchdog */ | ||
| 427 | outw(0x0, | ||
| 428 | devpriv->i_IobaseAddon + | ||
| 429 | APCI1516_WATCHDOG_ENABLEDISABLE); | ||
| 430 | /* Loading the Reload value */ | ||
| 431 | outw(data[1], | ||
| 432 | devpriv->i_IobaseAddon + | ||
| 433 | APCI1516_WATCHDOG_RELOAD_VALUE); | ||
| 434 | data[1] = data[1] >> 16; | ||
| 435 | outw(data[1], | ||
| 436 | devpriv->i_IobaseAddon + | ||
| 437 | APCI1516_WATCHDOG_RELOAD_VALUE + 2); | ||
| 438 | } /* if(data[0]==0) */ | ||
| 439 | else { | ||
| 440 | printk("\nThe input parameters are wrong\n"); | ||
| 441 | return -EINVAL; | ||
| 442 | } /* elseif(data[0]==0) */ | ||
| 443 | |||
| 444 | return insn->n; | ||
| 445 | } | ||
| 446 | |||
| 447 | /* | ||
| 448 | +----------------------------------------------------------------------------+ | ||
| 449 | | Function Name : int i_APCI1516_StartStopWriteWatchdog | | ||
| 450 | | (struct comedi_device *dev,struct comedi_subdevice *s, | ||
| 451 | struct comedi_insn *insn,unsigned int *data); | | ||
| 452 | +----------------------------------------------------------------------------+ | ||
| 453 | | Task : Start / Stop The Watchdog | | ||
| 454 | +----------------------------------------------------------------------------+ | ||
| 455 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 456 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 457 | struct comedi_insn *insn :pointer to insn structure | | ||
| 458 | | unsigned int *data : Data Pointer to read status | | ||
| 459 | +----------------------------------------------------------------------------+ | ||
| 460 | | Output Parameters : -- | | ||
| 461 | +----------------------------------------------------------------------------+ | ||
| 462 | | Return Value : TRUE : No error occur | | ||
| 463 | | : FALSE : Error occur. Return the error | | ||
| 464 | | | | ||
| 465 | +----------------------------------------------------------------------------+ | ||
| 466 | */ | ||
| 467 | |||
| 468 | int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 469 | struct comedi_insn *insn, unsigned int *data) | ||
| 470 | { | ||
| 471 | switch (data[0]) { | ||
| 472 | case 0: /* stop the watchdog */ | ||
| 473 | outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */ | ||
| 474 | break; | ||
| 475 | case 1: /* start the watchdog */ | ||
| 476 | outw(0x0001, | ||
| 477 | devpriv->i_IobaseAddon + | ||
| 478 | APCI1516_WATCHDOG_ENABLEDISABLE); | ||
| 479 | break; | ||
| 480 | case 2: /* Software trigger */ | ||
| 481 | outw(0x0201, | ||
| 482 | devpriv->i_IobaseAddon + | ||
| 483 | APCI1516_WATCHDOG_ENABLEDISABLE); | ||
| 484 | break; | ||
| 485 | default: | ||
| 486 | printk("\nSpecified functionality does not exist\n"); | ||
| 487 | return -EINVAL; | ||
| 488 | } /* switch(data[0]) */ | ||
| 489 | return insn->n; | ||
| 490 | } | ||
| 491 | |||
| 492 | /* | ||
| 493 | +----------------------------------------------------------------------------+ | ||
| 494 | | Function Name : int i_APCI1516_ReadWatchdog | | ||
| 495 | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, | ||
| 496 | unsigned int *data); | | ||
| 497 | +----------------------------------------------------------------------------+ | ||
| 498 | | Task : Read The Watchdog | | ||
| 499 | +----------------------------------------------------------------------------+ | ||
| 500 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 501 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 502 | struct comedi_insn *insn :pointer to insn structure | | ||
| 503 | | unsigned int *data : Data Pointer to read status | | ||
| 504 | +----------------------------------------------------------------------------+ | ||
| 505 | | Output Parameters : -- | | ||
| 506 | +----------------------------------------------------------------------------+ | ||
| 507 | | Return Value : TRUE : No error occur | | ||
| 508 | | : FALSE : Error occur. Return the error | | ||
| 509 | | | | ||
| 510 | +----------------------------------------------------------------------------+ | ||
| 511 | */ | ||
| 512 | |||
| 513 | int i_APCI1516_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 514 | struct comedi_insn *insn, unsigned int *data) | ||
| 515 | { | ||
| 516 | data[0] = inw(devpriv->i_IobaseAddon + APCI1516_WATCHDOG_STATUS) & 0x1; | ||
| 517 | return insn->n; | ||
| 518 | } | ||
| 519 | |||
| 520 | /* | ||
| 521 | +----------------------------------------------------------------------------+ | ||
| 522 | | Function Name : int i_APCI1516_Reset(struct comedi_device *dev) | | | ||
| 523 | +----------------------------------------------------------------------------+ | ||
| 524 | | Task :resets all the registers | | ||
| 525 | +----------------------------------------------------------------------------+ | ||
| 526 | | Input Parameters : struct comedi_device *dev | ||
| 527 | +----------------------------------------------------------------------------+ | ||
| 528 | | Output Parameters : -- | | ||
| 529 | +----------------------------------------------------------------------------+ | ||
| 530 | | Return Value : | | ||
| 531 | | | | ||
| 532 | +----------------------------------------------------------------------------+ | ||
| 533 | */ | ||
| 534 | |||
| 535 | int i_APCI1516_Reset(struct comedi_device *dev) | ||
| 536 | { | ||
| 537 | outw(0x0, devpriv->iobase + APCI1516_DIGITAL_OP); /* RESETS THE DIGITAL OUTPUTS */ | ||
| 538 | outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_ENABLEDISABLE); | ||
| 539 | outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE); | ||
| 540 | outw(0x0, devpriv->i_IobaseAddon + APCI1516_WATCHDOG_RELOAD_VALUE + 2); | ||
| 541 | return 0; | ||
| 542 | } | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h new file mode 100644 index 00000000000..44728293e49 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /********* Definitions for APCI-1516 card *****/ | ||
| 19 | |||
| 20 | /* Card Specific information */ | ||
| 21 | #define APCI1516_BOARD_VENDOR_ID 0x15B8 | ||
| 22 | #define APCI1516_ADDRESS_RANGE 8 | ||
| 23 | |||
| 24 | /* DIGITAL INPUT-OUTPUT DEFINE */ | ||
| 25 | |||
| 26 | #define APCI1516_DIGITAL_OP 4 | ||
| 27 | #define APCI1516_DIGITAL_OP_RW 4 | ||
| 28 | #define APCI1516_DIGITAL_IP 0 | ||
| 29 | |||
| 30 | /* TIMER COUNTER WATCHDOG DEFINES */ | ||
| 31 | |||
| 32 | #define ADDIDATA_WATCHDOG 2 | ||
| 33 | #define APCI1516_DIGITAL_OP_WATCHDOG 0 | ||
| 34 | #define APCI1516_WATCHDOG_ENABLEDISABLE 12 | ||
| 35 | #define APCI1516_WATCHDOG_RELOAD_VALUE 4 | ||
| 36 | #define APCI1516_WATCHDOG_STATUS 16 | ||
| 37 | |||
| 38 | /* Hardware Layer functions for Apci1516 */ | ||
| 39 | |||
| 40 | /* Digital Input */ | ||
| 41 | int i_APCI1516_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 42 | struct comedi_insn *insn, unsigned int *data); | ||
| 43 | int i_APCI1516_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 44 | struct comedi_insn *insn, unsigned int *data); | ||
| 45 | |||
| 46 | /* Digital Output */ | ||
| 47 | int i_APCI1516_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 48 | struct comedi_insn *insn, unsigned int *data); | ||
| 49 | int i_APCI1516_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 50 | struct comedi_insn *insn, unsigned int *data); | ||
| 51 | int i_APCI1516_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 52 | struct comedi_insn *insn, unsigned int *data); | ||
| 53 | |||
| 54 | /* | ||
| 55 | * TIMER timer value is passed as u seconds | ||
| 56 | */ | ||
| 57 | int i_APCI1516_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 58 | struct comedi_insn *insn, unsigned int *data); | ||
| 59 | int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 60 | struct comedi_insn *insn, unsigned int *data); | ||
| 61 | int i_APCI1516_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 62 | struct comedi_insn *insn, unsigned int *data); | ||
| 63 | |||
| 64 | /* reset */ | ||
| 65 | int i_APCI1516_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h new file mode 100644 index 00000000000..c91594d56a4 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /********* Definitions for APCI-1564 card *****/ | ||
| 19 | |||
| 20 | #define APCI1564_BOARD_VENDOR_ID 0x15B8 | ||
| 21 | #define APCI1564_ADDRESS_RANGE 128 | ||
| 22 | |||
| 23 | /* DIGITAL INPUT-OUTPUT DEFINE */ | ||
| 24 | /* Input defines */ | ||
| 25 | #define APCI1564_DIGITAL_IP 0x04 | ||
| 26 | #define APCI1564_DIGITAL_IP_INTERRUPT_MODE1 4 | ||
| 27 | #define APCI1564_DIGITAL_IP_INTERRUPT_MODE2 8 | ||
| 28 | #define APCI1564_DIGITAL_IP_IRQ 16 | ||
| 29 | |||
| 30 | /* Output defines */ | ||
| 31 | #define APCI1564_DIGITAL_OP 0x18 | ||
| 32 | #define APCI1564_DIGITAL_OP_RW 0 | ||
| 33 | #define APCI1564_DIGITAL_OP_INTERRUPT 4 | ||
| 34 | #define APCI1564_DIGITAL_OP_IRQ 12 | ||
| 35 | |||
| 36 | /* Digital Input IRQ Function Selection */ | ||
| 37 | #define ADDIDATA_OR 0 | ||
| 38 | #define ADDIDATA_AND 1 | ||
| 39 | |||
| 40 | /* Digital Input Interrupt Status */ | ||
| 41 | #define APCI1564_DIGITAL_IP_INTERRUPT_STATUS 12 | ||
| 42 | |||
| 43 | /* Digital Output Interrupt Status */ | ||
| 44 | #define APCI1564_DIGITAL_OP_INTERRUPT_STATUS 8 | ||
| 45 | |||
| 46 | /* Digital Input Interrupt Enable Disable. */ | ||
| 47 | #define APCI1564_DIGITAL_IP_INTERRUPT_ENABLE 0x4 | ||
| 48 | #define APCI1564_DIGITAL_IP_INTERRUPT_DISABLE 0xFFFFFFFB | ||
| 49 | |||
| 50 | /* Digital Output Interrupt Enable Disable. */ | ||
| 51 | #define APCI1564_DIGITAL_OP_VCC_INTERRUPT_ENABLE 0x1 | ||
| 52 | #define APCI1564_DIGITAL_OP_VCC_INTERRUPT_DISABLE 0xFFFFFFFE | ||
| 53 | #define APCI1564_DIGITAL_OP_CC_INTERRUPT_ENABLE 0x2 | ||
| 54 | #define APCI1564_DIGITAL_OP_CC_INTERRUPT_DISABLE 0xFFFFFFFD | ||
| 55 | |||
| 56 | /* ADDIDATA Enable Disable */ | ||
| 57 | |||
| 58 | #define ADDIDATA_ENABLE 1 | ||
| 59 | #define ADDIDATA_DISABLE 0 | ||
| 60 | |||
| 61 | /* TIMER COUNTER WATCHDOG DEFINES */ | ||
| 62 | |||
| 63 | #define ADDIDATA_TIMER 0 | ||
| 64 | #define ADDIDATA_COUNTER 1 | ||
| 65 | #define ADDIDATA_WATCHDOG 2 | ||
| 66 | #define APCI1564_DIGITAL_OP_WATCHDOG 0x28 | ||
| 67 | #define APCI1564_TIMER 0x48 | ||
| 68 | #define APCI1564_COUNTER1 0x0 | ||
| 69 | #define APCI1564_COUNTER2 0x20 | ||
| 70 | #define APCI1564_COUNTER3 0x40 | ||
| 71 | #define APCI1564_COUNTER4 0x60 | ||
| 72 | #define APCI1564_TCW_SYNC_ENABLEDISABLE 0 | ||
| 73 | #define APCI1564_TCW_RELOAD_VALUE 4 | ||
| 74 | #define APCI1564_TCW_TIMEBASE 8 | ||
| 75 | #define APCI1564_TCW_PROG 12 | ||
| 76 | #define APCI1564_TCW_TRIG_STATUS 16 | ||
| 77 | #define APCI1564_TCW_IRQ 20 | ||
| 78 | #define APCI1564_TCW_WARN_TIMEVAL 24 | ||
| 79 | #define APCI1564_TCW_WARN_TIMEBASE 28 | ||
| 80 | |||
| 81 | /* Hardware Layer functions for Apci1564 */ | ||
| 82 | |||
| 83 | /* | ||
| 84 | * DI for di read | ||
| 85 | */ | ||
| 86 | int i_APCI1564_ConfigDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 87 | struct comedi_insn *insn, unsigned int *data); | ||
| 88 | int i_APCI1564_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 89 | struct comedi_insn *insn, unsigned int *data); | ||
| 90 | int i_APCI1564_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 91 | struct comedi_insn *insn, unsigned int *data); | ||
| 92 | |||
| 93 | /* DO */ | ||
| 94 | int i_APCI1564_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 95 | struct comedi_insn *insn, unsigned int *data); | ||
| 96 | int i_APCI1564_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 97 | struct comedi_insn *insn, unsigned int *data); | ||
| 98 | int i_APCI1564_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 99 | struct comedi_insn *insn, unsigned int *data); | ||
| 100 | int i_APCI1564_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 101 | struct comedi_insn *insn, unsigned int *data); | ||
| 102 | |||
| 103 | /* | ||
| 104 | * TIMER timer value is passed as u seconds | ||
| 105 | */ | ||
| 106 | int i_APCI1564_ConfigTimerCounterWatchdog(struct comedi_device *dev, | ||
| 107 | struct comedi_subdevice *s, | ||
| 108 | struct comedi_insn *insn, unsigned int *data); | ||
| 109 | int i_APCI1564_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, | ||
| 110 | struct comedi_subdevice *s, | ||
| 111 | struct comedi_insn *insn, | ||
| 112 | unsigned int *data); | ||
| 113 | int i_APCI1564_ReadTimerCounterWatchdog(struct comedi_device *dev, | ||
| 114 | struct comedi_subdevice *s, | ||
| 115 | struct comedi_insn *insn, unsigned int *data); | ||
| 116 | |||
| 117 | /* intERRUPT */ | ||
| 118 | static void v_APCI1564_Interrupt(int irq, void *d); | ||
| 119 | |||
| 120 | /* RESET */ | ||
| 121 | int i_APCI1564_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h new file mode 100644 index 00000000000..5bf91e13a03 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data-com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef COMEDI_SUBD_TTLIO | ||
| 19 | #define COMEDI_SUBD_TTLIO 11 /* Digital Input Output But TTL */ | ||
| 20 | #endif | ||
| 21 | |||
| 22 | #ifndef ADDIDATA_ENABLE | ||
| 23 | #define ADDIDATA_ENABLE 1 | ||
| 24 | #define ADDIDATA_DISABLE 0 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #define APCI16XX_TTL_INIT 0 | ||
| 28 | #define APCI16XX_TTL_INITDIRECTION 1 | ||
| 29 | #define APCI16XX_TTL_OUTPUTMEMORY 2 | ||
| 30 | |||
| 31 | #define APCI16XX_TTL_READCHANNEL 0 | ||
| 32 | #define APCI16XX_TTL_READPORT 1 | ||
| 33 | |||
| 34 | #define APCI16XX_TTL_WRITECHANNEL_ON 0 | ||
| 35 | #define APCI16XX_TTL_WRITECHANNEL_OFF 1 | ||
| 36 | #define APCI16XX_TTL_WRITEPORT_ON 2 | ||
| 37 | #define APCI16XX_TTL_WRITEPORT_OFF 3 | ||
| 38 | |||
| 39 | #define APCI16XX_TTL_READ_ALL_INPUTS 0 | ||
| 40 | #define APCI16XX_TTL_READ_ALL_OUTPUTS 1 | ||
| 41 | |||
| 42 | #ifdef __KERNEL__ | ||
| 43 | |||
| 44 | static const struct comedi_lrange range_apci16xx_ttl = { 12, | ||
| 45 | {BIP_RANGE(1), | ||
| 46 | BIP_RANGE(1), | ||
| 47 | BIP_RANGE(1), | ||
| 48 | BIP_RANGE(1), | ||
| 49 | BIP_RANGE(1), | ||
| 50 | BIP_RANGE(1), | ||
| 51 | BIP_RANGE(1), | ||
| 52 | BIP_RANGE(1), | ||
| 53 | BIP_RANGE(1), | ||
| 54 | BIP_RANGE(1), | ||
| 55 | BIP_RANGE(1), | ||
| 56 | BIP_RANGE(1)} | ||
| 57 | }; | ||
| 58 | |||
| 59 | /* | ||
| 60 | +----------------------------------------------------------------------------+ | ||
| 61 | | TTL INISIALISATION FUNCTION | | ||
| 62 | +----------------------------------------------------------------------------+ | ||
| 63 | */ | ||
| 64 | |||
| 65 | int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device *dev, | ||
| 66 | struct comedi_subdevice *s, struct comedi_insn *insn, | ||
| 67 | unsigned int *data); | ||
| 68 | |||
| 69 | /* | ||
| 70 | +----------------------------------------------------------------------------+ | ||
| 71 | | TTL INPUT FUNCTION | | ||
| 72 | +----------------------------------------------------------------------------+ | ||
| 73 | */ | ||
| 74 | |||
| 75 | int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device *dev, | ||
| 76 | struct comedi_subdevice *s, struct comedi_insn *insn, | ||
| 77 | unsigned int *data); | ||
| 78 | |||
| 79 | int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device *dev, | ||
| 80 | struct comedi_subdevice *s, | ||
| 81 | struct comedi_insn *insn, unsigned int *data); | ||
| 82 | |||
| 83 | /* | ||
| 84 | +----------------------------------------------------------------------------+ | ||
| 85 | | TTL OUTPUT FUNCTIONS | | ||
| 86 | +----------------------------------------------------------------------------+ | ||
| 87 | */ | ||
| 88 | |||
| 89 | int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device *dev, | ||
| 90 | struct comedi_subdevice *s, struct comedi_insn *insn, | ||
| 91 | unsigned int *data); | ||
| 92 | |||
| 93 | int i_APCI16XX_Reset(struct comedi_device *dev); | ||
| 94 | #endif | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c new file mode 100644 index 00000000000..49dcbe24fcd --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c | |||
| @@ -0,0 +1,460 @@ | |||
| 1 | /** | ||
| 2 | @verbatim | ||
| 3 | |||
| 4 | Copyright (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 | |||
| 14 | 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. | ||
| 15 | |||
| 16 | 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. | ||
| 17 | |||
| 18 | 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 | ||
| 19 | |||
| 20 | You 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 | /* | ||
| 50 | +----------------------------------------------------------------------------+ | ||
| 51 | | Included files | | ||
| 52 | +----------------------------------------------------------------------------+ | ||
| 53 | */ | ||
| 54 | #include "hwdrv_apci2016.h" | ||
| 55 | |||
| 56 | /* | ||
| 57 | +----------------------------------------------------------------------------+ | ||
| 58 | | Function Name : int i_APCI2016_ConfigDigitalOutput | | ||
| 59 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 60 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 61 | +----------------------------------------------------------------------------+ | ||
| 62 | | Task : Configures The Digital Output Subdevice. | | ||
| 63 | +----------------------------------------------------------------------------+ | ||
| 64 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 65 | | unsigned int *data : Data Pointer contains | | ||
| 66 | | configuration parameters as below | | ||
| 67 | | | | ||
| 68 | | data[0] : 1 Digital Memory On | | ||
| 69 | | 0 Digital Memory Off | | ||
| 70 | +----------------------------------------------------------------------------+ | ||
| 71 | | Output Parameters : -- | | ||
| 72 | +----------------------------------------------------------------------------+ | ||
| 73 | | Return Value : TRUE : No error occur | | ||
| 74 | | : FALSE : Error occur. Return the error | | ||
| 75 | | | | ||
| 76 | +----------------------------------------------------------------------------+ | ||
| 77 | */ | ||
| 78 | int i_APCI2016_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 79 | struct comedi_insn *insn, unsigned int *data) | ||
| 80 | { | ||
| 81 | if ((data[0] != 0) && (data[0] != 1)) { | ||
| 82 | comedi_error(dev, | ||
| 83 | "Not a valid Data !!! ,Data should be 1 or 0\n"); | ||
| 84 | return -EINVAL; | ||
| 85 | } /* if ((data[0]!=0) && (data[0]!=1)) */ | ||
| 86 | if (data[0]) { | ||
| 87 | devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; | ||
| 88 | } /* if (data[0] */ | ||
| 89 | else { | ||
| 90 | devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; | ||
| 91 | } /* else if (data[0] */ | ||
| 92 | return insn->n; | ||
| 93 | } | ||
| 94 | |||
| 95 | /* | ||
| 96 | +----------------------------------------------------------------------------+ | ||
| 97 | | Function Name : int i_APCI2016_WriteDigitalOutput | | ||
| 98 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 99 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 100 | +----------------------------------------------------------------------------+ | ||
| 101 | | Task : Writes port value To the selected port | | ||
| 102 | +----------------------------------------------------------------------------+ | ||
| 103 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 104 | | unsigned int ui_NoOfChannels : No Of Channels To Write | | ||
| 105 | | unsigned int *data : Data Pointer to read status | | ||
| 106 | +----------------------------------------------------------------------------+ | ||
| 107 | | Output Parameters : -- | | ||
| 108 | +----------------------------------------------------------------------------+ | ||
| 109 | | Return Value : TRUE : No error occur | | ||
| 110 | | : FALSE : Error occur. Return the error | | ||
| 111 | | | | ||
| 112 | +----------------------------------------------------------------------------+ | ||
| 113 | */ | ||
| 114 | int i_APCI2016_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 115 | struct comedi_insn *insn, unsigned int *data) | ||
| 116 | { | ||
| 117 | unsigned int ui_NoOfChannel; | ||
| 118 | unsigned int ui_Temp, ui_Temp1; | ||
| 119 | ui_NoOfChannel = CR_CHAN(insn->chanspec); | ||
| 120 | if (ui_NoOfChannel > 15) { | ||
| 121 | comedi_error(dev, | ||
| 122 | "Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n"); | ||
| 123 | return -EINVAL; | ||
| 124 | } /* if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) */ | ||
| 125 | if (devpriv->b_OutputMemoryStatus) { | ||
| 126 | ui_Temp = inw(devpriv->iobase + APCI2016_DIGITAL_OP); | ||
| 127 | } /* if (devpriv->b_OutputMemoryStatus ) */ | ||
| 128 | else { | ||
| 129 | ui_Temp = 0; | ||
| 130 | } /* else if (devpriv->b_OutputMemoryStatus ) */ | ||
| 131 | if ((data[1] != 0) && (data[1] != 1)) { | ||
| 132 | comedi_error(dev, | ||
| 133 | "Invalid Data[1] value !!!, Data[1] should be 0 or 1\n"); | ||
| 134 | return -EINVAL; | ||
| 135 | } /* if ((data[1]!=0) && (data[1]!=1)) */ | ||
| 136 | |||
| 137 | if (data[3] == 0) { | ||
| 138 | if (data[1] == 0) { | ||
| 139 | data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; | ||
| 140 | outw(data[0], devpriv->iobase + APCI2016_DIGITAL_OP); | ||
| 141 | } /* if (data[1]==0) */ | ||
| 142 | else { | ||
| 143 | if (data[1] == 1) { | ||
| 144 | switch (ui_NoOfChannel) { | ||
| 145 | case 2: | ||
| 146 | data[0] = | ||
| 147 | (data[0] << (2 * | ||
| 148 | data[2])) | ui_Temp; | ||
| 149 | break; | ||
| 150 | case 4: | ||
| 151 | data[0] = | ||
| 152 | (data[0] << (4 * | ||
| 153 | data[2])) | ui_Temp; | ||
| 154 | break; | ||
| 155 | case 8: | ||
| 156 | data[0] = | ||
| 157 | (data[0] << (8 * | ||
| 158 | data[2])) | ui_Temp; | ||
| 159 | break; | ||
| 160 | case 15: | ||
| 161 | data[0] = data[0] | ui_Temp; | ||
| 162 | break; | ||
| 163 | default: | ||
| 164 | comedi_error(dev, " chan spec wrong"); | ||
| 165 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 166 | } /* switch(ui_NoOfChannels) */ | ||
| 167 | outw(data[0], | ||
| 168 | devpriv->iobase + APCI2016_DIGITAL_OP); | ||
| 169 | } /* if (data[1]==1) */ | ||
| 170 | else { | ||
| 171 | printk("\nSpecified channel not supported\n"); | ||
| 172 | } /* else if (data[1]==1) */ | ||
| 173 | } /* else if (data[1]==0) */ | ||
| 174 | } /* if (data[3]==0) */ | ||
| 175 | else { | ||
| 176 | if (data[3] == 1) { | ||
| 177 | if (data[1] == 0) { | ||
| 178 | data[0] = ~data[0] & 0x1; | ||
| 179 | ui_Temp1 = 1; | ||
| 180 | ui_Temp1 = ui_Temp1 << ui_NoOfChannel; | ||
| 181 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 182 | data[0] = (data[0] << ui_NoOfChannel) ^ 0xffff; | ||
| 183 | data[0] = data[0] & ui_Temp; | ||
| 184 | outw(data[0], | ||
| 185 | devpriv->iobase + APCI2016_DIGITAL_OP); | ||
| 186 | } /* if (data[1]==0) */ | ||
| 187 | else { | ||
| 188 | if (data[1] == 1) { | ||
| 189 | switch (ui_NoOfChannel) { | ||
| 190 | case 2: | ||
| 191 | data[0] = ~data[0] & 0x3; | ||
| 192 | ui_Temp1 = 3; | ||
| 193 | ui_Temp1 = | ||
| 194 | ui_Temp1 << 2 * data[2]; | ||
| 195 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 196 | data[0] = | ||
| 197 | ((data[0] << (2 * | ||
| 198 | data | ||
| 199 | [2])) ^ | ||
| 200 | 0xffff) & ui_Temp; | ||
| 201 | break; | ||
| 202 | case 4: | ||
| 203 | data[0] = ~data[0] & 0xf; | ||
| 204 | ui_Temp1 = 15; | ||
| 205 | ui_Temp1 = | ||
| 206 | ui_Temp1 << 4 * data[2]; | ||
| 207 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 208 | data[0] = | ||
| 209 | ((data[0] << (4 * | ||
| 210 | data | ||
| 211 | [2])) ^ | ||
| 212 | 0xffff) & ui_Temp; | ||
| 213 | break; | ||
| 214 | case 8: | ||
| 215 | data[0] = ~data[0] & 0xff; | ||
| 216 | ui_Temp1 = 255; | ||
| 217 | ui_Temp1 = | ||
| 218 | ui_Temp1 << 8 * data[2]; | ||
| 219 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 220 | data[0] = | ||
| 221 | ((data[0] << (8 * | ||
| 222 | data | ||
| 223 | [2])) ^ | ||
| 224 | 0xffff) & ui_Temp; | ||
| 225 | break; | ||
| 226 | case 15: | ||
| 227 | break; | ||
| 228 | default: | ||
| 229 | comedi_error(dev, | ||
| 230 | " chan spec wrong"); | ||
| 231 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 232 | } /* switch(ui_NoOfChannels) */ | ||
| 233 | outw(data[0], | ||
| 234 | devpriv->iobase + | ||
| 235 | APCI2016_DIGITAL_OP); | ||
| 236 | } /* if(data[1]==1) */ | ||
| 237 | else { | ||
| 238 | printk("\nSpecified channel not supported\n"); | ||
| 239 | } /* else if(data[1]==1) */ | ||
| 240 | } /* elseif(data[1]==0) */ | ||
| 241 | } /* if(data[3]==1); */ | ||
| 242 | else { | ||
| 243 | printk("\nSpecified functionality does not exist\n"); | ||
| 244 | return -EINVAL; | ||
| 245 | } /* if else data[3]==1) */ | ||
| 246 | } /* if else data[3]==0) */ | ||
| 247 | return insn->n; | ||
| 248 | } | ||
| 249 | |||
| 250 | /* | ||
| 251 | +----------------------------------------------------------------------------+ | ||
| 252 | | Function Name : int i_APCI2016_BitsDigitalOutput | | ||
| 253 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 254 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 255 | +----------------------------------------------------------------------------+ | ||
| 256 | | Task : Read value of the selected channel or port | | ||
| 257 | +----------------------------------------------------------------------------+ | ||
| 258 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 259 | | unsigned int ui_NoOfChannels : No Of Channels To read | | ||
| 260 | | unsigned int *data : Data Pointer to read status | | ||
| 261 | +----------------------------------------------------------------------------+ | ||
| 262 | | Output Parameters : -- | | ||
| 263 | +----------------------------------------------------------------------------+ | ||
| 264 | | Return Value : TRUE : No error occur | | ||
| 265 | | : FALSE : Error occur. Return the error | | ||
| 266 | | | | ||
| 267 | +----------------------------------------------------------------------------+ | ||
| 268 | */ | ||
| 269 | int i_APCI2016_BitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 270 | struct comedi_insn *insn, unsigned int *data) | ||
| 271 | { | ||
| 272 | unsigned int ui_Temp; | ||
| 273 | unsigned int ui_NoOfChannel; | ||
| 274 | ui_NoOfChannel = CR_CHAN(insn->chanspec); | ||
| 275 | if (ui_NoOfChannel > 15) { | ||
| 276 | comedi_error(dev, | ||
| 277 | "Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n"); | ||
| 278 | return -EINVAL; | ||
| 279 | } /* if ((ui_NoOfChannel<0) || (ui_NoOfChannel>15)) */ | ||
| 280 | if ((data[0] != 0) && (data[0] != 1)) { | ||
| 281 | comedi_error(dev, | ||
| 282 | "Invalid Data[0] value !!!, Data[0] should be 0 or 1\n"); | ||
| 283 | return -EINVAL; | ||
| 284 | } /* if ((data[0]!=0) && (data[0]!=1)) */ | ||
| 285 | ui_Temp = data[0]; | ||
| 286 | *data = inw(devpriv->iobase + APCI2016_DIGITAL_OP_RW); | ||
| 287 | if (ui_Temp == 0) { | ||
| 288 | *data = (*data >> ui_NoOfChannel) & 0x1; | ||
| 289 | } /* if (ui_Temp==0) */ | ||
| 290 | else { | ||
| 291 | if (ui_Temp == 1) { | ||
| 292 | switch (ui_NoOfChannel) { | ||
| 293 | case 2: | ||
| 294 | *data = (*data >> (2 * data[1])) & 3; | ||
| 295 | break; | ||
| 296 | |||
| 297 | case 4: | ||
| 298 | *data = (*data >> (4 * data[1])) & 15; | ||
| 299 | break; | ||
| 300 | |||
| 301 | case 8: | ||
| 302 | *data = (*data >> (8 * data[1])) & 255; | ||
| 303 | break; | ||
| 304 | |||
| 305 | case 15: | ||
| 306 | break; | ||
| 307 | |||
| 308 | default: | ||
| 309 | comedi_error(dev, " chan spec wrong"); | ||
| 310 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 311 | } /* switch(ui_NoOfChannel) */ | ||
| 312 | } /* if (ui_Temp==1) */ | ||
| 313 | else { | ||
| 314 | printk("\nSpecified channel not supported \n"); | ||
| 315 | } /* else if (ui_Temp==1) */ | ||
| 316 | } /* if (ui_Temp==0) */ | ||
| 317 | return insn->n; | ||
| 318 | } | ||
| 319 | |||
| 320 | /* | ||
| 321 | +----------------------------------------------------------------------------+ | ||
| 322 | | Function Name : int i_APCI2016_ConfigWatchdog | | ||
| 323 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 324 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 325 | +----------------------------------------------------------------------------+ | ||
| 326 | | Task : Configures The Watchdog | | ||
| 327 | +----------------------------------------------------------------------------+ | ||
| 328 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 329 | | struct comedi_subdevice *s, :pointer to subdevice structure | | ||
| 330 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 331 | | unsigned int *data : Data Pointer to read status | | ||
| 332 | +----------------------------------------------------------------------------+ | ||
| 333 | | Output Parameters : -- | | ||
| 334 | +----------------------------------------------------------------------------+ | ||
| 335 | | Return Value : TRUE : No error occur | | ||
| 336 | | : FALSE : Error occur. Return the error | | ||
| 337 | | | | ||
| 338 | +----------------------------------------------------------------------------+ | ||
| 339 | */ | ||
| 340 | int i_APCI2016_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 341 | struct comedi_insn *insn, unsigned int *data) | ||
| 342 | { | ||
| 343 | |||
| 344 | if (data[0] == 0) { | ||
| 345 | /* Disable the watchdog */ | ||
| 346 | outw(0x0, | ||
| 347 | devpriv->i_IobaseAddon + | ||
| 348 | APCI2016_WATCHDOG_ENABLEDISABLE); | ||
| 349 | /* Loading the Reload value */ | ||
| 350 | outw(data[1], | ||
| 351 | devpriv->i_IobaseAddon + | ||
| 352 | APCI2016_WATCHDOG_RELOAD_VALUE); | ||
| 353 | data[1] = data[1] >> 16; | ||
| 354 | outw(data[1], | ||
| 355 | devpriv->i_IobaseAddon + | ||
| 356 | APCI2016_WATCHDOG_RELOAD_VALUE + 2); | ||
| 357 | } else { | ||
| 358 | printk("\nThe input parameters are wrong\n"); | ||
| 359 | } | ||
| 360 | return insn->n; | ||
| 361 | } | ||
| 362 | |||
| 363 | /* | ||
| 364 | +----------------------------------------------------------------------------+ | ||
| 365 | | Function Name : int i_APCI2016_StartStopWriteWatchdog | | ||
| 366 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 367 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 368 | +----------------------------------------------------------------------------+ | ||
| 369 | | Task : Start / Stop The Watchdog | | ||
| 370 | +----------------------------------------------------------------------------+ | ||
| 371 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 372 | | struct comedi_subdevice *s, :pointer to subdevice structure | | ||
| 373 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 374 | | unsigned int *data : Data Pointer to read status | | ||
| 375 | +----------------------------------------------------------------------------+ | ||
| 376 | | Output Parameters : -- | | ||
| 377 | +----------------------------------------------------------------------------+ | ||
| 378 | | Return Value : TRUE : No error occur | | ||
| 379 | | : FALSE : Error occur. Return the error | | ||
| 380 | | | | ||
| 381 | +----------------------------------------------------------------------------+ | ||
| 382 | */ | ||
| 383 | int i_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 384 | struct comedi_insn *insn, unsigned int *data) | ||
| 385 | { | ||
| 386 | |||
| 387 | switch (data[0]) { | ||
| 388 | case 0: /* stop the watchdog */ | ||
| 389 | outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */ | ||
| 390 | break; | ||
| 391 | case 1: /* start the watchdog */ | ||
| 392 | outw(0x0001, | ||
| 393 | devpriv->i_IobaseAddon + | ||
| 394 | APCI2016_WATCHDOG_ENABLEDISABLE); | ||
| 395 | break; | ||
| 396 | case 2: /* Software trigger */ | ||
| 397 | outw(0x0201, | ||
| 398 | devpriv->i_IobaseAddon + | ||
| 399 | APCI2016_WATCHDOG_ENABLEDISABLE); | ||
| 400 | break; | ||
| 401 | default: | ||
| 402 | printk("\nSpecified functionality does not exist\n"); | ||
| 403 | return -EINVAL; | ||
| 404 | } /* switch(data[0]) */ | ||
| 405 | |||
| 406 | return insn->n; | ||
| 407 | } | ||
| 408 | |||
| 409 | /* | ||
| 410 | +----------------------------------------------------------------------------+ | ||
| 411 | | Function Name : int i_APCI2016_ReadWatchdog | | ||
| 412 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 413 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 414 | +----------------------------------------------------------------------------+ | ||
| 415 | | Task : Read The Watchdog | | ||
| 416 | +----------------------------------------------------------------------------+ | ||
| 417 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 418 | | struct comedi_subdevice *s, :pointer to subdevice structure | | ||
| 419 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 420 | | unsigned int *data : Data Pointer to read status | | ||
| 421 | +----------------------------------------------------------------------------+ | ||
| 422 | | Output Parameters : -- | | ||
| 423 | +----------------------------------------------------------------------------+ | ||
| 424 | | Return Value : TRUE : No error occur | | ||
| 425 | | : FALSE : Error occur. Return the error | | ||
| 426 | | | | ||
| 427 | +----------------------------------------------------------------------------+ | ||
| 428 | */ | ||
| 429 | |||
| 430 | int i_APCI2016_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 431 | struct comedi_insn *insn, unsigned int *data) | ||
| 432 | { | ||
| 433 | udelay(5); | ||
| 434 | data[0] = inw(devpriv->i_IobaseAddon + APCI2016_WATCHDOG_STATUS) & 0x1; | ||
| 435 | return insn->n; | ||
| 436 | } | ||
| 437 | |||
| 438 | /* | ||
| 439 | +----------------------------------------------------------------------------+ | ||
| 440 | | Function Name : int i_APCI2016_Reset(struct comedi_device *dev) | | | ||
| 441 | +----------------------------------------------------------------------------+ | ||
| 442 | | Task :resets all the registers | | ||
| 443 | +----------------------------------------------------------------------------+ | ||
| 444 | | Input Parameters : struct comedi_device *dev | ||
| 445 | +----------------------------------------------------------------------------+ | ||
| 446 | | Output Parameters : -- | | ||
| 447 | +----------------------------------------------------------------------------+ | ||
| 448 | | Return Value : | | ||
| 449 | | | | ||
| 450 | +----------------------------------------------------------------------------+ | ||
| 451 | */ | ||
| 452 | |||
| 453 | int i_APCI2016_Reset(struct comedi_device *dev) | ||
| 454 | { | ||
| 455 | outw(0x0, devpriv->iobase + APCI2016_DIGITAL_OP); /* Resets the digital output channels */ | ||
| 456 | outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_ENABLEDISABLE); | ||
| 457 | outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE); | ||
| 458 | outw(0x0, devpriv->i_IobaseAddon + APCI2016_WATCHDOG_RELOAD_VALUE + 2); | ||
| 459 | return 0; | ||
| 460 | } | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h new file mode 100644 index 00000000000..c42612af0fa --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | /********* Definitions for APCI-2016 card *****/ | ||
| 18 | |||
| 19 | #define APCI2016_BOARD_VENDOR_ID 0x15B8 | ||
| 20 | #define APCI2016_ADDRESS_RANGE 8 | ||
| 21 | |||
| 22 | /* DIGITAL INPUT-OUTPUT DEFINE */ | ||
| 23 | |||
| 24 | #define APCI2016_DIGITAL_OP 0x04 | ||
| 25 | #define APCI2016_DIGITAL_OP_RW 4 | ||
| 26 | |||
| 27 | /* ADDIDATA Enable Disable */ | ||
| 28 | |||
| 29 | #define ADDIDATA_ENABLE 1 | ||
| 30 | #define ADDIDATA_DISABLE 0 | ||
| 31 | |||
| 32 | /* TIMER COUNTER WATCHDOG DEFINES */ | ||
| 33 | |||
| 34 | #define ADDIDATA_WATCHDOG 2 | ||
| 35 | #define APCI2016_DIGITAL_OP_WATCHDOG 0 | ||
| 36 | #define APCI2016_WATCHDOG_ENABLEDISABLE 12 | ||
| 37 | #define APCI2016_WATCHDOG_RELOAD_VALUE 4 | ||
| 38 | #define APCI2016_WATCHDOG_STATUS 16 | ||
| 39 | |||
| 40 | /* Hardware Layer functions for Apci2016 */ | ||
| 41 | |||
| 42 | /* DO */ | ||
| 43 | int i_APCI2016_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 44 | struct comedi_insn *insn, unsigned int *data); | ||
| 45 | |||
| 46 | int i_APCI2016_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 47 | struct comedi_insn *insn, unsigned int *data); | ||
| 48 | |||
| 49 | int i_APCI2016_BitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 50 | struct comedi_insn *insn, unsigned int *data); | ||
| 51 | |||
| 52 | /* | ||
| 53 | * TIMER | ||
| 54 | * timer value is passed as u seconds | ||
| 55 | */ | ||
| 56 | |||
| 57 | int i_APCI2016_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 58 | struct comedi_insn *insn, unsigned int *data); | ||
| 59 | |||
| 60 | int i_APCI2016_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 61 | struct comedi_insn *insn, unsigned int *data); | ||
| 62 | |||
| 63 | int i_APCI2016_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 64 | struct comedi_insn *insn, unsigned int *data); | ||
| 65 | |||
| 66 | /* Interrupt functions..... */ | ||
| 67 | |||
| 68 | /* void v_APCI2016_Interrupt(int irq, void *d); */ | ||
| 69 | |||
| 70 | /* void v_APCI2016_Interrupt(int irq, void *d); */ | ||
| 71 | /* RESET */ | ||
| 72 | int i_APCI2016_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c new file mode 100644 index 00000000000..002297dfe33 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c | |||
| @@ -0,0 +1,579 @@ | |||
| 1 | /** | ||
| 2 | @verbatim | ||
| 3 | |||
| 4 | Copyright (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 | |||
| 14 | 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. | ||
| 15 | |||
| 16 | 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. | ||
| 17 | |||
| 18 | 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 | ||
| 19 | |||
| 20 | You 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-2032 | Compiler : GCC | | ||
| 33 | | Module name : hwdrv_apci2032.c| Version : 2.96 | | ||
| 34 | +-------------------------------+---------------------------------------+ | ||
| 35 | | Project manager: Eric Stolz | Date : 02/12/2002 | | ||
| 36 | +-------------------------------+---------------------------------------+ | ||
| 37 | | Description : Hardware Layer Access For APCI-2032 | | ||
| 38 | +-----------------------------------------------------------------------+ | ||
| 39 | | UPDATES | | ||
| 40 | +----------+-----------+------------------------------------------------+ | ||
| 41 | | Date | Author | Description of updates | | ||
| 42 | +----------+-----------+------------------------------------------------+ | ||
| 43 | | | | | | ||
| 44 | | | | | | ||
| 45 | | | | | | ||
| 46 | +----------+-----------+------------------------------------------------+ | ||
| 47 | */ | ||
| 48 | |||
| 49 | /* | ||
| 50 | +----------------------------------------------------------------------------+ | ||
| 51 | | Included files | | ||
| 52 | +----------------------------------------------------------------------------+ | ||
| 53 | */ | ||
| 54 | |||
| 55 | #include "hwdrv_apci2032.h" | ||
| 56 | static unsigned int ui_InterruptData, ui_Type; | ||
| 57 | /* | ||
| 58 | +----------------------------------------------------------------------------+ | ||
| 59 | | Function Name : int i_APCI2032_ConfigDigitalOutput | | ||
| 60 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 61 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 62 | +----------------------------------------------------------------------------+ | ||
| 63 | | Task : Configures The Digital Output Subdevice. | | ||
| 64 | +----------------------------------------------------------------------------+ | ||
| 65 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 66 | | unsigned int *data : Data Pointer contains | | ||
| 67 | | configuration parameters as below | | ||
| 68 | | | | ||
| 69 | | data[1] : 1 Enable VCC Interrupt | | ||
| 70 | | 0 Disable VCC Interrupt | | ||
| 71 | | data[2] : 1 Enable CC Interrupt | | ||
| 72 | | 0 Disable CC Interrupt | | ||
| 73 | | | | ||
| 74 | +----------------------------------------------------------------------------+ | ||
| 75 | | Output Parameters : -- | | ||
| 76 | +----------------------------------------------------------------------------+ | ||
| 77 | | Return Value : TRUE : No error occur | | ||
| 78 | | : FALSE : Error occur. Return the error | | ||
| 79 | | | | ||
| 80 | +----------------------------------------------------------------------------+ | ||
| 81 | */ | ||
| 82 | int i_APCI2032_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 83 | struct comedi_insn *insn, unsigned int *data) | ||
| 84 | { | ||
| 85 | unsigned int ul_Command = 0; | ||
| 86 | devpriv->tsk_Current = current; | ||
| 87 | |||
| 88 | if ((data[0] != 0) && (data[0] != 1)) { | ||
| 89 | comedi_error(dev, | ||
| 90 | "Not a valid Data !!! ,Data should be 1 or 0\n"); | ||
| 91 | return -EINVAL; | ||
| 92 | } /* if ( (data[0]!=0) && (data[0]!=1) ) */ | ||
| 93 | if (data[0]) { | ||
| 94 | devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; | ||
| 95 | } /* if (data[0]) */ | ||
| 96 | else { | ||
| 97 | devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; | ||
| 98 | } /* else if (data[0]) */ | ||
| 99 | |||
| 100 | if (data[1] == ADDIDATA_ENABLE) { | ||
| 101 | ul_Command = ul_Command | 0x1; | ||
| 102 | } /* if (data[1] == ADDIDATA_ENABLE) */ | ||
| 103 | else { | ||
| 104 | ul_Command = ul_Command & 0xFFFFFFFE; | ||
| 105 | } /* elseif (data[1] == ADDIDATA_ENABLE) */ | ||
| 106 | if (data[2] == ADDIDATA_ENABLE) { | ||
| 107 | ul_Command = ul_Command | 0x2; | ||
| 108 | } /* if (data[2] == ADDIDATA_ENABLE) */ | ||
| 109 | else { | ||
| 110 | ul_Command = ul_Command & 0xFFFFFFFD; | ||
| 111 | } /* elseif (data[2] == ADDIDATA_ENABLE) */ | ||
| 112 | outl(ul_Command, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); | ||
| 113 | ui_InterruptData = inl(devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); | ||
| 114 | return insn->n; | ||
| 115 | } | ||
| 116 | |||
| 117 | /* | ||
| 118 | +----------------------------------------------------------------------------+ | ||
| 119 | | Function Name : int i_APCI2032_WriteDigitalOutput | | ||
| 120 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 121 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 122 | +----------------------------------------------------------------------------+ | ||
| 123 | | Task : Writes port value To the selected port | | ||
| 124 | +----------------------------------------------------------------------------+ | ||
| 125 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 126 | | unsigned int ui_NoOfChannels : No Of Channels To Write | | ||
| 127 | | unsigned int *data : Data Pointer to read status | | ||
| 128 | +----------------------------------------------------------------------------+ | ||
| 129 | | Output Parameters : -- | | ||
| 130 | +----------------------------------------------------------------------------+ | ||
| 131 | | Return Value : TRUE : No error occur | | ||
| 132 | | : FALSE : Error occur. Return the error | | ||
| 133 | | | | ||
| 134 | +----------------------------------------------------------------------------+ | ||
| 135 | */ | ||
| 136 | |||
| 137 | int i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 138 | struct comedi_insn *insn, unsigned int *data) | ||
| 139 | { | ||
| 140 | unsigned int ui_Temp, ui_Temp1; | ||
| 141 | unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ | ||
| 142 | if (devpriv->b_OutputMemoryStatus) { | ||
| 143 | ui_Temp = inl(devpriv->iobase + APCI2032_DIGITAL_OP); | ||
| 144 | |||
| 145 | } /* if(devpriv->b_OutputMemoryStatus ) */ | ||
| 146 | else { | ||
| 147 | ui_Temp = 0; | ||
| 148 | } /* if(devpriv->b_OutputMemoryStatus ) */ | ||
| 149 | if (data[3] == 0) { | ||
| 150 | if (data[1] == 0) { | ||
| 151 | data[0] = (data[0] << ui_NoOfChannel) | ui_Temp; | ||
| 152 | outl(data[0], devpriv->iobase + APCI2032_DIGITAL_OP); | ||
| 153 | } /* if(data[1]==0) */ | ||
| 154 | else { | ||
| 155 | if (data[1] == 1) { | ||
| 156 | switch (ui_NoOfChannel) { | ||
| 157 | |||
| 158 | case 2: | ||
| 159 | data[0] = | ||
| 160 | (data[0] << (2 * | ||
| 161 | data[2])) | ui_Temp; | ||
| 162 | break; | ||
| 163 | |||
| 164 | case 4: | ||
| 165 | data[0] = | ||
| 166 | (data[0] << (4 * | ||
| 167 | data[2])) | ui_Temp; | ||
| 168 | break; | ||
| 169 | |||
| 170 | case 8: | ||
| 171 | data[0] = | ||
| 172 | (data[0] << (8 * | ||
| 173 | data[2])) | ui_Temp; | ||
| 174 | break; | ||
| 175 | |||
| 176 | case 16: | ||
| 177 | data[0] = | ||
| 178 | (data[0] << (16 * | ||
| 179 | data[2])) | ui_Temp; | ||
| 180 | break; | ||
| 181 | case 31: | ||
| 182 | data[0] = data[0] | ui_Temp; | ||
| 183 | break; | ||
| 184 | |||
| 185 | default: | ||
| 186 | comedi_error(dev, " chan spec wrong"); | ||
| 187 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 188 | |||
| 189 | } /* switch(ui_NoOfChannels) */ | ||
| 190 | |||
| 191 | outl(data[0], | ||
| 192 | devpriv->iobase + APCI2032_DIGITAL_OP); | ||
| 193 | } /* if(data[1]==1) */ | ||
| 194 | else { | ||
| 195 | printk("\nSpecified channel not supported\n"); | ||
| 196 | } /* else if(data[1]==1) */ | ||
| 197 | } /* elseif(data[1]==0) */ | ||
| 198 | } /* if(data[3]==0) */ | ||
| 199 | else { | ||
| 200 | if (data[3] == 1) { | ||
| 201 | if (data[1] == 0) { | ||
| 202 | data[0] = ~data[0] & 0x1; | ||
| 203 | ui_Temp1 = 1; | ||
| 204 | ui_Temp1 = ui_Temp1 << ui_NoOfChannel; | ||
| 205 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 206 | data[0] = | ||
| 207 | (data[0] << ui_NoOfChannel) ^ | ||
| 208 | 0xffffffff; | ||
| 209 | data[0] = data[0] & ui_Temp; | ||
| 210 | outl(data[0], | ||
| 211 | devpriv->iobase + APCI2032_DIGITAL_OP); | ||
| 212 | } /* if(data[1]==0) */ | ||
| 213 | else { | ||
| 214 | if (data[1] == 1) { | ||
| 215 | switch (ui_NoOfChannel) { | ||
| 216 | |||
| 217 | case 2: | ||
| 218 | data[0] = ~data[0] & 0x3; | ||
| 219 | ui_Temp1 = 3; | ||
| 220 | ui_Temp1 = | ||
| 221 | ui_Temp1 << 2 * data[2]; | ||
| 222 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 223 | data[0] = | ||
| 224 | ((data[0] << (2 * | ||
| 225 | data | ||
| 226 | [2])) ^ | ||
| 227 | 0xffffffff) & ui_Temp; | ||
| 228 | break; | ||
| 229 | |||
| 230 | case 4: | ||
| 231 | data[0] = ~data[0] & 0xf; | ||
| 232 | ui_Temp1 = 15; | ||
| 233 | ui_Temp1 = | ||
| 234 | ui_Temp1 << 4 * data[2]; | ||
| 235 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 236 | data[0] = | ||
| 237 | ((data[0] << (4 * | ||
| 238 | data | ||
| 239 | [2])) ^ | ||
| 240 | 0xffffffff) & ui_Temp; | ||
| 241 | break; | ||
| 242 | |||
| 243 | case 8: | ||
| 244 | data[0] = ~data[0] & 0xff; | ||
| 245 | ui_Temp1 = 255; | ||
| 246 | ui_Temp1 = | ||
| 247 | ui_Temp1 << 8 * data[2]; | ||
| 248 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 249 | data[0] = | ||
| 250 | ((data[0] << (8 * | ||
| 251 | data | ||
| 252 | [2])) ^ | ||
| 253 | 0xffffffff) & ui_Temp; | ||
| 254 | break; | ||
| 255 | |||
| 256 | case 16: | ||
| 257 | data[0] = ~data[0] & 0xffff; | ||
| 258 | ui_Temp1 = 65535; | ||
| 259 | ui_Temp1 = | ||
| 260 | ui_Temp1 << 16 * | ||
| 261 | data[2]; | ||
| 262 | ui_Temp = ui_Temp | ui_Temp1; | ||
| 263 | data[0] = | ||
| 264 | ((data[0] << (16 * | ||
| 265 | data | ||
| 266 | [2])) ^ | ||
| 267 | 0xffffffff) & ui_Temp; | ||
| 268 | break; | ||
| 269 | |||
| 270 | case 31: | ||
| 271 | break; | ||
| 272 | default: | ||
| 273 | comedi_error(dev, | ||
| 274 | " chan spec wrong"); | ||
| 275 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 276 | |||
| 277 | } /* switch(ui_NoOfChannels) */ | ||
| 278 | |||
| 279 | outl(data[0], | ||
| 280 | devpriv->iobase + | ||
| 281 | APCI2032_DIGITAL_OP); | ||
| 282 | } /* if(data[1]==1) */ | ||
| 283 | else { | ||
| 284 | printk("\nSpecified channel not supported\n"); | ||
| 285 | } /* else if(data[1]==1) */ | ||
| 286 | } /* elseif(data[1]==0) */ | ||
| 287 | } /* if(data[3]==1); */ | ||
| 288 | else { | ||
| 289 | printk("\nSpecified functionality does not exist\n"); | ||
| 290 | return -EINVAL; | ||
| 291 | } /* if else data[3]==1) */ | ||
| 292 | } /* if else data[3]==0) */ | ||
| 293 | return insn->n; | ||
| 294 | } | ||
| 295 | |||
| 296 | /* | ||
| 297 | +----------------------------------------------------------------------------+ | ||
| 298 | | Function Name : int i_APCI2032_ReadDigitalOutput | | ||
| 299 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 300 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 301 | +----------------------------------------------------------------------------+ | ||
| 302 | | Task : Read value of the selected channel or port | | ||
| 303 | +----------------------------------------------------------------------------+ | ||
| 304 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 305 | | unsigned int ui_NoOfChannels : No Of Channels To read | | ||
| 306 | | unsigned int *data : Data Pointer to read status | | ||
| 307 | +----------------------------------------------------------------------------+ | ||
| 308 | | Output Parameters : -- | | ||
| 309 | +----------------------------------------------------------------------------+ | ||
| 310 | | Return Value : TRUE : No error occur | | ||
| 311 | | : FALSE : Error occur. Return the error | | ||
| 312 | | | | ||
| 313 | +----------------------------------------------------------------------------+ | ||
| 314 | */ | ||
| 315 | |||
| 316 | int i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 317 | struct comedi_insn *insn, unsigned int *data) | ||
| 318 | { | ||
| 319 | unsigned int ui_Temp; | ||
| 320 | unsigned int ui_NoOfChannel; | ||
| 321 | ui_NoOfChannel = CR_CHAN(insn->chanspec); | ||
| 322 | ui_Temp = data[0]; | ||
| 323 | *data = inl(devpriv->iobase + APCI2032_DIGITAL_OP_RW); | ||
| 324 | if (ui_Temp == 0) { | ||
| 325 | *data = (*data >> ui_NoOfChannel) & 0x1; | ||
| 326 | } /* if (ui_Temp==0) */ | ||
| 327 | else { | ||
| 328 | if (ui_Temp == 1) { | ||
| 329 | switch (ui_NoOfChannel) { | ||
| 330 | |||
| 331 | case 2: | ||
| 332 | *data = (*data >> (2 * data[1])) & 3; | ||
| 333 | break; | ||
| 334 | |||
| 335 | case 4: | ||
| 336 | *data = (*data >> (4 * data[1])) & 15; | ||
| 337 | break; | ||
| 338 | |||
| 339 | case 8: | ||
| 340 | *data = (*data >> (8 * data[1])) & 255; | ||
| 341 | break; | ||
| 342 | |||
| 343 | case 16: | ||
| 344 | *data = (*data >> (16 * data[1])) & 65535; | ||
| 345 | break; | ||
| 346 | |||
| 347 | case 31: | ||
| 348 | break; | ||
| 349 | |||
| 350 | default: | ||
| 351 | comedi_error(dev, " chan spec wrong"); | ||
| 352 | return -EINVAL; /* "sorry channel spec wrong " */ | ||
| 353 | |||
| 354 | } /* switch(ui_NoOfChannels) */ | ||
| 355 | } /* if (ui_Temp==1) */ | ||
| 356 | else { | ||
| 357 | printk("\nSpecified channel not supported \n"); | ||
| 358 | } /* elseif (ui_Temp==1) */ | ||
| 359 | } | ||
| 360 | return insn->n; | ||
| 361 | } | ||
| 362 | |||
| 363 | /* | ||
| 364 | +----------------------------------------------------------------------------+ | ||
| 365 | | Function Name : int i_APCI2032_ConfigWatchdog(comedi_device | ||
| 366 | | *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)| | ||
| 367 | | | | ||
| 368 | +----------------------------------------------------------------------------+ | ||
| 369 | | Task : Configures The Watchdog | | ||
| 370 | +----------------------------------------------------------------------------+ | ||
| 371 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 372 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 373 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 374 | | unsigned int *data : Data Pointer to read status | | ||
| 375 | +----------------------------------------------------------------------------+ | ||
| 376 | | Output Parameters : -- | | ||
| 377 | +----------------------------------------------------------------------------+ | ||
| 378 | | Return Value : TRUE : No error occur | | ||
| 379 | | : FALSE : Error occur. Return the error | | ||
| 380 | | | | ||
| 381 | +----------------------------------------------------------------------------+ | ||
| 382 | */ | ||
| 383 | int i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 384 | struct comedi_insn *insn, unsigned int *data) | ||
| 385 | { | ||
| 386 | if (data[0] == 0) { | ||
| 387 | /* Disable the watchdog */ | ||
| 388 | outl(0x0, | ||
| 389 | devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + | ||
| 390 | APCI2032_TCW_PROG); | ||
| 391 | /* Loading the Reload value */ | ||
| 392 | outl(data[1], | ||
| 393 | devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + | ||
| 394 | APCI2032_TCW_RELOAD_VALUE); | ||
| 395 | } else { | ||
| 396 | printk("\nThe input parameters are wrong\n"); | ||
| 397 | return -EINVAL; | ||
| 398 | } | ||
| 399 | |||
| 400 | return insn->n; | ||
| 401 | } | ||
| 402 | |||
| 403 | /* | ||
| 404 | +----------------------------------------------------------------------------+ | ||
| 405 | | Function Name : int i_APCI2032_StartStopWriteWatchdog | | ||
| 406 | | (struct comedi_device *dev,struct comedi_subdevice *s, | ||
| 407 | struct comedi_insn *insn,unsigned int *data); | | ||
| 408 | +----------------------------------------------------------------------------+ | ||
| 409 | | Task : Start / Stop The Watchdog | | ||
| 410 | +----------------------------------------------------------------------------+ | ||
| 411 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 412 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 413 | struct comedi_insn *insn :pointer to insn structure | | ||
| 414 | | unsigned int *data : Data Pointer to read status | | ||
| 415 | +----------------------------------------------------------------------------+ | ||
| 416 | | Output Parameters : -- | | ||
| 417 | +----------------------------------------------------------------------------+ | ||
| 418 | | Return Value : TRUE : No error occur | | ||
| 419 | | : FALSE : Error occur. Return the error | | ||
| 420 | | | | ||
| 421 | +----------------------------------------------------------------------------+ | ||
| 422 | */ | ||
| 423 | |||
| 424 | int i_APCI2032_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 425 | struct comedi_insn *insn, unsigned int *data) | ||
| 426 | { | ||
| 427 | switch (data[0]) { | ||
| 428 | case 0: /* stop the watchdog */ | ||
| 429 | outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); /* disable the watchdog */ | ||
| 430 | break; | ||
| 431 | case 1: /* start the watchdog */ | ||
| 432 | outl(0x0001, | ||
| 433 | devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + | ||
| 434 | APCI2032_TCW_PROG); | ||
| 435 | break; | ||
| 436 | case 2: /* Software trigger */ | ||
| 437 | outl(0x0201, | ||
| 438 | devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + | ||
| 439 | APCI2032_TCW_PROG); | ||
| 440 | break; | ||
| 441 | default: | ||
| 442 | printk("\nSpecified functionality does not exist\n"); | ||
| 443 | return -EINVAL; | ||
| 444 | } | ||
| 445 | return insn->n; | ||
| 446 | } | ||
| 447 | |||
| 448 | /* | ||
| 449 | +----------------------------------------------------------------------------+ | ||
| 450 | | Function Name : int i_APCI2032_ReadWatchdog | | ||
| 451 | | (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, | ||
| 452 | | unsigned int *data); | | ||
| 453 | +----------------------------------------------------------------------------+ | ||
| 454 | | Task : Read The Watchdog | | ||
| 455 | +----------------------------------------------------------------------------+ | ||
| 456 | | Input Parameters : struct comedi_device *dev : Driver handle | | ||
| 457 | | struct comedi_subdevice *s, :pointer to subdevice structure | ||
| 458 | | struct comedi_insn *insn :pointer to insn structure | | ||
| 459 | | unsigned int *data : Data Pointer to read status | | ||
| 460 | +----------------------------------------------------------------------------+ | ||
| 461 | | Output Parameters : -- | | ||
| 462 | +----------------------------------------------------------------------------+ | ||
| 463 | | Return Value : TRUE : No error occur | | ||
| 464 | | : FALSE : Error occur. Return the error | | ||
| 465 | | | | ||
| 466 | +----------------------------------------------------------------------------+ | ||
| 467 | */ | ||
| 468 | |||
| 469 | int i_APCI2032_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 470 | struct comedi_insn *insn, unsigned int *data) | ||
| 471 | { | ||
| 472 | |||
| 473 | data[0] = | ||
| 474 | inl(devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + | ||
| 475 | APCI2032_TCW_TRIG_STATUS) & 0x1; | ||
| 476 | return insn->n; | ||
| 477 | } | ||
| 478 | |||
| 479 | /* | ||
| 480 | +----------------------------------------------------------------------------+ | ||
| 481 | | Function Name : void v_APCI2032_Interrupt | | ||
| 482 | | (int irq , void *d) | | ||
| 483 | +----------------------------------------------------------------------------+ | ||
| 484 | | Task : Writes port value To the selected port | | ||
| 485 | +----------------------------------------------------------------------------+ | ||
| 486 | | Input Parameters : int irq : irq number | | ||
| 487 | | void *d : void pointer | | ||
| 488 | +----------------------------------------------------------------------------+ | ||
| 489 | | Output Parameters : -- | | ||
| 490 | +----------------------------------------------------------------------------+ | ||
| 491 | | Return Value : TRUE : No error occur | | ||
| 492 | | : FALSE : Error occur. Return the error | | ||
| 493 | | | | ||
| 494 | +----------------------------------------------------------------------------+ | ||
| 495 | */ | ||
| 496 | void v_APCI2032_Interrupt(int irq, void *d) | ||
| 497 | { | ||
| 498 | struct comedi_device *dev = d; | ||
| 499 | unsigned int ui_DO; | ||
| 500 | |||
| 501 | ui_DO = inl(devpriv->iobase + APCI2032_DIGITAL_OP_IRQ) & 0x1; /* Check if VCC OR CC interrupt has occurred. */ | ||
| 502 | |||
| 503 | if (ui_DO == 0) { | ||
| 504 | printk("\nInterrupt from unKnown source\n"); | ||
| 505 | } /* if(ui_DO==0) */ | ||
| 506 | if (ui_DO) { | ||
| 507 | /* Check for Digital Output interrupt Type - 1: Vcc interrupt 2: CC interrupt. */ | ||
| 508 | ui_Type = | ||
| 509 | inl(devpriv->iobase + | ||
| 510 | APCI2032_DIGITAL_OP_INTERRUPT_STATUS) & 0x3; | ||
| 511 | outl(0x0, | ||
| 512 | devpriv->iobase + APCI2032_DIGITAL_OP + | ||
| 513 | APCI2032_DIGITAL_OP_INTERRUPT); | ||
| 514 | if (ui_Type == 1) { | ||
| 515 | /* Sends signal to user space */ | ||
| 516 | send_sig(SIGIO, devpriv->tsk_Current, 0); | ||
| 517 | } /* if (ui_Type==1) */ | ||
| 518 | else { | ||
| 519 | if (ui_Type == 2) { | ||
| 520 | /* Sends signal to user space */ | ||
| 521 | send_sig(SIGIO, devpriv->tsk_Current, 0); | ||
| 522 | } /* if (ui_Type==2) */ | ||
| 523 | } /* else if (ui_Type==1) */ | ||
| 524 | } /* if(ui_DO) */ | ||
| 525 | |||
| 526 | return; | ||
| 527 | |||
| 528 | } | ||
| 529 | |||
| 530 | /* | ||
| 531 | +----------------------------------------------------------------------------+ | ||
| 532 | | Function Name : int i_APCI2032_ReadInterruptStatus | | ||
| 533 | | (struct comedi_device *dev,struct comedi_subdevice *s, | | ||
| 534 | | struct comedi_insn *insn,unsigned int *data) | | ||
| 535 | +----------------------------------------------------------------------------+ | ||
| 536 | | Task :Reads the interrupt status register | | ||
| 537 | +----------------------------------------------------------------------------+ | ||
| 538 | | Input Parameters : | | ||
| 539 | +----------------------------------------------------------------------------+ | ||
| 540 | | Output Parameters : -- | | ||
| 541 | +----------------------------------------------------------------------------+ | ||
| 542 | | Return Value : | | ||
| 543 | | | | ||
| 544 | +----------------------------------------------------------------------------+ | ||
| 545 | */ | ||
| 546 | |||
| 547 | int i_APCI2032_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 548 | struct comedi_insn *insn, unsigned int *data) | ||
| 549 | { | ||
| 550 | *data = ui_Type; | ||
| 551 | return insn->n; | ||
| 552 | } | ||
| 553 | |||
| 554 | /* | ||
| 555 | +----------------------------------------------------------------------------+ | ||
| 556 | | Function Name : int i_APCI2032_Reset(struct comedi_device *dev) | | ||
| 557 | | | | ||
| 558 | +----------------------------------------------------------------------------+ | ||
| 559 | | Task :Resets the registers of the card | | ||
| 560 | +----------------------------------------------------------------------------+ | ||
| 561 | | Input Parameters : | | ||
| 562 | +----------------------------------------------------------------------------+ | ||
| 563 | | Output Parameters : -- | | ||
| 564 | +----------------------------------------------------------------------------+ | ||
| 565 | | Return Value : | | ||
| 566 | | | | ||
| 567 | +----------------------------------------------------------------------------+ | ||
| 568 | */ | ||
| 569 | |||
| 570 | int i_APCI2032_Reset(struct comedi_device *dev) | ||
| 571 | { | ||
| 572 | devpriv->b_DigitalOutputRegister = 0; | ||
| 573 | ui_Type = 0; | ||
| 574 | outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP); /* Resets the output channels */ | ||
| 575 | outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_INTERRUPT); /* Disables the interrupt. */ | ||
| 576 | outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_PROG); /* disable the watchdog */ | ||
| 577 | outl(0x0, devpriv->iobase + APCI2032_DIGITAL_OP_WATCHDOG + APCI2032_TCW_RELOAD_VALUE); /* reload=0 */ | ||
| 578 | return 0; | ||
| 579 | } | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h new file mode 100644 index 00000000000..ab145e7c940 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /********* Definitions for APCI-2032 card *****/ | ||
| 19 | |||
| 20 | /* Card Specific information */ | ||
| 21 | #define APCI2032_BOARD_VENDOR_ID 0x15B8 | ||
| 22 | #define APCI2032_ADDRESS_RANGE 63 | ||
| 23 | |||
| 24 | /* DIGITAL INPUT-OUTPUT DEFINE */ | ||
| 25 | |||
| 26 | #define APCI2032_DIGITAL_OP 0 | ||
| 27 | #define APCI2032_DIGITAL_OP_RW 0 | ||
| 28 | #define APCI2032_DIGITAL_OP_INTERRUPT 4 | ||
| 29 | #define APCI2032_DIGITAL_OP_IRQ 12 | ||
| 30 | |||
| 31 | /* Digital Output Interrupt Status */ | ||
| 32 | #define APCI2032_DIGITAL_OP_INTERRUPT_STATUS 8 | ||
| 33 | |||
| 34 | /* Digital Output Interrupt Enable Disable. */ | ||
| 35 | #define APCI2032_DIGITAL_OP_VCC_INTERRUPT_ENABLE 0x1 | ||
| 36 | #define APCI2032_DIGITAL_OP_VCC_INTERRUPT_DISABLE 0xFFFFFFFE | ||
| 37 | #define APCI2032_DIGITAL_OP_CC_INTERRUPT_ENABLE 0x2 | ||
| 38 | #define APCI2032_DIGITAL_OP_CC_INTERRUPT_DISABLE 0xFFFFFFFD | ||
| 39 | |||
| 40 | /* ADDIDATA Enable Disable */ | ||
| 41 | |||
| 42 | #define ADDIDATA_ENABLE 1 | ||
| 43 | #define ADDIDATA_DISABLE 0 | ||
| 44 | |||
| 45 | /* TIMER COUNTER WATCHDOG DEFINES */ | ||
| 46 | |||
| 47 | #define ADDIDATA_WATCHDOG 2 | ||
| 48 | #define APCI2032_DIGITAL_OP_WATCHDOG 16 | ||
| 49 | #define APCI2032_TCW_RELOAD_VALUE 4 | ||
| 50 | #define APCI2032_TCW_TIMEBASE 8 | ||
| 51 | #define APCI2032_TCW_PROG 12 | ||
| 52 | #define APCI2032_TCW_TRIG_STATUS 16 | ||
| 53 | #define APCI2032_TCW_IRQ 20 | ||
| 54 | |||
| 55 | /* Hardware Layer functions for Apci2032 */ | ||
| 56 | |||
| 57 | /* DO */ | ||
| 58 | int i_APCI2032_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 59 | struct comedi_insn *insn, unsigned int *data); | ||
| 60 | int i_APCI2032_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 61 | struct comedi_insn *insn, unsigned int *data); | ||
| 62 | int i_APCI2032_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 63 | struct comedi_insn *insn, unsigned int *data); | ||
| 64 | int i_APCI2032_ReadInterruptStatus(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 65 | struct comedi_insn *insn, unsigned int *data); | ||
| 66 | |||
| 67 | /* TIMER | ||
| 68 | * timer value is passed as u seconds | ||
| 69 | */ | ||
| 70 | |||
| 71 | int i_APCI2032_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 72 | struct comedi_insn *insn, unsigned int *data); | ||
| 73 | int i_APCI2032_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 74 | struct comedi_insn *insn, unsigned int *data); | ||
| 75 | int i_APCI2032_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 76 | struct comedi_insn *insn, unsigned int *data); | ||
| 77 | |||
| 78 | /* Interrupt functions..... */ | ||
| 79 | |||
| 80 | void v_APCI2032_Interrupt(int irq, void *d); | ||
| 81 | |||
| 82 | /* Reset functions */ | ||
| 83 | int i_APCI2032_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h new file mode 100644 index 00000000000..83f42af84b8 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /********* Definitions for APCI-2200 card *****/ | ||
| 19 | |||
| 20 | /* Card Specific information */ | ||
| 21 | #define APCI2200_BOARD_VENDOR_ID 0x15b8 | ||
| 22 | #define APCI2200_ADDRESS_RANGE 64 | ||
| 23 | |||
| 24 | /* DIGITAL INPUT-OUTPUT DEFINE */ | ||
| 25 | |||
| 26 | #define APCI2200_DIGITAL_OP 4 | ||
| 27 | #define APCI2200_DIGITAL_IP 0 | ||
| 28 | |||
| 29 | /* TIMER COUNTER WATCHDOG DEFINES */ | ||
| 30 | |||
| 31 | #define APCI2200_WATCHDOG 0x08 | ||
| 32 | #define APCI2200_WATCHDOG_ENABLEDISABLE 12 | ||
| 33 | #define APCI2200_WATCHDOG_RELOAD_VALUE 4 | ||
| 34 | #define APCI2200_WATCHDOG_STATUS 16 | ||
| 35 | |||
| 36 | /* Hardware Layer functions for Apci2200 */ | ||
| 37 | |||
| 38 | /* Digital Input */ | ||
| 39 | int i_APCI2200_ReadMoreDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 40 | struct comedi_insn *insn, unsigned int *data); | ||
| 41 | int i_APCI2200_Read1DigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 42 | struct comedi_insn *insn, unsigned int *data); | ||
| 43 | |||
| 44 | /* Digital Output */ | ||
| 45 | int i_APCI2200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 46 | struct comedi_insn *insn, unsigned int *data); | ||
| 47 | int i_APCI2200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 48 | struct comedi_insn *insn, unsigned int *data); | ||
| 49 | int i_APCI2200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 50 | struct comedi_insn *insn, unsigned int *data); | ||
| 51 | |||
| 52 | /* TIMER */ | ||
| 53 | int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 54 | struct comedi_insn *insn, unsigned int *data); | ||
| 55 | int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 56 | struct comedi_insn *insn, unsigned int *data); | ||
| 57 | int i_APCI2200_ReadWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 58 | struct comedi_insn *insn, unsigned int *data); | ||
| 59 | |||
| 60 | /* reset */ | ||
| 61 | int i_APCI2200_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h new file mode 100644 index 00000000000..50eb0a0a0a0 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h | |||
| @@ -0,0 +1,249 @@ | |||
| 1 | |||
| 2 | /* hwdrv_apci3120.h */ | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 6 | * | ||
| 7 | * ADDI-DATA GmbH | ||
| 8 | * Dieselstrasse 3 | ||
| 9 | * D-77833 Ottersweier | ||
| 10 | * Tel: +19(0)7223/9493-0 | ||
| 11 | * Fax: +49(0)7223/9493-92 | ||
| 12 | * http://www.addi-data.com | ||
| 13 | * info@addi-data.com | ||
| 14 | * | ||
| 15 | * This program is free software; you can redistribute it and/or modify it | ||
| 16 | * under the terms of the GNU General Public License as published by the Free | ||
| 17 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 18 | * any later version. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /* comedi related defines */ | ||
| 22 | |||
| 23 | /* ANALOG INPUT RANGE */ | ||
| 24 | static const struct comedi_lrange range_apci3120_ai = { 8, { | ||
| 25 | BIP_RANGE(10), | ||
| 26 | BIP_RANGE(5), | ||
| 27 | BIP_RANGE(2), | ||
| 28 | BIP_RANGE(1), | ||
| 29 | UNI_RANGE(10), | ||
| 30 | UNI_RANGE(5), | ||
| 31 | UNI_RANGE(2), | ||
| 32 | UNI_RANGE(1) | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | |||
| 36 | /* ANALOG OUTPUT RANGE */ | ||
| 37 | static const struct comedi_lrange range_apci3120_ao = { 2, { | ||
| 38 | BIP_RANGE(10), | ||
| 39 | UNI_RANGE(10) | ||
| 40 | } | ||
| 41 | }; | ||
| 42 | |||
| 43 | #define APCI3120_BIPOLAR_RANGES 4 /* used for test on mixture of BIP/UNI ranges */ | ||
| 44 | |||
| 45 | #define APCI3120_BOARD_VENDOR_ID 0x10E8 | ||
| 46 | #define APCI3120_ADDRESS_RANGE 16 | ||
| 47 | |||
| 48 | #define APCI3120_DISABLE 0 | ||
| 49 | #define APCI3120_ENABLE 1 | ||
| 50 | |||
| 51 | #define APCI3120_START 1 | ||
| 52 | #define APCI3120_STOP 0 | ||
| 53 | |||
| 54 | #define APCI3120_EOC_MODE 1 | ||
| 55 | #define APCI3120_EOS_MODE 2 | ||
| 56 | #define APCI3120_DMA_MODE 3 | ||
| 57 | |||
| 58 | /* DIGITAL INPUT-OUTPUT DEFINE */ | ||
| 59 | |||
| 60 | #define APCI3120_DIGITAL_OUTPUT 0x0D | ||
| 61 | #define APCI3120_RD_STATUS 0x02 | ||
| 62 | #define APCI3120_RD_FIFO 0x00 | ||
| 63 | |||
| 64 | /* digital output insn_write ON /OFF selection */ | ||
| 65 | #define APCI3120_SET4DIGITALOUTPUTON 1 | ||
| 66 | #define APCI3120_SET4DIGITALOUTPUTOFF 0 | ||
| 67 | |||
| 68 | /* analog output SELECT BIT */ | ||
| 69 | #define APCI3120_ANALOG_OP_CHANNEL_1 0x0000 | ||
| 70 | #define APCI3120_ANALOG_OP_CHANNEL_2 0x4000 | ||
| 71 | #define APCI3120_ANALOG_OP_CHANNEL_3 0x8000 | ||
| 72 | #define APCI3120_ANALOG_OP_CHANNEL_4 0xC000 | ||
| 73 | #define APCI3120_ANALOG_OP_CHANNEL_5 0x0000 | ||
| 74 | #define APCI3120_ANALOG_OP_CHANNEL_6 0x4000 | ||
| 75 | #define APCI3120_ANALOG_OP_CHANNEL_7 0x8000 | ||
| 76 | #define APCI3120_ANALOG_OP_CHANNEL_8 0xC000 | ||
| 77 | |||
| 78 | /* Enable external trigger bit in nWrAddress */ | ||
| 79 | #define APCI3120_ENABLE_EXT_TRIGGER 0x8000 | ||
| 80 | |||
| 81 | /* ANALOG OUTPUT AND INPUT DEFINE */ | ||
| 82 | #define APCI3120_UNIPOLAR 0x80 /* $$ RAM sequence polarity BIT */ | ||
| 83 | #define APCI3120_BIPOLAR 0x00 /* $$ RAM sequence polarity BIT */ | ||
| 84 | #define APCI3120_ANALOG_OUTPUT_1 0x08 /* (ADDRESS ) */ | ||
| 85 | #define APCI3120_ANALOG_OUTPUT_2 0x0A /* (ADDRESS ) */ | ||
| 86 | #define APCI3120_1_GAIN 0x00 /* $$ RAM sequence Gain Bits for gain 1 */ | ||
| 87 | #define APCI3120_2_GAIN 0x10 /* $$ RAM sequence Gain Bits for gain 2 */ | ||
| 88 | #define APCI3120_5_GAIN 0x20 /* $$ RAM sequence Gain Bits for gain 5 */ | ||
| 89 | #define APCI3120_10_GAIN 0x30 /* $$ RAM sequence Gain Bits for gain 10 */ | ||
| 90 | #define APCI3120_SEQ_RAM_ADDRESS 0x06 /* $$ EARLIER NAMED APCI3120_FIFO_ADDRESS */ | ||
| 91 | #define APCI3120_RESET_FIFO 0x0C /* (ADDRESS) */ | ||
| 92 | #define APCI3120_TIMER_0_MODE_2 0x01 /* $$ Bits for timer mode */ | ||
| 93 | #define APCI3120_TIMER_0_MODE_4 0x2 | ||
| 94 | #define APCI3120_SELECT_TIMER_0_WORD 0x00 | ||
| 95 | #define APCI3120_ENABLE_TIMER0 0x1000 /* $$Gatebit 0 in nWrAddress */ | ||
| 96 | #define APCI3120_CLEAR_PR 0xF0FF | ||
| 97 | #define APCI3120_CLEAR_PA 0xFFF0 | ||
| 98 | #define APCI3120_CLEAR_PA_PR (APCI3120_CLEAR_PR & APCI3120_CLEAR_PA) | ||
| 99 | |||
| 100 | /* nWrMode_Select */ | ||
| 101 | #define APCI3120_ENABLE_SCAN 0x8 /* $$ bit in nWrMode_Select */ | ||
| 102 | #define APCI3120_DISABLE_SCAN (~APCI3120_ENABLE_SCAN) | ||
| 103 | #define APCI3120_ENABLE_EOS_INT 0x2 /* $$ bit in nWrMode_Select */ | ||
| 104 | |||
| 105 | #define APCI3120_DISABLE_EOS_INT (~APCI3120_ENABLE_EOS_INT) | ||
| 106 | #define APCI3120_ENABLE_EOC_INT 0x1 | ||
| 107 | #define APCI3120_DISABLE_EOC_INT (~APCI3120_ENABLE_EOC_INT) | ||
| 108 | #define APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER (APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT) | ||
| 109 | #define APCI3120_DISABLE_ALL_INTERRUPT (APCI3120_DISABLE_TIMER_INT & APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT) | ||
| 110 | |||
| 111 | /* status register bits */ | ||
| 112 | #define APCI3120_EOC 0x8000 | ||
| 113 | #define APCI3120_EOS 0x2000 | ||
| 114 | |||
| 115 | /* software trigger dummy register */ | ||
| 116 | #define APCI3120_START_CONVERSION 0x02 /* (ADDRESS) */ | ||
| 117 | |||
| 118 | /* TIMER DEFINE */ | ||
| 119 | #define APCI3120_QUARTZ_A 70 | ||
| 120 | #define APCI3120_QUARTZ_B 50 | ||
| 121 | #define APCI3120_TIMER 1 | ||
| 122 | #define APCI3120_WATCHDOG 2 | ||
| 123 | #define APCI3120_TIMER_DISABLE 0 | ||
| 124 | #define APCI3120_TIMER_ENABLE 1 | ||
| 125 | #define APCI3120_ENABLE_TIMER2 0x4000 /* $$ gatebit 2 in nWrAddress */ | ||
| 126 | #define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2) | ||
| 127 | #define APCI3120_ENABLE_TIMER_INT 0x04 /* $$ ENAIRQ_FC_Bit in nWrModeSelect */ | ||
| 128 | #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) | ||
| 129 | #define APCI3120_WRITE_MODE_SELECT 0x0E /* (ADDRESS) */ | ||
| 130 | #define APCI3120_SELECT_TIMER_0_WORD 0x00 | ||
| 131 | #define APCI3120_SELECT_TIMER_1_WORD 0x01 | ||
| 132 | #define APCI3120_TIMER_1_MODE_2 0x4 | ||
| 133 | |||
| 134 | /* $$ BIT FOR MODE IN nCsTimerCtr1 */ | ||
| 135 | #define APCI3120_TIMER_2_MODE_0 0x0 | ||
| 136 | #define APCI3120_TIMER_2_MODE_2 0x10 | ||
| 137 | #define APCI3120_TIMER_2_MODE_5 0x30 | ||
| 138 | |||
| 139 | /* $$ BIT FOR MODE IN nCsTimerCtr0 */ | ||
| 140 | #define APCI3120_SELECT_TIMER_2_LOW_WORD 0x02 | ||
| 141 | #define APCI3120_SELECT_TIMER_2_HIGH_WORD 0x03 | ||
| 142 | |||
| 143 | #define APCI3120_TIMER_CRT0 0x0D /* (ADDRESS for cCsTimerCtr0) */ | ||
| 144 | #define APCI3120_TIMER_CRT1 0x0C /* (ADDRESS for cCsTimerCtr1) */ | ||
| 145 | |||
| 146 | #define APCI3120_TIMER_VALUE 0x04 /* ADDRESS for nCsTimerWert */ | ||
| 147 | #define APCI3120_TIMER_STATUS_REGISTER 0x0D /* ADDRESS for delete timer 2 interrupt */ | ||
| 148 | #define APCI3120_RD_STATUS 0x02 /* ADDRESS */ | ||
| 149 | #define APCI3120_WR_ADDRESS 0x00 /* ADDRESS */ | ||
| 150 | #define APCI3120_ENABLE_WATCHDOG 0x20 /* $$BIT in nWrMode_Select */ | ||
| 151 | #define APCI3120_DISABLE_WATCHDOG (~APCI3120_ENABLE_WATCHDOG) | ||
| 152 | #define APCI3120_ENABLE_TIMER_COUNTER 0x10 /* $$BIT in nWrMode_Select */ | ||
| 153 | #define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER) | ||
| 154 | #define APCI3120_FC_TIMER 0x1000 /* bit in status register */ | ||
| 155 | #define APCI3120_ENABLE_TIMER0 0x1000 | ||
| 156 | #define APCI3120_ENABLE_TIMER1 0x2000 | ||
| 157 | #define APCI3120_ENABLE_TIMER2 0x4000 | ||
| 158 | #define APCI3120_DISABLE_TIMER0 (~APCI3120_ENABLE_TIMER0) | ||
| 159 | #define APCI3120_DISABLE_TIMER1 (~APCI3120_ENABLE_TIMER1) | ||
| 160 | #define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2) | ||
| 161 | |||
| 162 | #define APCI3120_TIMER2_SELECT_EOS 0xC0 /* ADDED on 20-6 */ | ||
| 163 | #define APCI3120_COUNTER 3 /* on 20-6 */ | ||
| 164 | #define APCI3120_DISABLE_ALL_TIMER (APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 & APCI3120_DISABLE_TIMER2) /* on 20-6 */ | ||
| 165 | |||
| 166 | #define MAX_ANALOGINPUT_CHANNELS 32 | ||
| 167 | |||
| 168 | struct str_AnalogReadInformation { | ||
| 169 | |||
| 170 | unsigned char b_Type; /* EOC or EOS */ | ||
| 171 | unsigned char b_InterruptFlag; /* Interrupt use or not */ | ||
| 172 | unsigned int ui_ConvertTiming; /* Selection of the conversion time */ | ||
| 173 | unsigned char b_NbrOfChannel; /* Number of channel to read */ | ||
| 174 | unsigned int ui_ChannelList[MAX_ANALOGINPUT_CHANNELS]; /* Number of the channel to be read */ | ||
| 175 | unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; /* Gain of each channel */ | ||
| 176 | |||
| 177 | }; | ||
| 178 | |||
| 179 | |||
| 180 | /* Function Declaration For APCI-3120 */ | ||
| 181 | |||
| 182 | /* Internal functions */ | ||
| 183 | int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 184 | int n_chan, unsigned int *chanlist, char check); | ||
| 185 | int i_APCI3120_ExttrigEnable(struct comedi_device *dev); | ||
| 186 | int i_APCI3120_ExttrigDisable(struct comedi_device *dev); | ||
| 187 | int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s); | ||
| 188 | int i_APCI3120_Reset(struct comedi_device *dev); | ||
| 189 | int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev, | ||
| 190 | struct comedi_subdevice *s); | ||
| 191 | /* Interrupt functions */ | ||
| 192 | void v_APCI3120_Interrupt(int irq, void *d); | ||
| 193 | /* UPDATE-0.7.57->0.7.68 void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n); */ | ||
| 194 | void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, | ||
| 195 | struct comedi_subdevice *s, | ||
| 196 | short *dma_buffer, | ||
| 197 | unsigned int num_samples); | ||
| 198 | int i_APCI3120_InterruptHandleEos(struct comedi_device *dev); | ||
| 199 | void v_APCI3120_InterruptDma(int irq, void *d); | ||
| 200 | |||
| 201 | /* TIMER */ | ||
| 202 | |||
| 203 | int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 204 | struct comedi_insn *insn, unsigned int *data); | ||
| 205 | int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 206 | struct comedi_insn *insn, unsigned int *data); | ||
| 207 | int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 208 | struct comedi_insn *insn, unsigned int *data); | ||
| 209 | |||
| 210 | /* | ||
| 211 | * DI for di read | ||
| 212 | */ | ||
| 213 | |||
| 214 | int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 215 | struct comedi_insn *insn, unsigned int *data); | ||
| 216 | int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 217 | struct comedi_insn *insn, unsigned int *data); | ||
| 218 | |||
| 219 | /* DO */ | ||
| 220 | /* int i_APCI3120_WriteDigitalOutput(struct comedi_device *dev, | ||
| 221 | * unsigned char data); | ||
| 222 | */ | ||
| 223 | int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev, | ||
| 224 | struct comedi_subdevice *s, struct comedi_insn *insn, | ||
| 225 | unsigned int *data); | ||
| 226 | int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 227 | struct comedi_insn *insn, unsigned int *data); | ||
| 228 | int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 229 | struct comedi_insn *insn, unsigned int *data); | ||
| 230 | |||
| 231 | /* AO */ | ||
| 232 | /* int i_APCI3120_Write1AnalogValue(struct comedi_device *dev,UINT ui_Range, | ||
| 233 | * UINT ui_Channel,UINT data ); | ||
| 234 | */ | ||
| 235 | |||
| 236 | int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 237 | struct comedi_insn *insn, unsigned int *data); | ||
| 238 | |||
| 239 | /* AI HArdware layer */ | ||
| 240 | |||
| 241 | int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 242 | struct comedi_insn *insn, unsigned int *data); | ||
| 243 | int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 244 | struct comedi_insn *insn, unsigned int *data); | ||
| 245 | int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 246 | struct comedi_cmd *cmd); | ||
| 247 | int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); | ||
| 248 | /* int i_APCI3120_CancelAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); */ | ||
| 249 | int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h new file mode 100644 index 00000000000..812a9c46e11 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h | |||
| @@ -0,0 +1,191 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* Card Specific information */ | ||
| 19 | #define APCI3200_BOARD_VENDOR_ID 0x15B8 | ||
| 20 | /* #define APCI3200_ADDRESS_RANGE 264 */ | ||
| 21 | |||
| 22 | int MODULE_NO; | ||
| 23 | struct { | ||
| 24 | int i_Gain; | ||
| 25 | int i_Polarity; | ||
| 26 | int i_OffsetRange; | ||
| 27 | int i_Coupling; | ||
| 28 | int i_SingleDiff; | ||
| 29 | int i_AutoCalibration; | ||
| 30 | unsigned int ui_ReloadValue; | ||
| 31 | unsigned int ui_TimeUnitReloadVal; | ||
| 32 | int i_Interrupt; | ||
| 33 | int i_ModuleSelection; | ||
| 34 | } Config_Parameters_Module1, Config_Parameters_Module2, | ||
| 35 | Config_Parameters_Module3, Config_Parameters_Module4; | ||
| 36 | |||
| 37 | /* ANALOG INPUT RANGE */ | ||
| 38 | static const struct comedi_lrange range_apci3200_ai = { 8, { | ||
| 39 | BIP_RANGE(10), | ||
| 40 | BIP_RANGE(5), | ||
| 41 | BIP_RANGE(2), | ||
| 42 | BIP_RANGE(1), | ||
| 43 | UNI_RANGE(10), | ||
| 44 | UNI_RANGE(5), | ||
| 45 | UNI_RANGE(2), | ||
| 46 | UNI_RANGE(1) | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | |||
| 50 | static const struct comedi_lrange range_apci3300_ai = { 4, { | ||
| 51 | UNI_RANGE(10), | ||
| 52 | UNI_RANGE(5), | ||
| 53 | UNI_RANGE(2), | ||
| 54 | UNI_RANGE(1) | ||
| 55 | } | ||
| 56 | }; | ||
| 57 | |||
| 58 | /* Analog Input related Defines */ | ||
| 59 | #define APCI3200_AI_OFFSET_GAIN 0 | ||
| 60 | #define APCI3200_AI_SC_TEST 4 | ||
| 61 | #define APCI3200_AI_IRQ 8 | ||
| 62 | #define APCI3200_AI_AUTOCAL 12 | ||
| 63 | #define APCI3200_RELOAD_CONV_TIME_VAL 32 | ||
| 64 | #define APCI3200_CONV_TIME_TIME_BASE 36 | ||
| 65 | #define APCI3200_RELOAD_DELAY_TIME_VAL 40 | ||
| 66 | #define APCI3200_DELAY_TIME_TIME_BASE 44 | ||
| 67 | #define APCI3200_AI_MODULE1 0 | ||
| 68 | #define APCI3200_AI_MODULE2 64 | ||
| 69 | #define APCI3200_AI_MODULE3 128 | ||
| 70 | #define APCI3200_AI_MODULE4 192 | ||
| 71 | #define TRUE 1 | ||
| 72 | #define FALSE 0 | ||
| 73 | #define APCI3200_AI_EOSIRQ 16 | ||
| 74 | #define APCI3200_AI_EOS 20 | ||
| 75 | #define APCI3200_AI_CHAN_ID 24 | ||
| 76 | #define APCI3200_AI_CHAN_VAL 28 | ||
| 77 | #define ANALOG_INPUT 0 | ||
| 78 | #define TEMPERATURE 1 | ||
| 79 | #define RESISTANCE 2 | ||
| 80 | |||
| 81 | #define ENABLE_EXT_TRIG 1 | ||
| 82 | #define ENABLE_EXT_GATE 2 | ||
| 83 | #define ENABLE_EXT_TRIG_GATE 3 | ||
| 84 | |||
| 85 | #define APCI3200_MAXVOLT 2.5 | ||
| 86 | #define ADDIDATA_GREATER_THAN_TEST 0 | ||
| 87 | #define ADDIDATA_LESS_THAN_TEST 1 | ||
| 88 | |||
| 89 | #define ADDIDATA_UNIPOLAR 1 | ||
| 90 | #define ADDIDATA_BIPOLAR 2 | ||
| 91 | |||
| 92 | /* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ | ||
| 93 | #define MAX_MODULE 4 | ||
| 94 | /* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ | ||
| 95 | |||
| 96 | struct str_ADDIDATA_RTDStruct { | ||
| 97 | unsigned int ul_NumberOfValue; | ||
| 98 | unsigned int *pul_ResistanceValue; | ||
| 99 | unsigned int *pul_TemperatureValue; | ||
| 100 | }; | ||
| 101 | |||
| 102 | /* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ | ||
| 103 | struct str_Module { | ||
| 104 | |||
| 105 | /* Begin JK 05/08/2003 change for Linux */ | ||
| 106 | unsigned long ul_CurrentSourceCJC; | ||
| 107 | unsigned long ul_CurrentSource[5]; | ||
| 108 | /* End JK 05/08/2003 change for Linux */ | ||
| 109 | |||
| 110 | /* Begin CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */ | ||
| 111 | unsigned long ul_GainFactor[8]; /* Gain Factor */ | ||
| 112 | unsigned int w_GainValue[10]; | ||
| 113 | /* End CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */ | ||
| 114 | }; | ||
| 115 | |||
| 116 | /* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ | ||
| 117 | |||
| 118 | /* BEGIN JK 06.07.04: Management of sevrals boards */ | ||
| 119 | struct str_BoardInfos { | ||
| 120 | |||
| 121 | int i_CJCAvailable; | ||
| 122 | int i_CJCPolarity; | ||
| 123 | int i_CJCGain; | ||
| 124 | int i_InterruptFlag; | ||
| 125 | int i_ADDIDATAPolarity; | ||
| 126 | int i_ADDIDATAGain; | ||
| 127 | int i_AutoCalibration; | ||
| 128 | int i_ADDIDATAConversionTime; | ||
| 129 | int i_ADDIDATAConversionTimeUnit; | ||
| 130 | int i_ADDIDATAType; | ||
| 131 | int i_ChannelNo; | ||
| 132 | int i_ChannelCount; | ||
| 133 | int i_ScanType; | ||
| 134 | int i_FirstChannel; | ||
| 135 | int i_LastChannel; | ||
| 136 | int i_Sum; | ||
| 137 | int i_Offset; | ||
| 138 | unsigned int ui_Channel_num; | ||
| 139 | int i_Count; | ||
| 140 | int i_Initialised; | ||
| 141 | /* UINT ui_InterruptChannelValue[96]; //Buffer */ | ||
| 142 | unsigned int ui_InterruptChannelValue[144]; /* Buffer */ | ||
| 143 | unsigned char b_StructInitialized; | ||
| 144 | /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ | ||
| 145 | unsigned int ui_ScanValueArray[7 + 12]; /* 7 is the maximal number of channels */ | ||
| 146 | /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ | ||
| 147 | |||
| 148 | /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ | ||
| 149 | int i_ConnectionType; | ||
| 150 | int i_NbrOfModule; | ||
| 151 | struct str_Module s_Module[MAX_MODULE]; | ||
| 152 | /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ | ||
| 153 | }; | ||
| 154 | |||
| 155 | /* END JK 06.07.04: Management of sevrals boards */ | ||
| 156 | |||
| 157 | /* Hardware Layer functions for Apci3200 */ | ||
| 158 | |||
| 159 | /* AI */ | ||
| 160 | |||
| 161 | int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 162 | struct comedi_insn *insn, unsigned int *data); | ||
| 163 | int i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 164 | struct comedi_insn *insn, unsigned int *data); | ||
| 165 | int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev, | ||
| 166 | struct comedi_subdevice *s, | ||
| 167 | struct comedi_insn *insn, unsigned int *data); | ||
| 168 | int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev, | ||
| 169 | struct comedi_subdevice *s, | ||
| 170 | struct comedi_insn *insn, unsigned int *data); | ||
| 171 | int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s); | ||
| 172 | int i_APCI3200_InterruptHandleEos(struct comedi_device *dev); | ||
| 173 | int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 174 | struct comedi_cmd *cmd); | ||
| 175 | int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); | ||
| 176 | int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 177 | struct comedi_insn *insn, unsigned int *data); | ||
| 178 | /* Interrupt */ | ||
| 179 | void v_APCI3200_Interrupt(int irq, void *d); | ||
| 180 | int i_APCI3200_InterruptHandleEos(struct comedi_device *dev); | ||
| 181 | /* Reset functions */ | ||
| 182 | int i_APCI3200_Reset(struct comedi_device *dev); | ||
| 183 | |||
| 184 | int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, unsigned int *data); | ||
| 185 | int i_APCI3200_ReadCJCValue(struct comedi_device *dev, unsigned int *data); | ||
| 186 | int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int *data); | ||
| 187 | int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned int *data); | ||
| 188 | int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev, | ||
| 189 | struct comedi_subdevice *s, struct comedi_insn *insn, | ||
| 190 | unsigned int *data); | ||
| 191 | int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev, unsigned int *data); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h new file mode 100644 index 00000000000..63df635a7b6 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* Card Specific information */ | ||
| 19 | #define APCI3501_BOARD_VENDOR_ID 0x15B8 | ||
| 20 | #define APCI3501_ADDRESS_RANGE 255 | ||
| 21 | |||
| 22 | #define APCI3501_DIGITAL_IP 0x50 | ||
| 23 | #define APCI3501_DIGITAL_OP 0x40 | ||
| 24 | #define APCI3501_ANALOG_OUTPUT 0x00 | ||
| 25 | |||
| 26 | /* Analog Output related Defines */ | ||
| 27 | #define APCI3501_AO_VOLT_MODE 0 | ||
| 28 | #define APCI3501_AO_PROG 4 | ||
| 29 | #define APCI3501_AO_TRIG_SCS 8 | ||
| 30 | #define UNIPOLAR 0 | ||
| 31 | #define BIPOLAR 1 | ||
| 32 | #define MODE0 0 | ||
| 33 | #define MODE1 1 | ||
| 34 | /* ANALOG OUTPUT RANGE */ | ||
| 35 | static struct comedi_lrange range_apci3501_ao = { 2, { | ||
| 36 | BIP_RANGE(10), | ||
| 37 | UNI_RANGE(10) | ||
| 38 | } | ||
| 39 | }; | ||
| 40 | |||
| 41 | /* Watchdog Related Defines */ | ||
| 42 | |||
| 43 | #define APCI3501_WATCHDOG 0x20 | ||
| 44 | #define APCI3501_TCW_SYNC_ENABLEDISABLE 0 | ||
| 45 | #define APCI3501_TCW_RELOAD_VALUE 4 | ||
| 46 | #define APCI3501_TCW_TIMEBASE 8 | ||
| 47 | #define APCI3501_TCW_PROG 12 | ||
| 48 | #define APCI3501_TCW_TRIG_STATUS 16 | ||
| 49 | #define APCI3501_TCW_IRQ 20 | ||
| 50 | #define APCI3501_TCW_WARN_TIMEVAL 24 | ||
| 51 | #define APCI3501_TCW_WARN_TIMEBASE 28 | ||
| 52 | #define ADDIDATA_TIMER 0 | ||
| 53 | #define ADDIDATA_WATCHDOG 2 | ||
| 54 | |||
| 55 | /* Hardware Layer functions for Apci3501 */ | ||
| 56 | |||
| 57 | /* AO */ | ||
| 58 | int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 59 | struct comedi_insn *insn, unsigned int *data); | ||
| 60 | int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 61 | struct comedi_insn *insn, unsigned int *data); | ||
| 62 | |||
| 63 | /* | ||
| 64 | * DI for di read INT i_APCI3501_ReadDigitalInput(struct | ||
| 65 | * comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn | ||
| 66 | * *insn,unsigned int *data); | ||
| 67 | */ | ||
| 68 | |||
| 69 | int i_APCI3501_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 70 | struct comedi_insn *insn, unsigned int *data); | ||
| 71 | |||
| 72 | /* DO */ | ||
| 73 | int i_APCI3501_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 74 | struct comedi_insn *insn, unsigned int *data); | ||
| 75 | int i_APCI3501_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 76 | struct comedi_insn *insn, unsigned int *data); | ||
| 77 | int i_APCI3501_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 78 | struct comedi_insn *insn, unsigned int *data); | ||
| 79 | |||
| 80 | /* TIMER | ||
| 81 | * timer value is passed as u seconds | ||
| 82 | */ | ||
| 83 | |||
| 84 | int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev, | ||
| 85 | struct comedi_subdevice *s, | ||
| 86 | struct comedi_insn *insn, unsigned int *data); | ||
| 87 | int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, | ||
| 88 | struct comedi_subdevice *s, | ||
| 89 | struct comedi_insn *insn, | ||
| 90 | unsigned int *data); | ||
| 91 | int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev, | ||
| 92 | struct comedi_subdevice *s, | ||
| 93 | struct comedi_insn *insn, unsigned int *data); | ||
| 94 | /* Interrupt */ | ||
| 95 | void v_APCI3501_Interrupt(int irq, void *d); | ||
| 96 | |||
| 97 | /* Reset functions */ | ||
| 98 | int i_APCI3501_Reset(struct comedi_device *dev); | ||
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h new file mode 100644 index 00000000000..cce9e12e820 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. | ||
| 3 | * | ||
| 4 | * ADDI-DATA GmbH | ||
| 5 | * Dieselstrasse 3 | ||
| 6 | * D-77833 Ottersweier | ||
| 7 | * Tel: +19(0)7223/9493-0 | ||
| 8 | * Fax: +49(0)7223/9493-92 | ||
| 9 | * http://www.addi-data.com | ||
| 10 | * info@addi-data.com | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License as published by the Free | ||
| 14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 15 | * any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef COMEDI_SUBD_TTLIO | ||
| 19 | #define COMEDI_SUBD_TTLIO 11 /* Digital Input Output But TTL */ | ||
| 20 | #endif | ||
| 21 | |||
| 22 | #ifndef ADDIDATA_ENABLE | ||
| 23 | #define ADDIDATA_ENABLE 1 | ||
| 24 | #define ADDIDATA_DISABLE 0 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #define APCI3XXX_SINGLE 0 | ||
| 28 | #define APCI3XXX_DIFF 1 | ||
| 29 | #define APCI3XXX_CONFIGURATION 0 | ||
| 30 | |||
| 31 | #define APCI3XXX_TTL_INIT_DIRECTION_PORT2 0 | ||
| 32 | |||
| 33 | #ifdef __KERNEL__ | ||
| 34 | |||
| 35 | static const struct comedi_lrange range_apci3XXX_ai = { 8, {BIP_RANGE(10), | ||
| 36 | BIP_RANGE(5), | ||
| 37 | BIP_RANGE(2), | ||
| 38 | BIP_RANGE(1), | ||
| 39 | UNI_RANGE(10), | ||
| 40 | UNI_RANGE(5), | ||
| 41 | UNI_RANGE(2), | ||
| 42 | UNI_RANGE(1)} | ||
| 43 | }; | ||
| 44 | |||
| 45 | static const struct comedi_lrange range_apci3XXX_ttl = { 12, {BIP_RANGE(1), | ||
| 46 | BIP_RANGE(1), | ||
| 47 | BIP_RANGE(1), | ||
| 48 | BIP_RANGE(1), | ||
| 49 | BIP_RANGE(1), | ||
| 50 | BIP_RANGE(1), | ||
| 51 | BIP_RANGE(1), | ||
| 52 | BIP_RANGE(1), | ||
| 53 | BIP_RANGE(1), | ||
| 54 | BIP_RANGE(1), | ||
| 55 | BIP_RANGE(1), | ||
| 56 | BIP_RANGE(1)} | ||
| 57 | }; | ||
| 58 | |||
| 59 | static const struct comedi_lrange range_apci3XXX_ao = { 2, {BIP_RANGE(10), | ||
| 60 | UNI_RANGE(10)} | ||
| 61 | }; | ||
| 62 | #endif | ||
diff --git a/drivers/staging/comedi/drivers/addi_apci_2016.c b/drivers/staging/comedi/drivers/addi_apci_2016.c new file mode 100644 index 00000000000..fa50c7bb7ad --- /dev/null +++ b/drivers/staging/comedi/drivers/addi_apci_2016.c | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #define CONFIG_APCI_2016 1 | ||
| 2 | |||
| 3 | #define ADDIDATA_DRIVER_NAME "addi_apci_2016" | ||
| 4 | |||
| 5 | #include "addi-data/addi_common.c" | ||
| 6 | |||
| 7 | MODULE_AUTHOR("Comedi http://www.comedi.org"); | ||
| 8 | MODULE_DESCRIPTION("Comedi low-level driver"); | ||
| 9 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/comedi/drivers/addi_apci_3001.c b/drivers/staging/comedi/drivers/addi_apci_3001.c new file mode 100644 index 00000000000..00ac762965c --- /dev/null +++ b/drivers/staging/comedi/drivers/addi_apci_3001.c | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #define CONFIG_APCI_3001 1 | ||
| 2 | |||
| 3 | #define ADDIDATA_DRIVER_NAME "addi_apci_3001" | ||
| 4 | |||
| 5 | #include "addi-data/addi_common.c" | ||
| 6 | |||
| 7 | MODULE_AUTHOR("Comedi http://www.comedi.org"); | ||
| 8 | MODULE_DESCRIPTION("Comedi low-level driver"); | ||
| 9 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/comedi/drivers/addi_apci_3300.c b/drivers/staging/comedi/drivers/addi_apci_3300.c new file mode 100644 index 00000000000..733c69abc43 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi_apci_3300.c | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | #define CONFIG_APCI_3300 1 | ||
| 2 | |||
| 3 | #define ADDIDATA_DRIVER_NAME "addi_apci_3300" | ||
| 4 | |||
| 5 | #include "addi-data/addi_common.c" | ||
diff --git a/drivers/staging/comedi/drivers/addi_apci_all.c b/drivers/staging/comedi/drivers/addi_apci_all.c new file mode 100644 index 00000000000..aeb1b2688f3 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi_apci_all.c | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | #define CONFIG_APCI_035 1 | ||
| 2 | #define CONFIG_APCI_1032 1 | ||
| 3 | #define CONFIG_APCI_1500 1 | ||
| 4 | #define CONFIG_APCI_1516 1 | ||
| 5 | #define CONFIG_APCI_1564 1 | ||
| 6 | #define CONFIG_APCI_16XX 1 | ||
| 7 | #define CONFIG_APCI_1710 1 | ||
| 8 | #define CONFIG_APCI_2016 1 | ||
| 9 | #define CONFIG_APCI_2032 1 | ||
| 10 | #define CONFIG_APCI_2200 1 | ||
| 11 | #define CONFIG_APCI_3001 1 | ||
| 12 | #define CONFIG_APCI_3120 1 | ||
| 13 | #define CONFIG_APCI_3200 1 | ||
| 14 | #define CONFIG_APCI_3300 1 | ||
| 15 | #define CONFIG_APCI_3501 1 | ||
| 16 | #define CONFIG_APCI_3XXX 1 | ||
| 17 | |||
| 18 | #include "addi-data/addi_common.c" | ||
diff --git a/drivers/staging/comedi/drivers/adl_pci7230.c b/drivers/staging/comedi/drivers/adl_pci7230.c new file mode 100644 index 00000000000..72a7258b5b9 --- /dev/null +++ b/drivers/staging/comedi/drivers/adl_pci7230.c | |||
| @@ -0,0 +1,245 @@ | |||
| 1 | /* | ||
| 2 | comedi/drivers/adl_pci7230.c | ||
| 3 | |||
| 4 | Hardware comedi driver fot PCI7230 Adlink card | ||
| 5 | Copyright (C) 2010 David Fernandez <dfcastelao@gmail.com> | ||
| 6 | |||
| 7 | This program is free software; you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation; either version 2 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | This program is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with this program; if not, write to the Free Software | ||
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | |||
| 21 | */ | ||
| 22 | /* | ||
| 23 | Driver: adl_pci7230 | ||
| 24 | Description: Driver for the Adlink PCI-7230 32 ch. isolated digital io board | ||
| 25 | Devices: [ADLink] PCI-7230 (adl_pci7230) | ||
| 26 | Author: David Fernandez <dfcastelao@gmail.com> | ||
| 27 | Status: experimental | ||
| 28 | Updated: Mon, 14 Apr 2008 15:08:14 +0100 | ||
| 29 | |||
| 30 | Configuration Options: | ||
| 31 | [0] - PCI bus of device (optional) | ||
| 32 | [1] - PCI slot of device (optional) | ||
| 33 | If bus/slot is not specified, the first supported | ||
| 34 | PCI device found will be used. | ||
| 35 | */ | ||
| 36 | |||
| 37 | #include "../comedidev.h" | ||
| 38 | #include <linux/kernel.h> | ||
| 39 | #include "comedi_pci.h" | ||
| 40 | |||
| 41 | #define PCI7230_DI 0x00 | ||
| 42 | #define PCI7230_DO 0x00 | ||
| 43 | |||
| 44 | #define PCI_DEVICE_ID_PCI7230 0x7230 | ||
| 45 | |||
| 46 | static DEFINE_PCI_DEVICE_TABLE(adl_pci7230_pci_table) = { | ||
| 47 | { | ||
| 48 | PCI_VENDOR_ID_ADLINK, | ||
| 49 | PCI_DEVICE_ID_PCI7230, | ||
| 50 | PCI_ANY_ID, | ||
| 51 | PCI_ANY_ID, | ||
| 52 | 0, | ||
| 53 | 0, | ||
| 54 | 0 | ||
| 55 | }, | ||
| 56 | {0} | ||
| 57 | }; | ||
| 58 | |||
| 59 | MODULE_DEVICE_TABLE(pci, adl_pci7230_pci_table); | ||
| 60 | |||
| 61 | struct adl_pci7230_private { | ||
| 62 | int data; | ||
| 63 | struct pci_dev *pci_dev; | ||
| 64 | }; | ||
| 65 | |||
| 66 | #define devpriv ((struct adl_pci7230_private *)dev->private) | ||
| 67 | |||
| 68 | static int adl_pci7230_attach(struct comedi_device *dev, | ||
| 69 | struct comedi_devconfig *it); | ||
| 70 | static int adl_pci7230_detach(struct comedi_device *dev); | ||
| 71 | static struct comedi_driver driver_adl_pci7230 = { | ||
| 72 | .driver_name = "adl_pci7230", | ||
| 73 | .module = THIS_MODULE, | ||
| 74 | .attach = adl_pci7230_attach, | ||
| 75 | .detach = adl_pci7230_detach, | ||
| 76 | }; | ||
| 77 | |||
| 78 | /* Digital IO */ | ||
| 79 | |||
| 80 | static int adl_pci7230_di_insn_bits(struct comedi_device *dev, | ||
| 81 | struct comedi_subdevice *s, | ||
| 82 | struct comedi_insn *insn, | ||
| 83 | unsigned int *data); | ||
| 84 | |||
| 85 | static int adl_pci7230_do_insn_bits(struct comedi_device *dev, | ||
| 86 | struct comedi_subdevice *s, | ||
| 87 | struct comedi_insn *insn, | ||
| 88 | unsigned int *data); | ||
| 89 | |||
| 90 | static int adl_pci7230_attach(struct comedi_device *dev, | ||
| 91 | struct comedi_devconfig *it) | ||
| 92 | { | ||
| 93 | struct pci_dev *pcidev = NULL; | ||
| 94 | struct comedi_subdevice *s; | ||
| 95 | int bus, slot; | ||
| 96 | |||
| 97 | printk(KERN_INFO "comedi%d: adl_pci7230\n", dev->minor); | ||
| 98 | |||
| 99 | dev->board_name = "pci7230"; | ||
| 100 | bus = it->options[0]; | ||
| 101 | slot = it->options[1]; | ||
| 102 | |||
| 103 | if (alloc_private(dev, sizeof(struct adl_pci7230_private)) < 0) | ||
| 104 | return -ENOMEM; | ||
| 105 | |||
| 106 | if (alloc_subdevices(dev, 2) < 0) | ||
| 107 | return -ENOMEM; | ||
| 108 | |||
| 109 | for_each_pci_dev(pcidev) { | ||
| 110 | if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && | ||
| 111 | pcidev->device == PCI_DEVICE_ID_PCI7230) { | ||
| 112 | if (bus || slot) { | ||
| 113 | /* requested particular bus/slot */ | ||
| 114 | if (pcidev->bus->number != bus || | ||
| 115 | PCI_SLOT(pcidev->devfn) != slot) { | ||
| 116 | continue; | ||
| 117 | } | ||
| 118 | } | ||
| 119 | devpriv->pci_dev = pcidev; | ||
| 120 | break; | ||
| 121 | } | ||
| 122 | } | ||
| 123 | if (pcidev == NULL) { | ||
| 124 | printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", | ||
| 125 | dev->minor, bus, slot); | ||
| 126 | return -EIO; | ||
| 127 | } | ||
| 128 | if (comedi_pci_enable(pcidev, "adl_pci7230") < 0) { | ||
| 129 | printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n", | ||
| 130 | dev->minor); | ||
| 131 | return -EIO; | ||
| 132 | } | ||
| 133 | dev->iobase = pci_resource_start(pcidev, 2); | ||
| 134 | printk(KERN_DEBUG "comedi: base addr %4lx\n", dev->iobase); | ||
| 135 | |||
| 136 | s = dev->subdevices + 0; | ||
| 137 | /* Isolated do */ | ||
| 138 | s->type = COMEDI_SUBD_DO; | ||
| 139 | s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; | ||
| 140 | s->n_chan = 16; | ||
| 141 | s->maxdata = 1; | ||
| 142 | s->range_table = &range_digital; | ||
| 143 | s->insn_bits = adl_pci7230_do_insn_bits; | ||
| 144 | |||
| 145 | s = dev->subdevices + 1; | ||
| 146 | /* Isolated di */ | ||
| 147 | s->type = COMEDI_SUBD_DI; | ||
| 148 | s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; | ||
| 149 | s->n_chan = 16; | ||
| 150 | s->maxdata = 1; | ||
| 151 | s->range_table = &range_digital; | ||
| 152 | s->insn_bits = adl_pci7230_di_insn_bits; | ||
| 153 | |||
| 154 | printk(KERN_DEBUG "comedi: attached\n"); | ||
| 155 | |||
| 156 | return 1; | ||
| 157 | } | ||
| 158 | |||
| 159 | static int adl_pci7230_detach(struct comedi_device *dev) | ||
| 160 | { | ||
| 161 | printk(KERN_DEBUG "comedi%d: pci7230: remove\n", dev->minor); | ||
| 162 | |||
| 163 | if (devpriv && devpriv->pci_dev) { | ||
| 164 | if (dev->iobase) | ||
| 165 | comedi_pci_disable(devpriv->pci_dev); | ||
| 166 | pci_dev_put(devpriv->pci_dev); | ||
| 167 | } | ||
| 168 | |||
| 169 | return 0; | ||
| 170 | } | ||
| 171 | |||
| 172 | static int adl_pci7230_do_insn_bits(struct comedi_device *dev, | ||
| 173 | struct comedi_subdevice *s, | ||
| 174 | struct comedi_insn *insn, | ||
| 175 | unsigned int *data) | ||
| 176 | { | ||
| 177 | if (insn->n != 2) | ||
| 178 | return -EINVAL; | ||
| 179 | |||
| 180 | if (data[0]) { | ||
| 181 | s->state &= ~data[0]; | ||
| 182 | s->state |= (data[0] & data[1]); | ||
| 183 | |||
| 184 | outl((s->state << 16) & 0xffffffff, dev->iobase + PCI7230_DO); | ||
| 185 | } | ||
| 186 | |||
| 187 | return 2; | ||
| 188 | } | ||
| 189 | |||
| 190 | static int adl_pci7230_di_insn_bits(struct comedi_device *dev, | ||
| 191 | struct comedi_subdevice *s, | ||
| 192 | struct comedi_insn *insn, | ||
| 193 | unsigned int *data) | ||
| 194 | { | ||
| 195 | if (insn->n != 2) | ||
| 196 | return -EINVAL; | ||
| 197 | |||
| 198 | data[1] = inl(dev->iobase + PCI7230_DI) & 0xffffffff; | ||
| 199 | |||
| 200 | return 2; | ||
| 201 | } | ||
| 202 | |||
| 203 | static int __devinit driver_adl_pci7230_pci_probe(struct pci_dev *dev, | ||
| 204 | const struct pci_device_id | ||
| 205 | *ent) | ||
| 206 | { | ||
| 207 | return comedi_pci_auto_config(dev, driver_adl_pci7230.driver_name); | ||
| 208 | } | ||
| 209 | |||
| 210 | static void __devexit driver_adl_pci7230_pci_remove(struct pci_dev *dev) | ||
| 211 | { | ||
| 212 | comedi_pci_auto_unconfig(dev); | ||
| 213 | } | ||
| 214 | |||
| 215 | static struct pci_driver driver_adl_pci7230_pci_driver = { | ||
| 216 | .id_table = adl_pci7230_pci_table, | ||
| 217 | .probe = &driver_adl_pci7230_pci_probe, | ||
| 218 | .remove = __devexit_p(&driver_adl_pci7230_pci_remove) | ||
| 219 | }; | ||
| 220 | |||
| 221 | static int __init driver_adl_pci7230_init_module(void) | ||
| 222 | { | ||
| 223 | int retval; | ||
| 224 | |||
| 225 | retval = comedi_driver_register(&driver_adl_pci7230); | ||
| 226 | if (retval < 0) | ||
| 227 | return retval; | ||
| 228 | |||
| 229 | driver_adl_pci7230_pci_driver.name = | ||
| 230 | (char *)driver_adl_pci7230.driver_name; | ||
| 231 | return pci_register_driver(&driver_adl_pci7230_pci_driver); | ||
| 232 | } | ||
| 233 | |||
| 234 | static void __exit driver_adl_pci7230_cleanup_module(void) | ||
| 235 | { | ||
| 236 | pci_unregister_driver(&driver_adl_pci7230_pci_driver); | ||
| 237 | comedi_driver_unregister(&driver_adl_pci7230); | ||
| 238 | } | ||
| 239 | |||
| 240 | module_init(driver_adl_pci7230_init_module); | ||
| 241 | module_exit(driver_adl_pci7230_cleanup_module); | ||
| 242 | |||
| 243 | MODULE_AUTHOR("Comedi http://www.comedi.org"); | ||
| 244 | MODULE_DESCRIPTION("Comedi low-level driver"); | ||
| 245 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/comedi/drivers/adl_pci7296.c b/drivers/staging/comedi/drivers/adl_pci7296.c new file mode 100644 index 00000000000..f28fe6bec05 --- /dev/null +++ b/drivers/staging/comedi/drivers/adl_pci7296.c | |||
| @@ -0,0 +1,219 @@ | |||
| 1 | /* | ||
| 2 | comedi/drivers/adl_pci7296.c | ||
| 3 | |||
| 4 | COMEDI - Linux Control and Measurement Device Interface | ||
| 5 | Copyright (C) 2000 David A. Schleef <ds@schleef.org> | ||
| 6 | |||
| 7 | This program is free software; you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation; either version 2 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | This program is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with this program; if not, write to the Free Software | ||
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | |||
| 21 | */ | ||
| 22 | /* | ||
| 23 | Driver: adl_pci7296 | ||
| 24 | Description: Driver for the Adlink PCI-7296 96 ch. digital io board | ||
| 25 | Devices: [ADLink] PCI-7296 (adl_pci7296) | ||
| 26 | Author: Jon Grierson <jd@renko.co.uk> | ||
| 27 | Updated: Mon, 14 Apr 2008 15:05:56 +0100 | ||
| 28 | Status: testing | ||
| 29 | |||
| 30 | Configuration Options: | ||
| 31 | [0] - PCI bus of device (optional) | ||
| 32 | [1] - PCI slot of device (optional) | ||
| 33 | If bus/slot is not specified, the first supported | ||
| 34 | PCI device found will be used. | ||
| 35 | */ | ||
| 36 | |||
| 37 | #include "../comedidev.h" | ||
| 38 | #include <linux/kernel.h> | ||
| 39 | |||
| 40 | #include "comedi_pci.h" | ||
| 41 | #include "8255.h" | ||
| 42 | /* #include "8253.h" */ | ||
| 43 | |||
| 44 | #define PORT1A 0 | ||
| 45 | #define PORT2A 4 | ||
| 46 | #define PORT3A 8 | ||
| 47 | #define PORT4A 12 | ||
| 48 | |||
| 49 | #define PCI_DEVICE_ID_PCI7296 0x7296 | ||
| 50 | |||
| 51 | static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = { | ||
| 52 | { | ||
| 53 | PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID, | ||
| 54 | PCI_ANY_ID, 0, 0, 0}, { | ||
| 55 | 0} | ||
| 56 | }; | ||
| 57 | |||
| 58 | MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table); | ||
| 59 | |||
| 60 | struct adl_pci7296_private { | ||
| 61 | int data; | ||
| 62 | struct pci_dev *pci_dev; | ||
| 63 | }; | ||
| 64 | |||
| 65 | #define devpriv ((struct adl_pci7296_private *)dev->private) | ||
| 66 | |||
| 67 | static int adl_pci7296_attach(struct comedi_device *dev, | ||
| 68 | struct comedi_devconfig *it); | ||
| 69 | static int adl_pci7296_detach(struct comedi_device *dev); | ||
| 70 | static struct comedi_driver driver_adl_pci7296 = { | ||
| 71 | .driver_name = "adl_pci7296", | ||
| 72 | .module = THIS_MODULE, | ||
| 73 | .attach = adl_pci7296_attach, | ||
| 74 | .detach = adl_pci7296_detach, | ||
| 75 | }; | ||
| 76 | |||
| 77 | static int adl_pci7296_attach(struct comedi_device *dev, | ||
| 78 | struct comedi_devconfig *it) | ||
| 79 | { | ||
| 80 | struct pci_dev *pcidev = NULL; | ||
| 81 | struct comedi_subdevice *s; | ||
| 82 | int bus, slot; | ||
| 83 | int ret; | ||
| 84 | |||
| 85 | printk(KERN_INFO "comedi%d: attach adl_pci7432\n", dev->minor); | ||
| 86 | |||
| 87 | dev->board_name = "pci7432"; | ||
| 88 | bus = it->options[0]; | ||
| 89 | slot = it->options[1]; | ||
| 90 | |||
| 91 | if (alloc_private(dev, sizeof(struct adl_pci7296_private)) < 0) | ||
| 92 | return -ENOMEM; | ||
| 93 | |||
| 94 | if (alloc_subdevices(dev, 4) < 0) | ||
| 95 | return -ENOMEM; | ||
| 96 | |||
| 97 | for_each_pci_dev(pcidev) { | ||
| 98 | if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && | ||
| 99 | pcidev->device == PCI_DEVICE_ID_PCI7296) { | ||
| 100 | if (bus || slot) { | ||
| 101 | /* requested particular bus/slot */ | ||
| 102 | if (pcidev->bus->number != bus | ||
| 103 | || PCI_SLOT(pcidev->devfn) != slot) { | ||
| 104 | continue; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | devpriv->pci_dev = pcidev; | ||
| 108 | if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) { | ||
| 109 | printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n", | ||
| 110 | dev->minor); | ||
| 111 | return -EIO; | ||
| 112 | } | ||
| 113 | |||
| 114 | dev->iobase = pci_resource_start(pcidev, 2); | ||
| 115 | printk(KERN_INFO "comedi: base addr %4lx\n", | ||
| 116 | dev->iobase); | ||
| 117 | |||
| 118 | /* four 8255 digital io subdevices */ | ||
| 119 | s = dev->subdevices + 0; | ||
| 120 | subdev_8255_init(dev, s, NULL, | ||
| 121 | (unsigned long)(dev->iobase)); | ||
| 122 | |||
| 123 | s = dev->subdevices + 1; | ||
| 124 | ret = subdev_8255_init(dev, s, NULL, | ||
| 125 | (unsigned long)(dev->iobase + | ||
| 126 | PORT2A)); | ||
| 127 | if (ret < 0) | ||
| 128 | return ret; | ||
| 129 | |||
| 130 | s = dev->subdevices + 2; | ||
| 131 | ret = subdev_8255_init(dev, s, NULL, | ||
| 132 | (unsigned long)(dev->iobase + | ||
| 133 | PORT3A)); | ||
| 134 | if (ret < 0) | ||
| 135 | return ret; | ||
| 136 | |||
| 137 | s = dev->subdevices + 3; | ||
| 138 | ret = subdev_8255_init(dev, s, NULL, | ||
| 139 | (unsigned long)(dev->iobase + | ||
| 140 | PORT4A)); | ||
| 141 | if (ret < 0) | ||
| 142 | return ret; | ||
| 143 | |||
| 144 | printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n", | ||
| 145 | dev->minor); | ||
| 146 | |||
| 147 | return 1; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", | ||
| 152 | dev->minor, bus, slot); | ||
| 153 | return -EIO; | ||
| 154 | } | ||
| 155 | |||
| 156 | static int adl_pci7296_detach(struct comedi_device *dev) | ||
| 157 | { | ||
| 158 | printk(KERN_INFO "comedi%d: pci7432: remove\n", dev->minor); | ||
| 159 | |||
| 160 | if (devpriv && devpriv->pci_dev) { | ||
| 161 | if (dev->iobase) | ||
| 162 | comedi_pci_disable(devpriv->pci_dev); | ||
| 163 | pci_dev_put(devpriv->pci_dev); | ||
| 164 | } | ||
| 165 | /* detach four 8255 digital io subdevices */ | ||
| 166 | if (dev->subdevices) { | ||
| 167 | subdev_8255_cleanup(dev, dev->subdevices + 0); | ||
| 168 | subdev_8255_cleanup(dev, dev->subdevices + 1); | ||
| 169 | subdev_8255_cleanup(dev, dev->subdevices + 2); | ||
| 170 | subdev_8255_cleanup(dev, dev->subdevices + 3); | ||
| 171 | |||
| 172 | } | ||
| 173 | |||
| 174 | return 0; | ||
| 175 | } | ||
| 176 | |||
| 177 | static int __devinit driver_adl_pci7296_pci_probe(struct pci_dev *dev, | ||
| 178 | const struct pci_device_id | ||
| 179 | *ent) | ||
| 180 | { | ||
| 181 | return comedi_pci_auto_config(dev, driver_adl_pci7296.driver_name); | ||
| 182 | } | ||
| 183 | |||
| 184 | static void __devexit driver_adl_pci7296_pci_remove(struct pci_dev *dev) | ||
| 185 | { | ||
| 186 | comedi_pci_auto_unconfig(dev); | ||
| 187 | } | ||
| 188 | |||
| 189 | static struct pci_driver driver_adl_pci7296_pci_driver = { | ||
| 190 | .id_table = adl_pci7296_pci_table, | ||
| 191 | .probe = &driver_adl_pci7296_pci_probe, | ||
| 192 | .remove = __devexit_p(&driver_adl_pci7296_pci_remove) | ||
| 193 | }; | ||
| 194 | |||
| 195 | static int __init driver_adl_pci7296_init_module(void) | ||
| 196 | { | ||
| 197 | int retval; | ||
| 198 | |||
| 199 | retval = comedi_driver_register(&driver_adl_pci7296); | ||
| 200 | if (retval < 0) | ||
| 201 | return retval; | ||
| 202 | |||
| 203 | driver_adl_pci7296_pci_driver.name = | ||
| 204 | (char *)driver_adl_pci7296.driver_name; | ||
| 205 | return pci_register_driver(&driver_adl_pci7296_pci_driver); | ||
| 206 | } | ||
| 207 | |||
| 208 | static void __exit driver_adl_pci7296_cleanup_module(void) | ||
| 209 | { | ||
| 210 | pci_unregister_driver(&driver_adl_pci7296_pci_driver); | ||
| 211 | comedi_driver_unregister(&driver_adl_pci7296); | ||
| 212 | } | ||
| 213 | |||
| 214 | module_init(driver_adl_pci7296_init_module); | ||
| 215 | module_exit(driver_adl_pci7296_cleanup_module); | ||
| 216 | |||
| 217 | MODULE_AUTHOR("Comedi http://www.comedi.org"); | ||
| 218 | MODULE_DESCRIPTION("Comedi low-level driver"); | ||
| 219 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/comedi/drivers/adl_pci7432.c b/drivers/staging/comedi/drivers/adl_pci7432.c new file mode 100644 index 00000000000..262da7b29b2 --- /dev/null +++ b/drivers/staging/comedi/drivers/adl_pci7432.c | |||
| @@ -0,0 +1,252 @@ | |||
| 1 | /* | ||
| 2 | comedi/drivers/adl_pci7432.c | ||
| 3 | |||
| 4 | Hardware comedi driver fot PCI7432 Adlink card | ||
| 5 | Copyright (C) 2004 Michel Lachine <mike@mikelachaine.ca> | ||
| 6 | |||
| 7 | This program is free software; you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation; either version 2 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | This program is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with this program; if not, write to the Free Software | ||
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | |||
| 21 | */ | ||
| 22 | /* | ||
| 23 | Driver: adl_pci7432 | ||
| 24 | Description: Driver for the Adlink PCI-7432 64 ch. isolated digital io board | ||
| 25 | Devices: [ADLink] PCI-7432 (adl_pci7432) | ||
| 26 | Author: Michel Lachaine <mike@mikelachaine.ca> | ||
| 27 | Status: experimental | ||
| 28 | Updated: Mon, 14 Apr 2008 15:08:14 +0100 | ||
| 29 | |||
| 30 | Configuration Options: | ||
| 31 | [0] - PCI bus of device (optional) | ||
| 32 | [1] - PCI slot of device (optional) | ||
| 33 | If bus/slot is not specified, the first supported | ||
| 34 | PCI device found will be used. | ||
| 35 | */ | ||
| 36 | |||
| 37 | #include "../comedidev.h" | ||
| 38 | #include <linux/kernel.h> | ||
| 39 | #include "comedi_pci.h" | ||
| 40 | |||
| 41 | #define PCI7432_DI 0x00 | ||
| 42 | #define PCI7432_DO 0x00 | ||
| 43 | |||
| 44 | #define PCI_DEVICE_ID_PCI7432 0x7432 | ||
| 45 | |||
| 46 | static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = { | ||
| 47 | { | ||
| 48 | PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID, | ||
| 49 | PCI_ANY_ID, 0, 0, 0}, { | ||
| 50 | 0} | ||
| 51 | }; | ||
| 52 | |||
| 53 | MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table); | ||
| 54 | |||
| 55 | struct adl_pci7432_private { | ||
| 56 | int data; | ||
| 57 | struct pci_dev *pci_dev; | ||
| 58 | }; | ||
| 59 | |||
| 60 | #define devpriv ((struct adl_pci7432_private *)dev->private) | ||
| 61 | |||
| 62 | static int adl_pci7432_attach(struct comedi_device *dev, | ||
| 63 | struct comedi_devconfig *it); | ||
| 64 | static int adl_pci7432_detach(struct comedi_device *dev); | ||
| 65 | static struct comedi_driver driver_adl_pci7432 = { | ||
| 66 | .driver_name = "adl_pci7432", | ||
| 67 | .module = THIS_MODULE, | ||
| 68 | .attach = adl_pci7432_attach, | ||
| 69 | .detach = adl_pci7432_detach, | ||
| 70 | }; | ||
| 71 | |||
| 72 | /* Digital IO */ | ||
| 73 | |||
| 74 | static int adl_pci7432_di_insn_bits(struct comedi_device *dev, | ||
| 75 | struct comedi_subdevice *s, | ||
| 76 | struct comedi_insn *insn, | ||
| 77 | unsigned int *data); | ||
| 78 | |||
| 79 | static int adl_pci7432_do_insn_bits(struct comedi_device *dev, | ||
| 80 | struct comedi_subdevice *s, | ||
| 81 | struct comedi_insn *insn, | ||
| 82 | unsigned int *data); | ||
| 83 | |||
| 84 | /* */ | ||
| 85 | |||
| 86 | static int adl_pci7432_attach(struct comedi_device *dev, | ||
| 87 | struct comedi_devconfig *it) | ||
| 88 | { | ||
| 89 | struct pci_dev *pcidev = NULL; | ||
| 90 | struct comedi_subdevice *s; | ||
| 91 | int bus, slot; | ||
| 92 | |||
| 93 | printk(KERN_INFO "comedi%d: attach adl_pci7432\n", dev->minor); | ||
| 94 | |||
| 95 | dev->board_name = "pci7432"; | ||
| 96 | bus = it->options[0]; | ||
| 97 | slot = it->options[1]; | ||
| 98 | |||
| 99 | if (alloc_private(dev, sizeof(struct adl_pci7432_private)) < 0) | ||
| 100 | return -ENOMEM; | ||
| 101 | |||
| 102 | if (alloc_subdevices(dev, 2) < 0) | ||
| 103 | return -ENOMEM; | ||
| 104 | |||
| 105 | for_each_pci_dev(pcidev) { | ||
| 106 | if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && | ||
| 107 | pcidev->device == PCI_DEVICE_ID_PCI7432) { | ||
| 108 | if (bus || slot) { | ||
| 109 | /* requested particular bus/slot */ | ||
| 110 | if (pcidev->bus->number != bus | ||
| 111 | || PCI_SLOT(pcidev->devfn) != slot) { | ||
| 112 | continue; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | devpriv->pci_dev = pcidev; | ||
| 116 | if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) { | ||
| 117 | printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n", | ||
| 118 | dev->minor); | ||
| 119 | return -EIO; | ||
| 120 | } | ||
| 121 | dev->iobase = pci_resource_start(pcidev, 2); | ||
| 122 | printk(KERN_INFO "comedi: base addr %4lx\n", | ||
| 123 | dev->iobase); | ||
| 124 | |||
| 125 | s = dev->subdevices + 0; | ||
| 126 | s->type = COMEDI_SUBD_DI; | ||
| 127 | s->subdev_flags = | ||
| 128 | SDF_READABLE | SDF_GROUND | SDF_COMMON; | ||
| 129 | s->n_chan = 32; | ||
| 130 | s->maxdata = 1; | ||
| 131 | s->len_chanlist = 32; | ||
| 132 | s->io_bits = 0x00000000; | ||
| 133 | s->range_table = &range_digital; | ||
| 134 | s->insn_bits = adl_pci7432_di_insn_bits; | ||
| 135 | |||
| 136 | s = dev->subdevices + 1; | ||
| 137 | s->type = COMEDI_SUBD_DO; | ||
| 138 | s->subdev_flags = | ||
| 139 | SDF_WRITABLE | SDF_GROUND | SDF_COMMON; | ||
| 140 | s->n_chan = 32; | ||
| 141 | s->maxdata = 1; | ||
| 142 | s->len_chanlist = 32; | ||
| 143 | s->io_bits = 0xffffffff; | ||
| 144 | s->range_table = &range_digital; | ||
| 145 | s->insn_bits = adl_pci7432_do_insn_bits; | ||
| 146 | |||
| 147 | printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n", | ||
| 148 | dev->minor); | ||
| 149 | return 1; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", | ||
| 154 | dev->minor, bus, slot); | ||
| 155 | return -EIO; | ||
| 156 | } | ||
| 157 | |||
| 158 | static int adl_pci7432_detach(struct comedi_device *dev) | ||
| 159 | { | ||
| 160 | printk(KERN_INFO "comedi%d: pci7432: remove\n", dev->minor); | ||
| 161 | |||
| 162 | if (devpriv && devpriv->pci_dev) { | ||
| 163 | if (dev->iobase) | ||
| 164 | comedi_pci_disable(devpriv->pci_dev); | ||
| 165 | pci_dev_put(devpriv->pci_dev); | ||
| 166 | } | ||
| 167 | |||
| 168 | return 0; | ||
| 169 | } | ||
| 170 | |||
| 171 | static int adl_pci7432_do_insn_bits(struct comedi_device *dev, | ||
| 172 | struct comedi_subdevice *s, | ||
| 173 | struct comedi_insn *insn, | ||
| 174 | unsigned int *data) | ||
| 175 | { | ||
| 176 | printk(KERN_DEBUG "comedi: pci7432_do_insn_bits called\n"); | ||
| 177 | printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]); | ||
| 178 | |||
| 179 | if (insn->n != 2) | ||
| 180 | return -EINVAL; | ||
| 181 | |||
| 182 | if (data[0]) { | ||
| 183 | s->state &= ~data[0]; | ||
| 184 | s->state |= (data[0] & data[1]); | ||
| 185 | |||
| 186 | printk(KERN_DEBUG "comedi: out: %8x on iobase %4lx\n", s->state, | ||
| 187 | dev->iobase + PCI7432_DO); | ||
| 188 | outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO); | ||
| 189 | } | ||
| 190 | return 2; | ||
| 191 | } | ||
| 192 | |||
| 193 | static int adl_pci7432_di_insn_bits(struct comedi_device *dev, | ||
| 194 | struct comedi_subdevice *s, | ||
| 195 | struct comedi_insn *insn, | ||
| 196 | unsigned int *data) | ||
| 197 | { | ||
| 198 | printk(KERN_DEBUG "comedi: pci7432_di_insn_bits called\n"); | ||
| 199 | printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]); | ||
| 200 | |||
| 201 | if (insn->n != 2) | ||
| 202 | return -EINVAL; | ||
| 203 | |||
| 204 | data[1] = inl(dev->iobase + PCI7432_DI) & 0xffffffff; | ||
| 205 | printk(KERN_DEBUG "comedi: data1 %8x\n", data[1]); | ||
| 206 | |||
| 207 | return 2; | ||
| 208 | } | ||
| 209 | |||
| 210 | static int __devinit driver_adl_pci7432_pci_probe(struct pci_dev *dev, | ||
| 211 | const struct pci_device_id | ||
| 212 | *ent) | ||
| 213 | { | ||
| 214 | return comedi_pci_auto_config(dev, driver_adl_pci7432.driver_name); | ||
| 215 | } | ||
| 216 | |||
| 217 | static void __devexit driver_adl_pci7432_pci_remove(struct pci_dev *dev) | ||
| 218 | { | ||
| 219 | comedi_pci_auto_unconfig(dev); | ||
| 220 | } | ||
| 221 | |||
| 222 | static struct pci_driver driver_adl_pci7432_pci_driver = { | ||
| 223 | .id_table = adl_pci7432_pci_table, | ||
| 224 | .probe = &driver_adl_pci7432_pci_probe, | ||
| 225 | .remove = __devexit_p(&driver_adl_pci7432_pci_remove) | ||
| 226 | }; | ||
| 227 | |||
| 228 | static int __init driver_adl_pci7432_init_module(void) | ||
| 229 | { | ||
| 230 | int retval; | ||
| 231 | |||
| 232 | retval = comedi_driver_register(&driver_adl_pci7432); | ||
| 233 | if (retval < 0) | ||
| 234 | return retval; | ||
| 235 | |||
| 236 | driver_adl_pci7432_pci_driver.name = | ||
| 237 | (char *)driver_adl_pci7432.driver_name; | ||
| 238 | return pci_register_driver(&driver_adl_pci7432_pci_driver); | ||
| 239 | } | ||
| 240 | |||
| 241 | static void __exit driver_adl_pci7432_cleanup_module(void) | ||
| 242 | { | ||
| 243 | pci_unregister_driver(&driver_adl_pci7432_pci_driver); | ||
| 244 | comedi_driver_unregister(&driver_adl_pci7432); | ||
| 245 | } | ||
| 246 | |||
| 247 | module_init(driver_adl_pci7432_init_module); | ||
| 248 | module_exit(driver_adl_pci7432_cleanup_module); | ||
| 249 | |||
| 250 | MODULE_AUTHOR("Comedi http://www.comedi.org"); | ||
| 251 | MODULE_DESCRIPTION("Comedi low-level driver"); | ||
| 252 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c new file mode 100644 index 00000000000..79477a595ef --- /dev/null +++ b/drivers/staging/comedi/drivers/cb_pcidio.c | |||
| @@ -0,0 +1,340 @@ | |||
| 1 | /* | ||
| 2 | comedi/drivers/cb_pcidio.c | ||
| 3 | A Comedi driver for PCI-DIO24H & PCI-DIO48H of ComputerBoards (currently MeasurementComputing) | ||
| 4 | |||
| 5 | COMEDI - Linux Control and Measurement Device Interface | ||
| 6 | Copyright (C) 2000 David A. Schleef <ds@schleef.org> | ||
| 7 | |||
| 8 | This program is free software; you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation; either version 2 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with this program; if not, write to the Free Software | ||
| 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 21 | |||
| 22 | */ | ||
| 23 | /* | ||
| 24 | Driver: cb_pcidio | ||
| 25 | Description: ComputerBoards' DIO boards with PCI interface | ||
| 26 | Devices: [Measurement Computing] PCI-DIO24 (cb_pcidio), PCI-DIO24H, PCI-DIO48H | ||
| 27 | Author: Yoshiya Matsuzaka | ||
| 28 | Updated: Mon, 29 Oct 2007 15:40:47 +0000 | ||
| 29 | Status: experimental | ||
| 30 | |||
| 31 | This driver has been modified from skel.c of comedi-0.7.70. | ||
| 32 | |||
| 33 | Configuration Options: | ||
| 34 | [0] - PCI bus of device (optional) | ||
| 35 | [1] - PCI slot of device (optional) | ||
| 36 | If bus/slot is not specified, the first available PCI device will | ||
| 37 | be used. | ||
| 38 | |||
| 39 | Passing a zero for an option is the same as leaving it unspecified. | ||
| 40 | */ | ||
| 41 | |||
| 42 | /*------------------------------ HEADER FILES ---------------------------------*/ | ||
| 43 | #include "../comedidev.h" | ||
| 44 | #include "comedi_pci.h" | ||
| 45 | #include "8255.h" | ||
| 46 | |||
| 47 | /*-------------------------- MACROS and DATATYPES -----------------------------*/ | ||
| 48 | #define PCI_VENDOR_ID_CB 0x1307 | ||
| 49 | |||
| 50 | /* | ||
| 51 | * Board descriptions for two imaginary boards. Describing the | ||
| 52 | * boards in this way is optional, and completely driver-dependent. | ||
| 53 | * Some drivers use arrays such as this, other do not. | ||
| 54 | */ | ||
| 55 | struct pcidio_board { | ||
| 56 | const char *name; /* name of the board */ | ||
| 57 | int dev_id; | ||
| 58 | int n_8255; /* number of 8255 chips on board */ | ||
| 59 | |||
| 60 | /* indices of base address regions */ | ||
| 61 | int pcicontroler_badrindex; | ||
| 62 | int dioregs_badrindex; | ||
| 63 | }; | ||
| 64 | |||
| 65 | static const struct pcidio_board pcidio_boards[] = { | ||
| 66 | { | ||
| 67 | .name = "pci-dio24", | ||
| 68 | .dev_id = 0x0028, | ||
| 69 | .n_8255 = 1, | ||
| 70 | .pcicontroler_badrindex = 1, | ||
| 71 | .dioregs_badrindex = 2, | ||
| 72 | }, | ||
| 73 | { | ||
| 74 | .name = "pci-dio24h", | ||
| 75 | .dev_id = 0x0014, | ||
| 76 | .n_8255 = 1, | ||
| 77 | .pcicontroler_badrindex = 1, | ||
| 78 | .dioregs_badrindex = 2, | ||
| 79 | }, | ||
| 80 | { | ||
| 81 | .name = "pci-dio48h", | ||
| 82 | .dev_id = 0x000b, | ||
| 83 | .n_8255 = 2, | ||
| 84 | .pcicontroler_badrindex = 0, | ||
| 85 | .dioregs_badrindex = 1, | ||
| 86 | }, | ||
| 87 | }; | ||
| 88 | |||
| 89 | /* This is used by modprobe to translate PCI IDs to drivers. Should | ||
| 90 | * only be used for PCI and ISA-PnP devices */ | ||
| 91 | /* Please add your PCI vendor ID to comedidev.h, and it will be forwarded | ||
| 92 | * upstream. */ | ||
| 93 | static DEFINE_PCI_DEVICE_TABLE(pcidio_pci_table) = { | ||
| 94 | { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0028) }, | ||
| 95 | { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0014) }, | ||
| 96 | { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000b) }, | ||
| 97 | { 0 } | ||
| 98 | }; | ||
| 99 | |||
| 100 | MODULE_DEVICE_TABLE(pci, pcidio_pci_table); | ||
| 101 | |||
| 102 | /* | ||
| 103 | * Useful for shorthand access to the particular board structure | ||
| 104 | */ | ||
| 105 | #define thisboard ((const struct pcidio_board *)dev->board_ptr) | ||
| 106 | |||
| 107 | /* this structure is for data unique to this hardware driver. If | ||
| 108 | several hardware drivers keep similar information in this structure, | ||
| 109 | feel free to suggest moving the variable to the struct comedi_device struct. */ | ||
| 110 | struct pcidio_private { | ||
| 111 | int data; /* currently unused */ | ||
| 112 | |||
| 113 | /* would be useful for a PCI device */ | ||
| 114 | struct pci_dev *pci_dev; | ||
| 115 | |||
| 116 | /* used for DO readback, currently unused */ | ||
| 117 | unsigned int do_readback[4]; /* up to 4 unsigned int suffice to hold 96 bits for PCI-DIO96 */ | ||
| 118 | |||
| 119 | unsigned long dio_reg_base; /* address of port A of the first 8255 chip on board */ | ||
| 120 | }; | ||
| 121 | |||
| 122 | /* | ||
| 123 | * most drivers define the following macro to make it easy to | ||
| 124 | * access the private structure. | ||
| 125 | */ | ||
| 126 | #define devpriv ((struct pcidio_private *)dev->private) | ||
| 127 | |||
| 128 | /* | ||
| 129 | * The struct comedi_driver structure tells the Comedi core module | ||
| 130 | * which functions to call to configure/deconfigure (attach/detach) | ||
| 131 | * the board, and also about the kernel module that contains | ||
| 132 | * the device code. | ||
| 133 | */ | ||
| 134 | static int pcidio_attach(struct comedi_device *dev, | ||
| 135 | struct comedi_devconfig *it); | ||
| 136 | static int pcidio_detach(struct comedi_device *dev); | ||
| 137 | static struct comedi_driver driver_cb_pcidio = { | ||
| 138 | .driver_name = "cb_pcidio", | ||
| 139 | .module = THIS_MODULE, | ||
| 140 | .attach = pcidio_attach, | ||
| 141 | .detach = pcidio_detach, | ||
| 142 | |||
| 143 | /* It is not necessary to implement the following members if you are | ||
| 144 | * writing a driver for a ISA PnP or PCI card */ | ||
| 145 | |||
| 146 | /* Most drivers will support multiple types of boards by | ||
| 147 | * having an array of board structures. These were defined | ||
| 148 | * in pcidio_boards[] above. Note that the element 'name' | ||
| 149 | * was first in the structure -- Comedi uses this fact to | ||
| 150 | * extract the name of the board without knowing any details | ||
| 151 | * about the structure except for its length. | ||
| 152 | * When a device is attached (by comedi_config), the name | ||
| 153 | * of the device is given to Comedi, and Comedi tries to | ||
| 154 | * match it by going through the list of board names. If | ||
| 155 | * there is a match, the address of the pointer is put | ||
| 156 | * into dev->board_ptr and driver->attach() is called. | ||
| 157 | * | ||
| 158 | * Note that these are not necessary if you can determine | ||
| 159 | * the type of board in software. ISA PnP, PCI, and PCMCIA | ||
| 160 | * devices are such boards. | ||
| 161 | */ | ||
| 162 | |||
| 163 | /* The following fields should NOT be initialized if you are dealing | ||
| 164 | * with PCI devices | ||
| 165 | * | ||
| 166 | * .board_name = pcidio_boards, | ||
| 167 | * .offset = sizeof(struct pcidio_board), | ||
| 168 | * .num_names = sizeof(pcidio_boards) / sizeof(structpcidio_board), | ||
| 169 | */ | ||
| 170 | |||
| 171 | }; | ||
| 172 | |||
| 173 | /*------------------------------- FUNCTIONS -----------------------------------*/ | ||
| 174 | |||
| 175 | /* | ||
| 176 | * Attach is called by the Comedi core to configure the driver | ||
| 177 | * for a particular board. If you specified a board_name array | ||
| 178 | * in the driver structure, dev->board_ptr contains that | ||
| 179 | * address. | ||
| 180 | */ | ||
| 181 | static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it) | ||
| 182 | { | ||
| 183 | struct pci_dev *pcidev = NULL; | ||
| 184 | int index; | ||
| 185 | int i; | ||
| 186 | |||
| 187 | printk("comedi%d: cb_pcidio: \n", dev->minor); | ||
| 188 | |||
| 189 | /* | ||
| 190 | * Allocate the private structure area. alloc_private() is a | ||
| 191 | * convenient macro defined in comedidev.h. | ||
| 192 | */ | ||
| 193 | if (alloc_private(dev, sizeof(struct pcidio_private)) < 0) | ||
| 194 | return -ENOMEM; | ||
| 195 | /* | ||
| 196 | * If you can probe the device to determine what device in a series | ||
| 197 | * it is, this is the place to do it. Otherwise, dev->board_ptr | ||
| 198 | * should already be initialized. | ||
| 199 | */ | ||
| 200 | /* | ||
| 201 | * Probe the device to determine what device in the series it is. | ||
| 202 | */ | ||
| 203 | |||
| 204 | for_each_pci_dev(pcidev) { | ||
| 205 | /* is it not a computer boards card? */ | ||
| 206 | if (pcidev->vendor != PCI_VENDOR_ID_CB) | ||
| 207 | continue; | ||
| 208 | /* loop through cards supported by this driver */ | ||
| 209 | for (index = 0; index < ARRAY_SIZE(pcidio_boards); index++) { | ||
| 210 | if (pcidio_boards[index].dev_id != pcidev->device) | ||
| 211 | continue; | ||
| 212 | |||
| 213 | /* was a particular bus/slot requested? */ | ||
| 214 | if (it->options[0] || it->options[1]) { | ||
| 215 | /* are we on the wrong bus/slot? */ | ||
| 216 | if (pcidev->bus->number != it->options[0] || | ||
| 217 | PCI_SLOT(pcidev->devfn) != it->options[1]) { | ||
| 218 | continue; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | dev->board_ptr = pcidio_boards + index; | ||
| 222 | goto found; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | |||
| 226 | printk("No supported ComputerBoards/MeasurementComputing card found on " | ||
| 227 | "requested position\n"); | ||
| 228 | return -EIO; | ||
| 229 | |||
| 230 | found: | ||
| 231 | |||
| 232 | /* | ||
| 233 | * Initialize dev->board_name. Note that we can use the "thisboard" | ||
| 234 | * macro now, since we just initialized it in the last line. | ||
| 235 | */ | ||
| 236 | dev->board_name = thisboard->name; | ||
| 237 | |||
| 238 | devpriv->pci_dev = pcidev; | ||
| 239 | printk("Found %s on bus %i, slot %i\n", thisboard->name, | ||
| 240 | devpriv->pci_dev->bus->number, | ||
| 241 | PCI_SLOT(devpriv->pci_dev->devfn)); | ||
| 242 | if (comedi_pci_enable(pcidev, thisboard->name)) { | ||
| 243 | printk | ||
| 244 | ("cb_pcidio: failed to enable PCI device and request regions\n"); | ||
| 245 | return -EIO; | ||
| 246 | } | ||
| 247 | devpriv->dio_reg_base | ||
| 248 | = | ||
| 249 | pci_resource_start(devpriv->pci_dev, | ||
| 250 | pcidio_boards[index].dioregs_badrindex); | ||
| 251 | |||
| 252 | /* | ||
| 253 | * Allocate the subdevice structures. alloc_subdevice() is a | ||
| 254 | * convenient macro defined in comedidev.h. | ||
| 255 | */ | ||
| 256 | if (alloc_subdevices(dev, thisboard->n_8255) < 0) | ||
| 257 | return -ENOMEM; | ||
| 258 | |||
| 259 | for (i = 0; i < thisboard->n_8255; i++) { | ||
| 260 | subdev_8255_init(dev, dev->subdevices + i, | ||
| 261 | NULL, devpriv->dio_reg_base + i * 4); | ||
| 262 | printk(" subdev %d: base = 0x%lx\n", i, | ||
| 263 | devpriv->dio_reg_base + i * 4); | ||
| 264 | } | ||
| 265 | |||
| 266 | printk("attached\n"); | ||
| 267 | return 1; | ||
| 268 | } | ||
| 269 | |||
| 270 | /* | ||
| 271 | * _detach is called to deconfigure a device. It should deallocate | ||
| 272 | * resources. | ||
| 273 | * This function is also called when _attach() fails, so it should be | ||
| 274 | * careful not to release resources that were not necessarily | ||
| 275 | * allocated by _attach(). dev->private and dev->subdevices are | ||
| 276 | * deallocated automatically by the core. | ||
| 277 | */ | ||
| 278 | static int pcidio_detach(struct comedi_device *dev) | ||
| 279 | { | ||
| 280 | printk("comedi%d: cb_pcidio: remove\n", dev->minor); | ||
| 281 | if (devpriv) { | ||
| 282 | if (devpriv->pci_dev) { | ||
| 283 | if (devpriv->dio_reg_base) | ||
| 284 | comedi_pci_disable(devpriv->pci_dev); | ||
| 285 | pci_dev_put(devpriv->pci_dev); | ||
| 286 | } | ||
| 287 | } | ||
| 288 | if (dev->subdevices) { | ||
| 289 | int i; | ||
| 290 | for (i = 0; i < thisboard->n_8255; i++) | ||
| 291 | subdev_8255_cleanup(dev, dev->subdevices + i); | ||
| 292 | } | ||
| 293 | return 0; | ||
| 294 | } | ||
| 295 | |||
| 296 | /* | ||
| 297 | * A convenient macro that defines init_module() and cleanup_module(), | ||
| 298 | * as necessary. | ||
| 299 | */ | ||
| 300 | static int __devinit driver_cb_pcidio_pci_probe(struct pci_dev *dev, | ||
| 301 | const struct pci_device_id *ent) | ||
| 302 | { | ||
| 303 | return comedi_pci_auto_config(dev, driver_cb_pcidio.driver_name); | ||
| 304 | } | ||
| 305 | |||
| 306 | static void __devexit driver_cb_pcidio_pci_remove(struct pci_dev *dev) | ||
| 307 | { | ||
| 308 | comedi_pci_auto_unconfig(dev); | ||
| 309 | } | ||
| 310 | |||
| 311 | static struct pci_driver driver_cb_pcidio_pci_driver = { | ||
| 312 | .id_table = pcidio_pci_table, | ||
| 313 | .probe = &driver_cb_pcidio_pci_probe, | ||
| 314 | .remove = __devexit_p(&driver_cb_pcidio_pci_remove) | ||
| 315 | }; | ||
| 316 | |||
| 317 | static int __init driver_cb_pcidio_init_module(void) | ||
| 318 | { | ||
| 319 | int retval; | ||
| 320 | |||
| 321 | retval = comedi_driver_register(&driver_cb_pcidio); | ||
| 322 | if (retval < 0) | ||
| 323 | return retval; | ||
| 324 | |||
| 325 | driver_cb_pcidio_pci_driver.name = (char *)driver_cb_pcidio.driver_name; | ||
| 326 | return pci_register_driver(&driver_cb_pcidio_pci_driver); | ||
| 327 | } | ||
| 328 | |||
| 329 | static void __exit driver_cb_pcidio_cleanup_module(void) | ||
| 330 | { | ||
| 331 | pci_unregister_driver(&driver_cb_pcidio_pci_driver); | ||
| 332 | comedi_driver_unregister(&driver_cb_pcidio); | ||
| 333 | } | ||
| 334 | |||
| 335 | module_init(driver_cb_pcidio_init_module); | ||
| 336 | module_exit(driver_cb_pcidio_cleanup_module); | ||
| 337 | |||
| 338 | MODULE_AUTHOR("Comedi http://www.comedi.org"); | ||
| 339 | MODULE_DESCRIPTION("Comedi low-level driver"); | ||
| 340 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/comedi/drivers/comedi_pci.h b/drivers/staging/comedi/drivers/comedi_pci.h new file mode 100644 index 00000000000..c14a036a053 --- /dev/null +++ b/drivers/staging/comedi/drivers/comedi_pci.h | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | /* | ||
| 2 | comedi/drivers/comedi_pci.h | ||
| 3 | Various PCI functions for drivers. | ||
| 4 | |||
| 5 | Copyright (C) 2007 MEV Ltd. <http://www.mev.co.uk/> | ||
| 6 | |||
| 7 | COMEDI - Linux Control and Measurement Device Interface | ||
| 8 | Copyright (C) 2000 David A. Schleef <ds@schleef.org> | ||
| 9 | |||
| 10 | This program is free software; you can redistribute it and/or modify | ||
| 11 | it under the terms of the GNU General Public License as published by | ||
| 12 | the Free Software Foundation; either version 2 of the License, or | ||
| 13 | (at your option) any later version. | ||
| 14 | |||
| 15 | This program is distributed in the hope that it will be useful, | ||
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | GNU General Public License for more details. | ||
| 19 | |||
| 20 | You should have received a copy of the GNU General Public License | ||
| 21 | along with this program; if not, write to the Free Software | ||
| 22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 23 | |||
| 24 | */ | ||
| 25 | |||
| 26 | #ifndef _COMEDI_PCI_H_ | ||
| 27 | #define _COMEDI_PCI_H_ | ||
| 28 | |||
| 29 | #include <linux/pci.h> | ||
| 30 | |||
| 31 | /* | ||
| 32 | * Enable the PCI device and request the regions. | ||
| 33 | */ | ||
| 34 | static inline int comedi_pci_enable(struct pci_dev *pdev, const char *res_name) | ||
| 35 | { | ||
| 36 | int rc; | ||
| 37 | |||
| 38 | rc = pci_enable_device(pdev); | ||
| 39 | if (rc < 0) | ||
| 40 | return rc; | ||
| 41 | |||
| 42 | rc = pci_request_regions(pdev, res_name); | ||
| 43 | if (rc < 0) | ||
| 44 | pci_disable_device(pdev); | ||
| 45 | |||
| 46 | return rc; | ||
| 47 | } | ||
| 48 | |||
| 49 | /* | ||
| 50 | * Release the regions and disable the PCI device. | ||
| 51 | * | ||
| 52 | * This must be matched with a previous successful call to comedi_pci_enable(). | ||
| 53 | */ | ||
| 54 | static inline void comedi_pci_disable(struct pci_dev *pdev) | ||
| 55 | { | ||
| 56 | pci_release_regions(pdev); | ||
| 57 | pci_disable_device(pdev); | ||
| 58 | } | ||
| 59 | |||
| 60 | #endif | ||
diff --git a/drivers/staging/comedi/drivers/icp_multi.h b/drivers/staging/comedi/drivers/icp_multi.h new file mode 100644 index 00000000000..68acefe1688 --- /dev/null +++ b/drivers/staging/comedi/drivers/icp_multi.h | |||
| @@ -0,0 +1,298 @@ | |||
| 1 | /* | ||
| 2 | comedi/drivers/icp_multi.h | ||
| 3 | |||
| 4 | Stuff for ICP Multi | ||
| 5 | |||
| 6 | Author: Anne Smorthit <anne.smorthit@sfwte.ch> | ||
| 7 | |||
| 8 | */ | ||
| 9 | |||
| 10 | #ifndef _ICP_MULTI_H_ | ||
| 11 | #define _ICP_MULTI_H_ | ||
| 12 | |||
| 13 | #include "../comedidev.h" | ||
| 14 | #include "comedi_pci.h" | ||
| 15 | |||
| 16 | /****************************************************************************/ | ||
| 17 | |||
| 18 | struct pcilst_struct { | ||
| 19 | struct pcilst_struct *next; | ||
| 20 | int used; | ||
| 21 | struct pci_dev *pcidev; | ||
| 22 | unsigned short vendor; | ||
| 23 | unsigned short device; | ||
| 24 | unsigned char pci_bus; | ||
| 25 | unsigned char pci_slot; | ||
| 26 | unsigned char pci_func; | ||
| 27 | resource_size_t io_addr[5]; | ||
| 28 | unsigned int irq; | ||
| 29 | }; | ||
| 30 | |||
| 31 | struct pcilst_struct *inova_devices; | ||
| 32 | /* ptr to root list of all Inova devices */ | ||
| 33 | |||
| 34 | /****************************************************************************/ | ||
| 35 | |||
| 36 | static void pci_card_list_init(unsigned short pci_vendor, char display); | ||
| 37 | static void pci_card_list_cleanup(unsigned short pci_vendor); | ||
| 38 | static struct pcilst_struct *find_free_pci_card_by_device(unsigned short | ||
| 39 | vendor_id, | ||
| 40 | unsigned short | ||
| 41 | device_id); | ||
| 42 | static int find_free_pci_card_by_position(unsigned short vendor_id, | ||
| 43 | unsigned short device_id, | ||
| 44 | unsigned short pci_bus, | ||
| 45 | unsigned short pci_slot, | ||
| 46 | struct pcilst_struct **card); | ||
| 47 | static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id, | ||
| 48 | unsigned short device_id, | ||
| 49 | unsigned short pci_bus, | ||
| 50 | unsigned short pci_slot); | ||
| 51 | |||
| 52 | static int pci_card_alloc(struct pcilst_struct *amcc); | ||
| 53 | static int pci_card_free(struct pcilst_struct *amcc); | ||
| 54 | static void pci_card_list_display(void); | ||
| 55 | static int pci_card_data(struct pcilst_struct *amcc, | ||
| 56 | unsigned char *pci_bus, unsigned char *pci_slot, | ||
| 57 | unsigned char *pci_func, resource_size_t * io_addr, | ||
| 58 | unsigned int *irq); | ||
| 59 | |||
| 60 | /****************************************************************************/ | ||
| 61 | |||
| 62 | /* build list of Inova cards in this system */ | ||
| 63 | static void pci_card_list_init(unsigned short pci_vendor, char display) | ||
| 64 | { | ||
| 65 | struct pci_dev *pcidev = NULL; | ||
| 66 | struct pcilst_struct *inova, *last; | ||
| 67 | int i; | ||
| 68 | |||
| 69 | inova_devices = NULL; | ||
| 70 | last = NULL; | ||
| 71 | |||
| 72 | for_each_pci_dev(pcidev) { | ||
| 73 | if (pcidev->vendor == pci_vendor) { | ||
| 74 | inova = kzalloc(sizeof(*inova), GFP_KERNEL); | ||
| 75 | if (!inova) { | ||
| 76 | printk | ||
| 77 | ("icp_multi: pci_card_list_init: allocation failed\n"); | ||
| 78 | pci_dev_put(pcidev); | ||
| 79 | break; | ||
| 80 | } | ||
| 81 | |||
| 82 | inova->pcidev = pci_dev_get(pcidev); | ||
| 83 | if (last) { | ||
| 84 | last->next = inova; | ||
| 85 | } else { | ||
| 86 | inova_devices = inova; | ||
| 87 | } | ||
| 88 | last = inova; | ||
| 89 | |||
| 90 | inova->vendor = pcidev->vendor; | ||
| 91 | inova->device = pcidev->device; | ||
| 92 | inova->pci_bus = pcidev->bus->number; | ||
| 93 | inova->pci_slot = PCI_SLOT(pcidev->devfn); | ||
| 94 | inova->pci_func = PCI_FUNC(pcidev->devfn); | ||
| 95 | /* Note: resources may be invalid if PCI device | ||
| 96 | * not enabled, but they are corrected in | ||
| 97 | * pci_card_alloc. */ | ||
| 98 | for (i = 0; i < 5; i++) | ||
| 99 | inova->io_addr[i] = | ||
| 100 | pci_resource_start(pcidev, i); | ||
| 101 | inova->irq = pcidev->irq; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | if (display) | ||
| 106 | pci_card_list_display(); | ||
| 107 | } | ||
| 108 | |||
| 109 | /****************************************************************************/ | ||
| 110 | /* free up list of amcc cards in this system */ | ||
| 111 | static void pci_card_list_cleanup(unsigned short pci_vendor) | ||
| 112 | { | ||
| 113 | struct pcilst_struct *inova, *next; | ||
| 114 | |||
| 115 | for (inova = inova_devices; inova; inova = next) { | ||
| 116 | next = inova->next; | ||
| 117 | pci_dev_put(inova->pcidev); | ||
| 118 | kfree(inova); | ||
| 119 | } | ||
| 120 | |||
| 121 | inova_devices = NULL; | ||
| 122 | } | ||
| 123 | |||
| 124 | /****************************************************************************/ | ||
| 125 | /* find first unused card with this device_id */ | ||
| 126 | static struct pcilst_struct *find_free_pci_card_by_device(unsigned short | ||
| 127 | vendor_id, | ||
| 128 | unsigned short | ||
| 129 | device_id) | ||
| 130 | { | ||
| 131 | struct pcilst_struct *inova, *next; | ||
| 132 | |||
| 133 | for (inova = inova_devices; inova; inova = next) { | ||
| 134 | next = inova->next; | ||
| 135 | if ((!inova->used) && (inova->device == device_id) | ||
| 136 | && (inova->vendor == vendor_id)) | ||
| 137 | return inova; | ||
| 138 | |||
| 139 | } | ||
| 140 | |||
| 141 | return NULL; | ||
| 142 | } | ||
| 143 | |||
| 144 | /****************************************************************************/ | ||
| 145 | /* find card on requested position */ | ||
| 146 | static int find_free_pci_card_by_position(unsigned short vendor_id, | ||
| 147 | unsigned short device_id, | ||
| 148 | unsigned short pci_bus, | ||
| 149 | unsigned short pci_slot, | ||
| 150 | struct pcilst_struct **card) | ||
| 151 | { | ||
| 152 | struct pcilst_struct *inova, *next; | ||
| 153 | |||
| 154 | *card = NULL; | ||
| 155 | for (inova = inova_devices; inova; inova = next) { | ||
| 156 | next = inova->next; | ||
| 157 | if ((inova->vendor == vendor_id) && (inova->device == device_id) | ||
| 158 | && (inova->pci_bus == pci_bus) | ||
| 159 | && (inova->pci_slot == pci_slot)) { | ||
| 160 | if (!(inova->used)) { | ||
| 161 | *card = inova; | ||
| 162 | return 0; /* ok, card is found */ | ||
| 163 | } else { | ||
| 164 | return 2; /* card exist but is used */ | ||
| 165 | } | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | return 1; /* no card found */ | ||
| 170 | } | ||
| 171 | |||
| 172 | /****************************************************************************/ | ||
| 173 | /* mark card as used */ | ||
| 174 | static int pci_card_alloc(struct pcilst_struct *inova) | ||
| 175 | { | ||
| 176 | int i; | ||
| 177 | |||
| 178 | if (!inova) { | ||
| 179 | printk(" - BUG!! inova is NULL!\n"); | ||
| 180 | return -1; | ||
| 181 | } | ||
| 182 | |||
| 183 | if (inova->used) | ||
| 184 | return 1; | ||
| 185 | if (comedi_pci_enable(inova->pcidev, "icp_multi")) { | ||
| 186 | printk(" - Can't enable PCI device and request regions!\n"); | ||
| 187 | return -1; | ||
| 188 | } | ||
| 189 | /* Resources will be accurate now. */ | ||
| 190 | for (i = 0; i < 5; i++) | ||
| 191 | inova->io_addr[i] = pci_resource_start(inova->pcidev, i); | ||
| 192 | inova->irq = inova->pcidev->irq; | ||
| 193 | inova->used = 1; | ||
| 194 | return 0; | ||
| 195 | } | ||
| 196 | |||
| 197 | /****************************************************************************/ | ||
| 198 | /* mark card as free */ | ||
| 199 | static int pci_card_free(struct pcilst_struct *inova) | ||
| 200 | { | ||
| 201 | if (!inova) | ||
| 202 | return -1; | ||
| 203 | |||
| 204 | if (!inova->used) | ||
| 205 | return 1; | ||
| 206 | inova->used = 0; | ||
| 207 | comedi_pci_disable(inova->pcidev); | ||
| 208 | return 0; | ||
| 209 | } | ||
| 210 | |||
| 211 | /****************************************************************************/ | ||
| 212 | /* display list of found cards */ | ||
| 213 | static void pci_card_list_display(void) | ||
| 214 | { | ||
| 215 | struct pcilst_struct *inova, *next; | ||
| 216 | |||
| 217 | printk("Anne's List of pci cards\n"); | ||
| 218 | printk("bus:slot:func vendor device io_inova io_daq irq used\n"); | ||
| 219 | |||
| 220 | for (inova = inova_devices; inova; inova = next) { | ||
| 221 | next = inova->next; | ||
| 222 | printk | ||
| 223 | ("%2d %2d %2d 0x%4x 0x%4x 0x%8llx 0x%8llx %2u %2d\n", | ||
| 224 | inova->pci_bus, inova->pci_slot, inova->pci_func, | ||
| 225 | inova->vendor, inova->device, | ||
| 226 | (unsigned long long)inova->io_addr[0], | ||
| 227 | (unsigned long long)inova->io_addr[2], inova->irq, | ||
| 228 | inova->used); | ||
| 229 | |||
| 230 | } | ||
| 231 | } | ||
| 232 | |||
| 233 | /****************************************************************************/ | ||
| 234 | /* return all card information for driver */ | ||
| 235 | static int pci_card_data(struct pcilst_struct *inova, | ||
| 236 | unsigned char *pci_bus, unsigned char *pci_slot, | ||
| 237 | unsigned char *pci_func, resource_size_t * io_addr, | ||
| 238 | unsigned int *irq) | ||
| 239 | { | ||
| 240 | int i; | ||
| 241 | |||
| 242 | if (!inova) | ||
| 243 | return -1; | ||
| 244 | *pci_bus = inova->pci_bus; | ||
| 245 | *pci_slot = inova->pci_slot; | ||
| 246 | *pci_func = inova->pci_func; | ||
| 247 | for (i = 0; i < 5; i++) | ||
| 248 | io_addr[i] = inova->io_addr[i]; | ||
| 249 | *irq = inova->irq; | ||
| 250 | return 0; | ||
| 251 | } | ||
| 252 | |||
| 253 | /****************************************************************************/ | ||
| 254 | /* select and alloc card */ | ||
| 255 | static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id, | ||
| 256 | unsigned short device_id, | ||
| 257 | unsigned short pci_bus, | ||
| 258 | unsigned short pci_slot) | ||
| 259 | { | ||
| 260 | struct pcilst_struct *card; | ||
| 261 | int err; | ||
| 262 | |||
| 263 | if ((pci_bus < 1) & (pci_slot < 1)) { /* use autodetection */ | ||
| 264 | |||
| 265 | card = find_free_pci_card_by_device(vendor_id, device_id); | ||
| 266 | if (card == NULL) { | ||
| 267 | printk(" - Unused card not found in system!\n"); | ||
| 268 | return NULL; | ||
| 269 | } | ||
| 270 | } else { | ||
| 271 | switch (find_free_pci_card_by_position(vendor_id, device_id, | ||
| 272 | pci_bus, pci_slot, | ||
| 273 | &card)) { | ||
| 274 | case 1: | ||
| 275 | printk | ||
| 276 | (" - Card not found on requested position b:s %d:%d!\n", | ||
| 277 | pci_bus, pci_slot); | ||
| 278 | return NULL; | ||
| 279 | case 2: | ||
| 280 | printk | ||
| 281 | (" - Card on requested position is used b:s %d:%d!\n", | ||
| 282 | pci_bus, pci_slot); | ||
| 283 | return NULL; | ||
| 284 | } | ||
| 285 | } | ||
| 286 | |||
| 287 | err = pci_card_alloc(card); | ||
| 288 | if (err != 0) { | ||
| 289 | if (err > 0) | ||
| 290 | printk(" - Can't allocate card!\n"); | ||
| 291 | /* else: error already printed. */ | ||
| 292 | return NULL; | ||
| 293 | } | ||
| 294 | |||
| 295 | return card; | ||
| 296 | } | ||
| 297 | |||
| 298 | #endif | ||
diff --git a/drivers/staging/comedi/drivers/me4000.h b/drivers/staging/comedi/drivers/me4000.h new file mode 100644 index 00000000000..733b19243c7 --- /dev/null +++ b/drivers/staging/comedi/drivers/me4000.h | |||
| @@ -0,0 +1,446 @@ | |||
| 1 | /* | ||
| 2 | me4000.h | ||
| 3 | Register descriptions and defines for the ME-4000 board family | ||
| 4 | |||
| 5 | COMEDI - Linux Control and Measurement Device Interface | ||
| 6 | Copyright (C) 1998-9 David A. Schleef <ds@schleef.org> | ||
| 7 | |||
| 8 | This program is free software; you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation; either version 2 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with this program; if not, write to the Free Software | ||
| 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 21 | |||
| 22 | */ | ||
| 23 | |||
| 24 | #ifndef _ME4000_H_ | ||
| 25 | #define _ME4000_H_ | ||
| 26 | |||
| 27 | /*============================================================================= | ||
| 28 | Debug section | ||
| 29 | ===========================================================================*/ | ||
| 30 | |||
| 31 | #undef ME4000_CALL_DEBUG /* Debug function entry and exit */ | ||
| 32 | #undef ME4000_PORT_DEBUG /* Debug port access */ | ||
| 33 | #undef ME4000_ISR_DEBUG /* Debug the interrupt service routine */ | ||
| 34 | #undef ME4000_DEBUG /* General purpose debug masseges */ | ||
| 35 | |||
| 36 | #ifdef ME4000_CALL_DEBUG | ||
| 37 | #undef CALL_PDEBUG | ||
| 38 | #define CALL_PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args) | ||
| 39 | #else | ||
| 40 | # define CALL_PDEBUG(fmt, args...) /* no debugging, do nothing */ | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #ifdef ME4000_PORT_DEBUG | ||
| 44 | #undef PORT_PDEBUG | ||
| 45 | #define PORT_PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args) | ||
| 46 | #else | ||
| 47 | #define PORT_PDEBUG(fmt, args...) /* no debugging, do nothing */ | ||
| 48 | #endif | ||
| 49 | |||
| 50 | #ifdef ME4000_ISR_DEBUG | ||
| 51 | #undef ISR_PDEBUG | ||
| 52 | #define ISR_PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args) | ||
| 53 | #else | ||
| 54 | #define ISR_PDEBUG(fmt, args...) /* no debugging, do nothing */ | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #ifdef ME4000_DEBUG | ||
| 58 | #undef PDEBUG | ||
| 59 | #define PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args) | ||
| 60 | #else | ||
| 61 | #define PDEBUG(fmt, args...) /* no debugging, do nothing */ | ||
| 62 | #endif | ||
| 63 | |||
| 64 | /*============================================================================= | ||
| 65 | PCI vendor and device IDs | ||
| 66 | ===========================================================================*/ | ||
| 67 | |||
| 68 | #define PCI_VENDOR_ID_MEILHAUS 0x1402 | ||
| 69 | |||
| 70 | #define PCI_DEVICE_ID_MEILHAUS_ME4650 0x4650 /* Low Cost version */ | ||
| 71 | |||
| 72 | #define PCI_DEVICE_ID_MEILHAUS_ME4660 0x4660 /* Standard version */ | ||
| 73 | #define PCI_DEVICE_ID_MEILHAUS_ME4660I 0x4661 /* Isolated version */ | ||
| 74 | #define PCI_DEVICE_ID_MEILHAUS_ME4660S 0x4662 /* Standard version with Sample and Hold */ | ||
| 75 | #define PCI_DEVICE_ID_MEILHAUS_ME4660IS 0x4663 /* Isolated version with Sample and Hold */ | ||
| 76 | |||
| 77 | #define PCI_DEVICE_ID_MEILHAUS_ME4670 0x4670 /* Standard version */ | ||
| 78 | #define PCI_DEVICE_ID_MEILHAUS_ME4670I 0x4671 /* Isolated version */ | ||
| 79 | #define PCI_DEVICE_ID_MEILHAUS_ME4670S 0x4672 /* Standard version with Sample and Hold */ | ||
| 80 | #define PCI_DEVICE_ID_MEILHAUS_ME4670IS 0x4673 /* Isolated version with Sample and Hold */ | ||
| 81 | |||
| 82 | #define PCI_DEVICE_ID_MEILHAUS_ME4680 0x4680 /* Standard version */ | ||
| 83 | #define PCI_DEVICE_ID_MEILHAUS_ME4680I 0x4681 /* Isolated version */ | ||
| 84 | #define PCI_DEVICE_ID_MEILHAUS_ME4680S 0x4682 /* Standard version with Sample and Hold */ | ||
| 85 | #define PCI_DEVICE_ID_MEILHAUS_ME4680IS 0x4683 /* Isolated version with Sample and Hold */ | ||
| 86 | |||
| 87 | /*============================================================================= | ||
| 88 | ME-4000 base register offsets | ||
| 89 | ===========================================================================*/ | ||
| 90 | |||
| 91 | #define ME4000_AO_00_CTRL_REG 0x00 /* R/W */ | ||
| 92 | #define ME4000_AO_00_STATUS_REG 0x04 /* R/_ */ | ||
| 93 | #define ME4000_AO_00_FIFO_REG 0x08 /* _/W */ | ||
| 94 | #define ME4000_AO_00_SINGLE_REG 0x0C /* R/W */ | ||
| 95 | #define ME4000_AO_00_TIMER_REG 0x10 /* _/W */ | ||
| 96 | |||
| 97 | #define ME4000_AO_01_CTRL_REG 0x18 /* R/W */ | ||
| 98 | #define ME4000_AO_01_STATUS_REG 0x1C /* R/_ */ | ||
| 99 | #define ME4000_AO_01_FIFO_REG 0x20 /* _/W */ | ||
| 100 | #define ME4000_AO_01_SINGLE_REG 0x24 /* R/W */ | ||
| 101 | #define ME4000_AO_01_TIMER_REG 0x28 /* _/W */ | ||
| 102 | |||
| 103 | #define ME4000_AO_02_CTRL_REG 0x30 /* R/W */ | ||
| 104 | #define ME4000_AO_02_STATUS_REG 0x34 /* R/_ */ | ||
| 105 | #define ME4000_AO_02_FIFO_REG 0x38 /* _/W */ | ||
| 106 | #define ME4000_AO_02_SINGLE_REG 0x3C /* R/W */ | ||
| 107 | #define ME4000_AO_02_TIMER_REG 0x40 /* _/W */ | ||
| 108 | |||
| 109 | #define ME4000_AO_03_CTRL_REG 0x48 /* R/W */ | ||
| 110 | #define ME4000_AO_03_STATUS_REG 0x4C /* R/_ */ | ||
| 111 | #define ME4000_AO_03_FIFO_REG 0x50 /* _/W */ | ||
| 112 | #define ME4000_AO_03_SINGLE_REG 0x54 /* R/W */ | ||
| 113 | #define ME4000_AO_03_TIMER_REG 0x58 /* _/W */ | ||
| 114 | |||
| 115 | #define ME4000_AI_CTRL_REG 0x74 /* _/W */ | ||
| 116 | #define ME4000_AI_STATUS_REG 0x74 /* R/_ */ | ||
| 117 | #define ME4000_AI_CHANNEL_LIST_REG 0x78 /* _/W */ | ||
| 118 | #define ME4000_AI_DATA_REG 0x7C /* R/_ */ | ||
| 119 | #define ME4000_AI_CHAN_TIMER_REG 0x80 /* _/W */ | ||
| 120 | #define ME4000_AI_CHAN_PRE_TIMER_REG 0x84 /* _/W */ | ||
| 121 | #define ME4000_AI_SCAN_TIMER_LOW_REG 0x88 /* _/W */ | ||
| 122 | #define ME4000_AI_SCAN_TIMER_HIGH_REG 0x8C /* _/W */ | ||
| 123 | #define ME4000_AI_SCAN_PRE_TIMER_LOW_REG 0x90 /* _/W */ | ||
| 124 | #define ME4000_AI_SCAN_PRE_TIMER_HIGH_REG 0x94 /* _/W */ | ||
| 125 | #define ME4000_AI_START_REG 0x98 /* R/_ */ | ||
| 126 | |||
| 127 | #define ME4000_IRQ_STATUS_REG 0x9C /* R/_ */ | ||
| 128 | |||
| 129 | #define ME4000_DIO_PORT_0_REG 0xA0 /* R/W */ | ||
| 130 | #define ME4000_DIO_PORT_1_REG 0xA4 /* R/W */ | ||
| 131 | #define ME4000_DIO_PORT_2_REG 0xA8 /* R/W */ | ||
| 132 | #define ME4000_DIO_PORT_3_REG 0xAC /* R/W */ | ||
| 133 | #define ME4000_DIO_DIR_REG 0xB0 /* R/W */ | ||
| 134 | |||
| 135 | #define ME4000_AO_LOADSETREG_XX 0xB4 /* R/W */ | ||
| 136 | |||
| 137 | #define ME4000_DIO_CTRL_REG 0xB8 /* R/W */ | ||
| 138 | |||
| 139 | #define ME4000_AO_DEMUX_ADJUST_REG 0xBC /* -/W */ | ||
| 140 | |||
| 141 | #define ME4000_AI_SAMPLE_COUNTER_REG 0xC0 /* _/W */ | ||
| 142 | |||
| 143 | /*============================================================================= | ||
| 144 | Value to adjust Demux | ||
| 145 | ===========================================================================*/ | ||
| 146 | |||
| 147 | #define ME4000_AO_DEMUX_ADJUST_VALUE 0x4C | ||
| 148 | |||
| 149 | /*============================================================================= | ||
| 150 | Counter base register offsets | ||
| 151 | ===========================================================================*/ | ||
| 152 | |||
| 153 | #define ME4000_CNT_COUNTER_0_REG 0x00 | ||
| 154 | #define ME4000_CNT_COUNTER_1_REG 0x01 | ||
| 155 | #define ME4000_CNT_COUNTER_2_REG 0x02 | ||
| 156 | #define ME4000_CNT_CTRL_REG 0x03 | ||
| 157 | |||
| 158 | /*============================================================================= | ||
| 159 | PLX base register offsets | ||
| 160 | ===========================================================================*/ | ||
| 161 | |||
| 162 | #define PLX_INTCSR 0x4C /* Interrupt control and status register */ | ||
| 163 | #define PLX_ICR 0x50 /* Initialization control register */ | ||
| 164 | |||
| 165 | /*============================================================================= | ||
| 166 | Bits for the PLX_ICSR register | ||
| 167 | ===========================================================================*/ | ||
| 168 | |||
| 169 | #define PLX_INTCSR_LOCAL_INT1_EN 0x01 /* If set, local interrupt 1 is enabled (r/w) */ | ||
| 170 | #define PLX_INTCSR_LOCAL_INT1_POL 0x02 /* If set, local interrupt 1 polarity is active high (r/w) */ | ||
| 171 | #define PLX_INTCSR_LOCAL_INT1_STATE 0x04 /* If set, local interrupt 1 is active (r/_) */ | ||
| 172 | #define PLX_INTCSR_LOCAL_INT2_EN 0x08 /* If set, local interrupt 2 is enabled (r/w) */ | ||
| 173 | #define PLX_INTCSR_LOCAL_INT2_POL 0x10 /* If set, local interrupt 2 polarity is active high (r/w) */ | ||
| 174 | #define PLX_INTCSR_LOCAL_INT2_STATE 0x20 /* If set, local interrupt 2 is active (r/_) */ | ||
| 175 | #define PLX_INTCSR_PCI_INT_EN 0x40 /* If set, PCI interrupt is enabled (r/w) */ | ||
| 176 | #define PLX_INTCSR_SOFT_INT 0x80 /* If set, a software interrupt is generated (r/w) */ | ||
| 177 | |||
| 178 | /*============================================================================= | ||
| 179 | Bits for the PLX_ICR register | ||
| 180 | ===========================================================================*/ | ||
| 181 | |||
| 182 | #define PLX_ICR_BIT_EEPROM_CLOCK_SET 0x01000000 | ||
| 183 | #define PLX_ICR_BIT_EEPROM_CHIP_SELECT 0x02000000 | ||
| 184 | #define PLX_ICR_BIT_EEPROM_WRITE 0x04000000 | ||
| 185 | #define PLX_ICR_BIT_EEPROM_READ 0x08000000 | ||
| 186 | #define PLX_ICR_BIT_EEPROM_VALID 0x10000000 | ||
| 187 | |||
| 188 | #define PLX_ICR_MASK_EEPROM 0x1F000000 | ||
| 189 | |||
| 190 | #define EEPROM_DELAY 1 | ||
| 191 | |||
| 192 | /*============================================================================= | ||
| 193 | Bits for the ME4000_AO_CTRL_REG register | ||
| 194 | ===========================================================================*/ | ||
| 195 | |||
| 196 | #define ME4000_AO_CTRL_BIT_MODE_0 0x001 | ||
| 197 | #define ME4000_AO_CTRL_BIT_MODE_1 0x002 | ||
| 198 | #define ME4000_AO_CTRL_MASK_MODE 0x003 | ||
| 199 | #define ME4000_AO_CTRL_BIT_STOP 0x004 | ||
| 200 | #define ME4000_AO_CTRL_BIT_ENABLE_FIFO 0x008 | ||
| 201 | #define ME4000_AO_CTRL_BIT_ENABLE_EX_TRIG 0x010 | ||
| 202 | #define ME4000_AO_CTRL_BIT_EX_TRIG_EDGE 0x020 | ||
| 203 | #define ME4000_AO_CTRL_BIT_IMMEDIATE_STOP 0x080 | ||
| 204 | #define ME4000_AO_CTRL_BIT_ENABLE_DO 0x100 | ||
| 205 | #define ME4000_AO_CTRL_BIT_ENABLE_IRQ 0x200 | ||
| 206 | #define ME4000_AO_CTRL_BIT_RESET_IRQ 0x400 | ||
| 207 | |||
| 208 | /*============================================================================= | ||
| 209 | Bits for the ME4000_AO_STATUS_REG register | ||
| 210 | ===========================================================================*/ | ||
| 211 | |||
| 212 | #define ME4000_AO_STATUS_BIT_FSM 0x01 | ||
| 213 | #define ME4000_AO_STATUS_BIT_FF 0x02 | ||
| 214 | #define ME4000_AO_STATUS_BIT_HF 0x04 | ||
| 215 | #define ME4000_AO_STATUS_BIT_EF 0x08 | ||
| 216 | |||
| 217 | /*============================================================================= | ||
| 218 | Bits for the ME4000_AI_CTRL_REG register | ||
| 219 | ===========================================================================*/ | ||
| 220 | |||
| 221 | #define ME4000_AI_CTRL_BIT_MODE_0 0x00000001 | ||
| 222 | #define ME4000_AI_CTRL_BIT_MODE_1 0x00000002 | ||
| 223 | #define ME4000_AI_CTRL_BIT_MODE_2 0x00000004 | ||
| 224 | #define ME4000_AI_CTRL_BIT_SAMPLE_HOLD 0x00000008 | ||
| 225 | #define ME4000_AI_CTRL_BIT_IMMEDIATE_STOP 0x00000010 | ||
| 226 | #define ME4000_AI_CTRL_BIT_STOP 0x00000020 | ||
| 227 | #define ME4000_AI_CTRL_BIT_CHANNEL_FIFO 0x00000040 | ||
| 228 | #define ME4000_AI_CTRL_BIT_DATA_FIFO 0x00000080 | ||
| 229 | #define ME4000_AI_CTRL_BIT_FULLSCALE 0x00000100 | ||
| 230 | #define ME4000_AI_CTRL_BIT_OFFSET 0x00000200 | ||
| 231 | #define ME4000_AI_CTRL_BIT_EX_TRIG_ANALOG 0x00000400 | ||
| 232 | #define ME4000_AI_CTRL_BIT_EX_TRIG 0x00000800 | ||
| 233 | #define ME4000_AI_CTRL_BIT_EX_TRIG_FALLING 0x00001000 | ||
| 234 | #define ME4000_AI_CTRL_BIT_EX_IRQ 0x00002000 | ||
| 235 | #define ME4000_AI_CTRL_BIT_EX_IRQ_RESET 0x00004000 | ||
| 236 | #define ME4000_AI_CTRL_BIT_LE_IRQ 0x00008000 | ||
| 237 | #define ME4000_AI_CTRL_BIT_LE_IRQ_RESET 0x00010000 | ||
| 238 | #define ME4000_AI_CTRL_BIT_HF_IRQ 0x00020000 | ||
| 239 | #define ME4000_AI_CTRL_BIT_HF_IRQ_RESET 0x00040000 | ||
| 240 | #define ME4000_AI_CTRL_BIT_SC_IRQ 0x00080000 | ||
| 241 | #define ME4000_AI_CTRL_BIT_SC_IRQ_RESET 0x00100000 | ||
| 242 | #define ME4000_AI_CTRL_BIT_SC_RELOAD 0x00200000 | ||
| 243 | #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH 0x80000000 | ||
| 244 | |||
| 245 | /*============================================================================= | ||
| 246 | Bits for the ME4000_AI_STATUS_REG register | ||
| 247 | ===========================================================================*/ | ||
| 248 | |||
| 249 | #define ME4000_AI_STATUS_BIT_EF_CHANNEL 0x00400000 | ||
| 250 | #define ME4000_AI_STATUS_BIT_HF_CHANNEL 0x00800000 | ||
| 251 | #define ME4000_AI_STATUS_BIT_FF_CHANNEL 0x01000000 | ||
| 252 | #define ME4000_AI_STATUS_BIT_EF_DATA 0x02000000 | ||
| 253 | #define ME4000_AI_STATUS_BIT_HF_DATA 0x04000000 | ||
| 254 | #define ME4000_AI_STATUS_BIT_FF_DATA 0x08000000 | ||
| 255 | #define ME4000_AI_STATUS_BIT_LE 0x10000000 | ||
| 256 | #define ME4000_AI_STATUS_BIT_FSM 0x20000000 | ||
| 257 | |||
| 258 | /*============================================================================= | ||
| 259 | Bits for the ME4000_IRQ_STATUS_REG register | ||
| 260 | ===========================================================================*/ | ||
| 261 | |||
| 262 | #define ME4000_IRQ_STATUS_BIT_EX 0x01 | ||
| 263 | #define ME4000_IRQ_STATUS_BIT_LE 0x02 | ||
| 264 | #define ME4000_IRQ_STATUS_BIT_AI_HF 0x04 | ||
| 265 | #define ME4000_IRQ_STATUS_BIT_AO_0_HF 0x08 | ||
| 266 | #define ME4000_IRQ_STATUS_BIT_AO_1_HF 0x10 | ||
| 267 | #define ME4000_IRQ_STATUS_BIT_AO_2_HF 0x20 | ||
| 268 | #define ME4000_IRQ_STATUS_BIT_AO_3_HF 0x40 | ||
| 269 | #define ME4000_IRQ_STATUS_BIT_SC 0x80 | ||
| 270 | |||
| 271 | /*============================================================================= | ||
| 272 | Bits for the ME4000_DIO_CTRL_REG register | ||
| 273 | ===========================================================================*/ | ||
| 274 | |||
| 275 | #define ME4000_DIO_CTRL_BIT_MODE_0 0x0001 | ||
| 276 | #define ME4000_DIO_CTRL_BIT_MODE_1 0x0002 | ||
| 277 | #define ME4000_DIO_CTRL_BIT_MODE_2 0x0004 | ||
| 278 | #define ME4000_DIO_CTRL_BIT_MODE_3 0x0008 | ||
| 279 | #define ME4000_DIO_CTRL_BIT_MODE_4 0x0010 | ||
| 280 | #define ME4000_DIO_CTRL_BIT_MODE_5 0x0020 | ||
| 281 | #define ME4000_DIO_CTRL_BIT_MODE_6 0x0040 | ||
| 282 | #define ME4000_DIO_CTRL_BIT_MODE_7 0x0080 | ||
| 283 | |||
| 284 | #define ME4000_DIO_CTRL_BIT_FUNCTION_0 0x0100 | ||
| 285 | #define ME4000_DIO_CTRL_BIT_FUNCTION_1 0x0200 | ||
| 286 | |||
| 287 | #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_0 0x0400 | ||
| 288 | #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_1 0x0800 | ||
| 289 | #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_2 0x1000 | ||
| 290 | #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_3 0x2000 | ||
| 291 | |||
| 292 | /*============================================================================= | ||
| 293 | Information about the hardware capabilities | ||
| 294 | ===========================================================================*/ | ||
| 295 | |||
| 296 | struct me4000_ao_info { | ||
| 297 | int count; | ||
| 298 | int fifo_count; | ||
| 299 | }; | ||
| 300 | |||
| 301 | struct me4000_ai_info { | ||
| 302 | int count; | ||
| 303 | int sh_count; | ||
| 304 | int diff_count; | ||
| 305 | int ex_trig_analog; | ||
| 306 | }; | ||
| 307 | |||
| 308 | struct me4000_dio_info { | ||
| 309 | int count; | ||
| 310 | }; | ||
| 311 | |||
| 312 | struct me4000_cnt_info { | ||
| 313 | int count; | ||
| 314 | }; | ||
| 315 | |||
| 316 | struct me4000_board { | ||
| 317 | const char *name; | ||
| 318 | unsigned short device_id; | ||
| 319 | struct me4000_ao_info ao; | ||
| 320 | struct me4000_ai_info ai; | ||
| 321 | struct me4000_dio_info dio; | ||
| 322 | struct me4000_cnt_info cnt; | ||
| 323 | }; | ||
| 324 | |||
| 325 | #define thisboard ((const struct me4000_board *)dev->board_ptr) | ||
| 326 | |||
| 327 | /*============================================================================= | ||
| 328 | Global board and subdevice information structures | ||
| 329 | ===========================================================================*/ | ||
| 330 | |||
| 331 | struct me4000_ao_context { | ||
| 332 | int irq; | ||
| 333 | |||
| 334 | unsigned long mirror; /* Store the last written value */ | ||
| 335 | |||
| 336 | unsigned long ctrl_reg; | ||
| 337 | unsigned long status_reg; | ||
| 338 | unsigned long fifo_reg; | ||
| 339 | unsigned long single_reg; | ||
| 340 | unsigned long timer_reg; | ||
| 341 | unsigned long irq_status_reg; | ||
| 342 | unsigned long preload_reg; | ||
| 343 | }; | ||
| 344 | |||
| 345 | struct me4000_ai_context { | ||
| 346 | int irq; | ||
| 347 | |||
| 348 | unsigned long ctrl_reg; | ||
| 349 | unsigned long status_reg; | ||
| 350 | unsigned long channel_list_reg; | ||
| 351 | unsigned long data_reg; | ||
| 352 | unsigned long chan_timer_reg; | ||
| 353 | unsigned long chan_pre_timer_reg; | ||
| 354 | unsigned long scan_timer_low_reg; | ||
| 355 | unsigned long scan_timer_high_reg; | ||
| 356 | unsigned long scan_pre_timer_low_reg; | ||
| 357 | unsigned long scan_pre_timer_high_reg; | ||
| 358 | unsigned long start_reg; | ||
| 359 | unsigned long irq_status_reg; | ||
| 360 | unsigned long sample_counter_reg; | ||
| 361 | }; | ||
| 362 | |||
| 363 | struct me4000_dio_context { | ||
| 364 | unsigned long dir_reg; | ||
| 365 | unsigned long ctrl_reg; | ||
| 366 | unsigned long port_0_reg; | ||
| 367 | unsigned long port_1_reg; | ||
| 368 | unsigned long port_2_reg; | ||
| 369 | unsigned long port_3_reg; | ||
| 370 | }; | ||
| 371 | |||
| 372 | struct me4000_cnt_context { | ||
| 373 | unsigned long ctrl_reg; | ||
| 374 | unsigned long counter_0_reg; | ||
| 375 | unsigned long counter_1_reg; | ||
| 376 | unsigned long counter_2_reg; | ||
| 377 | }; | ||
| 378 | |||
| 379 | struct me4000_info { | ||
| 380 | unsigned long plx_regbase; /* PLX configuration space base address */ | ||
| 381 | unsigned long me4000_regbase; /* Base address of the ME4000 */ | ||
| 382 | unsigned long timer_regbase; /* Base address of the timer circuit */ | ||
| 383 | unsigned long program_regbase; /* Base address to set the program pin for the xilinx */ | ||
| 384 | |||
| 385 | unsigned long plx_regbase_size; /* PLX register set space */ | ||
| 386 | unsigned long me4000_regbase_size; /* ME4000 register set space */ | ||
| 387 | unsigned long timer_regbase_size; /* Timer circuit register set space */ | ||
| 388 | unsigned long program_regbase_size; /* Size of program base address of the ME4000 */ | ||
| 389 | |||
| 390 | unsigned int serial_no; /* Serial number of the board */ | ||
| 391 | unsigned char hw_revision; /* Hardware revision of the board */ | ||
| 392 | unsigned short vendor_id; /* Meilhaus vendor id */ | ||
| 393 | unsigned short device_id; /* Device id */ | ||
| 394 | |||
| 395 | struct pci_dev *pci_dev_p; /* General PCI information */ | ||
| 396 | |||
| 397 | unsigned int irq; /* IRQ assigned from the PCI BIOS */ | ||
| 398 | |||
| 399 | struct me4000_ai_context ai_context; /* Analog input specific context */ | ||
| 400 | struct me4000_ao_context ao_context[4]; /* Vector with analog output specific context */ | ||
| 401 | struct me4000_dio_context dio_context; /* Digital I/O specific context */ | ||
| 402 | struct me4000_cnt_context cnt_context; /* Counter specific context */ | ||
| 403 | }; | ||
| 404 | |||
| 405 | #define info ((struct me4000_info *)dev->private) | ||
| 406 | |||
| 407 | /*----------------------------------------------------------------------------- | ||
| 408 | Defines for analog input | ||
| 409 | ----------------------------------------------------------------------------*/ | ||
| 410 | |||
| 411 | /* General stuff */ | ||
| 412 | #define ME4000_AI_FIFO_COUNT 2048 | ||
| 413 | |||
| 414 | #define ME4000_AI_MIN_TICKS 66 | ||
| 415 | #define ME4000_AI_MIN_SAMPLE_TIME 2000 /* Minimum sample time [ns] */ | ||
| 416 | #define ME4000_AI_BASE_FREQUENCY (unsigned int) 33E6 | ||
| 417 | |||
| 418 | /* Channel list defines and masks */ | ||
| 419 | #define ME4000_AI_CHANNEL_LIST_COUNT 1024 | ||
| 420 | |||
| 421 | #define ME4000_AI_LIST_INPUT_SINGLE_ENDED 0x000 | ||
| 422 | #define ME4000_AI_LIST_INPUT_DIFFERENTIAL 0x020 | ||
| 423 | |||
| 424 | #define ME4000_AI_LIST_RANGE_BIPOLAR_10 0x000 | ||
| 425 | #define ME4000_AI_LIST_RANGE_BIPOLAR_2_5 0x040 | ||
| 426 | #define ME4000_AI_LIST_RANGE_UNIPOLAR_10 0x080 | ||
| 427 | #define ME4000_AI_LIST_RANGE_UNIPOLAR_2_5 0x0C0 | ||
| 428 | |||
| 429 | #define ME4000_AI_LIST_LAST_ENTRY 0x100 | ||
| 430 | |||
| 431 | /*----------------------------------------------------------------------------- | ||
| 432 | Defines for counters | ||
| 433 | ----------------------------------------------------------------------------*/ | ||
| 434 | |||
| 435 | #define ME4000_CNT_COUNTER_0 0x00 | ||
| 436 | #define ME4000_CNT_COUNTER_1 0x40 | ||
| 437 | #define ME4000_CNT_COUNTER_2 0x80 | ||
| 438 | |||
| 439 | #define ME4000_CNT_MODE_0 0x00 /* Change state if zero crossing */ | ||
| 440 | #define ME4000_CNT_MODE_1 0x02 /* Retriggerable One-Shot */ | ||
| 441 | #define ME4000_CNT_MODE_2 0x04 /* Asymmetrical divider */ | ||
| 442 | #define ME4000_CNT_MODE_3 0x06 /* Symmetrical divider */ | ||
| 443 | #define ME4000_CNT_MODE_4 0x08 /* Counter start by software trigger */ | ||
| 444 | #define ME4000_CNT_MODE_5 0x0A /* Counter start by hardware trigger */ | ||
| 445 | |||
| 446 | #endif | ||
diff --git a/drivers/staging/comedi/drivers/mpc8260cpm.c b/drivers/staging/comedi/drivers/mpc8260cpm.c new file mode 100644 index 00000000000..5f6816a3fe8 --- /dev/null +++ b/drivers/staging/comedi/drivers/mpc8260cpm.c | |||
| @@ -0,0 +1,186 @@ | |||
| 1 | /* | ||
| 2 | comedi/drivers/mpc8260.c | ||
| 3 | driver for digital I/O pins on the MPC 8260 CPM module | ||
| 4 | |||
| 5 | COMEDI - Linux Control and Measurement Device Interface | ||
| 6 | Copyright (C) 2000,2001 David A. Schleef <ds@schleef.org> | ||
| 7 | |||
| 8 | This program is free software; you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation; either version 2 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with this program; if not, write to the Free Software | ||
| 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 21 | |||
| 22 | */ | ||
| 23 | /* | ||
| 24 | Driver: mpc8260cpm | ||
| 25 | Description: MPC8260 CPM module generic digital I/O lines | ||
| 26 | Devices: [Motorola] MPC8260 CPM (mpc8260cpm) | ||
| 27 | Author: ds | ||
| 28 | Status: experimental | ||
| 29 | Updated: Sat, 16 Mar 2002 17:34:48 -0800 | ||
| 30 | |||
| 31 | This driver is specific to the Motorola MPC8260 processor, allowing | ||
| 32 | you to access the processor's generic digital I/O lines. | ||
| 33 | |||
| 34 | It is apparently missing some code. | ||
| 35 | */ | ||
| 36 | |||
| 37 | #include "../comedidev.h" | ||
| 38 | |||
| 39 | extern unsigned long mpc8260_dio_reserved[4]; | ||
| 40 | |||
| 41 | struct mpc8260cpm_private { | ||
| 42 | |||
| 43 | int data; | ||
| 44 | |||
| 45 | }; | ||
| 46 | |||
| 47 | #define devpriv ((struct mpc8260cpm_private *)dev->private) | ||
| 48 | |||
| 49 | static int mpc8260cpm_attach(struct comedi_device *dev, | ||
| 50 | struct comedi_devconfig *it); | ||
| 51 | static int mpc8260cpm_detach(struct comedi_device *dev); | ||
| 52 | static struct comedi_driver driver_mpc8260cpm = { | ||
| 53 | .driver_name = "mpc8260cpm", | ||
| 54 | .module = THIS_MODULE, | ||
| 55 | .attach = mpc8260cpm_attach, | ||
| 56 | .detach = mpc8260cpm_detach, | ||
| 57 | }; | ||
| 58 | |||
| 59 | static int __init driver_mpc8260cpm_init_module(void) | ||
| 60 | { | ||
| 61 | return comedi_driver_register(&driver_mpc8260cpm); | ||
| 62 | } | ||
| 63 | |||
| 64 | static void __exit driver_mpc8260cpm_cleanup_module(void) | ||
| 65 | { | ||
| 66 | comedi_driver_unregister(&driver_mpc8260cpm); | ||
| 67 | } | ||
| 68 | |||
| 69 | module_init(driver_mpc8260cpm_init_module); | ||
| 70 | module_exit(driver_mpc8260cpm_cleanup_module); | ||
| 71 | |||
| 72 | static int mpc8260cpm_dio_config(struct comedi_device *dev, | ||
| 73 | struct comedi_subdevice *s, | ||
| 74 | struct comedi_insn *insn, unsigned int *data); | ||
| 75 | static int mpc8260cpm_dio_bits(struct comedi_device *dev, | ||
| 76 | struct comedi_subdevice *s, | ||
| 77 | struct comedi_insn *insn, unsigned int *data); | ||
| 78 | |||
| 79 | static int mpc8260cpm_attach(struct comedi_device *dev, | ||
| 80 | struct comedi_devconfig *it) | ||
| 81 | { | ||
| 82 | struct comedi_subdevice *s; | ||
| 83 | int i; | ||
| 84 | |||
| 85 | printk("comedi%d: mpc8260cpm: ", dev->minor); | ||
| 86 | |||
| 87 | dev->board_ptr = mpc8260cpm_boards + dev->board; | ||
| 88 | |||
| 89 | dev->board_name = thisboard->name; | ||
| 90 | |||
| 91 | if (alloc_private(dev, sizeof(struct mpc8260cpm_private)) < 0) | ||
| 92 | return -ENOMEM; | ||
| 93 | |||
| 94 | if (alloc_subdevices(dev, 4) < 0) | ||
| 95 | return -ENOMEM; | ||
| 96 | |||
| 97 | for (i = 0; i < 4; i++) { | ||
| 98 | s = dev->subdevices + i; | ||
| 99 | s->type = COMEDI_SUBD_DIO; | ||
| 100 | s->subdev_flags = SDF_READABLE | SDF_WRITABLE; | ||
| 101 | s->n_chan = 32; | ||
| 102 | s->maxdata = 1; | ||
| 103 | s->range_table = &range_digital; | ||
| 104 | s->insn_config = mpc8260cpm_dio_config; | ||
| 105 | s->insn_bits = mpc8260cpm_dio_bits; | ||
| 106 | } | ||
| 107 | |||
| 108 | return 1; | ||
| 109 | } | ||
| 110 | |||
| 111 | static int mpc8260cpm_detach(struct comedi_device *dev) | ||
| 112 | { | ||
| 113 | printk("comedi%d: mpc8260cpm: remove\n", dev->minor); | ||
| 114 | |||
| 115 | return 0; | ||
| 116 | } | ||
| 117 | |||
| 118 | static unsigned long *cpm_pdat(int port) | ||
| 119 | { | ||
| 120 | switch (port) { | ||
| 121 | case 0: | ||
| 122 | return &io->iop_pdata; | ||
| 123 | case 1: | ||
| 124 | return &io->iop_pdatb; | ||
| 125 | case 2: | ||
| 126 | return &io->iop_pdatc; | ||
| 127 | case 3: | ||
| 128 | return &io->iop_pdatd; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | static int mpc8260cpm_dio_config(struct comedi_device *dev, | ||
| 133 | struct comedi_subdevice *s, | ||
| 134 | struct comedi_insn *insn, unsigned int *data) | ||
| 135 | { | ||
| 136 | int n; | ||
| 137 | unsigned int d; | ||
| 138 | unsigned int mask; | ||
| 139 | int port; | ||
| 140 | |||
| 141 | port = (int)s->private; | ||
| 142 | mask = 1 << CR_CHAN(insn->chanspec); | ||
| 143 | if (mask & cpm_reserved_bits[port]) { | ||
| 144 | return -EINVAL; | ||
| 145 | } | ||
| 146 | |||
| 147 | switch (data[0]) { | ||
| 148 | case INSN_CONFIG_DIO_OUTPUT: | ||
| 149 | s->io_bits |= mask; | ||
| 150 | break; | ||
| 151 | case INSN_CONFIG_DIO_INPUT: | ||
| 152 | s->io_bits &= ~mask; | ||
| 153 | break; | ||
| 154 | case INSN_CONFIG_DIO_QUERY: | ||
| 155 | data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; | ||
| 156 | return insn->n; | ||
| 157 | break; | ||
| 158 | default: | ||
| 159 | return -EINVAL; | ||
| 160 | } | ||
| 161 | |||
| 162 | switch (port) { | ||
| 163 | case 0: | ||
| 164 | return &io->iop_pdira; | ||
| 165 | case 1: | ||
| 166 | return &io->iop_pdirb; | ||
| 167 | case 2: | ||
| 168 | return &io->iop_pdirc; | ||
| 169 | case 3: | ||
| 170 | return &io->iop_pdird; | ||
| 171 | } | ||
| 172 | |||
| 173 | return 1; | ||
| 174 | } | ||
| 175 | |||
| 176 | static int mpc8260cpm_dio_bits(struct comedi_device *dev, | ||
| 177 | struct comedi_subdevice *s, | ||
| 178 | struct comedi_insn *insn, unsigned int *data) | ||
| 179 | { | ||
| 180 | int port; | ||
| 181 | unsigned long *p; | ||
| 182 | |||
| 183 | p = cpm_pdat((int)s->private); | ||
| 184 | |||
| 185 | return 2; | ||
| 186 | } | ||
diff --git a/drivers/staging/comedi/internal.h b/drivers/staging/comedi/internal.h new file mode 100644 index 00000000000..434ce343336 --- /dev/null +++ b/drivers/staging/comedi/internal.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | /* | ||
| 2 | * various internal comedi functions | ||
| 3 | */ | ||
| 4 | int do_rangeinfo_ioctl(struct comedi_device *dev, | ||
| 5 | struct comedi_rangeinfo __user *arg); | ||
| 6 | int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 7 | struct comedi_insn *insn, unsigned int *data); | ||
| 8 | int comedi_alloc_board_minor(struct device *hardware_device); | ||
| 9 | void comedi_free_board_minor(unsigned minor); | ||
| 10 | void comedi_reset_async_buf(struct comedi_async *async); | ||
| 11 | int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, | ||
| 12 | unsigned long new_size); | ||
